From 5c1b387b339e8503bed6fc1e1b2ee63a4bd6aa69 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 2 Aug 2026 19:19:57 -0400 Subject: [PATCH] Partial alarm UI update --- README.md | 4 ++-- package.json | 6 +++++ src/c/main.c | 64 +++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 11b7f85..8111c1a 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Trigalarm -A habit-correcting alarm for heavy sleepers. Cannot be shut off until you solve a triangle. +A habit-correcting alarm for heavy sleepers. Cannot be shut off until you describe a triangle. ## The Pitch ### Simple The app only has one page. You can only set one alarm. There is no snooze, there is no weekly schedule, and there is no way to disable the alarm (you'll always have one set - every day - like it or not). ### Persistent -The alarm cannot be stopped until you solve a randomized triangle. Even if you force-close the app, it will re-open itself until you solve the triangle. +The alarm cannot be stopped until you describe a randomized triangle. Even if you force-close the app, it will re-open itself until you correctly describe the triangle. You must identify the type of triangle and provide the equation to solve for θ. ## Why Trigonometry? Because it requires the perfect amount of thought to activate your brain in the morning. If the app gave you a more typical math problem, you could just mindlessly punch it into a calculator. Trigonometry still requires a base amount of thought ("Do I need sine, cosine, or tangent?") before a calculator is of any use. diff --git a/package.json b/package.json index a1c4254..5c96f15 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,12 @@ "file": "mansalva_regular.ttf", "name": "FONT_MANSALVA_REGULAR_22", "type": "font" + }, + { + "characterRegex": "[()]", + "file": "mansalva_regular.ttf", + "name": "FONT_MANSALVA_REGULAR_50", + "type": "font" } ] } diff --git a/src/c/main.c b/src/c/main.c index 187866d..e4c5a24 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -22,13 +22,20 @@ static Layer *s_highlight_layer; //// alarm static TextLayer *s_type_txt_layer; static TextLayer *s_theta_txt_layer; +static TextLayer *s_parenthesis_txt_layer; +static Layer *s_drop_type_layer; +static Layer *s_drop_function_layer; +// static Layer *s_drop_over_layer; +// static Layer *s_drop_under_layer; +static Layer *s_division_layer; // fonts //// setter GFont s_font_lecoish_big; GFont s_font_lecoish_small; //// alarm -GFont s_font_mansalva; +GFont s_font_mansalva_big; +GFont s_font_mansalva_small; // bitmaps //// setter @@ -295,16 +302,16 @@ static void setter_window_load() { static void setter_window_unload() { text_layer_destroy(s_setter_txt_layer); - fonts_unload_custom_font(s_font_lecoish_big); layer_destroy(s_highlight_layer); text_layer_destroy(s_countdown_txt_layer); - fonts_unload_custom_font(s_font_lecoish_small); bitmap_layer_destroy(s_check_bmp_layer); bitmap_layer_destroy(s_clock_bmp_layer); gbitmap_destroy(s_check_bmp); gbitmap_destroy(s_clock_bmp); layer_destroy(s_bottom_bar_layer); layer_destroy(s_top_bar_layer); + fonts_unload_custom_font(s_font_lecoish_big); + fonts_unload_custom_font(s_font_lecoish_small); } static void schedule_fallback_alarm() { @@ -327,6 +334,17 @@ static void alarm_seconds_handler(struct tm *tick_time, TimeUnits units_changed) vibes_short_pulse(); } +static void drop_layer_update_proc(Layer *layer, GContext *ctx) { + graphics_context_set_fill_color(ctx, GColorWhite); + graphics_fill_rect(ctx, layer_get_bounds(layer), 5, GCornersAll); +} + +static void division_layer_update_proc(Layer *layer, GContext *ctx) { + GRect bounds = layer_get_bounds(layer); + graphics_context_set_stroke_color(ctx, GColorWhite); + graphics_draw_line(ctx, GPoint(bounds.origin.x, bounds.origin.y), GPoint(bounds.origin.x + bounds.size.w, bounds.origin.y)); +} + static void alarm_window_load() { Layer *window_layer = window_get_root_layer(s_window); @@ -334,12 +352,12 @@ static void alarm_window_load() { add_bar_layers_to_window(window_layer); // type text - s_font_mansalva = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MANSALVA_REGULAR_22)); - s_type_txt_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 8), PBL_IF_ROUND_ELSE(4, 16), PBL_DISPLAY_WIDTH, 26)); + s_font_mansalva_small = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MANSALVA_REGULAR_22)); + s_type_txt_layer = text_layer_create(GRect(PBL_IF_ROUND_ELSE(0, 7), PBL_IF_ROUND_ELSE(4, 16), PBL_DISPLAY_WIDTH, 26)); text_layer_set_text_alignment(s_type_txt_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft)); text_layer_set_background_color(s_type_txt_layer, GColorClear); text_layer_set_text_color(s_type_txt_layer, GColorWhite); - text_layer_set_font(s_type_txt_layer, s_font_mansalva); + text_layer_set_font(s_type_txt_layer, s_font_mansalva_small); text_layer_set_text(s_type_txt_layer, "type:"); layer_add_child(window_layer, text_layer_get_layer(s_type_txt_layer)); @@ -348,20 +366,50 @@ static void alarm_window_load() { text_layer_set_text_alignment(s_theta_txt_layer, PBL_IF_ROUND_ELSE(GTextAlignmentCenter, GTextAlignmentLeft)); text_layer_set_background_color(s_theta_txt_layer, GColorClear); text_layer_set_text_color(s_theta_txt_layer, GColorWhite); - text_layer_set_font(s_theta_txt_layer, s_font_mansalva); + text_layer_set_font(s_theta_txt_layer, s_font_mansalva_small); text_layer_set_text(s_theta_txt_layer, PBL_IF_ROUND_ELSE("= θ", "θ =")); layer_add_child(window_layer, text_layer_get_layer(s_theta_txt_layer)); + // drop backgrounds + //// type + s_drop_type_layer = layer_create(GRect(PBL_IF_ROUND_ELSE(48, 62), (s_top_bar_grect.size.h / 2) - PBL_IF_ROUND_ELSE(-3, 12), PBL_DISPLAY_WIDTH - PBL_IF_ROUND_ELSE(96, 70), 24)); + layer_set_update_proc(s_drop_type_layer, drop_layer_update_proc); + layer_add_child(window_layer, s_drop_type_layer); + //// function + GRect s_drop_function_grect = GRect(PBL_IF_ROUND_ELSE(48, 45), s_bottom_bar_grect.origin.y + ((s_bottom_bar_grect.size.h / 2) - PBL_IF_ROUND_ELSE(24, 12)), PBL_DISPLAY_WIDTH / 4, 24); + s_drop_function_layer = layer_create(s_drop_function_grect); + layer_set_update_proc(s_drop_function_layer, drop_layer_update_proc); + layer_add_child(window_layer, s_drop_function_layer); + + // parenthesis text + s_font_mansalva_big = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MANSALVA_REGULAR_50)); + s_parenthesis_txt_layer = text_layer_create(GRect(s_drop_function_grect.origin.x + s_drop_function_grect.size.w + 2, s_bottom_bar_grect.origin.y - PBL_IF_ROUND_ELSE(12, 5), 200, 60)); + text_layer_set_background_color(s_parenthesis_txt_layer, GColorClear); + text_layer_set_text_color(s_parenthesis_txt_layer, GColorWhite); + text_layer_set_font(s_parenthesis_txt_layer, s_font_mansalva_big); + text_layer_set_text(s_parenthesis_txt_layer, "( )"); + layer_add_child(window_layer, text_layer_get_layer(s_parenthesis_txt_layer)); + + // division layer + s_division_layer = layer_create(GRect(s_drop_function_grect.origin.x + s_drop_function_grect.size.w + 25, s_drop_function_grect.origin.y + s_drop_function_grect.size.h / 2, 57, 1)); + layer_set_update_proc(s_division_layer, division_layer_update_proc); + layer_add_child(window_layer, s_division_layer); + schedule_fallback_alarm(); tick_timer_service_subscribe(SECOND_UNIT, alarm_seconds_handler); } static void alarm_window_unload() { + layer_destroy(s_division_layer); + text_layer_destroy(s_parenthesis_txt_layer); + layer_destroy(s_drop_function_layer); + layer_destroy(s_drop_type_layer); text_layer_destroy(s_theta_txt_layer); - fonts_unload_custom_font(s_font_mansalva); text_layer_destroy(s_type_txt_layer); layer_destroy(s_bottom_bar_layer); layer_destroy(s_top_bar_layer); + fonts_unload_custom_font(s_font_mansalva_big); + fonts_unload_custom_font(s_font_mansalva_small); } // DEBUG: logic will eventually be mapped to when triangle is solved