|
|
|
|
@@ -28,6 +28,7 @@ typedef struct {
|
|
|
|
|
int ns_start;
|
|
|
|
|
int ns_stop;
|
|
|
|
|
bool backlight;
|
|
|
|
|
bool weekday;
|
|
|
|
|
|
|
|
|
|
} Preferences;
|
|
|
|
|
|
|
|
|
|
@@ -52,14 +53,20 @@ enum {
|
|
|
|
|
KEY_NS_START,
|
|
|
|
|
KEY_NS_STOP,
|
|
|
|
|
KEY_BACKLIGHT,
|
|
|
|
|
KEY_WEEKDAY,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define KEY_DEBUGWATCH 50
|
|
|
|
|
|
|
|
|
|
#define PREFERENCES_KEY 0
|
|
|
|
|
|
|
|
|
|
#define US_DATE (!curPrefs.eu_date) // true == MM/DD, false == DD/MM
|
|
|
|
|
#define SCREENSHOTMODE false
|
|
|
|
|
|
|
|
|
|
#define EU_DATE (curPrefs.eu_date) // true == MM/DD, false == DD/MM
|
|
|
|
|
#define WEEKDAY (curPrefs.weekday)
|
|
|
|
|
#define CENTER_DATE (curPrefs.center)
|
|
|
|
|
#define DISCONNECT_VIBRATION (curPrefs.btvibe)
|
|
|
|
|
#define CONTRAST_WHILE_CHARGING (curPrefs.contrast)
|
|
|
|
|
#define CONTRAST_WHILE_CHARGING PBL_IF_BW_ELSE(false, (curPrefs.contrast))
|
|
|
|
|
#define LIGHT_WHILE_CHARGING (curPrefs.backlight)
|
|
|
|
|
#define DISABLE_ANIM (curPrefs.nightsaver)
|
|
|
|
|
#define DISABLE_ANIM_START_TIME (curPrefs.ns_start)
|
|
|
|
|
@@ -71,8 +78,8 @@ enum {
|
|
|
|
|
#define NUMSLOTS PBL_IF_RECT_ELSE(8, 18)
|
|
|
|
|
#define SPACING_X TILE_SIZE
|
|
|
|
|
#define SPACING_Y (curPrefs.large_mode ? TILE_SIZE - 1 : TILE_SIZE)
|
|
|
|
|
#define DIGIT_CHANGE_ANIM_DURATION 1500
|
|
|
|
|
#define STARTDELAY (curPrefs.quick_start ? 1000 : 2000)
|
|
|
|
|
#define DIGIT_CHANGE_ANIM_DURATION (curPrefs.quick_start ? 1500 : 2000)
|
|
|
|
|
#define STARTDELAY (curPrefs.quick_start ? 700 : 2000)
|
|
|
|
|
|
|
|
|
|
#define NUMBER_BASE_COLOR_ARGB8 (curPrefs.number_base_color)
|
|
|
|
|
#define ORNAMENT_BASE_COLOR_ARGB8 (curPrefs.ornament_base_color)
|
|
|
|
|
@@ -82,11 +89,13 @@ enum {
|
|
|
|
|
#define BACKGROUND_COLOR PBL_IF_BW_ELSE((INVERT ? GColorWhite : GColorBlack), ((GColor8) { .argb = curPrefs.background_color }))
|
|
|
|
|
|
|
|
|
|
#define FONT blocks
|
|
|
|
|
#define ALPHAFONT alphablocks
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
Layer *layer;
|
|
|
|
|
int prevDigit;
|
|
|
|
|
int curDigit;
|
|
|
|
|
bool isalpha;
|
|
|
|
|
int divider;
|
|
|
|
|
AnimationProgress normTime;
|
|
|
|
|
int slotIndex;
|
|
|
|
|
@@ -94,6 +103,8 @@ typedef struct {
|
|
|
|
|
|
|
|
|
|
digitSlot slot[NUMSLOTS];
|
|
|
|
|
|
|
|
|
|
static char weekday_buffer[16];
|
|
|
|
|
|
|
|
|
|
AnimationImplementation animImpl;
|
|
|
|
|
Animation *anim;
|
|
|
|
|
bool splashEnded = false;
|
|
|
|
|
@@ -183,13 +194,168 @@ unsigned char blocks[][5][5] = {{
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1}
|
|
|
|
|
}, {
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1}
|
|
|
|
|
},
|
|
|
|
|
[99] = {
|
|
|
|
|
{1,1,1,1,1},
|
|
|
|
|
{1,1,1,1,1},
|
|
|
|
|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1,1,1,1}
|
|
|
|
|
},
|
|
|
|
|
[86] = { // V
|
|
|
|
|
{1,0,2,0,1},
|
|
|
|
|
{1,0,2,0,1},
|
|
|
|
|
{1,0,2,0,1},
|
|
|
|
|
{1,0,0,0,1},
|
|
|
|
|
{1,1,1,1,0}
|
|
|
|
|
},
|
|
|
|
|
[87] = { // W
|
|
|
|
|
{1,0,2,0,1},
|
|
|
|
|
{1,0,0,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,1,1,1,1}
|
|
|
|
|
},
|
|
|
|
|
[10] = {
|
|
|
|
|
{2,2,2,2,2},
|
|
|
|
|
{0,0,0,0,0},
|
|
|
|
|
{2,2,2,2,2},
|
|
|
|
|
{0,0,0,0,0},
|
|
|
|
|
{2,2,2,2,2}
|
|
|
|
|
},
|
|
|
|
|
[11] = {
|
|
|
|
|
{2,0,2,0,2},
|
|
|
|
|
{2,0,2,0,2},
|
|
|
|
|
{2,0,2,0,2},
|
|
|
|
|
{2,0,2,0,2},
|
|
|
|
|
{2,0,2,0,2}
|
|
|
|
|
},
|
|
|
|
|
[12] = {
|
|
|
|
|
{1,1,1,1,1},
|
|
|
|
|
{0,0,0,0,0},
|
|
|
|
|
{1,1,1,1,1},
|
|
|
|
|
{0,0,0,0,0},
|
|
|
|
|
{1,1,1,1,1}
|
|
|
|
|
},
|
|
|
|
|
[13] = {
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1},
|
|
|
|
|
{1,0,1,0,1}
|
|
|
|
|
}};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int startDigit[18] = {
|
|
|
|
|
11,12,12,11,11,12,10,13,12,11,12,11,11,12,10,13,12,10 // 2x h, 2x m, 4x date, 2x filler top, 4x filler sides, 2x filler bottom, 2x filler bottom sides
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char variation[] = {
|
|
|
|
|
0b00000000, 0b00010000, 0b00000100, 0b00010000, 0b00000000,
|
|
|
|
|
0b00010001, 0b00010000, 0b00000000, 0b00000101, 0b00010000,
|
|
|
|
|
@@ -254,7 +420,7 @@ uint8_t combine_colors(uint8_t fg_color, uint8_t bg_color) {
|
|
|
|
|
#define ORIGIN_X PBL_IF_RECT_ELSE(((144 - TILES_X)/2), ((180 - TILES_X)/2))
|
|
|
|
|
#define ORIGIN_Y PBL_IF_RECT_ELSE((curPrefs.large_mode ? 1 : TILE_SIZE*1.5), (TILE_SIZE*2.2))
|
|
|
|
|
|
|
|
|
|
static bool contrastmode = false, previous_contrastmode = false, allow_animate = true;
|
|
|
|
|
static bool contrastmode = false, previous_contrastmode = false, allow_animate = true, initial_anim = false;
|
|
|
|
|
|
|
|
|
|
static void handle_bluetooth(bool connected) {
|
|
|
|
|
if (DISCONNECT_VIBRATION && !connected) {
|
|
|
|
|
@@ -328,15 +494,22 @@ static GRect slotFrame(int i) {
|
|
|
|
|
return GRect(x, y, w, h);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GColor8 getSlotColor(int x, int y, int digit, int pos) {
|
|
|
|
|
static GColor8 getSlotColor(int x, int y, int digit, int pos, bool isalpha) {
|
|
|
|
|
int argb;
|
|
|
|
|
bool should_add_var = false;
|
|
|
|
|
if (FONT[digit][y][x] == 0) {
|
|
|
|
|
int thisrect = FONT[digit][y][x];
|
|
|
|
|
if (isalpha) {
|
|
|
|
|
thisrect = ALPHAFONT[digit][y][x];
|
|
|
|
|
}
|
|
|
|
|
if (SCREENSHOTMODE) {
|
|
|
|
|
thisrect = FONT[99][y][x];
|
|
|
|
|
}
|
|
|
|
|
if (thisrect == 0) {
|
|
|
|
|
if (contrastmode) {
|
|
|
|
|
return GColorBlack;
|
|
|
|
|
}
|
|
|
|
|
return BACKGROUND_COLOR;
|
|
|
|
|
} else if (FONT[digit][y][x] == 1) {
|
|
|
|
|
} else if (thisrect == 1) {
|
|
|
|
|
#if defined(PBL_COLOR)
|
|
|
|
|
if (contrastmode && pos >= 8) {
|
|
|
|
|
argb = 0b11000000;
|
|
|
|
|
@@ -368,8 +541,12 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos) {
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
if (should_add_var) {
|
|
|
|
|
if (argb == 0b11111111) {
|
|
|
|
|
argb -= variation[ ( y*5 + x + digit*17 + pos*19 )%sizeof(variation) ];
|
|
|
|
|
} else {
|
|
|
|
|
argb += variation[ ( y*5 + x + digit*17 + pos*19 )%sizeof(variation) ];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (pos >= 8) {
|
|
|
|
|
int argb_temp = shadowtable[alpha & argb];
|
|
|
|
|
if (argb_temp == BACKGROUND_COLOR.argb) {
|
|
|
|
|
@@ -403,8 +580,8 @@ static void updateSlot(Layer *layer, GContext *ctx) {
|
|
|
|
|
ty = t / FONT_HEIGHT_BLOCKS;
|
|
|
|
|
shift = 0-(t-ty);
|
|
|
|
|
|
|
|
|
|
GColor8 oldColor = getSlotColor(tx, ty, slot->prevDigit, slot->slotIndex);
|
|
|
|
|
GColor8 newColor = getSlotColor(tx, ty, slot->curDigit, slot->slotIndex);
|
|
|
|
|
GColor8 oldColor = getSlotColor(tx, ty, slot->prevDigit, slot->slotIndex, slot->isalpha);
|
|
|
|
|
GColor8 newColor = getSlotColor(tx, ty, slot->curDigit, slot->slotIndex, slot->isalpha);
|
|
|
|
|
|
|
|
|
|
graphics_context_set_fill_color(ctx, oldColor);
|
|
|
|
|
graphics_fill_rect(ctx, GRect((tx*tilesize)-(tx*widthadjust), ty*tilesize-(ty*widthadjust), tilesize-widthadjust, tilesize-widthadjust), 0, GCornerNone);
|
|
|
|
|
@@ -455,7 +632,7 @@ static void destroyAnimation() {
|
|
|
|
|
void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
|
int ho, mi, da, mo, i;
|
|
|
|
|
|
|
|
|
|
if (splashEnded) {
|
|
|
|
|
if (splashEnded && !initial_anim) {
|
|
|
|
|
if (animation_is_scheduled(anim)){
|
|
|
|
|
animation_unschedule(anim);
|
|
|
|
|
animation_destroy(anim);
|
|
|
|
|
@@ -465,19 +642,41 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
|
da = t->tm_mday;
|
|
|
|
|
mo = t->tm_mon+1;
|
|
|
|
|
if (debug) {
|
|
|
|
|
ho = 9;
|
|
|
|
|
//ho = 9;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (WEEKDAY) {
|
|
|
|
|
strftime(weekday_buffer, sizeof(weekday_buffer), "%a", t);
|
|
|
|
|
for (int i=0; i<2; i++) {
|
|
|
|
|
if ((int) weekday_buffer[i] == 225) { // á
|
|
|
|
|
weekday_buffer[i] = 65; // A
|
|
|
|
|
}
|
|
|
|
|
if ((int) weekday_buffer[i] > 90) { // lower case
|
|
|
|
|
weekday_buffer[i] =weekday_buffer[i]-0x20; // make upper case
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "It is now %d:%d %d.%d.", (int)ho, (int)mi, (int)da, (int)mo);
|
|
|
|
|
if (WEEKDAY) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "The Weekday is %c%c", weekday_buffer[0], weekday_buffer[1]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
allow_animate = true;
|
|
|
|
|
if (DISABLE_ANIM) {
|
|
|
|
|
if (DISABLE_ANIM_START_TIME > DISABLE_ANIM_END_TIME) {
|
|
|
|
|
if (DISABLE_ANIM_START_TIME == DISABLE_ANIM_END_TIME) {
|
|
|
|
|
allow_animate = false;
|
|
|
|
|
if (debug) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "No Animation because activation and deactivation times are the same");
|
|
|
|
|
}
|
|
|
|
|
} else if (DISABLE_ANIM_START_TIME > DISABLE_ANIM_END_TIME) {
|
|
|
|
|
// across midnight
|
|
|
|
|
if (ho >= DISABLE_ANIM_START_TIME || ho < DISABLE_ANIM_END_TIME) {
|
|
|
|
|
allow_animate = false;
|
|
|
|
|
if (debug) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Hour %d was after %d and before %d", (int)ho, (int)DISABLE_ANIM_START_TIME , (int)DISABLE_ANIM_END_TIME );
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "No Animation because time is between %d:00 and %d:00", (int)DISABLE_ANIM_START_TIME , (int)DISABLE_ANIM_END_TIME );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
@@ -485,7 +684,7 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
|
if (ho >= DISABLE_ANIM_START_TIME && ho < DISABLE_ANIM_END_TIME) {
|
|
|
|
|
allow_animate = false;
|
|
|
|
|
if (debug) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Hour %d was after %d and before %d", (int)ho, (int)DISABLE_ANIM_START_TIME , (int)DISABLE_ANIM_END_TIME );
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "No Animation because time is between %d:00 and %d:00", (int)DISABLE_ANIM_START_TIME , (int)DISABLE_ANIM_END_TIME );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -499,9 +698,22 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
|
slot[1].curDigit = ho%10;
|
|
|
|
|
slot[2].curDigit = mi/10;
|
|
|
|
|
slot[3].curDigit = mi%10;
|
|
|
|
|
if (US_DATE) {
|
|
|
|
|
|
|
|
|
|
slot[4].isalpha = false;
|
|
|
|
|
slot[5].isalpha = false;
|
|
|
|
|
slot[6].isalpha = false;
|
|
|
|
|
slot[7].isalpha = false;
|
|
|
|
|
|
|
|
|
|
if (!EU_DATE) {
|
|
|
|
|
if (WEEKDAY) {
|
|
|
|
|
slot[4].isalpha = true;
|
|
|
|
|
slot[5].isalpha = true;
|
|
|
|
|
slot[4].curDigit = (int) weekday_buffer[0];
|
|
|
|
|
slot[5].curDigit = (int) weekday_buffer[1];
|
|
|
|
|
} else {
|
|
|
|
|
slot[4].curDigit = mo/10;
|
|
|
|
|
slot[5].curDigit = mo%10;
|
|
|
|
|
}
|
|
|
|
|
if (CENTER_DATE && da < 10) {
|
|
|
|
|
slot[6].curDigit = da%10;
|
|
|
|
|
if (slot[7].prevDigit == 10 || slot[7].prevDigit == 12) {
|
|
|
|
|
@@ -516,6 +728,12 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
|
} else {
|
|
|
|
|
slot[4].curDigit = da/10;
|
|
|
|
|
slot[5].curDigit = da%10;
|
|
|
|
|
if (WEEKDAY) {
|
|
|
|
|
slot[6].isalpha = true;
|
|
|
|
|
slot[7].isalpha = true;
|
|
|
|
|
slot[6].curDigit = (int) weekday_buffer[0];
|
|
|
|
|
slot[7].curDigit = (int) weekday_buffer[1];
|
|
|
|
|
} else {
|
|
|
|
|
if (CENTER_DATE && mo < 10) {
|
|
|
|
|
slot[6].curDigit = mo%10;
|
|
|
|
|
if (slot[7].prevDigit == 10 || slot[7].prevDigit == 12) {
|
|
|
|
|
@@ -528,6 +746,7 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
|
slot[7].curDigit = mo%10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NO_ZERO) {
|
|
|
|
|
if (debug) {
|
|
|
|
|
@@ -553,8 +772,10 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
|
slot[0].curDigit = 10;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (debug) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Slot 0 is now %d", (int) slot[0].curDigit);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (slot[4].curDigit == 0) {
|
|
|
|
|
slot[4].curDigit = 10;
|
|
|
|
|
if (slot[4].prevDigit == 10) {
|
|
|
|
|
@@ -582,6 +803,13 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void initialAnimationDone() {
|
|
|
|
|
if (debug) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Stopped initial Animation");
|
|
|
|
|
}
|
|
|
|
|
initial_anim = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handle_timer(void *data) {
|
|
|
|
|
time_t curTime;
|
|
|
|
|
|
|
|
|
|
@@ -589,6 +817,15 @@ void handle_timer(void *data) {
|
|
|
|
|
|
|
|
|
|
curTime = time(NULL);
|
|
|
|
|
handle_tick(localtime(&curTime), SECOND_UNIT|MINUTE_UNIT|HOUR_UNIT|DAY_UNIT|MONTH_UNIT|YEAR_UNIT);
|
|
|
|
|
initial_anim = true;
|
|
|
|
|
if (debug) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Starting initial Animation");
|
|
|
|
|
}
|
|
|
|
|
if (initial_anim) {
|
|
|
|
|
app_timer_register(contrastmode ? 500 : DIGIT_CHANGE_ANIM_DURATION, initialAnimationDone, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -662,6 +899,7 @@ static void teardownUI() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void battery_handler(BatteryChargeState charge_state) {
|
|
|
|
|
#if defined(PBL_COLOR)
|
|
|
|
|
if (CONTRAST_WHILE_CHARGING) {
|
|
|
|
|
previous_contrastmode = contrastmode;
|
|
|
|
|
if (charge_state.is_plugged) {
|
|
|
|
|
@@ -674,6 +912,7 @@ static void battery_handler(BatteryChargeState charge_state) {
|
|
|
|
|
setupUI();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
if (LIGHT_WHILE_CHARGING) {
|
|
|
|
|
if (charge_state.is_plugged) {
|
|
|
|
|
light_enable(true);
|
|
|
|
|
@@ -702,6 +941,20 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
|
Tuple *ns_start_t = dict_find(iter, KEY_NS_START);
|
|
|
|
|
Tuple *ns_stop_t = dict_find(iter, KEY_NS_STOP);
|
|
|
|
|
Tuple *backlight_t = dict_find(iter, KEY_BACKLIGHT);
|
|
|
|
|
Tuple *weekday_t = dict_find(iter, KEY_WEEKDAY);
|
|
|
|
|
Tuple *debug_t = dict_find(iter, KEY_DEBUGWATCH);
|
|
|
|
|
|
|
|
|
|
bool was_config = true;
|
|
|
|
|
|
|
|
|
|
if (debug_t) {
|
|
|
|
|
if (debug_t->value->int8 == 1) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Enabling debug infos for debug watch");
|
|
|
|
|
debug = true;
|
|
|
|
|
was_config = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (was_config) {
|
|
|
|
|
|
|
|
|
|
if (large_mode_t) {
|
|
|
|
|
curPrefs.large_mode = large_mode_t->value->int8;
|
|
|
|
|
@@ -757,8 +1010,12 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
|
if (backlight_t) {
|
|
|
|
|
curPrefs.backlight = backlight_t->value->int8;
|
|
|
|
|
}
|
|
|
|
|
if (weekday_t) {
|
|
|
|
|
curPrefs.weekday = weekday_t->value->int8;
|
|
|
|
|
}
|
|
|
|
|
persist_write_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs));
|
|
|
|
|
vibes_short_pulse();
|
|
|
|
|
#if defined(PBL_COLOR)
|
|
|
|
|
if (curPrefs.contrast == false) {
|
|
|
|
|
contrastmode = false;
|
|
|
|
|
previous_contrastmode = false;
|
|
|
|
|
@@ -769,6 +1026,7 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
|
previous_contrastmode = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
if (curPrefs.backlight == false) {
|
|
|
|
|
light_enable(false);
|
|
|
|
|
} else {
|
|
|
|
|
@@ -788,17 +1046,17 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
|
if (debug) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Done");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void in_dropped_handler(AppMessageResult reason, void *context) {
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_WARNING, "Dropped a message because %i", (int)reason);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void init() {
|
|
|
|
|
if (watch_info_get_model()==WATCH_INFO_MODEL_UNKNOWN) {
|
|
|
|
|
debug = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void init() {
|
|
|
|
|
setlocale(LC_ALL, "en_US");
|
|
|
|
|
window = window_create();
|
|
|
|
|
|
|
|
|
|
// Set up preferences
|
|
|
|
|
@@ -824,6 +1082,7 @@ static void init() {
|
|
|
|
|
.ns_start = 0,
|
|
|
|
|
.ns_stop = 6,
|
|
|
|
|
.backlight = false,
|
|
|
|
|
.weekday = false,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -832,12 +1091,14 @@ static void init() {
|
|
|
|
|
BatteryChargeState charge_state = battery_state_service_peek();
|
|
|
|
|
|
|
|
|
|
if (charge_state.is_plugged) {
|
|
|
|
|
#if defined(PBL_COLOR)
|
|
|
|
|
if (CONTRAST_WHILE_CHARGING) {
|
|
|
|
|
previous_contrastmode = true;
|
|
|
|
|
contrastmode = true;
|
|
|
|
|
teardownUI();
|
|
|
|
|
setupUI();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
if (LIGHT_WHILE_CHARGING) {
|
|
|
|
|
light_enable(true);
|
|
|
|
|
}
|
|
|
|
|
@@ -850,10 +1111,6 @@ static void init() {
|
|
|
|
|
|
|
|
|
|
tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
|
|
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
//light_enable(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handle_bluetooth(connection_service_peek_pebble_app_connection());
|
|
|
|
|
|
|
|
|
|
battery_state_service_subscribe(battery_handler);
|
|
|
|
|
|