|
|
|
@@ -2,7 +2,7 @@
|
|
|
|
* Original source code by lastfuture
|
|
|
|
* Original source code by lastfuture
|
|
|
|
* SDK 2.0beta4 port by Jnm
|
|
|
|
* SDK 2.0beta4 port by Jnm
|
|
|
|
* SDK 3.0 port and colorizing by hexahedria
|
|
|
|
* SDK 3.0 port and colorizing by hexahedria
|
|
|
|
* adaptations for Chalk and Aplite by lastfuture
|
|
|
|
* adaptations for Chalk and Aplite as well as continued development by lastfuture
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <pebble.h>
|
|
|
|
#include <pebble.h>
|
|
|
|
@@ -21,6 +21,14 @@ typedef struct {
|
|
|
|
bool ornament_variation;
|
|
|
|
bool ornament_variation;
|
|
|
|
bool invert;
|
|
|
|
bool invert;
|
|
|
|
bool monochrome;
|
|
|
|
bool monochrome;
|
|
|
|
|
|
|
|
bool center;
|
|
|
|
|
|
|
|
bool btvibe;
|
|
|
|
|
|
|
|
bool contrast;
|
|
|
|
|
|
|
|
bool nightsaver;
|
|
|
|
|
|
|
|
int ns_start;
|
|
|
|
|
|
|
|
int ns_stop;
|
|
|
|
|
|
|
|
bool backlight;
|
|
|
|
|
|
|
|
|
|
|
|
} Preferences;
|
|
|
|
} Preferences;
|
|
|
|
|
|
|
|
|
|
|
|
Preferences curPrefs;
|
|
|
|
Preferences curPrefs;
|
|
|
|
@@ -37,11 +45,25 @@ enum {
|
|
|
|
KEY_ORNAMENT_VARIATION,
|
|
|
|
KEY_ORNAMENT_VARIATION,
|
|
|
|
KEY_INVERT,
|
|
|
|
KEY_INVERT,
|
|
|
|
KEY_MONOCHROME,
|
|
|
|
KEY_MONOCHROME,
|
|
|
|
|
|
|
|
KEY_CENTER,
|
|
|
|
|
|
|
|
KEY_BTVIBE,
|
|
|
|
|
|
|
|
KEY_CONTRAST,
|
|
|
|
|
|
|
|
KEY_NIGHTSAVER,
|
|
|
|
|
|
|
|
KEY_NS_START,
|
|
|
|
|
|
|
|
KEY_NS_STOP,
|
|
|
|
|
|
|
|
KEY_BACKLIGHT,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define PREFERENCES_KEY 0
|
|
|
|
#define PREFERENCES_KEY 0
|
|
|
|
|
|
|
|
|
|
|
|
#define US_DATE (!curPrefs.eu_date) // true == MM/DD, false == DD/MM
|
|
|
|
#define US_DATE (!curPrefs.eu_date) // true == MM/DD, false == DD/MM
|
|
|
|
|
|
|
|
#define CENTER_DATE (curPrefs.center)
|
|
|
|
|
|
|
|
#define DISCONNECT_VIBRATION (curPrefs.btvibe)
|
|
|
|
|
|
|
|
#define CONTRAST_WHILE_CHARGING (curPrefs.contrast)
|
|
|
|
|
|
|
|
#define LIGHT_WHILE_CHARGING (curPrefs.backlight)
|
|
|
|
|
|
|
|
#define DISABLE_ANIM (curPrefs.nightsaver)
|
|
|
|
|
|
|
|
#define DISABLE_ANIM_START_TIME (curPrefs.ns_start)
|
|
|
|
|
|
|
|
#define DISABLE_ANIM_END_TIME (curPrefs.ns_stop)
|
|
|
|
#define NO_ZERO (!curPrefs.leading_zero) // true == replaces leading Zero for hour, day, month with a "cycler"
|
|
|
|
#define NO_ZERO (!curPrefs.leading_zero) // true == replaces leading Zero for hour, day, month with a "cycler"
|
|
|
|
#define TILE_SIZE PBL_IF_RECT_ELSE((curPrefs.large_mode ? 12 : 10), 10)
|
|
|
|
#define TILE_SIZE PBL_IF_RECT_ELSE((curPrefs.large_mode ? 12 : 10), 10)
|
|
|
|
#define INVERT (curPrefs.invert)
|
|
|
|
#define INVERT (curPrefs.invert)
|
|
|
|
@@ -70,7 +92,6 @@ typedef struct {
|
|
|
|
int slotIndex;
|
|
|
|
int slotIndex;
|
|
|
|
} digitSlot;
|
|
|
|
} digitSlot;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
digitSlot slot[NUMSLOTS];
|
|
|
|
digitSlot slot[NUMSLOTS];
|
|
|
|
|
|
|
|
|
|
|
|
AnimationImplementation animImpl;
|
|
|
|
AnimationImplementation animImpl;
|
|
|
|
@@ -192,25 +213,32 @@ unsigned char variation[] = {
|
|
|
|
0b00000000, 0b00000001, 0b00010001, 0b00000101, 0b00010100
|
|
|
|
0b00000000, 0b00000001, 0b00010001, 0b00000101, 0b00010100
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static uint8_t shadowtable[] = {192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
|
|
|
|
static uint8_t shadowtable[] = {
|
|
|
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
|
|
|
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
|
|
|
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
|
|
|
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
|
|
|
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, \
|
|
|
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
|
|
|
|
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
|
|
|
|
192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,
|
|
|
|
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
|
|
|
|
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197,
|
|
|
|
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197, \
|
|
|
|
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197,
|
|
|
|
208,208,208,209,208,208,208,209,208,208,208,209,212,212,212,213, \
|
|
|
|
192,192,192,193,192,192,192,193,192,192,192,193,196,196,196,197,
|
|
|
|
192,192,193,194,192,192,193,194,196,196,197,198,200,200,201,202, \
|
|
|
|
208,208,208,209,208,208,208,209,208,208,208,209,212,212,212,213,
|
|
|
|
192,192,193,194,192,192,193,194,196,196,197,198,200,200,201,202, \
|
|
|
|
192,192,193,194,192,192,193,194,196,196,197,198,200,200,201,202,
|
|
|
|
208,208,209,210,208,208,209,210,212,212,213,214,216,216,217,218, \
|
|
|
|
192,192,193,194,192,192,193,194,196,196,197,198,200,200,201,202,
|
|
|
|
224,224,225,226,224,224,225,226,228,228,229,230,232,232,233,234, \
|
|
|
|
208,208,209,210,208,208,209,210,212,212,213,214,216,216,217,218,
|
|
|
|
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, \
|
|
|
|
224,224,225,226,224,224,225,226,228,228,229,230,232,232,233,234,
|
|
|
|
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, \
|
|
|
|
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
|
|
|
|
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, \
|
|
|
|
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
|
|
|
|
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255};
|
|
|
|
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
|
|
|
|
|
|
|
|
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
|
|
|
|
|
|
|
|
};
|
|
|
|
// alpha should only be 0b??111111 where ?? = 00 (full shade), 01 (much shade), 10 (some shade), 11 (none shade)
|
|
|
|
// alpha should only be 0b??111111 where ?? = 00 (full shade), 01 (much shade), 10 (some shade), 11 (none shade)
|
|
|
|
static uint8_t alpha = 0b10111111;
|
|
|
|
static uint8_t alpha = 0b10111111;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
uint8_t combine_colors(uint8_t fg_color, uint8_t bg_color) {
|
|
|
|
|
|
|
|
return (shadowtable[((~fg_color)&0b11000000) + (bg_color&63)]&63) + shadowtable[fg_color];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#define FONT_HEIGHT_BLOCKS (sizeof *FONT / sizeof **FONT)
|
|
|
|
#define FONT_HEIGHT_BLOCKS (sizeof *FONT / sizeof **FONT)
|
|
|
|
#define FONT_WIDTH_BLOCKS (sizeof **FONT)
|
|
|
|
#define FONT_WIDTH_BLOCKS (sizeof **FONT)
|
|
|
|
@@ -226,6 +254,19 @@ static uint8_t alpha = 0b10111111;
|
|
|
|
#define ORIGIN_X PBL_IF_RECT_ELSE(((144 - TILES_X)/2), ((180 - TILES_X)/2))
|
|
|
|
#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))
|
|
|
|
#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 void handle_bluetooth(bool connected) {
|
|
|
|
|
|
|
|
if (DISCONNECT_VIBRATION && !connected) {
|
|
|
|
|
|
|
|
static uint32_t const segments[] = { 200, 200, 50, 150, 200 };
|
|
|
|
|
|
|
|
VibePattern pat = {
|
|
|
|
|
|
|
|
.durations = segments,
|
|
|
|
|
|
|
|
.num_segments = ARRAY_LENGTH(segments),
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
vibes_enqueue_custom_pattern(pat);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GRect slotFrame(int i) {
|
|
|
|
static GRect slotFrame(int i) {
|
|
|
|
int x, y, w, h;
|
|
|
|
int x, y, w, h;
|
|
|
|
if (i<4) { // main digits
|
|
|
|
if (i<4) { // main digits
|
|
|
|
@@ -262,7 +303,7 @@ static GRect slotFrame(int i) {
|
|
|
|
if (i%2) {
|
|
|
|
if (i%2) {
|
|
|
|
x = ORIGIN_X + FONT_WIDTH + SPACING_X + FONT_WIDTH + SPACING_X;
|
|
|
|
x = ORIGIN_X + FONT_WIDTH + SPACING_X + FONT_WIDTH + SPACING_X;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
x = ORIGIN_X - FONT_WIDTH - SPACING_X;
|
|
|
|
x = (int) (ORIGIN_X - FONT_WIDTH - SPACING_X);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i<12) {
|
|
|
|
if (i<12) {
|
|
|
|
y = ORIGIN_Y;
|
|
|
|
y = ORIGIN_Y;
|
|
|
|
@@ -291,11 +332,18 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos) {
|
|
|
|
int argb;
|
|
|
|
int argb;
|
|
|
|
bool should_add_var = false;
|
|
|
|
bool should_add_var = false;
|
|
|
|
if (FONT[digit][y][x] == 0) {
|
|
|
|
if (FONT[digit][y][x] == 0) {
|
|
|
|
|
|
|
|
if (contrastmode) {
|
|
|
|
|
|
|
|
return GColorBlack;
|
|
|
|
|
|
|
|
}
|
|
|
|
return BACKGROUND_COLOR;
|
|
|
|
return BACKGROUND_COLOR;
|
|
|
|
} else if (FONT[digit][y][x] == 1) {
|
|
|
|
} else if (FONT[digit][y][x] == 1) {
|
|
|
|
#if defined(PBL_COLOR)
|
|
|
|
#if defined(PBL_COLOR)
|
|
|
|
argb = NUMBER_BASE_COLOR_ARGB8;
|
|
|
|
if (contrastmode && pos >= 8) {
|
|
|
|
should_add_var = NUMBER_ADD_VARIATION;
|
|
|
|
argb = 0b11000000;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
argb = contrastmode ? 0b11111111 : NUMBER_BASE_COLOR_ARGB8;
|
|
|
|
|
|
|
|
should_add_var = contrastmode ? false : NUMBER_ADD_VARIATION;
|
|
|
|
|
|
|
|
}
|
|
|
|
#elif defined(PBL_BW)
|
|
|
|
#elif defined(PBL_BW)
|
|
|
|
if (!INVERT) {
|
|
|
|
if (!INVERT) {
|
|
|
|
argb = 0b11111111;
|
|
|
|
argb = 0b11111111;
|
|
|
|
@@ -305,8 +353,8 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
#if defined(PBL_COLOR)
|
|
|
|
#if defined(PBL_COLOR)
|
|
|
|
argb = ORNAMENT_BASE_COLOR_ARGB8;
|
|
|
|
argb = contrastmode ? 0b11000001 : ORNAMENT_BASE_COLOR_ARGB8;
|
|
|
|
should_add_var = ORNAMENT_ADD_VARIATION;
|
|
|
|
should_add_var = contrastmode ? false : ORNAMENT_ADD_VARIATION;
|
|
|
|
#elif defined(PBL_BW)
|
|
|
|
#elif defined(PBL_BW)
|
|
|
|
if (GREYS) {
|
|
|
|
if (GREYS) {
|
|
|
|
argb = 0b11010101;
|
|
|
|
argb = 0b11010101;
|
|
|
|
@@ -324,7 +372,7 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pos >= 8) {
|
|
|
|
if (pos >= 8) {
|
|
|
|
int argb_temp = shadowtable[alpha & argb];
|
|
|
|
int argb_temp = shadowtable[alpha & argb];
|
|
|
|
if (argb_temp == 0b11000000) {
|
|
|
|
if (argb_temp == BACKGROUND_COLOR.argb) {
|
|
|
|
argb_temp = argb;
|
|
|
|
argb_temp = argb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
argb = argb_temp;
|
|
|
|
argb = argb_temp;
|
|
|
|
@@ -346,7 +394,7 @@ static void updateSlot(Layer *layer, GContext *ctx) {
|
|
|
|
uint32_t skewedNormTime = slot->normTime*3;
|
|
|
|
uint32_t skewedNormTime = slot->normTime*3;
|
|
|
|
GRect r;
|
|
|
|
GRect r;
|
|
|
|
|
|
|
|
|
|
|
|
graphics_context_set_fill_color(ctx, BACKGROUND_COLOR);
|
|
|
|
graphics_context_set_fill_color(ctx, contrastmode ? GColorBlack : BACKGROUND_COLOR);
|
|
|
|
r = layer_get_bounds(slot->layer);
|
|
|
|
r = layer_get_bounds(slot->layer);
|
|
|
|
graphics_fill_rect(ctx, GRect(0, 0, r.size.w, r.size.h), 0, GCornerNone);
|
|
|
|
graphics_fill_rect(ctx, GRect(0, 0, r.size.w, r.size.h), 0, GCornerNone);
|
|
|
|
for (t=0; t<total; t++) {
|
|
|
|
for (t=0; t<total; t++) {
|
|
|
|
@@ -383,17 +431,23 @@ static unsigned short get_display_hour(unsigned short hour) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void setupAnimation() {
|
|
|
|
static void setupAnimation() {
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up anim");
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up anim");
|
|
|
|
|
|
|
|
}
|
|
|
|
anim = animation_create();
|
|
|
|
anim = animation_create();
|
|
|
|
animation_set_delay(anim, 0);
|
|
|
|
animation_set_delay(anim, 0);
|
|
|
|
animation_set_duration(anim, DIGIT_CHANGE_ANIM_DURATION);
|
|
|
|
animation_set_duration(anim, contrastmode ? 500 : DIGIT_CHANGE_ANIM_DURATION);
|
|
|
|
animation_set_implementation(anim, &animImpl);
|
|
|
|
animation_set_implementation(anim, &animImpl);
|
|
|
|
animation_set_curve(anim, AnimationCurveEaseInOut);
|
|
|
|
animation_set_curve(anim, AnimationCurveEaseInOut);
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Done setting up anim %i", (int)anim);
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Done setting up anim %i", (int)anim);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void destroyAnimation() {
|
|
|
|
static void destroyAnimation() {
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Destroying anim %i", (int)anim);
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Destroying anim %i", (int)anim);
|
|
|
|
|
|
|
|
}
|
|
|
|
animation_destroy(anim);
|
|
|
|
animation_destroy(anim);
|
|
|
|
anim = NULL;
|
|
|
|
anim = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -406,16 +460,35 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
animation_unschedule(anim);
|
|
|
|
animation_unschedule(anim);
|
|
|
|
animation_destroy(anim);
|
|
|
|
animation_destroy(anim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ho = get_display_hour(t->tm_hour);
|
|
|
|
|
|
|
|
mi = t->tm_min;
|
|
|
|
|
|
|
|
da = t->tm_mday;
|
|
|
|
|
|
|
|
mo = t->tm_mon+1;
|
|
|
|
if (debug) {
|
|
|
|
if (debug) {
|
|
|
|
ho = 19;
|
|
|
|
ho = 9;
|
|
|
|
mi = 24;
|
|
|
|
}
|
|
|
|
da = 3;
|
|
|
|
|
|
|
|
mo = 12;
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "It is now %d:%d %d.%d.", (int)ho, (int)mi, (int)da, (int)mo);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ho = get_display_hour(t->tm_hour);
|
|
|
|
allow_animate = true;
|
|
|
|
mi = t->tm_min;
|
|
|
|
if (DISABLE_ANIM) {
|
|
|
|
da = t->tm_mday;
|
|
|
|
if (DISABLE_ANIM_START_TIME > DISABLE_ANIM_END_TIME) {
|
|
|
|
mo = t->tm_mon+1;
|
|
|
|
// 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 );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// prior to 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 );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (i=0; i<NUMSLOTS; i++) {
|
|
|
|
for (i=0; i<NUMSLOTS; i++) {
|
|
|
|
@@ -427,23 +500,60 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|
|
|
slot[2].curDigit = mi/10;
|
|
|
|
slot[2].curDigit = mi/10;
|
|
|
|
slot[3].curDigit = mi%10;
|
|
|
|
slot[3].curDigit = mi%10;
|
|
|
|
if (US_DATE) {
|
|
|
|
if (US_DATE) {
|
|
|
|
slot[6].curDigit = da/10;
|
|
|
|
|
|
|
|
slot[7].curDigit = da%10;
|
|
|
|
|
|
|
|
slot[4].curDigit = mo/10;
|
|
|
|
slot[4].curDigit = mo/10;
|
|
|
|
slot[5].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) {
|
|
|
|
|
|
|
|
slot[7].curDigit = 11;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
slot[7].curDigit = 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
slot[6].curDigit = da/10;
|
|
|
|
|
|
|
|
slot[7].curDigit = da%10;
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
slot[4].curDigit = da/10;
|
|
|
|
slot[4].curDigit = da/10;
|
|
|
|
slot[5].curDigit = da%10;
|
|
|
|
slot[5].curDigit = da%10;
|
|
|
|
slot[6].curDigit = mo/10;
|
|
|
|
if (CENTER_DATE && mo < 10) {
|
|
|
|
slot[7].curDigit = mo%10;
|
|
|
|
slot[6].curDigit = mo%10;
|
|
|
|
|
|
|
|
if (slot[7].prevDigit == 10 || slot[7].prevDigit == 12) {
|
|
|
|
|
|
|
|
slot[7].curDigit = 11;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
slot[7].curDigit = 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
slot[6].curDigit = mo/10;
|
|
|
|
|
|
|
|
slot[7].curDigit = mo%10;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (NO_ZERO) {
|
|
|
|
if (NO_ZERO) {
|
|
|
|
if (slot[0].curDigit == 0) {
|
|
|
|
if (debug) {
|
|
|
|
slot[0].curDigit = 10;
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Slot 0 was %d", (int) slot[0].prevDigit);
|
|
|
|
if (slot[0].prevDigit == 10) {
|
|
|
|
}
|
|
|
|
slot[0].curDigit++;
|
|
|
|
if (ho < 10 && slot[0].prevDigit >= 10) {
|
|
|
|
|
|
|
|
if (NUMSLOTS > 8) {
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "More than 8 slots");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot[10].prevDigit != 10 && slot[10].prevDigit < 12) {
|
|
|
|
|
|
|
|
slot[0].curDigit = 11;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
slot[0].curDigit = 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "8 slots or fewer");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (slot[0].prevDigit == 10) {
|
|
|
|
|
|
|
|
slot[0].curDigit = 11;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
slot[0].curDigit = 10;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Slot 0 is now %d", (int) slot[0].curDigit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (slot[4].curDigit == 0) {
|
|
|
|
if (slot[4].curDigit == 0) {
|
|
|
|
slot[4].curDigit = 10;
|
|
|
|
slot[4].curDigit = 10;
|
|
|
|
@@ -487,7 +597,7 @@ void initSlot(int i, Layer *parent) {
|
|
|
|
|
|
|
|
|
|
|
|
s->slotIndex = i;
|
|
|
|
s->slotIndex = i;
|
|
|
|
s->normTime = ANIMATION_NORMALIZED_MAX;
|
|
|
|
s->normTime = ANIMATION_NORMALIZED_MAX;
|
|
|
|
s->prevDigit = 0;
|
|
|
|
s->prevDigit = startDigit[i];
|
|
|
|
s->curDigit = startDigit[i];
|
|
|
|
s->curDigit = startDigit[i];
|
|
|
|
if ((i<4 || i>=8) && i<14) {
|
|
|
|
if ((i<4 || i>=8) && i<14) {
|
|
|
|
s->divider = 1;
|
|
|
|
s->divider = 1;
|
|
|
|
@@ -506,11 +616,14 @@ static void deinitSlot(int i) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void animateDigits(struct Animation *anim, const AnimationProgress normTime) {
|
|
|
|
static void animateDigits(struct Animation *anim, const AnimationProgress normTime) {
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Tick! %i", (int)anim);
|
|
|
|
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
for (i=0; i<NUMSLOTS; i++) {
|
|
|
|
for (i=0; i<NUMSLOTS; i++) {
|
|
|
|
if (slot[i].curDigit != slot[i].prevDigit) {
|
|
|
|
if (slot[i].curDigit != slot[i].prevDigit) {
|
|
|
|
slot[i].normTime = normTime;
|
|
|
|
if (allow_animate) {
|
|
|
|
|
|
|
|
slot[i].normTime = normTime;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
slot[i].normTime = ANIMATION_NORMALIZED_MAX;
|
|
|
|
|
|
|
|
}
|
|
|
|
layer_mark_dirty(slot[i].layer);
|
|
|
|
layer_mark_dirty(slot[i].layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -520,7 +633,8 @@ static void setupUI() {
|
|
|
|
Layer *rootLayer;
|
|
|
|
Layer *rootLayer;
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
|
|
window_set_background_color(window, BACKGROUND_COLOR);
|
|
|
|
window_set_background_color(window, contrastmode ? GColorBlack : BACKGROUND_COLOR);
|
|
|
|
|
|
|
|
|
|
|
|
window_stack_push(window, true);
|
|
|
|
window_stack_push(window, true);
|
|
|
|
|
|
|
|
|
|
|
|
rootLayer = window_get_root_layer(window);
|
|
|
|
rootLayer = window_get_root_layer(window);
|
|
|
|
@@ -535,7 +649,7 @@ static void setupUI() {
|
|
|
|
|
|
|
|
|
|
|
|
setupAnimation();
|
|
|
|
setupAnimation();
|
|
|
|
|
|
|
|
|
|
|
|
app_timer_register(STARTDELAY, handle_timer, NULL);
|
|
|
|
app_timer_register(contrastmode ? 0 : STARTDELAY, handle_timer, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void teardownUI() {
|
|
|
|
static void teardownUI() {
|
|
|
|
@@ -547,6 +661,28 @@ static void teardownUI() {
|
|
|
|
animation_destroy(anim);
|
|
|
|
animation_destroy(anim);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void battery_handler(BatteryChargeState charge_state) {
|
|
|
|
|
|
|
|
if (CONTRAST_WHILE_CHARGING) {
|
|
|
|
|
|
|
|
previous_contrastmode = contrastmode;
|
|
|
|
|
|
|
|
if (charge_state.is_plugged) {
|
|
|
|
|
|
|
|
contrastmode = true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
contrastmode = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (previous_contrastmode != contrastmode) {
|
|
|
|
|
|
|
|
teardownUI();
|
|
|
|
|
|
|
|
setupUI();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LIGHT_WHILE_CHARGING) {
|
|
|
|
|
|
|
|
if (charge_state.is_plugged) {
|
|
|
|
|
|
|
|
light_enable(true);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
light_enable(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
Tuple *large_mode_t = dict_find(iter, KEY_LARGE_MODE);
|
|
|
|
Tuple *large_mode_t = dict_find(iter, KEY_LARGE_MODE);
|
|
|
|
Tuple *eu_date_t = dict_find(iter, KEY_EU_DATE);
|
|
|
|
Tuple *eu_date_t = dict_find(iter, KEY_EU_DATE);
|
|
|
|
@@ -559,6 +695,13 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
Tuple *ornament_variation_t = dict_find(iter, KEY_ORNAMENT_VARIATION);
|
|
|
|
Tuple *ornament_variation_t = dict_find(iter, KEY_ORNAMENT_VARIATION);
|
|
|
|
Tuple *invert_t = dict_find(iter, KEY_INVERT);
|
|
|
|
Tuple *invert_t = dict_find(iter, KEY_INVERT);
|
|
|
|
Tuple *monochrome_t = dict_find(iter, KEY_MONOCHROME);
|
|
|
|
Tuple *monochrome_t = dict_find(iter, KEY_MONOCHROME);
|
|
|
|
|
|
|
|
Tuple *center_t = dict_find(iter, KEY_CENTER);
|
|
|
|
|
|
|
|
Tuple *btvibe_t = dict_find(iter, KEY_BTVIBE);
|
|
|
|
|
|
|
|
Tuple *contrast_t = dict_find(iter, KEY_CONTRAST);
|
|
|
|
|
|
|
|
Tuple *nightsaver_t = dict_find(iter, KEY_NIGHTSAVER);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
if (large_mode_t) {
|
|
|
|
if (large_mode_t) {
|
|
|
|
curPrefs.large_mode = large_mode_t->value->int8;
|
|
|
|
curPrefs.large_mode = large_mode_t->value->int8;
|
|
|
|
@@ -593,12 +736,58 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|
|
|
if (monochrome_t) {
|
|
|
|
if (monochrome_t) {
|
|
|
|
curPrefs.monochrome = monochrome_t->value->int8;
|
|
|
|
curPrefs.monochrome = monochrome_t->value->int8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (center_t) {
|
|
|
|
|
|
|
|
curPrefs.center = center_t->value->int8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (btvibe_t) {
|
|
|
|
|
|
|
|
curPrefs.btvibe = btvibe_t->value->int8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (contrast_t) {
|
|
|
|
|
|
|
|
curPrefs.contrast = contrast_t->value->int8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nightsaver_t) {
|
|
|
|
|
|
|
|
curPrefs.nightsaver = nightsaver_t->value->int8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ns_start_t) {
|
|
|
|
|
|
|
|
curPrefs.ns_start = ns_start_t->value->int8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ns_stop_t) {
|
|
|
|
|
|
|
|
curPrefs.ns_stop = ns_stop_t->value->int8;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (backlight_t) {
|
|
|
|
|
|
|
|
curPrefs.backlight = backlight_t->value->int8;
|
|
|
|
|
|
|
|
}
|
|
|
|
persist_write_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs));
|
|
|
|
persist_write_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs));
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Tearing down");
|
|
|
|
vibes_short_pulse();
|
|
|
|
|
|
|
|
if (curPrefs.contrast == false) {
|
|
|
|
|
|
|
|
contrastmode = false;
|
|
|
|
|
|
|
|
previous_contrastmode = false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
BatteryChargeState charge_state = battery_state_service_peek();
|
|
|
|
|
|
|
|
if (charge_state.is_plugged) {
|
|
|
|
|
|
|
|
contrastmode = true;
|
|
|
|
|
|
|
|
previous_contrastmode = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (curPrefs.backlight == false) {
|
|
|
|
|
|
|
|
light_enable(false);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
BatteryChargeState charge_state = battery_state_service_peek();
|
|
|
|
|
|
|
|
if (charge_state.is_plugged) {
|
|
|
|
|
|
|
|
light_enable(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Tearing down");
|
|
|
|
|
|
|
|
}
|
|
|
|
teardownUI();
|
|
|
|
teardownUI();
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up");
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up");
|
|
|
|
|
|
|
|
}
|
|
|
|
setupUI();
|
|
|
|
setupUI();
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Done");
|
|
|
|
if (debug) {
|
|
|
|
|
|
|
|
APP_LOG(APP_LOG_LEVEL_INFO, "Done");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void in_dropped_handler(AppMessageResult reason, void *context) {
|
|
|
|
static void in_dropped_handler(AppMessageResult reason, void *context) {
|
|
|
|
@@ -618,7 +807,7 @@ static void init() {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
curPrefs = (Preferences) {
|
|
|
|
curPrefs = (Preferences) {
|
|
|
|
.large_mode = false,
|
|
|
|
.large_mode = false,
|
|
|
|
.eu_date = true,
|
|
|
|
.eu_date = false,
|
|
|
|
.quick_start = false,
|
|
|
|
.quick_start = false,
|
|
|
|
.leading_zero = false,
|
|
|
|
.leading_zero = false,
|
|
|
|
.background_color = 0b11000000,
|
|
|
|
.background_color = 0b11000000,
|
|
|
|
@@ -628,22 +817,56 @@ static void init() {
|
|
|
|
.ornament_variation = true,
|
|
|
|
.ornament_variation = true,
|
|
|
|
.invert = false,
|
|
|
|
.invert = false,
|
|
|
|
.monochrome = false,
|
|
|
|
.monochrome = false,
|
|
|
|
|
|
|
|
.center = false,
|
|
|
|
|
|
|
|
.btvibe = false,
|
|
|
|
|
|
|
|
.contrast = false,
|
|
|
|
|
|
|
|
.nightsaver = false,
|
|
|
|
|
|
|
|
.ns_start = 0,
|
|
|
|
|
|
|
|
.ns_stop = 6,
|
|
|
|
|
|
|
|
.backlight = false,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
setupUI();
|
|
|
|
setupUI();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BatteryChargeState charge_state = battery_state_service_peek();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (charge_state.is_plugged) {
|
|
|
|
|
|
|
|
if (CONTRAST_WHILE_CHARGING) {
|
|
|
|
|
|
|
|
previous_contrastmode = true;
|
|
|
|
|
|
|
|
contrastmode = true;
|
|
|
|
|
|
|
|
teardownUI();
|
|
|
|
|
|
|
|
setupUI();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (LIGHT_WHILE_CHARGING) {
|
|
|
|
|
|
|
|
light_enable(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Setup app message
|
|
|
|
// Setup app message
|
|
|
|
app_message_register_inbox_received(in_received_handler);
|
|
|
|
app_message_register_inbox_received(in_received_handler);
|
|
|
|
app_message_register_inbox_dropped(in_dropped_handler);
|
|
|
|
app_message_register_inbox_dropped(in_dropped_handler);
|
|
|
|
app_message_open(150,0);
|
|
|
|
app_message_open(200,0);
|
|
|
|
|
|
|
|
|
|
|
|
tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connection_service_subscribe((ConnectionHandlers) {
|
|
|
|
|
|
|
|
.pebble_app_connection_handler = handle_bluetooth
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void deinit() {
|
|
|
|
static void deinit() {
|
|
|
|
tick_timer_service_unsubscribe();
|
|
|
|
tick_timer_service_unsubscribe();
|
|
|
|
|
|
|
|
connection_service_unsubscribe();
|
|
|
|
|
|
|
|
battery_state_service_unsubscribe();
|
|
|
|
teardownUI();
|
|
|
|
teardownUI();
|
|
|
|
window_destroy(window);
|
|
|
|
window_destroy(window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|