Improve BT indicator

This commit is contained in:
2026-03-27 18:42:40 -04:00
parent 9fcd671daa
commit 45e42c2c21
4 changed files with 32 additions and 14 deletions

View File

@@ -21,7 +21,8 @@ static GBitmap *s_head_current;
static GBitmap *s_butt_current;
static GBitmap *s_head_next;
static GBitmap *s_butt_next;
static GBitmap *s_bt_icon;
static GBitmap *s_bt0_icon;
static GBitmap *s_bt1_icon;
// declare positions for animation stages
static GRect s_guy_head_grect_on_screen_raised;
@@ -333,10 +334,11 @@ static void main_window_unload(Window *window) {
}
static void bluetooth_callback(bool connected) {
replace_gbitmap_color(GColorLightGray, GColorBlack, s_bt_icon, s_bt_layer);
if (!connected) {
replace_gbitmap_color(GColorBlack, GColorLightGray, s_bt_icon, s_bt_layer);
}
if (connected) {
bitmap_layer_set_bitmap(s_bt_layer, s_bt1_icon);
} else {
bitmap_layer_set_bitmap(s_bt_layer, s_bt0_icon);
}
}
// DEBUG buttons
@@ -390,8 +392,9 @@ static void init() {
s_custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_RETRO_COMPUTER_34));
#endif
// load bluetooth indicator
s_bt_icon = gbitmap_create_with_resource(RESOURCE_ID_BT);
// load bluetooth indicators
s_bt0_icon = gbitmap_create_with_resource(RESOURCE_ID_BT0);
s_bt1_icon = gbitmap_create_with_resource(RESOURCE_ID_BT1);
// dynamically calculate coordinates for date/bt indicators
#if PBL_DISPLAY_WIDTH <= 144
@@ -432,7 +435,6 @@ static void init() {
s_bt_layer = bitmap_layer_create(s_bt_grect_a);
bitmap_layer_set_compositing_mode(s_bt_layer, GCompOpSet);
bitmap_layer_set_alignment(s_bt_layer, GAlignCenter);
bitmap_layer_set_bitmap(s_bt_layer, s_bt_icon);
//// DEBUG memory usage layer
s_memory_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT - 24, PBL_DISPLAY_WIDTH, 14));
text_layer_set_background_color(s_memory_layer, GColorClear);
@@ -443,15 +445,17 @@ static void init() {
// make sure the time is displayed from the start
// and that the date/bt indicators are centered
update_minute_1();
//// register with ConnectionService (bluetooth status)
connection_service_subscribe((ConnectionHandlers){.pebble_app_connection_handler = bluetooth_callback});
//// force a check to display correct bt indicator to start
bluetooth_callback(connection_service_peek_pebble_app_connection());
//// center data/bt indicators
layer_set_frame(text_layer_get_layer(s_date_layer), s_date_grect_a);
layer_set_frame(bitmap_layer_get_layer(s_bt_layer), s_bt_grect_a);
// show the Window on the watch, with animated=true
window_stack_push(s_main_window, true);
// register with ConnectionService (bluetooth status)
connection_service_subscribe((ConnectionHandlers){.pebble_app_connection_handler=bluetooth_callback});
// register with TickTimerService
tick_timer_service_subscribe(MINUTE_UNIT, minute_handler);
@@ -480,7 +484,8 @@ static void deinit() {
gbitmap_destroy(s_butt_current);
gbitmap_destroy(s_head_next);
gbitmap_destroy(s_butt_next);
gbitmap_destroy(s_bt_icon);
gbitmap_destroy(s_bt0_icon);
gbitmap_destroy(s_bt1_icon);
// destroy window
window_destroy(s_main_window);