Skip to content

Commit f95a63a

Browse files
committed
Fixed date color, and nices battery indicator
* Added ACTIVAE_COLOR_LOOP define for easy testing of display (dev.tool) * Fixed date color * Better color for battery charge (25-60%) * Use legible color for battery border, and filled background.
1 parent 8396e50 commit f95a63a

File tree

3 files changed

+50
-24
lines changed

3 files changed

+50
-24
lines changed

appinfo.json

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
"resources": {
3030
"media": [
3131
{
32-
"file": "images/battery.png",
33-
"name": "IMAGE_BATTERY",
32+
"file": "images/plugged.png",
33+
"name": "IMAGE_PLUGGED",
3434
"type": "png"
3535
},
3636
{
37-
"file": "images/bluetooth.png",
38-
"name": "IMAGE_BLUETOOTH",
37+
"file": "images/charging.png",
38+
"name": "IMAGE_CHARGING",
3939
"type": "png"
4040
},
4141
{
@@ -50,13 +50,8 @@
5050
"type": "png"
5151
},
5252
{
53-
"file": "images/charging.png",
54-
"name": "IMAGE_CHARGING",
55-
"type": "png"
56-
},
57-
{
58-
"file": "images/plugged.png",
59-
"name": "IMAGE_PLUGGED",
53+
"file": "images/bluetooth.png",
54+
"name": "IMAGE_BLUETOOTH",
6055
"type": "png"
6156
}
6257
]
@@ -67,7 +62,7 @@
6762
"basalt"
6863
],
6964
"uuid": "1289bd91-5811-40a5-a270-e8f97c126f18",
70-
"versionLabel": "0.9",
65+
"versionLabel": "0.10",
7166
"watchapp": {
7267
"watchface": true
7368
}

resources/images/battery.png

-929 Bytes
Binary file not shown.

src/main.c

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#define USE_FIXED_TIME_FOR_PUBLISHING_IMAGE 0
55

6+
#define ACTIVATE_COLOR_LOOP 0
7+
68
// BEGIN AUTO-GENERATED UI CODE; DO NOT MODIFY
79
static Window *s_window;
810
static GFont s_res_bitham_30_black;
@@ -138,9 +140,9 @@ static struct {
138140
.s_1x1R_square = {{113, 57}, { 29, 29}}, // 1x1 Square (right)
139141
.s_5x5_square = {{ 1, 85}, {141, 85}}, // 5x5 Square
140142
.s_outline = {{ -1, -1}, {146, 170}}, // outline (hide it outside the view)
141-
.s_time = {{ 0, 81}, {144, 40}},
142-
.s_date = {{ 0, 112}, {144, 40}},
143-
.s_week = {{ 0, 128}, {144, 40}},
143+
.s_time = {{ 0, 84}, {144, 40}},
144+
.s_date = {{ 0, 114}, {144, 40}},
145+
.s_week = {{ 0, 131}, {144, 40}},
144146
// }, { // FiboDispHorzontal, Not fully implemented yet (needs to rotate or move center of each arc)
145147
// .s_3x3_square = {{ 3, 75}, { 52, 52}}, // 3x3 Square
146148
// .s_2x2_square = {{ 3, 41}, { 35, 35}}, // 2x2 Square
@@ -165,6 +167,14 @@ static GBitmap *s_cross_image;
165167
static int s_curr_hour;
166168
static int s_curr_min;
167169

170+
// Path
171+
static GColor s_legibleColor;
172+
static GPath *s_bat_frame_path_ptr = NULL;
173+
static const GPathInfo BAT_FRAME_PATH_INFO = {
174+
.num_points = 8,
175+
.points = (GPoint []) {{4, 0}, {9, 0}, {9, 2}, {11, 2}, {11, 21}, {2, 21}, {2, 2}, {4, 2}}
176+
};
177+
168178
// Settings
169179
enum { // DON'T CHANGE THE ORDER OF THESES!!!
170180
ConfShowTime = 1,
@@ -307,6 +317,14 @@ static void fibo_layer_update_callback(Layer *layer, GContext *ctx) {
307317
if (m >= 1) { fc1R |= 0x02; m -= 1; } // The order of these two lines have been swapped, intentionally
308318
if (m >= 1) { fc1L |= 0x02; m -= 1; } // The order of these two lines have been swapped, intentionally
309319

320+
#if ACTIVATE_COLOR_LOOP
321+
{
322+
static int8_t cnt = 0;
323+
fc5 = cnt;
324+
cnt = (cnt == 3) ? 0 : cnt + 1;
325+
}
326+
#endif
327+
310328
// Draw the time boxes
311329
graphics_context_set_fill_color(ctx, fill_color[fc3]);
312330
graphics_fill_rect(ctx, fibo[conf.fiboDisplay].s_3x3_square, 0, GCornerNone);
@@ -317,9 +335,12 @@ static void fibo_layer_update_callback(Layer *layer, GContext *ctx) {
317335
graphics_context_set_fill_color(ctx, fill_color[fc1R]);
318336
graphics_fill_rect(ctx, fibo[conf.fiboDisplay].s_1x1R_square, 0, GCornerNone);
319337
graphics_context_set_fill_color(ctx, fill_color[fc5]);
320-
text_layer_set_text_color(s_time_layer, conf.legibleText ? gcolor_legible_over(fill_color[fc5]): conf.timeColor);
321-
text_layer_set_text_color(s_week_layer, conf.legibleText ? gcolor_legible_over(fill_color[fc5]): conf.timeColor);
322-
text_layer_set_text_color(s_time_layer, conf.legibleText ? gcolor_legible_over(fill_color[fc5]): conf.timeColor);
338+
339+
s_legibleColor = gcolor_legible_over(fill_color[fc5]); // Also used for battery frame
340+
341+
text_layer_set_text_color(s_time_layer, conf.legibleText ? s_legibleColor: conf.timeColor);
342+
text_layer_set_text_color(s_date_layer, conf.legibleText ? s_legibleColor: conf.timeColor);
343+
text_layer_set_text_color(s_week_layer, conf.legibleText ? s_legibleColor: conf.timeColor);
323344
graphics_fill_rect(ctx, fibo[conf.fiboDisplay].s_5x5_square, 0, GCornerNone);
324345

325346
// Draw the grid
@@ -357,11 +378,15 @@ static void charge_layer_update_callback(Layer *layer, GContext *ctx) {
357378
if (batChargeState.charge_percent >= 60) {
358379
charge_color = GColorGreen;
359380
} else if (batChargeState.charge_percent >= 25) {
360-
charge_color = GColorYellow;
381+
charge_color = GColorChromeYellow;
361382
} else {
362383
charge_color = GColorRed;
363384
}
364385

386+
// Fill the battery frame
387+
graphics_context_set_fill_color(ctx, GColorBlack);
388+
gpath_draw_filled(ctx, s_bat_frame_path_ptr);
389+
365390
// Draw battery charge
366391
graphics_context_set_fill_color(ctx, charge_color);
367392
int h = (100 - batChargeState.charge_percent) / 5 + 1;
@@ -372,9 +397,9 @@ static void charge_layer_update_callback(Layer *layer, GContext *ctx) {
372397
graphics_draw_pixel(ctx, GPoint(3, 1));
373398
graphics_draw_pixel(ctx, GPoint(10, 1));
374399

375-
// Draw battery outline
376-
graphics_context_set_compositing_mode(ctx, GCompOpSet);
377-
graphics_draw_bitmap_in_rect(ctx, s_battery_image, gbitmap_get_bounds(s_battery_image));
400+
// Stroke the battery frame
401+
graphics_context_set_stroke_color(ctx, (conf.fiboDisplay == FiboDispZoomed) ? s_legibleColor : GColorWhite);
402+
gpath_draw_outline(ctx, s_bat_frame_path_ptr);
378403

379404
if (batChargeState.is_charging) {
380405
// Draw charging icon
@@ -746,15 +771,18 @@ void show_main(void) {
746771
layer_set_update_proc(s_bluetooth_layer, bluetooth_layer_update_callback);
747772

748773
// Create bitmaps
749-
s_battery_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BATTERY);
750774
s_charging_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_CHARGING);
751775
s_plugged_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PLUGGED);
752776
s_bluetooth_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH);
753777
s_cross_image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_CROSS);
754778

755779
// Register with TickTimerService
780+
#if ACTIVATE_COLOR_LOOP
781+
tick_timer_service_subscribe(SECOND_UNIT, tick_handler);
782+
#else
756783
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
757-
784+
#endif
785+
758786
// Register with BatteryStateService
759787
battery_state_service_subscribe(battery_charge_handler);
760788

@@ -769,6 +797,9 @@ void show_main(void) {
769797
layer_set_hidden(text_layer_get_layer(s_date_layer), !(conf.showDate || conf.showMonth));
770798
layer_set_hidden(text_layer_get_layer(s_week_layer), !conf.showWeekNum);
771799

800+
// Create used path
801+
s_bat_frame_path_ptr = gpath_create(&BAT_FRAME_PATH_INFO);
802+
772803
// Make sure that the currnet time is displayed from the start
773804
time_t temp = time(NULL);
774805
struct tm *tick_time = localtime(&temp);

0 commit comments

Comments
 (0)