<commit_before>#include <pebble.h>

static Window *window;

static TextLayer *step_layer;
static char s_step_layer[32];

static TextLayer *countdown_layer;
static char s_countdown_layer[32];

static TextLayer *nextstep_layer;
static char s_nextstep_layer[32];

int nextstep=0;
int nextstep_countdown=-1;

static VibePattern oneshort_pattern = {
  .durations = (uint32_t []) {100},
  .num_segments = 1
};

static VibePattern twoshort_pattern = {
  .durations = (uint32_t []) {100, 200, 100},
  .num_segments = 3
};

static VibePattern threeshort_pattern = {
  .durations = (uint32_t []) {100, 200, 100, 200, 100},
  .num_segments = 5
};

struct {
	int time; // in seconds
	char *text;
	VibePattern *vibe;
#if 0
} msgs[13] = {
	{ 10, "Upper left inner" },
	{ 10, "Upper left top" },
	{ 10, "Upper left outer" },
	{ 10, "Upper right inner" },
	{ 10, "Upper right top" },
	{ 10, "Upper right outer" },
	{  3, "Spit" },
	{ 10, "Lower left inner" },
	{ 10, "Lower left top" },
	{ 10, "Lower left outer" },
	{ 10, "Lower right inner" },
	{ 10, "Lower right top" },
	{ 10, "Lower right outer" },
#else //0
} msgs[10] = {
	{  3, "Get ready", NULL },

	{ 15, "Lower right outer", &twoshort_pattern },
	{ 15, "Lower left outer", &oneshort_pattern },

	{ 15, "Lower left inner", &oneshort_pattern },
	{ 15, "Lower right inner", &oneshort_pattern },

	{  3, "Spit", &twoshort_pattern },

	{ 15, "Upper right outer", &twoshort_pattern },
	{ 15, "Upper left outer", &oneshort_pattern },

	{ 15, "Upper left inner", &oneshort_pattern },
	{ 15, "Upper right inner", &oneshort_pattern },
#endif
};

const int msgs_size = sizeof(msgs)/sizeof(msgs[0]);
AppTimer *tooth_timer = NULL;

static void
exit_callback(void *data)
{
  window_stack_pop_all(false);  
}

static void 
timer_callback(void *data)
{
	
	if (nextstep > msgs_size-1)
	{
		s_step_layer[0] = 0;
		s_nextstep_layer[0] = 0;
		snprintf(s_countdown_layer, sizeof(s_countdown_layer), "Done!");
		layer_mark_dirty(text_layer_get_layer(step_layer));
		layer_mark_dirty(text_layer_get_layer(nextstep_layer));
		layer_mark_dirty(text_layer_get_layer(countdown_layer));
		vibes_enqueue_custom_pattern(threeshort_pattern);
    tooth_timer = app_timer_register(5*60*1000 /* 5 minutes */, exit_callback, NULL);
		return;
	}

	tooth_timer = app_timer_register(1000 /* milliseconds */, timer_callback, NULL);
	APP_LOG(APP_LOG_LEVEL_DEBUG, "timer_callback nextstep:%d, nextstep_countdown:%d", nextstep, nextstep_countdown);
	if (nextstep_countdown <= 0)
	{
		nextstep_countdown = msgs[nextstep].time;
		if (msgs[nextstep].vibe)
			vibes_enqueue_custom_pattern(*msgs[nextstep].vibe);
		snprintf(s_step_layer, sizeof(s_step_layer), "%s", msgs[nextstep].text);
		APP_LOG(APP_LOG_LEVEL_DEBUG, "tc: new step: %s (%d)", msgs[nextstep].text, nextstep_countdown);
		if (nextstep < msgs_size-1)
			snprintf(s_nextstep_layer, sizeof(s_nextstep_layer), "Next:\n%s", msgs[nextstep+1].text);
		else
			snprintf(s_nextstep_layer, sizeof(s_nextstep_layer), "Next:\nDone!");
		layer_mark_dirty(text_layer_get_layer(step_layer));
		layer_mark_dirty(text_layer_get_layer(nextstep_layer));
	}
	snprintf(s_countdown_layer, sizeof(s_countdown_layer), "%d", nextstep_countdown);
	layer_mark_dirty(text_layer_get_layer(countdown_layer));
	nextstep_countdown --;
	if (nextstep_countdown == 0)
		nextstep ++;
}

static void
select_click_handler(ClickRecognizerRef recognizer, void *context)
{
	nextstep=0;
	nextstep_countdown = 0;
	if (tooth_timer != NULL)
	{<commit_msg>Added backlight when new step<commit_after>#include <pebble.h>

static Window *window;

static TextLayer *step_layer;
static char s_step_layer[32];

static TextLayer *countdown_layer;
static char s_countdown_layer[32];

static TextLayer *nextstep_layer;
static char s_nextstep_layer[32];

int nextstep=0;
int nextstep_countdown=-1;

static VibePattern oneshort_pattern = {
  .durations = (uint32_t []) {100},
  .num_segments = 1
};

static VibePattern twoshort_pattern = {
  .durations = (uint32_t []) {100, 200, 100},
  .num_segments = 3
};

static VibePattern threeshort_pattern = {
  .durations = (uint32_t []) {100, 200, 100, 200, 100},
  .num_segments = 5
};

struct {
	int time; // in seconds
	char *text;
	VibePattern *vibe;
#if 0
} msgs[13] = {
	{ 10, "Upper left inner" },
	{ 10, "Upper left top" },
	{ 10, "Upper left outer" },
	{ 10, "Upper right inner" },
	{ 10, "Upper right top" },
	{ 10, "Upper right outer" },
	{  3, "Spit" },
	{ 10, "Lower left inner" },
	{ 10, "Lower left top" },
	{ 10, "Lower left outer" },
	{ 10, "Lower right inner" },
	{ 10, "Lower right top" },
	{ 10, "Lower right outer" },
#else //0
} msgs[10] = {
	{  3, "Get ready", NULL },

	{ 15, "Lower right outer", &twoshort_pattern },
	{ 15, "Lower left outer", &oneshort_pattern },

	{ 15, "Lower left inner", &oneshort_pattern },
	{ 15, "Lower right inner", &oneshort_pattern },

	{  3, "Spit", &twoshort_pattern },

	{ 15, "Upper right outer", &twoshort_pattern },
	{ 15, "Upper left outer", &oneshort_pattern },

	{ 15, "Upper left inner", &oneshort_pattern },
	{ 15, "Upper right inner", &oneshort_pattern },
#endif
};

const int msgs_size = sizeof(msgs)/sizeof(msgs[0]);
AppTimer *tooth_timer = NULL;

static void
exit_callback(void *data)
{
  window_stack_pop_all(false);  
}

static void 
timer_callback(void *data)
{
	
	if (nextstep > msgs_size-1)
	{
		s_step_layer[0] = 0;
		s_nextstep_layer[0] = 0;
		snprintf(s_countdown_layer, sizeof(s_countdown_layer), "Done!");
		layer_mark_dirty(text_layer_get_layer(step_layer));
		layer_mark_dirty(text_layer_get_layer(nextstep_layer));
		layer_mark_dirty(text_layer_get_layer(countdown_layer));
		vibes_enqueue_custom_pattern(threeshort_pattern);
    tooth_timer = app_timer_register(5*60*1000 /* 5 minutes */, exit_callback, NULL);
		return;
	}

	tooth_timer = app_timer_register(1000 /* milliseconds */, timer_callback, NULL);
	APP_LOG(APP_LOG_LEVEL_DEBUG, "timer_callback nextstep:%d, nextstep_countdown:%d", nextstep, nextstep_countdown);
	if (nextstep_countdown <= 0)
	{
    light_enable_interaction();
		nextstep_countdown = msgs[nextstep].time;
		if (msgs[nextstep].vibe)
			vibes_enqueue_custom_pattern(*msgs[nextstep].vibe);
		snprintf(s_step_layer, sizeof(s_step_layer), "%s", msgs[nextstep].text);
		APP_LOG(APP_LOG_LEVEL_DEBUG, "tc: new step: %s (%d)", msgs[nextstep].text, nextstep_countdown);
		if (nextstep < msgs_size-1)
			snprintf(s_nextstep_layer, sizeof(s_nextstep_layer), "Next:\n%s", msgs[nextstep+1].text);
		else
			snprintf(s_nextstep_layer, sizeof(s_nextstep_layer), "Next:\nDone!");
		layer_mark_dirty(text_layer_get_layer(step_layer));
		layer_mark_dirty(text_layer_get_layer(nextstep_layer));
	}
	snprintf(s_countdown_layer, sizeof(s_countdown_layer), "%d", nextstep_countdown);
	layer_mark_dirty(text_layer_get_layer(countdown_layer));
	nextstep_countdown --;
	if (nextstep_countdown == 0)
		nextstep ++;
}

static void
select_click_handler(ClickRecognizerRef recognizer, void *context)
{
	nextstep=0;
	nextstep_countdown = 0;
	if (tooth_timer != NULL)
	{
{'fraction_non_alphanumeric': 0.14393939393939395, 'fraction_numerical': 0.03344768439108062, 'mean_word_length': 5.50278810408922, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5584281', 'n_tokens_mistral': 2919, 'n_tokens_neox': 2676, 'n_words': 551}