void headingSelected(NumberWindow *window, void * context){; static char msg[20]; snprintf(msg, 20, "%d;%d",selectedIndex,(int) number_window_get_value(window)); send_to_phone( MyTupletCString(105, msg)); //index maps to courseIdx! vibes_short_pulse(); number_window_destroy(degrees_window); window_stack_pop(true); //close this window (number window) window_stack_pop(true); //close this window (course menu) }
static void selected_callback(NumberWindow *window, void *data) { if (unit_mode) { ask_for_timeo(number_window_get_value(window)); window_stack_pop(true); } else { number_window_set_step_size(s_window, 1); number_window_set_label(s_window, "TIMEO units?"); unit_mode = true; } }
/** Handler for number window, when you select a value. Commits the selected value to the selected setting, and pops the window. */ void pomOnNumberSelect(struct NumberWindow *window, void *context) { int value = number_window_get_value(window); int ticks = value * 60; PomMenuId id = simple_menu_layer_get_selected_index(&menuLayer); switch (id) { case PomMenuRestDuration: app.settings.restTicks = ticks; break; case PomMenuWorkDuration: app.settings.workTicks = ticks; break; case PomMenuLongRestDuration: app.settings.longRestTicks = ticks; break; default: return; } window_stack_pop(true); pomUpdateMenus(); }
static void reset_menu() { int num_a_items = 0; menu_items[num_a_items++] = (SimpleMenuItem){ .title = "Start", .subtitle = "Lets Push-ups", .callback = select_menu_handler, }; persist_exists(GOAL_KEY)?1: persist_write_int(GOAL_KEY,15); snprintf(goal_str,sizeof(goal_str), "%ld once", persist_read_int(GOAL_KEY)); menu_items[num_a_items++] = (SimpleMenuItem){ .title= "Goal", .subtitle = goal_str, .callback = select_menu_handler, }; snprintf(history_str,sizeof(history_str), "Total: %ld Top: %ld", persist_exists(TOTAL_PUSHUPS_KEY)?persist_read_int(TOTAL_PUSHUPS_KEY) : 0, persist_exists(MAX_PUSHUPS_KEY)?persist_read_int(MAX_PUSHUPS_KEY) : 0); menu_items[num_a_items++] = (SimpleMenuItem){ .title = "History", .subtitle = history_str, .callback = select_menu_handler, }; menu_items[num_a_items++] = (SimpleMenuItem){ .title= "Version", .subtitle = "1.0 @copyright shanfeng", .callback = select_menu_handler, }; sections[0] = (SimpleMenuSection){ .num_items = SECTION_COUNT, .items = menu_items, }; if(menu_layer) { layer_remove_from_parent(simple_menu_layer_get_layer(menu_layer)); simple_menu_layer_destroy(menu_layer); } Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_bounds(window_layer); menu_layer = simple_menu_layer_create(bounds,window,sections, 1,NULL); simple_menu_layer_set_selected_index(menu_layer,menu_select,false); layer_add_child(window_layer, simple_menu_layer_get_layer(menu_layer)); } static void goal_select(struct NumberWindow *number_window, void *context) { persist_write_int(GOAL_KEY,number_window_get_value(number_window)); window_stack_pop(true); } static void select_menu_handler(int index, void *context) { APP_LOG(APP_LOG_LEVEL_DEBUG,"%d",index); switch(index) { case 0: if(!pushups_window) { APP_LOG(APP_LOG_LEVEL_DEBUG, "pushups_window create"); pushups_window = create_pushups_window(); } window_stack_push(pushups_window, true); break; case 1: if(!number_window) { number_window = number_window_create("Goal",(NumberWindowCallbacks){ .selected = goal_select, },NULL); number_window_set_value(number_window, persist_read_int(GOAL_KEY)); number_window_set_min(number_window,5); number_window_set_step_size(number_window, 5); number_window_set_max(number_window,1000); } window_stack_push((Window*)number_window,true); break; case 3: { if(!info_window) { info_window = aboutinfo_window_create(); } window_stack_push(info_window,true); } } menu_select = index; }
void store_snooze(NumberWindow *window,void* context) { *s_snooze_delay = number_window_get_value(s_window); persist_write_int(SNOOZE_KEY,*s_snooze_delay); window_stack_pop(true); }
static void number_selected_callback(NumberWindow *win, void *context) { send_weight(number_window_get_value(win)); window_stack_pop(true); //remove numwindow window_stack_pop(true); //remove weightinput window }