diff options
| author | LLLL Colonq <llll@colonq> | 2026-06-08 18:45:05 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2026-06-08 18:45:05 -0400 |
| commit | c60b54646439fb3c02b59a2bd7ff03d96d4aa91e (patch) | |
| tree | ebfb97ffd3dd06b6769338a23d8e5d25b5731dde /lcolonq/src | |
| parent | 39220190956935dc71564ffa135d99744a67bf27 (diff) | |
Diffstat (limited to 'lcolonq/src')
| -rw-r--r-- | lcolonq/src/c/lcolonq.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/lcolonq/src/c/lcolonq.c b/lcolonq/src/c/lcolonq.c new file mode 100644 index 0000000..ad44905 --- /dev/null +++ b/lcolonq/src/c/lcolonq.c @@ -0,0 +1,51 @@ +#include <pebble.h> + +static Window *WINDOW; +static TextLayer *TIME_TEXT_LAYER; + +static void tick_handler(struct tm *tick_time, TimeUnits units_changed) { + (void) units_changed; + static char buf[16]; + // time_t temp = time(NULL); + // struct tm *tick_time = localtime(&temp); + strftime(buf, sizeof(buf), "%H:%M", tick_time); + text_layer_set_text(TIME_TEXT_LAYER, buf); +} + +static void main_window_load(Window *window) { + Layer *window_layer = window_get_root_layer(window); + GRect bounds = layer_get_bounds(window_layer); + TIME_TEXT_LAYER = text_layer_create(GRect(0, 52, bounds.size.w, 50)); + text_layer_set_background_color(TIME_TEXT_LAYER, GColorClear); + text_layer_set_text_color(TIME_TEXT_LAYER, GColorWhite); + text_layer_set_font(TIME_TEXT_LAYER, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD)); + text_layer_set_text_alignment(TIME_TEXT_LAYER, GTextAlignmentCenter); + layer_add_child(window_layer, text_layer_get_layer(TIME_TEXT_LAYER)); +} +static void main_window_unload(Window *window) { + text_layer_destroy(TIME_TEXT_LAYER); +} + +static void init() { + WINDOW = window_create(); + window_set_background_color(WINDOW, GColorBlack); + window_set_window_handlers(WINDOW, (WindowHandlers) { + .load = main_window_load, + .unload = main_window_unload + }); + window_stack_push(WINDOW, true); + time_t temp = time(NULL); + struct tm *tick_time = localtime(&temp); + tick_handler(tick_time, MINUTE_UNIT); + tick_timer_service_subscribe(MINUTE_UNIT, tick_handler); +} + +static void deinit() { + window_destroy(WINDOW); +} + +int main(void) { + init(); + app_event_loop(); + deinit(); +} |
