/* * Set the fields to the values from the rest of the system */ static void set_values() { values[F_FROM_HOUR] = twenty_four_to_twelve(get_config_data()->fromhr); values[F_FROM_MINUTE] = get_config_data()->frommin; values[F_TO_HOUR] = twenty_four_to_twelve(get_config_data()->tohr); values[F_TO_MINUTE] = get_config_data()->tomin; if (!is24hr) { values[F_FROM_AMPM] = get_config_data()->fromhr >= 12 ? 1 : 0; values[F_TO_AMPM] = get_config_data()->tohr >= 12 ? 1 : 0; } }
/* * Set the on-screen status text */ void set_smart_status() { static char status_text[15]; snprintf(status_text, sizeof(status_text), "%d:%02d - %d:%02d", twenty_four_to_twelve(get_config_data()->fromhr), get_config_data()->frommin, twenty_four_to_twelve(get_config_data()->tohr), get_config_data()->tomin); set_icon(get_config_data()->smart && get_config_data()->weekend_until != 0, IS_WEEKEND); set_smart_status_on_screen(get_config_data()->smart, status_text); analogue_set_smart_times(); }
/* * This is the menu item draw callback where you specify what each item should look like */ static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) { #ifdef PBL_COLOR graphics_context_set_compositing_mode(ctx, GCompOpSet); #endif // Pick up names from the array except for the one instance where we fiddle with it int16_t index = cell_index->row + menu_slide; const char *subtitle = menu_def[index].subtitle; const char *title = menu_def[index].title; GBitmap *icon = menu_def[index].state == NULL ? NULL : menu_icons[*(menu_def[index].state)]; if ((menu_def[index].feature & FEATURE_WAKEUP) == FEATURE_WAKEUP && auto_reset_state == 1 && original_auto_reset_state == 1) { snprintf(menu_text, sizeof(menu_text), MENU_AUTO_RESET_DES_ON, twenty_four_to_twelve(get_config_data()->autohr), get_config_data()->automin, am_pm_text(get_config_data()->autohr)); subtitle = menu_text; } else if ((menu_def[index].feature & FEATURE_SMART_ALARM) == FEATURE_SMART_ALARM) { copy_alarm_time_range_into_field(menu_text, sizeof(menu_text)); subtitle = menu_text; } #ifndef PBL_ROUND menu_cell_basic_draw(ctx, cell_layer, title, subtitle, icon); #else menu_cell_basic_draw(ctx, cell_layer, title, subtitle, NULL); if (icon != NULL && menu_layer_get_selected_index(menu_layer).row == cell_index->row) { graphics_draw_bitmap_in_rect(ctx, icon, GRect(10, 7, 24, 28)); } #endif }
/* * This is the menu item draw callback where you specify what each item should look like */ static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) { int16_t index = cell_index->row; uint8_t no = menu_def[index].no; uint8_t icon = menu_def[index].set ? 1 : 0; snprintf(menu_text, sizeof(menu_text), "%d:%02d - %d:%02d", twenty_four_to_twelve(preset_data.fromhr[no]), preset_data.frommin[no], twenty_four_to_twelve(preset_data.tohr[no]), preset_data.tomin[no]); graphics_context_set_compositing_mode(ctx, GCompOpSet); menu_cell_basic_draw(ctx, cell_layer, menu_def[index].title, menu_text, menu_icons[icon]); }
EXTFN void copy_end_time_into_field(char *field, size_t fsize) { snprintf(field, fsize, MENU_SMART_ALARM_END_TIME_FORMAT, twenty_four_to_twelve(get_config_data()->tohr), get_config_data()->tomin, am_pm_text(get_config_data()->tohr)); }
static void copy_time_range_into_field(char *field, size_t fsize, uint8_t fromhr, uint8_t frommin, uint8_t tohr, uint8_t tomin ) { snprintf(field, fsize, MENU_SMART_ALARM_TIME_FORMAT, twenty_four_to_twelve(fromhr), frommin, am_pm_text(fromhr), twenty_four_to_twelve(tohr), tomin, am_pm_text(tohr)); }