Add initial configuration
This commit is contained in:
@@ -37,6 +37,7 @@ static GColor8 s_fg_color;
|
||||
|
||||
// bitmaps
|
||||
static GBitmap *s_font_bitmaps[10];
|
||||
static GBitmap *s_time_mg_0;
|
||||
static GBitmap *s_c_icon;
|
||||
static GBitmap *s_h_icon;
|
||||
static GBitmap *s_e_icon;
|
||||
@@ -128,8 +129,11 @@ static void main_window_load() {
|
||||
layer_set_update_proc(s_fuel_mg_layer, fuel_mg_update_proc);
|
||||
|
||||
if (persist_read_bool(storage_key_show_time_mg)) {
|
||||
s_time_mg_0 = gbitmap_create_with_resource(RESOURCE_ID_0);
|
||||
replace_gbitmap_color(GColorWhite, s_mg_color, s_time_mg_0, NULL);
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
s_time_mg_layers[i] = bitmap_layer_create(s_time_grects[i]);
|
||||
bitmap_layer_set_bitmap(s_time_mg_layers[i], s_time_mg_0);
|
||||
bitmap_layer_set_compositing_mode(s_time_mg_layers[i], GCompOpSet);
|
||||
layer_add_child(window_layer, bitmap_layer_get_layer(s_time_mg_layers[i]));
|
||||
}
|
||||
@@ -181,6 +185,9 @@ static void main_window_unload() {
|
||||
if (s_time_mg_layers[i]) {
|
||||
bitmap_layer_destroy(s_time_mg_layers[i]);
|
||||
s_time_mg_layers[i] = NULL;
|
||||
if (i == 0) {
|
||||
gbitmap_destroy(s_time_mg_0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -235,6 +242,25 @@ static void soft_reload(bool first_load) {
|
||||
window_stack_push(s_main_window, false);
|
||||
}
|
||||
|
||||
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
|
||||
Tuple *ready_tuple = dict_find(iter, MESSAGE_KEY_PKJS_READY);
|
||||
if (ready_tuple) {
|
||||
APP_LOG(APP_LOG_LEVEL_DEBUG, "PKJS IS READY");
|
||||
// TODO request temp bars from PKJS
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO set up receive handler for temp bars; be sure to return after to avoid soft reloading
|
||||
|
||||
Tuple *time_mg_tuple = dict_find(iter, MESSAGE_KEY_CLAY_SHOW_TIME_MG);
|
||||
if (time_mg_tuple) {
|
||||
APP_LOG(APP_LOG_LEVEL_DEBUG, "TIME MG TOGGLED");
|
||||
persist_write_bool(storage_key_show_time_mg, time_mg_tuple->value->int32 == 1);
|
||||
soft_reload(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void init() {
|
||||
// load bitmaps
|
||||
s_font_bitmaps[0] = gbitmap_create_with_resource(RESOURCE_ID_0);
|
||||
@@ -263,7 +289,12 @@ static void init() {
|
||||
|
||||
update_minute_1();
|
||||
batt_callback(battery_state_service_peek());
|
||||
|
||||
app_message_register_inbox_received(inbox_received_handler);
|
||||
app_message_open(255, 64);
|
||||
|
||||
soft_reload(true);
|
||||
|
||||
tick_timer_service_subscribe(MINUTE_UNIT, minute_handler);
|
||||
battery_state_service_subscribe(batt_callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user