Partial alarm UI update

This commit is contained in:
2026-08-02 19:19:57 -04:00
parent 030732c3b2
commit 5c1b387b33
3 changed files with 64 additions and 10 deletions
+2 -2
View File
@@ -1,11 +1,11 @@
# Trigalarm # 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 ## The Pitch
### Simple ### 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). 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 ### 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? ## 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. 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.
+6
View File
@@ -72,6 +72,12 @@
"file": "mansalva_regular.ttf", "file": "mansalva_regular.ttf",
"name": "FONT_MANSALVA_REGULAR_22", "name": "FONT_MANSALVA_REGULAR_22",
"type": "font" "type": "font"
},
{
"characterRegex": "[()]",
"file": "mansalva_regular.ttf",
"name": "FONT_MANSALVA_REGULAR_50",
"type": "font"
} }
] ]
} }
+56 -8
View File
@@ -22,13 +22,20 @@ static Layer *s_highlight_layer;
//// alarm //// alarm
static TextLayer *s_type_txt_layer; static TextLayer *s_type_txt_layer;
static TextLayer *s_theta_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 // fonts
//// setter //// setter
GFont s_font_lecoish_big; GFont s_font_lecoish_big;
GFont s_font_lecoish_small; GFont s_font_lecoish_small;
//// alarm //// alarm
GFont s_font_mansalva; GFont s_font_mansalva_big;
GFont s_font_mansalva_small;
// bitmaps // bitmaps
//// setter //// setter
@@ -295,16 +302,16 @@ static void setter_window_load() {
static void setter_window_unload() { static void setter_window_unload() {
text_layer_destroy(s_setter_txt_layer); text_layer_destroy(s_setter_txt_layer);
fonts_unload_custom_font(s_font_lecoish_big);
layer_destroy(s_highlight_layer); layer_destroy(s_highlight_layer);
text_layer_destroy(s_countdown_txt_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_check_bmp_layer);
bitmap_layer_destroy(s_clock_bmp_layer); bitmap_layer_destroy(s_clock_bmp_layer);
gbitmap_destroy(s_check_bmp); gbitmap_destroy(s_check_bmp);
gbitmap_destroy(s_clock_bmp); gbitmap_destroy(s_clock_bmp);
layer_destroy(s_bottom_bar_layer); layer_destroy(s_bottom_bar_layer);
layer_destroy(s_top_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() { static void schedule_fallback_alarm() {
@@ -327,6 +334,17 @@ static void alarm_seconds_handler(struct tm *tick_time, TimeUnits units_changed)
vibes_short_pulse(); 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() { static void alarm_window_load() {
Layer *window_layer = window_get_root_layer(s_window); 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); add_bar_layers_to_window(window_layer);
// type text // type text
s_font_mansalva = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MANSALVA_REGULAR_22)); 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, 8), PBL_IF_ROUND_ELSE(4, 16), PBL_DISPLAY_WIDTH, 26)); 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_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_background_color(s_type_txt_layer, GColorClear);
text_layer_set_text_color(s_type_txt_layer, GColorWhite); 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:"); text_layer_set_text(s_type_txt_layer, "type:");
layer_add_child(window_layer, text_layer_get_layer(s_type_txt_layer)); 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_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_background_color(s_theta_txt_layer, GColorClear);
text_layer_set_text_color(s_theta_txt_layer, GColorWhite); 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("= θ", "θ =")); 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)); 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(); schedule_fallback_alarm();
tick_timer_service_subscribe(SECOND_UNIT, alarm_seconds_handler); tick_timer_service_subscribe(SECOND_UNIT, alarm_seconds_handler);
} }
static void alarm_window_unload() { 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); text_layer_destroy(s_theta_txt_layer);
fonts_unload_custom_font(s_font_mansalva);
text_layer_destroy(s_type_txt_layer); text_layer_destroy(s_type_txt_layer);
layer_destroy(s_bottom_bar_layer); layer_destroy(s_bottom_bar_layer);
layer_destroy(s_top_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 // DEBUG: logic will eventually be mapped to when triangle is solved