Compare commits
4 Commits
4.10
...
archive/sq
| Author | SHA1 | Date | |
|---|---|---|---|
| 7679c3a7ff | |||
| 517d0180dc | |||
| a0454fb1cd | |||
| 2050b8c811 |
@@ -38,7 +38,7 @@
|
|||||||
"chalk"
|
"chalk"
|
||||||
],
|
],
|
||||||
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
|
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
|
||||||
"versionLabel": "4.10",
|
"versionLabel": "4.11",
|
||||||
"watchapp": {
|
"watchapp": {
|
||||||
"watchface": true
|
"watchface": true
|
||||||
}
|
}
|
||||||
|
|||||||
109
src/intersection.h
Normal file
109
src/intersection.h
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
#include <pebble.h>
|
||||||
|
|
||||||
|
#define DONT_INTERSECT 0
|
||||||
|
#define DO_INTERSECT 1
|
||||||
|
#define COLLINEAR 2
|
||||||
|
|
||||||
|
#define SAME_SIGNS( a, b ) \
|
||||||
|
(((long) ((unsigned long) a ^ (unsigned long) b)) >= 0 )
|
||||||
|
|
||||||
|
int lines_intersect(
|
||||||
|
x1, y1,
|
||||||
|
x2, y2,
|
||||||
|
x3, y3,
|
||||||
|
x4, y4,
|
||||||
|
x,
|
||||||
|
y
|
||||||
|
)
|
||||||
|
|
||||||
|
long x1, y1, x2, y2, x3, y3, x4, y4, *x, *y;
|
||||||
|
|
||||||
|
{
|
||||||
|
long a1, a2, b1, b2, c1, c2; /* Coefficients of line eqns. */
|
||||||
|
long r1, r2, r3, r4; /* 'Sign' values */
|
||||||
|
long denom, offset, num; /* Intermediate values */
|
||||||
|
|
||||||
|
a1 = y2 - y1;
|
||||||
|
b1 = x1 - x2;
|
||||||
|
c1 = x2 * y1 - x1 * y2;
|
||||||
|
|
||||||
|
r3 = a1 * x3 + b1 * y3 + c1;
|
||||||
|
r4 = a1 * x4 + b1 * y4 + c1;
|
||||||
|
|
||||||
|
if ( r3 != 0 &&
|
||||||
|
r4 != 0 &&
|
||||||
|
SAME_SIGNS( r3, r4 ))
|
||||||
|
return ( DONT_INTERSECT );
|
||||||
|
|
||||||
|
a2 = y4 - y3;
|
||||||
|
b2 = x3 - x4;
|
||||||
|
c2 = x4 * y3 - x3 * y4;
|
||||||
|
|
||||||
|
r1 = a2 * x1 + b2 * y1 + c2;
|
||||||
|
r2 = a2 * x2 + b2 * y2 + c2;
|
||||||
|
|
||||||
|
if ( r1 != 0 &&
|
||||||
|
r2 != 0 &&
|
||||||
|
SAME_SIGNS( r1, r2 ))
|
||||||
|
return ( DONT_INTERSECT );
|
||||||
|
|
||||||
|
denom = a1 * b2 - a2 * b1;
|
||||||
|
if ( denom == 0 )
|
||||||
|
return ( COLLINEAR );
|
||||||
|
offset = denom < 0 ? - denom / 2 : denom / 2;
|
||||||
|
|
||||||
|
num = b1 * c2 - b2 * c1;
|
||||||
|
*x = ( num < 0 ? num - offset : num + offset ) / denom;
|
||||||
|
|
||||||
|
num = a2 * c1 - a1 * c2;
|
||||||
|
*y = ( num < 0 ? num - offset : num + offset ) / denom;
|
||||||
|
|
||||||
|
return ( DO_INTERSECT );
|
||||||
|
}
|
||||||
|
|
||||||
|
#define INTERSECTION_NONE 0
|
||||||
|
#define INTERSECTION_PARTIAL 1
|
||||||
|
#define INTERSECTION_FULL 2
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t success;
|
||||||
|
GPoint p1;
|
||||||
|
GPoint p2;
|
||||||
|
} Intersection;
|
||||||
|
|
||||||
|
Intersection rectintersect(GPoint p1, GPoint p2, GRect rect) {
|
||||||
|
long x,y;
|
||||||
|
long x1=0,y1=0,x2=0,y2=0;
|
||||||
|
bool intersection = false, final_intersection = false;
|
||||||
|
if (lines_intersect(p1.x, p1.y, p2.x, p2.y, rect.origin.x, rect.origin.y, rect.origin.x, rect.origin.y+rect.size.h, &x, &y) == DO_INTERSECT) {
|
||||||
|
x1 = x; y1 = y; intersection = true;
|
||||||
|
}
|
||||||
|
if (lines_intersect(p1.x, p1.y, p2.x, p2.y, rect.origin.x, rect.origin.y, rect.origin.x+rect.size.w, rect.origin.y, &x, &y) == DO_INTERSECT) {
|
||||||
|
if (!intersection) {
|
||||||
|
x1 = x; y1 = y; intersection = true;
|
||||||
|
} else if (x != x1 && y != y1) {
|
||||||
|
x2 = x; y2 = y; final_intersection = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!final_intersection && lines_intersect(p1.x, p1.y, p2.x, p2.y, rect.origin.x, rect.origin.y+rect.size.h, rect.origin.x+rect.size.w, rect.origin.y+rect.size.h, &x, &y) == DO_INTERSECT) {
|
||||||
|
if (!intersection) {
|
||||||
|
x1 = x; y1 = y; intersection = true;
|
||||||
|
} else if (x != x1 && y != y1) {
|
||||||
|
x2 = x; y2 = y; final_intersection = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!final_intersection && lines_intersect(p1.x, p1.y, p2.x, p2.y, rect.origin.x+rect.size.w, rect.origin.y, rect.origin.x+rect.size.w, rect.origin.y+rect.size.h, &x, &y) == DO_INTERSECT) {
|
||||||
|
if (!intersection) {
|
||||||
|
x1 = x; y1 = y;
|
||||||
|
} else if (x != x1 && y != y1) {
|
||||||
|
x2 = x; y2 = y; final_intersection = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(final_intersection) {
|
||||||
|
return (Intersection) { .success = INTERSECTION_FULL, .p1 = (GPoint) { .x = x1, .y = y1 }, .p2 = (GPoint) { .x = x2, .y = y2 } };
|
||||||
|
} else if (intersection) {
|
||||||
|
return (Intersection) { .success = INTERSECTION_PARTIAL, .p1 = (GPoint) { .x = x1, .y = y1 }, .p2 = (GPoint) { .x = x2, .y = y2 } };
|
||||||
|
} else {
|
||||||
|
return (Intersection) { .success = INTERSECTION_NONE, .p1 = (GPoint) { .x = x1, .y = y1 }, .p2 = (GPoint) { .x = x2, .y = y2 } };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,17 +9,21 @@ String.prototype.hashCode = function(){
|
|||||||
return hash;
|
return hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
var debugwatches = Array(/*1568511776, */1135189913, -826258655, -1783317168);
|
var debugwatches = Array(
|
||||||
|
1568511776, //c
|
||||||
|
1135189913, //b
|
||||||
|
-826258655, //a
|
||||||
|
-1783317168, //em
|
||||||
|
91860716, //a sl
|
||||||
|
-1462573071, //b sl
|
||||||
|
244993878 //c sl
|
||||||
|
);
|
||||||
var tokenhash;
|
var tokenhash;
|
||||||
|
|
||||||
|
|
||||||
Pebble.addEventListener('ready', function() {
|
Pebble.addEventListener('ready', function() {
|
||||||
console.log('PebbleKit JS ready!');
|
console.log('PebbleKit JS ready!');
|
||||||
tokenhash = Pebble.getWatchToken().hashCode();
|
console.log('WatchToken '+Pebble.getWatchToken());
|
||||||
console.log('Watch identifier '+tokenhash);
|
|
||||||
if (debugwatches.indexOf(tokenhash) > -1) {
|
|
||||||
var dict = {"debugwatch": 1};
|
|
||||||
Pebble.sendAppMessage(dict);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Pebble.addEventListener('appmessage', function() {
|
Pebble.addEventListener('appmessage', function() {
|
||||||
@@ -47,33 +51,38 @@ Pebble.addEventListener('showConfiguration', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Pebble.addEventListener('webviewclosed', function(e) {
|
Pebble.addEventListener('webviewclosed', function(e) {
|
||||||
var configData = JSON.parse(decodeURIComponent(e.response));
|
var configData = JSON.parse(decodeURIComponent(e.response));
|
||||||
console.log('Configuration page returned: '+JSON.stringify(configData));
|
console.log('Configuration page returned: '+JSON.stringify(configData));
|
||||||
if (configData.background_color) {
|
var options = {
|
||||||
Pebble.sendAppMessage({
|
large_mode: 0+(configData.large_mode === 'true'),
|
||||||
large_mode: 0+(configData.large_mode === 'true'),
|
eu_date: 0+(configData.eu_date === 'true'),
|
||||||
eu_date: 0+(configData.eu_date === 'true'),
|
quick_start: 0+(configData.quick_start === 'true'),
|
||||||
quick_start: 0+(configData.quick_start === 'true'),
|
leading_zero: 0+(configData.leading_zero === 'true'),
|
||||||
leading_zero: 0+(configData.leading_zero === 'true'),
|
background_color: configData.background_color,
|
||||||
background_color: configData.background_color,
|
number_base_color: configData.number_base_color,
|
||||||
number_base_color: configData.number_base_color,
|
number_variation: configData.number_variation,
|
||||||
number_variation: configData.number_variation,
|
ornament_base_color: configData.ornament_base_color,
|
||||||
ornament_base_color: configData.ornament_base_color,
|
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'),
|
||||||
btvibe: 0+(configData.btvibe === 'true'),
|
contrast: 0+(configData.contrast === 'true'),
|
||||||
contrast: 0+(configData.contrast === 'true'),
|
nightsaver: 0+(configData.nightsaver === 'true'),
|
||||||
nightsaver: 0+(configData.nightsaver === 'true'),
|
ns_start: parseInt(configData.ns_start),
|
||||||
ns_start: parseInt(configData.ns_start),
|
ns_stop: parseInt(configData.ns_stop),
|
||||||
ns_stop: parseInt(configData.ns_stop),
|
backlight: 0+(configData.backlight === 'true'),
|
||||||
backlight: 0+(configData.backlight === 'true'),
|
weekday: 0+(configData.weekday === 'true'),
|
||||||
weekday: 0+(configData.weekday === 'true')
|
};
|
||||||
}, function() {
|
if (debugwatches.indexOf(tokenhash) > -1) {
|
||||||
console.log('Send successful!');
|
console.log('Debug Watch with Hash '+tokenhash+'. Setting debug flag on watchface …');
|
||||||
}, function() {
|
options.debugwatch = 1;
|
||||||
console.log('Send failed!');
|
}
|
||||||
});
|
if (configData.background_color) {
|
||||||
}
|
Pebble.sendAppMessage(options, function() {
|
||||||
|
console.log('Send successful!');
|
||||||
|
}, function() {
|
||||||
|
console.log('Send failed!');
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
506
src/squared.c
506
src/squared.c
@@ -6,6 +6,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <pebble.h>
|
#include <pebble.h>
|
||||||
|
#include <intersection.h>
|
||||||
|
|
||||||
|
|
||||||
Window *window;
|
Window *window;
|
||||||
|
|
||||||
@@ -14,10 +16,10 @@ typedef struct {
|
|||||||
bool eu_date;
|
bool eu_date;
|
||||||
bool quick_start;
|
bool quick_start;
|
||||||
bool leading_zero;
|
bool leading_zero;
|
||||||
int background_color;
|
uint8_t background_color;
|
||||||
int number_base_color;
|
uint8_t number_base_color;
|
||||||
bool number_variation;
|
bool number_variation;
|
||||||
int ornament_base_color;
|
uint8_t ornament_base_color;
|
||||||
bool ornament_variation;
|
bool ornament_variation;
|
||||||
bool invert;
|
bool invert;
|
||||||
bool monochrome;
|
bool monochrome;
|
||||||
@@ -25,8 +27,8 @@ typedef struct {
|
|||||||
bool btvibe;
|
bool btvibe;
|
||||||
bool contrast;
|
bool contrast;
|
||||||
bool nightsaver;
|
bool nightsaver;
|
||||||
int ns_start;
|
uint8_t ns_start;
|
||||||
int ns_stop;
|
uint8_t ns_stop;
|
||||||
bool backlight;
|
bool backlight;
|
||||||
bool weekday;
|
bool weekday;
|
||||||
|
|
||||||
@@ -62,6 +64,10 @@ enum {
|
|||||||
|
|
||||||
#define SCREENSHOTMODE false
|
#define SCREENSHOTMODE false
|
||||||
|
|
||||||
|
#define DEBUG false
|
||||||
|
#define SUPERDEBUG false
|
||||||
|
|
||||||
|
|
||||||
#define EU_DATE (curPrefs.eu_date) // true == MM/DD, false == DD/MM
|
#define EU_DATE (curPrefs.eu_date) // true == MM/DD, false == DD/MM
|
||||||
#define WEEKDAY (curPrefs.weekday)
|
#define WEEKDAY (curPrefs.weekday)
|
||||||
#define CENTER_DATE (curPrefs.center)
|
#define CENTER_DATE (curPrefs.center)
|
||||||
@@ -85,7 +91,6 @@ enum {
|
|||||||
#define ORNAMENT_BASE_COLOR_ARGB8 (curPrefs.ornament_base_color)
|
#define ORNAMENT_BASE_COLOR_ARGB8 (curPrefs.ornament_base_color)
|
||||||
#define NUMBER_ADD_VARIATION (curPrefs.number_variation)
|
#define NUMBER_ADD_VARIATION (curPrefs.number_variation)
|
||||||
#define ORNAMENT_ADD_VARIATION (curPrefs.ornament_variation)
|
#define ORNAMENT_ADD_VARIATION (curPrefs.ornament_variation)
|
||||||
|
|
||||||
#define BACKGROUND_COLOR PBL_IF_BW_ELSE((INVERT ? GColorWhite : GColorBlack), ((GColor8) { .argb = curPrefs.background_color }))
|
#define BACKGROUND_COLOR PBL_IF_BW_ELSE((INVERT ? GColorWhite : GColorBlack), ((GColor8) { .argb = curPrefs.background_color }))
|
||||||
|
|
||||||
#define FONT blocks
|
#define FONT blocks
|
||||||
@@ -93,147 +98,33 @@ enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Layer *layer;
|
Layer *layer;
|
||||||
int prevDigit;
|
uint8_t prevDigit;
|
||||||
int curDigit;
|
uint8_t curDigit;
|
||||||
bool isalpha;
|
bool isalpha;
|
||||||
int divider;
|
uint8_t divider;
|
||||||
AnimationProgress normTime;
|
AnimationProgress normTime;
|
||||||
int slotIndex;
|
uint8_t slotIndex;
|
||||||
} digitSlot;
|
} digitSlot;
|
||||||
|
|
||||||
digitSlot slot[NUMSLOTS];
|
digitSlot slot[NUMSLOTS];
|
||||||
|
|
||||||
static char weekday_buffer[16];
|
static char weekday_buffer[2];
|
||||||
|
|
||||||
AnimationImplementation animImpl;
|
AnimationImplementation animImpl;
|
||||||
Animation *anim;
|
Animation *anim;
|
||||||
bool splashEnded = false;
|
static bool splashEnded = false, debug = false;
|
||||||
static bool debug = false;
|
|
||||||
|
|
||||||
unsigned char blocks[][5][5] = {{
|
static const char * locales[6] = {"en", "de", "es", "fr", "it", "pt"};
|
||||||
{1,1,1,1,1},
|
static const char * weekdays[6][7] = {
|
||||||
{1,0,0,0,1},
|
{ "SU","MO","TU","WE","TH","FR","SA" }, // EN
|
||||||
{1,0,2,0,1},
|
{ "SO","MO","DI","MI","DO","FR","SA" }, // DE
|
||||||
{1,0,0,0,1},
|
{ "DO","LU","MA","MI","JU","VI","SA" }, // ES - from https://forums.getpebble.com/discussion/comment/166975/#Comment_166975
|
||||||
{1,1,1,1,1}
|
{ "DI","LU","MA","ME","JE","VE","SA" }, // FR - from https://www.quora.com/How-are-days-of-the-week-abbreviated-in-various-languages
|
||||||
}, {
|
{ "DO","LU","MA","ME","GI","VE","SA" }, // IT - from https://www.quora.com/How-are-days-of-the-week-abbreviated-in-various-languages
|
||||||
{2,2,0,1,1},
|
{ "DO","SG","TE","QA","QI","SX","SA" } // PT - from http://www.brazil-help.com/week.htm (is this correct?)
|
||||||
{0,0,0,0,1},
|
}; // required Letters: ADEFGHIJLMOQRSTUVWX
|
||||||
{2,2,2,0,1},
|
|
||||||
{0,0,0,0,1},
|
|
||||||
{2,2,2,0,1}
|
|
||||||
}, {
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{0,0,0,0,1},
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,0,0,0,0},
|
|
||||||
{1,1,1,1,1}
|
|
||||||
}, {
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{0,0,0,0,1},
|
|
||||||
{0,1,1,1,1},
|
|
||||||
{0,0,0,0,1},
|
|
||||||
{1,1,1,1,1}
|
|
||||||
}, {
|
|
||||||
{1,0,2,0,1},
|
|
||||||
{1,0,0,0,1},
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{0,0,0,0,1},
|
|
||||||
{2,2,2,0,1}
|
|
||||||
}, {
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,0,0,0,0},
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{0,0,0,0,1},
|
|
||||||
{1,1,1,1,1}
|
|
||||||
}, {
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,0,0,0,0},
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,0,0,0,1},
|
|
||||||
{1,1,1,1,1}
|
|
||||||
}, {
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{0,0,0,0,1},
|
|
||||||
{2,0,2,0,1},
|
|
||||||
{2,0,2,0,1},
|
|
||||||
{2,0,2,0,1}
|
|
||||||
}, {
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,0,0,0,1},
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,0,0,0,1},
|
|
||||||
{1,1,1,1,1}
|
|
||||||
}, {
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,0,0,0,1},
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{0,0,0,0,1},
|
|
||||||
{1,1,1,1,1}
|
|
||||||
}, {
|
|
||||||
{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}
|
|
||||||
}, {
|
|
||||||
{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}
|
|
||||||
}, {
|
|
||||||
{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}
|
|
||||||
}, {
|
|
||||||
{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},
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,1,1,1,1},
|
|
||||||
{1,1,1,1,1}
|
|
||||||
}};
|
|
||||||
|
|
||||||
enum {
|
static const uint8_t alphablocks[][5][5] = {
|
||||||
LANG_EN,
|
|
||||||
LANG_DE,
|
|
||||||
LANG_ES,
|
|
||||||
LANG_FR,
|
|
||||||
LANG_IT,
|
|
||||||
LANG_PT
|
|
||||||
};
|
|
||||||
|
|
||||||
const char* weekdays[][7] = {
|
|
||||||
[LANG_EN]={
|
|
||||||
"SU","MO","TU","WE","TH","FR","SA"
|
|
||||||
},
|
|
||||||
[LANG_DE]={
|
|
||||||
"SO","MO","DI","MI","DO","FR","SA"
|
|
||||||
},
|
|
||||||
[LANG_ES]={ // from https://forums.getpebble.com/discussion/comment/166975/#Comment_166975
|
|
||||||
"DO","LU","MA","MI","JU","VI","SA"
|
|
||||||
},
|
|
||||||
[LANG_FR]={ // from https://www.quora.com/How-are-days-of-the-week-abbreviated-in-various-languages
|
|
||||||
"DI","LU","MA","ME","JE","VE","SA"
|
|
||||||
},
|
|
||||||
[LANG_IT]={ // from https://www.quora.com/How-are-days-of-the-week-abbreviated-in-various-languages
|
|
||||||
"DO","LU","MA","ME","GI","VE","SA"
|
|
||||||
},
|
|
||||||
[LANG_PT]={ // from http://www.brazil-help.com/week.htm
|
|
||||||
"DO","SG","TE","QA","QI","SX","SA"
|
|
||||||
}
|
|
||||||
}; // required Letters: ADEFGHIJLMOQRSTUVWX
|
|
||||||
|
|
||||||
unsigned char alphablocks[][5][5] = {
|
|
||||||
[65] = { // A
|
[65] = { // A
|
||||||
{1,1,1,1,1},
|
{1,1,1,1,1},
|
||||||
{1,0,0,0,1},
|
{1,0,0,0,1},
|
||||||
@@ -396,12 +287,104 @@ unsigned char alphablocks[][5][5] = {
|
|||||||
{1,0,1,0,1}
|
{1,0,1,0,1}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
static const uint8_t blocks[][5][5] = {{
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,0,2,0,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
}, {
|
||||||
|
{2,2,0,1,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{2,2,2,0,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{2,2,2,0,1}
|
||||||
|
}, {
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,0},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
}, {
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{0,1,1,1,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
}, {
|
||||||
|
{1,0,2,0,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{2,2,2,0,1}
|
||||||
|
}, {
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,0},
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
}, {
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,0},
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
}, {
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{2,0,2,0,1},
|
||||||
|
{2,0,2,0,1},
|
||||||
|
{2,0,2,0,1}
|
||||||
|
}, {
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
}, {
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{0,0,0,0,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
}, {
|
||||||
|
{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}
|
||||||
|
}, {
|
||||||
|
{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}
|
||||||
|
}, {
|
||||||
|
{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}
|
||||||
|
}, {
|
||||||
|
{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},
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
}};
|
||||||
|
|
||||||
int startDigit[18] = {
|
static const uint8_t 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
|
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[] = {
|
static const uint8_t variation[100] = {
|
||||||
0b00000000, 0b00010000, 0b00000100, 0b00010000, 0b00000000,
|
0b00000000, 0b00010000, 0b00000100, 0b00010000, 0b00000000,
|
||||||
0b00010001, 0b00010000, 0b00000000, 0b00000101, 0b00010000,
|
0b00010001, 0b00010000, 0b00000000, 0b00000101, 0b00010000,
|
||||||
0b00000001, 0b00000000, 0b00000000, 0b00010100, 0b00010001,
|
0b00000001, 0b00000000, 0b00000000, 0b00010100, 0b00010001,
|
||||||
@@ -424,7 +407,7 @@ unsigned char variation[] = {
|
|||||||
0b00000000, 0b00000001, 0b00010001, 0b00000101, 0b00010100
|
0b00000000, 0b00000001, 0b00010001, 0b00000101, 0b00010100
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t shadowtable[] = {
|
static const uint8_t shadowtable[256] = {
|
||||||
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,
|
||||||
@@ -443,7 +426,7 @@ static uint8_t shadowtable[] = {
|
|||||||
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
|
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 const uint8_t alpha = 0b10111111;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
uint8_t combine_colors(uint8_t fg_color, uint8_t bg_color) {
|
uint8_t combine_colors(uint8_t fg_color, uint8_t bg_color) {
|
||||||
@@ -469,7 +452,7 @@ static bool contrastmode = false, previous_contrastmode = false, allow_animate =
|
|||||||
|
|
||||||
static void handle_bluetooth(bool connected) {
|
static void handle_bluetooth(bool connected) {
|
||||||
if (DISCONNECT_VIBRATION && !connected) {
|
if (DISCONNECT_VIBRATION && !connected) {
|
||||||
static uint32_t const segments[] = { 200, 200, 50, 150, 200 };
|
static const uint32_t segments[] = { 200, 200, 50, 150, 200 };
|
||||||
VibePattern pat = {
|
VibePattern pat = {
|
||||||
.durations = segments,
|
.durations = segments,
|
||||||
.num_segments = ARRAY_LENGTH(segments),
|
.num_segments = ARRAY_LENGTH(segments),
|
||||||
@@ -478,8 +461,8 @@ static void handle_bluetooth(bool connected) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GRect slotFrame(int i) {
|
static GRect slotFrame(int8_t i) {
|
||||||
int x, y, w, h;
|
int16_t x, y, w, h;
|
||||||
if (i<4) { // main digits
|
if (i<4) { // main digits
|
||||||
w = FONT_WIDTH;
|
w = FONT_WIDTH;
|
||||||
h = FONT_HEIGHT;
|
h = FONT_HEIGHT;
|
||||||
@@ -507,14 +490,14 @@ static GRect slotFrame(int i) {
|
|||||||
} else {
|
} else {
|
||||||
x = ORIGIN_X; // i = 0 or 2
|
x = ORIGIN_X; // i = 0 or 2
|
||||||
}
|
}
|
||||||
y = ORIGIN_Y - FONT_HEIGHT - SPACING_Y;
|
y = (int8_t) (ORIGIN_Y - FONT_HEIGHT - SPACING_Y);
|
||||||
} else if (i<14) { // side filler for round
|
} else if (i<14) { // side filler for round
|
||||||
w = FONT_WIDTH;
|
w = FONT_WIDTH;
|
||||||
h = FONT_HEIGHT;
|
h = FONT_HEIGHT;
|
||||||
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 = (int) (ORIGIN_X - FONT_WIDTH - SPACING_X);
|
x = (int8_t) (ORIGIN_X - FONT_WIDTH - SPACING_X);
|
||||||
}
|
}
|
||||||
if (i<12) {
|
if (i<12) {
|
||||||
y = ORIGIN_Y;
|
y = ORIGIN_Y;
|
||||||
@@ -539,10 +522,10 @@ static GRect slotFrame(int i) {
|
|||||||
return GRect(x, y, w, h);
|
return GRect(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GColor8 getSlotColor(int x, int y, int digit, int pos, bool isalpha) {
|
static GColor8 getSlotColor(uint8_t x, uint8_t y, uint8_t digit, uint8_t pos, bool isalpha) {
|
||||||
int argb;
|
static uint8_t argb;
|
||||||
bool should_add_var = false;
|
static bool should_add_var = false;
|
||||||
int thisrect = FONT[digit][y][x];
|
uint8_t thisrect = FONT[digit][y][x];
|
||||||
if (isalpha) {
|
if (isalpha) {
|
||||||
thisrect = ALPHAFONT[digit][y][x];
|
thisrect = ALPHAFONT[digit][y][x];
|
||||||
}
|
}
|
||||||
@@ -593,7 +576,7 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos, bool isalpha) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (pos >= 8) {
|
if (pos >= 8) {
|
||||||
int argb_temp = shadowtable[alpha & argb];
|
uint8_t argb_temp = shadowtable[alpha & argb];
|
||||||
if (argb_temp == BACKGROUND_COLOR.argb) {
|
if (argb_temp == BACKGROUND_COLOR.argb) {
|
||||||
argb_temp = argb;
|
argb_temp = argb;
|
||||||
}
|
}
|
||||||
@@ -629,8 +612,11 @@ static void updateSlot(Layer *layer, GContext *ctx) {
|
|||||||
GColor8 newColor = getSlotColor(tx, ty, slot->curDigit, slot->slotIndex, slot->isalpha);
|
GColor8 newColor = getSlotColor(tx, ty, slot->curDigit, slot->slotIndex, slot->isalpha);
|
||||||
|
|
||||||
graphics_context_set_fill_color(ctx, oldColor);
|
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);
|
|
||||||
|
GRect singletile = GRect((tx*tilesize)-(tx*widthadjust), ty*tilesize-(ty*widthadjust), tilesize-widthadjust, tilesize-widthadjust);
|
||||||
|
|
||||||
|
graphics_fill_rect(ctx, singletile, 0, GCornerNone);
|
||||||
|
|
||||||
if(!gcolor_equal(oldColor, newColor)) {
|
if(!gcolor_equal(oldColor, newColor)) {
|
||||||
w = (skewedNormTime*TILE_SIZE/ANIMATION_NORMALIZED_MAX)+shift-widthadjust;
|
w = (skewedNormTime*TILE_SIZE/ANIMATION_NORMALIZED_MAX)+shift-widthadjust;
|
||||||
if (w < 0) {
|
if (w < 0) {
|
||||||
@@ -641,28 +627,41 @@ static void updateSlot(Layer *layer, GContext *ctx) {
|
|||||||
graphics_context_set_fill_color(ctx, newColor);
|
graphics_context_set_fill_color(ctx, newColor);
|
||||||
graphics_fill_rect(ctx, GRect((tx*tilesize)-(tx*widthadjust), ty*tilesize-(ty*widthadjust), w, tilesize-widthadjust), 0, GCornerNone);
|
graphics_fill_rect(ctx, GRect((tx*tilesize)-(tx*widthadjust), ty*tilesize-(ty*widthadjust), w, tilesize-widthadjust), 0, GCornerNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPoint line_start = GPoint(0,0);
|
||||||
|
GPoint line_end = GPoint(90,180);
|
||||||
|
|
||||||
|
graphics_context_set_stroke_width(ctx, 1);
|
||||||
|
graphics_context_set_stroke_color(ctx, GColorRed);
|
||||||
|
//graphics_draw_line(ctx, line_start, line_end);
|
||||||
|
|
||||||
|
Intersection intersect = rectintersect(line_start, line_end, singletile);
|
||||||
|
|
||||||
|
if (intersect.success >= INTERSECTION_FULL && !gcolor_equal(newColor, BACKGROUND_COLOR)) {
|
||||||
|
graphics_context_set_stroke_color(ctx, GColorWhite);
|
||||||
|
graphics_context_set_stroke_width(ctx, 2);
|
||||||
|
graphics_draw_line(ctx, intersect.p1, intersect.p2);
|
||||||
|
//APP_LOG(APP_LOG_LEVEL_INFO, "intersection at %d,%d and %d,%d", intersect.p1.x, intersect.p1.y, intersect.p2.x, intersect.p2.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned short get_display_hour(unsigned short hour) {
|
static unsigned short get_display_hour(uint8_t hour) {
|
||||||
if (clock_is_24h_style()) {
|
if (clock_is_24h_style()) {
|
||||||
return hour;
|
return hour;
|
||||||
}
|
}
|
||||||
unsigned short display_hour = hour % 12;
|
uint8_t display_hour = hour % 12;
|
||||||
return display_hour ? display_hour : 12;
|
return display_hour ? display_hour : 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setupAnimation() {
|
static void setupAnimation() {
|
||||||
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, contrastmode ? 500 : 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);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "Done setting up anim %i", (int)anim);
|
APP_LOG(APP_LOG_LEVEL_INFO, "Set up anim %i", (int)anim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,8 +673,8 @@ static void destroyAnimation() {
|
|||||||
anim = NULL;
|
anim = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_tick(struct tm *t, TimeUnits units_changed) {
|
static void handle_tick(struct tm *t, TimeUnits units_changed) {
|
||||||
int ho, mi, da, mo, i;
|
static uint8_t ho, mi, da, mo;
|
||||||
|
|
||||||
if (splashEnded && !initial_anim) {
|
if (splashEnded && !initial_anim) {
|
||||||
if (animation_is_scheduled(anim)){
|
if (animation_is_scheduled(anim)){
|
||||||
@@ -686,56 +685,38 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|||||||
mi = t->tm_min;
|
mi = t->tm_min;
|
||||||
da = t->tm_mday;
|
da = t->tm_mday;
|
||||||
mo = t->tm_mon+1;
|
mo = t->tm_mon+1;
|
||||||
if (debug) {
|
if (debug && SUPERDEBUG) {
|
||||||
//ho = 8+(mi%4);
|
ho = 8+(mi%4);
|
||||||
}
|
}
|
||||||
const char* locale;
|
uint8_t localeid = 0;
|
||||||
uint8_t localeid;
|
static char weekdayname[3];
|
||||||
char weekdayname[5];
|
static char locale[3];
|
||||||
locale = i18n_get_system_locale();
|
strncpy(locale, i18n_get_system_locale(), 2);
|
||||||
if (WEEKDAY) {
|
if (WEEKDAY) {
|
||||||
strftime(weekday_buffer, sizeof(weekday_buffer), "%w", t);
|
strftime(weekday_buffer, sizeof(weekday_buffer), "%w", t);
|
||||||
if (strncmp("de", locale, 2) == 0) {
|
for (uint8_t lid = 0; lid < 6; lid++) {
|
||||||
localeid = 1;
|
if (strncmp(locales[lid], locale, 2) == 0) { localeid = lid; }
|
||||||
} else if (strncmp("es", locale, 2) == 0) {
|
|
||||||
localeid = 2;
|
|
||||||
} else if (strncmp("fr", locale, 2) == 0) {
|
|
||||||
localeid = 3;
|
|
||||||
} else if (strncmp("it", locale, 2) == 0) {
|
|
||||||
localeid = 4;
|
|
||||||
} else if (strncmp("pt", locale, 2) == 0) {
|
|
||||||
localeid = 5;
|
|
||||||
} else {
|
|
||||||
localeid = 0;
|
|
||||||
}
|
}
|
||||||
uint8_t weekdaynum = ((int)weekday_buffer[0])-0x30;
|
uint8_t weekdaynum = ((int)weekday_buffer[0])-0x30;
|
||||||
if (debug) {
|
if (debug && SUPERDEBUG) {
|
||||||
//weekdaynum = (int)mi%7;
|
weekdaynum = (int)mi%7;
|
||||||
}
|
}
|
||||||
strcpy(weekdayname, weekdays[localeid][weekdaynum]);
|
strcpy(weekdayname, weekdays[localeid][weekdaynum]);
|
||||||
}
|
}
|
||||||
|
|
||||||
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, "Locale is %s", locale);
|
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "The Weekday is %c%c", weekdayname[0], weekdayname[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allow_animate = true;
|
allow_animate = true;
|
||||||
if (DISABLE_ANIM) {
|
if (DISABLE_ANIM) {
|
||||||
if (DISABLE_ANIM_START_TIME == DISABLE_ANIM_END_TIME) {
|
if (DISABLE_ANIM_START_TIME == DISABLE_ANIM_END_TIME) {
|
||||||
allow_animate = false;
|
allow_animate = false;
|
||||||
if (debug) {
|
if (debug) {
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "No Animation because activation and deactivation times are the same");
|
APP_LOG(APP_LOG_LEVEL_INFO, "Animation always off");
|
||||||
}
|
}
|
||||||
} else if (DISABLE_ANIM_START_TIME > DISABLE_ANIM_END_TIME) {
|
} else if (DISABLE_ANIM_START_TIME > DISABLE_ANIM_END_TIME) {
|
||||||
// across midnight
|
// across midnight
|
||||||
if (t->tm_hour >= DISABLE_ANIM_START_TIME || t->tm_hour < DISABLE_ANIM_END_TIME) {
|
if (t->tm_hour >= DISABLE_ANIM_START_TIME || t->tm_hour < DISABLE_ANIM_END_TIME) {
|
||||||
allow_animate = false;
|
allow_animate = false;
|
||||||
if (debug) {
|
if (debug) {
|
||||||
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 );
|
APP_LOG(APP_LOG_LEVEL_INFO, "Animation off (%d:00 - %d:00)", (int)DISABLE_ANIM_START_TIME , (int)DISABLE_ANIM_END_TIME );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -743,13 +724,13 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|||||||
if (t->tm_hour >= DISABLE_ANIM_START_TIME && t->tm_hour < DISABLE_ANIM_END_TIME) {
|
if (t->tm_hour >= DISABLE_ANIM_START_TIME && t->tm_hour < DISABLE_ANIM_END_TIME) {
|
||||||
allow_animate = false;
|
allow_animate = false;
|
||||||
if (debug) {
|
if (debug) {
|
||||||
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 );
|
APP_LOG(APP_LOG_LEVEL_INFO, "Animation off (%d:00 - %d:00)", (int)DISABLE_ANIM_START_TIME , (int)DISABLE_ANIM_END_TIME );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<NUMSLOTS; i++) {
|
for (uint8_t i=0; i<NUMSLOTS; i++) {
|
||||||
slot[i].prevDigit = slot[i].curDigit;
|
slot[i].prevDigit = slot[i].curDigit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -767,8 +748,8 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|||||||
if (WEEKDAY) {
|
if (WEEKDAY) {
|
||||||
slot[4].isalpha = true;
|
slot[4].isalpha = true;
|
||||||
slot[5].isalpha = true;
|
slot[5].isalpha = true;
|
||||||
slot[4].curDigit = (int) weekdayname[0];
|
slot[4].curDigit = (uint8_t) weekdayname[0];
|
||||||
slot[5].curDigit = (int) weekdayname[1];
|
slot[5].curDigit = (uint8_t) weekdayname[1];
|
||||||
} else {
|
} else {
|
||||||
slot[4].curDigit = mo/10;
|
slot[4].curDigit = mo/10;
|
||||||
slot[5].curDigit = mo%10;
|
slot[5].curDigit = mo%10;
|
||||||
@@ -790,8 +771,8 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|||||||
if (WEEKDAY) {
|
if (WEEKDAY) {
|
||||||
slot[6].isalpha = true;
|
slot[6].isalpha = true;
|
||||||
slot[7].isalpha = true;
|
slot[7].isalpha = true;
|
||||||
slot[6].curDigit = (int) weekdayname[0];
|
slot[6].curDigit = (uint8_t) weekdayname[0];
|
||||||
slot[7].curDigit = (int) weekdayname[1];
|
slot[7].curDigit = (uint8_t) weekdayname[1];
|
||||||
} else {
|
} else {
|
||||||
if (CENTER_DATE && mo < 10) {
|
if (CENTER_DATE && mo < 10) {
|
||||||
slot[6].curDigit = mo%10;
|
slot[6].curDigit = mo%10;
|
||||||
@@ -808,32 +789,20 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (NO_ZERO) {
|
if (NO_ZERO) {
|
||||||
if (debug) {
|
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "Slot 0 was %d and is %d", (int) slot[0].prevDigit, (int) slot[0].curDigit);
|
|
||||||
}
|
|
||||||
if (slot[0].curDigit == 0) {
|
if (slot[0].curDigit == 0) {
|
||||||
if (NUMSLOTS > 8) {
|
if (NUMSLOTS > 8) {
|
||||||
if (debug) {
|
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "More than 8 slots");
|
|
||||||
}
|
|
||||||
if (slot[10].prevDigit != 10 && slot[10].prevDigit != 12) {
|
if (slot[10].prevDigit != 10 && slot[10].prevDigit != 12) {
|
||||||
slot[0].curDigit = 11;
|
slot[0].curDigit = 11;
|
||||||
} else {
|
} else {
|
||||||
slot[0].curDigit = 10;
|
slot[0].curDigit = 10;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (debug) {
|
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "8 slots or fewer");
|
|
||||||
}
|
|
||||||
if (slot[0].prevDigit == 10) {
|
if (slot[0].prevDigit == 10) {
|
||||||
slot[0].curDigit = 11;
|
slot[0].curDigit = 11;
|
||||||
} else {
|
} else {
|
||||||
slot[0].curDigit = 10;
|
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) {
|
if (slot[4].curDigit == 0) {
|
||||||
slot[4].curDigit = 10;
|
slot[4].curDigit = 10;
|
||||||
@@ -863,9 +832,6 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void initialAnimationDone() {
|
static void initialAnimationDone() {
|
||||||
if (debug) {
|
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "Stopped initial Animation");
|
|
||||||
}
|
|
||||||
initial_anim = false;
|
initial_anim = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -877,9 +843,6 @@ void handle_timer(void *data) {
|
|||||||
curTime = time(NULL);
|
curTime = time(NULL);
|
||||||
handle_tick(localtime(&curTime), SECOND_UNIT|MINUTE_UNIT|HOUR_UNIT|DAY_UNIT|MONTH_UNIT|YEAR_UNIT);
|
handle_tick(localtime(&curTime), SECOND_UNIT|MINUTE_UNIT|HOUR_UNIT|DAY_UNIT|MONTH_UNIT|YEAR_UNIT);
|
||||||
initial_anim = true;
|
initial_anim = true;
|
||||||
if (debug) {
|
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "Starting initial Animation");
|
|
||||||
}
|
|
||||||
if (initial_anim) {
|
if (initial_anim) {
|
||||||
app_timer_register(contrastmode ? 500 : DIGIT_CHANGE_ANIM_DURATION, initialAnimationDone, NULL);
|
app_timer_register(contrastmode ? 500 : DIGIT_CHANGE_ANIM_DURATION, initialAnimationDone, NULL);
|
||||||
}
|
}
|
||||||
@@ -907,13 +870,12 @@ void initSlot(int i, Layer *parent) {
|
|||||||
layer_add_child(parent, s->layer);
|
layer_add_child(parent, s->layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deinitSlot(int i) {
|
static void deinitSlot(uint8_t i) {
|
||||||
layer_destroy(slot[i].layer);
|
layer_destroy(slot[i].layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void animateDigits(struct Animation *anim, const AnimationProgress normTime) {
|
static void animateDigits(struct Animation *anim, const AnimationProgress normTime) {
|
||||||
int i;
|
for (uint8_t 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) {
|
||||||
if (allow_animate) {
|
if (allow_animate) {
|
||||||
slot[i].normTime = normTime;
|
slot[i].normTime = normTime;
|
||||||
@@ -927,7 +889,6 @@ static void animateDigits(struct Animation *anim, const AnimationProgress normTi
|
|||||||
|
|
||||||
static void setupUI() {
|
static void setupUI() {
|
||||||
Layer *rootLayer;
|
Layer *rootLayer;
|
||||||
int i;
|
|
||||||
|
|
||||||
window_set_background_color(window, contrastmode ? GColorBlack : BACKGROUND_COLOR);
|
window_set_background_color(window, contrastmode ? GColorBlack : BACKGROUND_COLOR);
|
||||||
|
|
||||||
@@ -935,7 +896,7 @@ static void setupUI() {
|
|||||||
|
|
||||||
rootLayer = window_get_root_layer(window);
|
rootLayer = window_get_root_layer(window);
|
||||||
|
|
||||||
for (i=0; i<NUMSLOTS; i++) {
|
for (uint8_t i=0; i<NUMSLOTS; i++) {
|
||||||
initSlot(i, rootLayer);
|
initSlot(i, rootLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -949,8 +910,7 @@ static void setupUI() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void teardownUI() {
|
static void teardownUI() {
|
||||||
int i;
|
for (uint8_t i=0; i<NUMSLOTS; i++) {
|
||||||
for (i=0; i<NUMSLOTS; i++) {
|
|
||||||
deinitSlot(i);
|
deinitSlot(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1003,76 +963,43 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|||||||
Tuple *weekday_t = dict_find(iter, KEY_WEEKDAY);
|
Tuple *weekday_t = dict_find(iter, KEY_WEEKDAY);
|
||||||
Tuple *debug_t = dict_find(iter, KEY_DEBUGWATCH);
|
Tuple *debug_t = dict_find(iter, KEY_DEBUGWATCH);
|
||||||
|
|
||||||
bool was_config = true;
|
|
||||||
|
|
||||||
if (debug_t) {
|
if (debug_t) {
|
||||||
if (debug_t->value->int8 == 1) {
|
if (debug_t->value->int8 == 1) {
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "Enabling debug infos for debug watch");
|
APP_LOG(APP_LOG_LEVEL_INFO, "Setting debug watch");
|
||||||
debug = true;
|
debug = true;
|
||||||
was_config = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (was_config) {
|
if (debug) {
|
||||||
|
APP_LOG(APP_LOG_LEVEL_INFO, "Got config");
|
||||||
if (large_mode_t) {
|
|
||||||
curPrefs.large_mode = large_mode_t->value->int8;
|
|
||||||
}
|
}
|
||||||
if (eu_date_t) {
|
if (large_mode_t) { curPrefs.large_mode = large_mode_t->value->int8; }
|
||||||
curPrefs.eu_date = eu_date_t->value->int8;
|
if (eu_date_t) { curPrefs.eu_date = eu_date_t->value->int8; }
|
||||||
}
|
if (quick_start_t) { curPrefs.quick_start = quick_start_t->value->int8; }
|
||||||
if (quick_start_t) {
|
if (leading_zero_t) { curPrefs.leading_zero = leading_zero_t->value->int8; }
|
||||||
curPrefs.quick_start = quick_start_t->value->int8;
|
if (background_color_t) { curPrefs.background_color = background_color_t->value->int8; }
|
||||||
}
|
if (number_base_color_t) { curPrefs.number_base_color = number_base_color_t->value->int8; }
|
||||||
if (leading_zero_t) {
|
if (number_variation_t) { curPrefs.number_variation = number_variation_t->value->int8; }
|
||||||
curPrefs.leading_zero = leading_zero_t->value->int8;
|
if (ornament_base_color_t) { curPrefs.ornament_base_color = ornament_base_color_t->value->int8; }
|
||||||
}
|
if (ornament_variation_t) { curPrefs.ornament_variation = ornament_variation_t->value->int8; }
|
||||||
if (background_color_t) {
|
if (invert_t) { curPrefs.invert = invert_t->value->int8; }
|
||||||
curPrefs.background_color = background_color_t->value->int32;
|
if (monochrome_t) { curPrefs.monochrome = monochrome_t->value->int8; }
|
||||||
}
|
if (center_t) { curPrefs.center = center_t->value->int8; }
|
||||||
if (number_base_color_t) {
|
if (btvibe_t) { curPrefs.btvibe = btvibe_t->value->int8; }
|
||||||
curPrefs.number_base_color = number_base_color_t->value->int32;
|
if (contrast_t) { curPrefs.contrast = contrast_t->value->int8; }
|
||||||
}
|
if (nightsaver_t) { curPrefs.nightsaver = nightsaver_t->value->int8; }
|
||||||
if (number_variation_t) {
|
if (ns_start_t) { curPrefs.ns_start = ns_start_t->value->int8; }
|
||||||
curPrefs.number_variation = number_variation_t->value->int8;
|
if (ns_stop_t) { curPrefs.ns_stop = ns_stop_t->value->int8; }
|
||||||
}
|
if (backlight_t) { curPrefs.backlight = backlight_t->value->int8; }
|
||||||
if (ornament_base_color_t) {
|
if (weekday_t) { curPrefs.weekday = weekday_t->value->int8; }
|
||||||
curPrefs.ornament_base_color = ornament_base_color_t->value->int32;
|
|
||||||
}
|
if (debug) {
|
||||||
if (ornament_variation_t) {
|
APP_LOG(APP_LOG_LEVEL_INFO, "Writing config");
|
||||||
curPrefs.ornament_variation = ornament_variation_t->value->int8;
|
|
||||||
}
|
|
||||||
if (invert_t) {
|
|
||||||
curPrefs.invert = invert_t->value->int8;
|
|
||||||
}
|
|
||||||
if (monochrome_t) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
if (weekday_t) {
|
|
||||||
curPrefs.weekday = weekday_t->value->int8;
|
|
||||||
}
|
}
|
||||||
persist_write_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs));
|
persist_write_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs));
|
||||||
|
if (debug) {
|
||||||
|
APP_LOG(APP_LOG_LEVEL_INFO, "Wrote config");
|
||||||
|
}
|
||||||
vibes_short_pulse();
|
vibes_short_pulse();
|
||||||
#if defined(PBL_COLOR)
|
#if defined(PBL_COLOR)
|
||||||
if (curPrefs.contrast == false) {
|
if (curPrefs.contrast == false) {
|
||||||
@@ -1095,29 +1022,30 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug) {
|
if (debug) {
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "Tearing down");
|
APP_LOG(APP_LOG_LEVEL_INFO, "Teardown");
|
||||||
}
|
}
|
||||||
teardownUI();
|
teardownUI();
|
||||||
if (debug) {
|
if (debug) {
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up");
|
APP_LOG(APP_LOG_LEVEL_INFO, "Setup");
|
||||||
}
|
}
|
||||||
setupUI();
|
setupUI();
|
||||||
if (debug) {
|
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 message because %i", (int)reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void init() {
|
static void init() {
|
||||||
setlocale(LC_ALL, "en_US");
|
|
||||||
window = window_create();
|
window = window_create();
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
debug = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Set up preferences
|
// Set up preferences
|
||||||
if(persist_exists(PREFERENCES_KEY)){
|
if(persist_exists(PREFERENCES_KEY)){
|
||||||
persist_read_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs));
|
persist_read_data(PREFERENCES_KEY, &curPrefs, sizeof(curPrefs));
|
||||||
|
|||||||
Reference in New Issue
Block a user