Improve BT indicator
This commit is contained in:
17
package.json
17
package.json
@@ -674,9 +674,22 @@
|
|||||||
"type": "bitmap"
|
"type": "bitmap"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "images/bt.png",
|
"file": "images/bt-0.png",
|
||||||
"memoryFormat": "Smallest",
|
"memoryFormat": "Smallest",
|
||||||
"name": "BT",
|
"name": "BT0",
|
||||||
|
"spaceOptimization": "storage",
|
||||||
|
"targetPlatforms": [
|
||||||
|
"basalt",
|
||||||
|
"chalk",
|
||||||
|
"emery",
|
||||||
|
"gabbro"
|
||||||
|
],
|
||||||
|
"type": "bitmap"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"file": "images/bt-1.png",
|
||||||
|
"memoryFormat": "Smallest",
|
||||||
|
"name": "BT1",
|
||||||
"spaceOptimization": "storage",
|
"spaceOptimization": "storage",
|
||||||
"targetPlatforms": [
|
"targetPlatforms": [
|
||||||
"basalt",
|
"basalt",
|
||||||
|
|||||||
BIN
resources/images/bt-0.png
Normal file
BIN
resources/images/bt-0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 129 B |
|
Before Width: | Height: | Size: 128 B After Width: | Height: | Size: 128 B |
29
src/c/main.c
29
src/c/main.c
@@ -21,7 +21,8 @@ static GBitmap *s_head_current;
|
|||||||
static GBitmap *s_butt_current;
|
static GBitmap *s_butt_current;
|
||||||
static GBitmap *s_head_next;
|
static GBitmap *s_head_next;
|
||||||
static GBitmap *s_butt_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
|
// declare positions for animation stages
|
||||||
static GRect s_guy_head_grect_on_screen_raised;
|
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) {
|
static void bluetooth_callback(bool connected) {
|
||||||
replace_gbitmap_color(GColorLightGray, GColorBlack, s_bt_icon, s_bt_layer);
|
if (connected) {
|
||||||
if (!connected) {
|
bitmap_layer_set_bitmap(s_bt_layer, s_bt1_icon);
|
||||||
replace_gbitmap_color(GColorBlack, GColorLightGray, s_bt_icon, s_bt_layer);
|
} else {
|
||||||
}
|
bitmap_layer_set_bitmap(s_bt_layer, s_bt0_icon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DEBUG buttons
|
// 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));
|
s_custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_RETRO_COMPUTER_34));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// load bluetooth indicator
|
// load bluetooth indicators
|
||||||
s_bt_icon = gbitmap_create_with_resource(RESOURCE_ID_BT);
|
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
|
// dynamically calculate coordinates for date/bt indicators
|
||||||
#if PBL_DISPLAY_WIDTH <= 144
|
#if PBL_DISPLAY_WIDTH <= 144
|
||||||
@@ -432,7 +435,6 @@ static void init() {
|
|||||||
s_bt_layer = bitmap_layer_create(s_bt_grect_a);
|
s_bt_layer = bitmap_layer_create(s_bt_grect_a);
|
||||||
bitmap_layer_set_compositing_mode(s_bt_layer, GCompOpSet);
|
bitmap_layer_set_compositing_mode(s_bt_layer, GCompOpSet);
|
||||||
bitmap_layer_set_alignment(s_bt_layer, GAlignCenter);
|
bitmap_layer_set_alignment(s_bt_layer, GAlignCenter);
|
||||||
bitmap_layer_set_bitmap(s_bt_layer, s_bt_icon);
|
|
||||||
//// DEBUG memory usage layer
|
//// DEBUG memory usage layer
|
||||||
s_memory_layer = text_layer_create(GRect(0, PBL_DISPLAY_HEIGHT - 24, PBL_DISPLAY_WIDTH, 14));
|
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);
|
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
|
// make sure the time is displayed from the start
|
||||||
// and that the date/bt indicators are centered
|
// and that the date/bt indicators are centered
|
||||||
update_minute_1();
|
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(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);
|
layer_set_frame(bitmap_layer_get_layer(s_bt_layer), s_bt_grect_a);
|
||||||
|
|
||||||
// show the Window on the watch, with animated=true
|
// show the Window on the watch, with animated=true
|
||||||
window_stack_push(s_main_window, 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
|
// register with TickTimerService
|
||||||
tick_timer_service_subscribe(MINUTE_UNIT, minute_handler);
|
tick_timer_service_subscribe(MINUTE_UNIT, minute_handler);
|
||||||
|
|
||||||
@@ -480,7 +484,8 @@ static void deinit() {
|
|||||||
gbitmap_destroy(s_butt_current);
|
gbitmap_destroy(s_butt_current);
|
||||||
gbitmap_destroy(s_head_next);
|
gbitmap_destroy(s_head_next);
|
||||||
gbitmap_destroy(s_butt_next);
|
gbitmap_destroy(s_butt_next);
|
||||||
gbitmap_destroy(s_bt_icon);
|
gbitmap_destroy(s_bt0_icon);
|
||||||
|
gbitmap_destroy(s_bt1_icon);
|
||||||
|
|
||||||
// destroy window
|
// destroy window
|
||||||
window_destroy(s_main_window);
|
window_destroy(s_main_window);
|
||||||
|
|||||||
Reference in New Issue
Block a user