this repo has no description
0
fork

Configure Feed

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

minor fixes, cleanup

alice 74b98d22 4f10ae71

+19 -15
+7 -12
src/c/clock_closest_airport_noon.h
··· 3 3 4 4 // A header-only implementation of a Pebble clock module that displays the 5 5 // IATA code of a randomly-chosen airport whose local time is the *closest past 6 - //* but not before* 12:00:00 (noon) relative to the current UTC. The 6 + // but not before* 12:00:00 (noon) relative to the current UTC. The 7 7 // underlying data come from the generated `airport_tz_list.c`, which is built 8 8 // by `generate_airport_tz_list.py`. 9 9 // ··· 205 205 206 206 // Update text layers --------------------------------------------------- 207 207 text_layer_set_text(code_layer, s_selected_code); 208 - 209 208 long offset_seconds = (long)(s_selected_offset_hours * 3600.0f); 210 - time_t local_epoch = current_utc_t + offset_seconds; 211 - struct tm *local_tm = gmtime(&local_epoch); 212 - 209 + // Compute local time using utc_tm and offset to avoid second gmtime() 210 + long total_local_secs = (utc_tm->tm_hour * 3600L + utc_tm->tm_min * 60L + utc_tm->tm_sec + offset_seconds) % DAY_SECONDS; 211 + if (total_local_secs < 0) total_local_secs += DAY_SECONDS; 212 + int local_min = (int)((total_local_secs / 60) % 60); 213 + int local_sec = (int)(total_local_secs % 60); 213 214 static char s_timebuf[10]; 214 - if (local_tm) { 215 - snprintf(s_timebuf, sizeof(s_timebuf), "%02d:%02d", local_tm->tm_min, local_tm->tm_sec); 216 - } else { 217 - snprintf(s_timebuf, sizeof(s_timebuf), "ERR"); 218 - } 215 + snprintf(s_timebuf, sizeof(s_timebuf), "%02d:%02d", local_min, local_sec); 219 216 text_layer_set_text(time_layer, s_timebuf); 220 217 } 221 218 ··· 224 221 #endif 225 222 226 223 #endif /* CLOCK_CLOSEST_AIRPORT_NOON_H */ 227 - 228 - // Note: using airport_name_offsets[] directly for name lookup
+12 -3
src/c/watchface.c
··· 45 45 } 46 46 47 47 static void inbox_received_handler(DictionaryIterator *iter, void *context) { 48 + (void)context; 48 49 APP_LOG(APP_LOG_LEVEL_INFO, "Inbox received!"); 49 50 // Read timeAlignmentMode preference 50 51 Tuple *target_time_mode_t = dict_find(iter, MESSAGE_KEY_timeAlignmentMode); ··· 71 72 72 73 // Handles updates from the TickTimerService 73 74 static void tick_handler(struct tm *tick_time, TimeUnits units_changed) { 75 + (void)tick_time; 76 + (void)units_changed; 74 77 time_t seconds; 75 78 uint16_t milliseconds; 76 79 time_ms(&seconds, &milliseconds); ··· 133 136 } 134 137 135 138 static void main_window_unload(Window *window) { 139 + (void)window; 136 140 // Destroy Closest Noon layers 137 141 clock_closest_airport_noon_deinit(s_airport_noon_code_layer); 138 142 text_layer_destroy(s_airport_noon_name_layer); ··· 142 146 } 143 147 144 148 static void init() { 145 - srand(time(NULL)); 146 - 149 + { 150 + time_t seed_sec; 151 + uint16_t seed_ms; 152 + time_ms(&seed_sec, &seed_ms); 153 + srand((unsigned int)(seed_sec * 1000 + seed_ms)); 154 + } 147 155 // Load settings 148 156 load_settings(); 149 157 ··· 182 190 } 183 191 184 192 static void deinit() { 185 - window_destroy(s_main_window); 193 + tick_timer_service_unsubscribe(); 194 + window_destroy(s_main_window); 186 195 } 187 196 188 197 int main(void) {