this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

redesign, fixes

alice b0af04fd 3858900f

+82 -67
+30 -43
src/c/clock_closest_noon.c
··· 87 87 88 88 // --- Interface Functions (Pebble only) --- 89 89 90 - TextLayer* clock_closest_noon_init(GRect bounds, Layer *window_layer) { 91 - TextLayer* layer = text_layer_util_create(bounds, window_layer, "Wait...", FONT_KEY_GOTHIC_18_BOLD); 92 - 90 + // Initializes the city name TextLayer for Closest Noon 91 + TextLayer* clock_closest_noon_city_init(GRect bounds, Layer *window_layer) { 92 + TextLayer* layer = text_layer_util_create(bounds, window_layer, "Wait...", FONT_KEY_GOTHIC_24_BOLD); 93 93 // Initialize static vars 94 94 s_selected_city_name = "Wait..."; 95 - s_selected_offset_hours = 0.0f; 96 95 s_last_update_time = -1; 97 - s_last_re_evaluation_time = -1; // Force re-evaluation on first update 96 + s_last_re_evaluation_time = -1; 97 + return layer; 98 + } 98 99 100 + // Initializes the hero time TextLayer for Closest Noon 101 + TextLayer* clock_closest_noon_time_init(GRect bounds, Layer *window_layer) { 102 + TextLayer* layer = text_layer_util_create(bounds, window_layer, "--:--", FONT_KEY_LECO_42_NUMBERS); 103 + s_selected_offset_hours = 0.0f; 99 104 return layer; 100 105 } 101 106 ··· 105 110 } 106 111 } 107 112 108 - void clock_closest_noon_update(TextLayer *layer, time_t current_utc_t) { 109 - if (!layer) return; 113 + // Updates both the city and hero time TextLayers for Closest Noon 114 + void clock_closest_noon_update(TextLayer *city_layer, TextLayer *time_layer, time_t current_utc_t) { 115 + if (!city_layer || !time_layer) return; 110 116 111 117 // Avoid redundant updates for the same second 112 118 if (current_utc_t == s_last_update_time) { ··· 115 121 s_last_update_time = current_utc_t; 116 122 117 123 // --- Check if it's time for re-evaluation --- 118 - struct tm *utc_tm_struct = gmtime(&current_utc_t); // Use a different name to avoid shadowing 124 + struct tm *utc_tm_struct = gmtime(&current_utc_t); 119 125 bool needs_re_evaluation = false; 120 - 121 - // Check if gmtime succeeded and if it's a re-evaluation time point (:00, :15, :30) 122 126 if (utc_tm_struct && (utc_tm_struct->tm_min % 15 == 0) && (utc_tm_struct->tm_min != 45) && (utc_tm_struct->tm_sec == 0)) { 123 - // Avoid re-evaluating multiple times within the same second if update is called rapidly 124 - if (current_utc_t != s_last_re_evaluation_time) { 127 + if (current_utc_t != s_last_re_evaluation_time) { 125 128 needs_re_evaluation = true; 126 - } 129 + } 127 130 } else if (s_last_re_evaluation_time == -1) { 128 131 // Ensure initial evaluation happens if starting between intervals 129 132 needs_re_evaluation = true; ··· 133 136 update_selected_timezone_and_city(current_utc_t); 134 137 } 135 138 139 + // Format and set city name 140 + text_layer_set_text(city_layer, s_selected_city_name ? s_selected_city_name : "ERR"); 136 141 137 - // --- Calculate current local time based on selected zone --- 138 - // Use the stored offset from the last re-evaluation 139 - long current_offset_seconds = (long)(s_selected_offset_hours * 3600.0f); 140 - time_t local_time_epoch = current_utc_t + current_offset_seconds; // Use a distinct name 141 - 142 - // --- Format and display the time --- 143 - struct tm *current_local_tm_struct = gmtime(&local_time_epoch); // Use gmtime to format based on the calculated local epoch time 144 - 145 - // Check if a valid city was selected in the last evaluation or if it's fallback 146 - if (s_selected_city_name && strcmp(s_selected_city_name, "Wait...") != 0 && 147 - strncmp(s_selected_city_name, "ERR:", 4) != 0) 148 - { 149 - if (current_local_tm_struct) { 150 - // Display format: CityName:MM:SS using actual local time 151 - snprintf(s_closest_noon_buffer, sizeof(s_closest_noon_buffer), 152 - "%s:%02d:%02d", 153 - s_selected_city_name, // Already checked for null/error states 154 - current_local_tm_struct->tm_min, 155 - current_local_tm_struct->tm_sec); 156 - } else { 157 - // Handle gmtime failure for a selected city 158 - snprintf(s_closest_noon_buffer, sizeof(s_closest_noon_buffer), "%s:ERR:TIME", 159 - s_selected_city_name); 160 - } 142 + // Calculate and format hero time (MM:SS) 143 + long offset_seconds = (long)(s_selected_offset_hours * 3600.0f); 144 + time_t local_epoch = current_utc_t + offset_seconds; 145 + struct tm *local_tm_struct = gmtime(&local_epoch); 146 + static char s_time_buffer[10]; 147 + if (local_tm_struct) { 148 + // Hero time: display minutes and seconds 149 + snprintf(s_time_buffer, sizeof(s_time_buffer), "%02d:%02d", 150 + local_tm_struct->tm_min, 151 + local_tm_struct->tm_sec); 161 152 } else { 162 - // Display the fallback/error name directly (e.g., "Wait...", "ERR:NOZONE") 163 - snprintf(s_closest_noon_buffer, sizeof(s_closest_noon_buffer), "%s", 164 - s_selected_city_name ? s_selected_city_name : "ERR:NULL"); 153 + snprintf(s_time_buffer, sizeof(s_time_buffer), "ERR"); 165 154 } 166 - 167 - 168 - text_layer_set_text(layer, s_closest_noon_buffer); 155 + text_layer_set_text(time_layer, s_time_buffer); 169 156 }
+8 -5
src/c/clock_closest_noon.h
··· 4 4 #include <pebble.h> // Pebble time_t definition and UI types 5 5 #include <stddef.h> // For size_t 6 6 7 - // Initializes the Closest Noon clock layer 8 - TextLayer* clock_closest_noon_init(GRect bounds, Layer *window_layer); 7 + // Initializes the city name TextLayer for the Closest Noon clock 8 + TextLayer* clock_closest_noon_city_init(GRect bounds, Layer *window_layer); 9 + 10 + // Initializes the hero time TextLayer for the Closest Noon clock 11 + TextLayer* clock_closest_noon_time_init(GRect bounds, Layer *window_layer); 9 12 10 - // Deinitializes the Closest Noon clock layer 13 + // Deinitializes a Closest Noon TextLayer (city or time) 11 14 void clock_closest_noon_deinit(TextLayer *layer); 12 15 13 - // Updates the Closest Noon clock layer 14 - void clock_closest_noon_update(TextLayer *layer, time_t current_seconds_utc); 16 + // Updates the Closest Noon city and time TextLayers 17 + void clock_closest_noon_update(TextLayer *city_layer, TextLayer *time_layer, time_t current_seconds_utc); 15 18 16 19 #endif // CLOCK_CLOSEST_NOON_H
+44 -19
src/c/watchface.c
··· 10 10 11 11 // --- Window and Layer Globals --- 12 12 static Window *s_main_window; 13 - static TextLayer *s_beat_layer; 13 + static TextLayer *s_closest_noon_city_layer; 14 + static TextLayer *s_closest_noon_time_layer; 14 15 static TextLayer *s_tid_layer; 15 - static TextLayer *s_closest_noon_layer; 16 - static TextLayer *s_decimal_layer; 16 + static TextLayer *s_beat_layer; 17 17 18 18 // --- Pebble Window Management --- 19 19 ··· 22 22 time_t seconds; 23 23 uint16_t milliseconds; 24 24 time_ms(&seconds, &milliseconds); 25 - 26 - // Update both time displays 27 - clock_beat_update(s_beat_layer, seconds); 25 + // Hero: Closest Noon (update city and time layers) 26 + clock_closest_noon_update(s_closest_noon_city_layer, s_closest_noon_time_layer, seconds); 27 + // Footer: TID (larger) and Beat (smaller) 28 28 clock_tid_update(s_tid_layer, seconds, milliseconds); 29 - clock_closest_noon_update(s_closest_noon_layer, seconds); 30 - clock_decimal_update(s_decimal_layer, seconds); 29 + clock_beat_update(s_beat_layer, seconds); 31 30 } 32 31 33 32 static void main_window_load(Window *window) { 34 33 Layer *window_layer = window_get_root_layer(window); 35 34 GRect bounds = layer_get_bounds(window_layer); 36 - const int16_t total_h = bounds.size.h; 37 - const int16_t layer_h = total_h / 4; 35 + // Hero area for Closest Noon: split into city + large time 36 + int footer_h = 48; 37 + int hero_h = bounds.size.h - footer_h; 38 + const int city_h = 24; 39 + const int usable_h = hero_h - city_h; 40 + const int time_font_h = 42; 41 + // Create city name line 42 + s_closest_noon_city_layer = clock_closest_noon_city_init( 43 + GRect(0, 0, bounds.size.w, city_h), window_layer); 44 + text_layer_set_text_alignment(s_closest_noon_city_layer, GTextAlignmentCenter); 45 + // Create hero time line, vertically centered 46 + int time_y = city_h + (usable_h - time_font_h) / 2; 47 + s_closest_noon_time_layer = clock_closest_noon_time_init( 48 + GRect(0, time_y, bounds.size.w, time_font_h), window_layer); 49 + 50 + // Setup footer area 51 + int w = bounds.size.w; 52 + int h = bounds.size.h; 53 + int footer_y = h - footer_h; 54 + // Two line heights to fit fonts without clipping 55 + int tid_h = 26; // tall enough for 18px font + padding 56 + int beat_h = footer_h - tid_h; 38 57 39 - // Create layers 40 - s_beat_layer = clock_beat_init(GRect(0, 0, bounds.size.w, layer_h), window_layer); 41 - s_decimal_layer = clock_decimal_init(GRect(0, layer_h, bounds.size.w, layer_h), window_layer); 42 - s_closest_noon_layer = clock_closest_noon_init(GRect(0, 2 * layer_h, bounds.size.w, layer_h), window_layer); 43 - s_tid_layer = clock_tid_init(GRect(0, 3 * layer_h, bounds.size.w, layer_h), window_layer); 58 + // Footer line 1: TID (bigger, center aligned) 59 + s_tid_layer = clock_tid_init(GRect(0, footer_y, w, tid_h), window_layer); 60 + text_layer_set_font(s_tid_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD)); 61 + text_layer_set_text_alignment(s_tid_layer, GTextAlignmentCenter); 62 + 63 + // Footer line 2: Beat (smaller, center aligned) 64 + s_beat_layer = clock_beat_init(GRect(0, footer_y + tid_h, w, beat_h), window_layer); 65 + text_layer_set_font(s_beat_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14)); 66 + text_layer_set_text_alignment(s_beat_layer, GTextAlignmentCenter); 44 67 } 45 68 46 69 static void main_window_unload(Window *window) { 47 - // Destroy TextLayers 70 + // Destroy Closest Noon layers 71 + clock_closest_noon_deinit(s_closest_noon_city_layer); 72 + clock_closest_noon_deinit(s_closest_noon_time_layer); 73 + clock_tid_deinit(s_tid_layer); 48 74 clock_beat_deinit(s_beat_layer); 49 - clock_closest_noon_deinit(s_closest_noon_layer); 50 - clock_tid_deinit(s_tid_layer); 51 - clock_decimal_deinit(s_decimal_layer); 52 75 } 53 76 54 77 static void init() { ··· 56 79 57 80 // Create main Window element and assign to pointer 58 81 s_main_window = window_create(); 82 + // Ensure text layers with clear background show up on white 83 + window_set_background_color(s_main_window, GColorWhite); 59 84 60 85 // Set handlers to manage the elements inside the Window 61 86 window_set_window_handlers(