1
1

3 Commits
4.3 ... 4.5

3 changed files with 72 additions and 19 deletions

View File

@@ -1,6 +1,7 @@
{ {
"appKeys": { "appKeys": {
"background_color": 4, "background_color": 4,
"btvibe": 12,
"center": 11, "center": 11,
"eu_date": 1, "eu_date": 1,
"invert": 9, "invert": 9,
@@ -30,7 +31,7 @@
"chalk" "chalk"
], ],
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8", "uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
"versionLabel": "4.3", "versionLabel": "4.5",
"watchapp": { "watchapp": {
"watchface": true "watchface": true
} }

View File

@@ -7,7 +7,7 @@ Pebble.addEventListener('showConfiguration', function() {
if(Pebble.getActiveWatchInfo) { if(Pebble.getActiveWatchInfo) {
watch = Pebble.getActiveWatchInfo(); watch = Pebble.getActiveWatchInfo();
} }
var url='http://pebble.lastfuture.de/config/squared43/'; var url='http://pebble.lastfuture.de/config/squared45/';
if (watch.platform == "basalt") { if (watch.platform == "basalt") {
url += "?rect=true"; url += "?rect=true";
} else if (watch.platform == "aplite") { } else if (watch.platform == "aplite") {
@@ -33,7 +33,8 @@ Pebble.addEventListener('webviewclosed', function(e) {
ornament_variation: configData.ornament_variation, ornament_variation: configData.ornament_variation,
invert: 0+(configData.invert === 'true'), invert: 0+(configData.invert === 'true'),
monochrome: 0+(configData.monochrome === 'true'), monochrome: 0+(configData.monochrome === 'true'),
center: 0+(configData.center === 'true') center: 0+(configData.center === 'true'),
btvibe: 0+(configData.btvibe === 'true')
}, function() { }, function() {
console.log('Send successful!'); console.log('Send successful!');
}, function() { }, function() {

View File

@@ -22,6 +22,7 @@ typedef struct {
bool invert; bool invert;
bool monochrome; bool monochrome;
bool center; bool center;
bool btvibe;
} Preferences; } Preferences;
Preferences curPrefs; Preferences curPrefs;
@@ -39,12 +40,14 @@ enum {
KEY_INVERT, KEY_INVERT,
KEY_MONOCHROME, KEY_MONOCHROME,
KEY_CENTER, KEY_CENTER,
KEY_BTVIBE,
}; };
#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 CENTER_DATE (curPrefs.center)
#define DISCONNECT_VIBRATION (curPrefs.btvibe)
#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)
@@ -214,6 +217,11 @@ static uint8_t shadowtable[] = {192,192,192,192,192,192,192,192,192,192,192,192,
// 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)
@@ -229,6 +237,17 @@ 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 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
@@ -265,7 +284,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;
@@ -327,7 +346,8 @@ 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) { //int argb_temp = combine_colors(argb-0b01000000, BACKGROUND_COLOR.argb);
if (argb_temp == BACKGROUND_COLOR.argb) {
argb_temp = argb; argb_temp = argb;
} }
argb = argb_temp; argb = argb_temp;
@@ -386,17 +406,23 @@ static unsigned short get_display_hour(unsigned short hour) {
} }
static void setupAnimation() { static void setupAnimation() {
if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up anim"); 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, DIGIT_CHANGE_ANIM_DURATION);
animation_set_implementation(anim, &animImpl); animation_set_implementation(anim, &animImpl);
animation_set_curve(anim, AnimationCurveEaseInOut); animation_set_curve(anim, AnimationCurveEaseInOut);
if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Done setting up anim %i", (int)anim); APP_LOG(APP_LOG_LEVEL_INFO, "Done setting up anim %i", (int)anim);
} }
}
static void destroyAnimation() { static void destroyAnimation() {
if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Destroying anim %i", (int)anim); APP_LOG(APP_LOG_LEVEL_INFO, "Destroying anim %i", (int)anim);
}
animation_destroy(anim); animation_destroy(anim);
anim = NULL; anim = NULL;
} }
@@ -410,10 +436,10 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
animation_destroy(anim); animation_destroy(anim);
} }
if (debug) { if (debug) {
ho = get_display_hour(t->tm_hour); ho = 5;
mi = t->tm_min; mi = 15;
da = 10; da = 12;
mo = 1; mo = 3;
} else { } else {
ho = get_display_hour(t->tm_hour); ho = get_display_hour(t->tm_hour);
mi = t->tm_min; mi = t->tm_min;
@@ -508,7 +534,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;
@@ -527,7 +553,11 @@ static void deinitSlot(int i) {
} }
static void animateDigits(struct Animation *anim, const AnimationProgress normTime) { static void animateDigits(struct Animation *anim, const AnimationProgress normTime) {
/*
if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Tick! %i", (int)anim); 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) {
@@ -581,6 +611,7 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
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 *center_t = dict_find(iter, KEY_CENTER);
Tuple *btvibe_t = dict_find(iter, KEY_BTVIBE);
if (large_mode_t) { if (large_mode_t) {
curPrefs.large_mode = large_mode_t->value->int8; curPrefs.large_mode = large_mode_t->value->int8;
@@ -618,14 +649,23 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
if (center_t) { if (center_t) {
curPrefs.center = center_t->value->int8; curPrefs.center = center_t->value->int8;
} }
if (btvibe_t) {
curPrefs.btvibe = btvibe_t->value->int8;
}
persist_write_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs)); persist_write_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs));
vibes_short_pulse(); vibes_short_pulse();
if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Tearing down"); APP_LOG(APP_LOG_LEVEL_INFO, "Tearing down");
}
teardownUI(); teardownUI();
if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up"); APP_LOG(APP_LOG_LEVEL_INFO, "Setting up");
}
setupUI(); setupUI();
if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Done"); 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) {
APP_LOG(APP_LOG_LEVEL_WARNING, "Dropped a message because %i", (int)reason); APP_LOG(APP_LOG_LEVEL_WARNING, "Dropped a message because %i", (int)reason);
@@ -655,6 +695,7 @@ static void init() {
.invert = false, .invert = false,
.monochrome = false, .monochrome = false,
.center = false, .center = false,
.btvibe = false,
}; };
} }
@@ -666,11 +707,21 @@ static void init() {
app_message_open(150,0); app_message_open(150,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());
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();
teardownUI(); teardownUI();
window_destroy(window); window_destroy(window);
} }