classic-lite

Minimalist rewrite of Łukasz Zalewski's "classic" pebble watchface
git clone https://git.instinctive.eu/classic-lite.git
Log | Files | Refs | README | LICENSE

commit 5951270f9d2dd5953ce528f473c0c84c1b6b12a5
parent 74bf3e8c879c7c601b1559131f06e4235bf75f5e
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Tue, 29 Dec 2015 18:22:45 +0000

Add a secondary color for battery icon, to help finer reading
Diffstat:
Mconfig.html | 6++++++
Msrc/classic-lite.c | 26+++++++++++++++++++++++---
Msrc/js/pebble-js-app.js | 2++
3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/config.html b/config.html @@ -39,6 +39,7 @@ "minuteColor": document.getElementById("minuteColorPicker").value, "textColor": document.getElementById("textColorPicker").value, "batteryColor": document.getElementById("batteryColorPicker").value, + "batteryColor2": document.getElementById("batteryColorPicker2").value, "lowBatteryLevel": document.getElementById("lowBatteryLevel").value, "bluetoothColor": document.getElementById("bluetoothColorPicker").value, "bluetoothVibration": document.getElementById("bluetoothVibration").checked ? "1" : "0", @@ -92,6 +93,10 @@ Icon Color <input id="batteryColorPicker" type="text" class="item-color item-color-normal" value="0x555555"> </label> + <label class="item"> + Secondary Icon Color + <input id="batteryColorPicker2" type="text" class="item-color item-color-normal" value="0x555555"> + </label> </div> </div> @@ -149,6 +154,7 @@ document.getElementById("lowBatteryLevelSlider").value = document.getElementById("lowBatteryLevel").value = getQueryParam("battlvl", "50"); document.getElementById("batteryColorPicker").value = getQueryParam("battcol", "0x555555"); + document.getElementById("batteryColorPicker2").value = getQueryParam("battcol2", "0x555555"); document.getElementById("bluetoothColorPicker").value = getQueryParam("bluetooth", "0x000000"); document.getElementById("bluetoothVibration").checked = (parseInt(getQueryParam("vibrate", "1")) > 0); document.getElementById("textColorPicker").value = getQueryParam("textcol", "0x000000"); diff --git a/src/classic-lite.c b/src/classic-lite.c @@ -25,6 +25,7 @@ static GColor background_color; static GColor battery_color; +static GColor battery_color2; static GColor bluetooth_color; static GColor hand_color; static GColor hour_mark_color; @@ -39,10 +40,12 @@ static uint8_t show_battery_icon_below = 100; #ifdef PBL_SDK_3 #define IS_VISIBLE(color) ((color).argb != background_color.argb) +#define IS_EQUAL(color1, color2) ((color1).argb == (color2).argb) #define READ_COLOR(color, byte) do { (color).argb = (byte); } while (0) #define SAVE_COLOR(byte, color) do { (byte) = (color).argb; } while (0) #elif PBL_SDK_2 #define IS_VISIBLE(color) ((color) != background_color) +#define IS_EQUAL(color1, color2) ((color1) == (color2)) #define READ_COLOR(color, byte) do { (color) = (byte); } while (0) #define SAVE_COLOR(byte, color) do { (byte) = (color); } while (0) #endif @@ -81,6 +84,8 @@ read_config(void) { show_battery_icon_below = buffer[10]; memcpy(text_format, buffer + 11, sizeof text_format); + + battery_color2 = battery_color; } static void @@ -244,7 +249,8 @@ static uint8_t current_battery = 100; #define ICON_LAYER_SET_HIDDEN do { \ layer_set_hidden(icon_layer, \ (bluetooth_connected || !IS_VISIBLE(bluetooth_color)) \ - && (has_battery || !IS_VISIBLE(battery_color))); \ + && (has_battery \ + || !(IS_VISIBLE(battery_color) || IS_VISIBLE(battery_color2)))); \ } while (0) #ifdef CACHE_BACKGROUND @@ -556,7 +562,8 @@ icon_layer_draw(Layer *layer, GContext *ctx) { #endif } - if (!has_battery && IS_VISIBLE(battery_color)) { + if (!has_battery + && (IS_VISIBLE(battery_color) || IS_VISIBLE(battery_color2))) { pt.x = center.x - 11; pt.y = center.y + (bluetooth_connected ? 0 : PBL_IF_RECT_ELSE(9, 11)); @@ -567,6 +574,15 @@ icon_layer_draw(Layer *layer, GContext *ctx) { graphics_fill_rect(ctx, GRect(pt.x + 22, pt.y + 2, 2, 3), 0, GCornerNone); + if (!IS_EQUAL(battery_color2, battery_color)) { + graphics_context_set_fill_color(ctx, battery_color2); + graphics_fill_rect(ctx, + GRect(pt.x + 5, pt.y + 1, 4, 5), + 0, GCornerNone); + graphics_fill_rect(ctx, + GRect(pt.x + 13, pt.y + 1, 4, 5), + 0, GCornerNone); + } graphics_context_set_fill_color(ctx, background_color); if (current_battery >= 5) graphics_fill_rect(ctx, @@ -647,7 +663,10 @@ inbox_received_handler(DictionaryIterator *iterator, void *context) { text_color = color_from_tuple(tuple); text_layer_set_text_color(text_layer, text_color); break; - /* case 9: is reserved for a future color */ + case 9: + battery_color2 = color_from_tuple(tuple); + layer_mark_dirty(icon_layer); + break; /* case 10: TODO: text_font */ case 11: if (tuple->type == TUPLE_CSTRING) { @@ -795,6 +814,7 @@ init(void) { battery_color = GColorDarkGray; inner_rectangle_color = GColorLightGray; #endif + battery_color2 = battery_color; bluetooth_connected = connection_service_peek_pebble_app_connection(); current_battery = battery_state_service_peek().charge_percent; diff --git a/src/js/pebble-js-app.js b/src/js/pebble-js-app.js @@ -22,6 +22,7 @@ const settings = { /* "name in local storage": "form input parameter" */ "minuteColor": "minutes", "lowBatteryLevel": "battlvl", "batteryColor": "battcol", + "batteryColor2": "battcol2", "bluetoothColor": "bluetooth", "bluetoothVibration": "vibrate", "textColor": "textcol", @@ -63,6 +64,7 @@ Pebble.addEventListener("webviewclosed", function(e) { 6: parseInt(configData["innerColor"]), 7: parseInt(configData["minuteColor"]), 8: parseInt(configData["textColor"]), + 9: parseInt(configData["batteryColor2"]), 11: configData["textFormat"], 12: parseInt(configData["bluetoothVibration"]), 13: parseInt(configData["lowBatteryLevel"]),