Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a291b56e5e | |||
| a572e02813 | |||
| 467173ad9e | |||
| 8913a7699a | |||
| 48259f4ddc | |||
| aeebe1ef80 | |||
| 163f5ce393 | |||
| 8cfdb4e198 | |||
| da68da4fe2 | |||
| 1388670ce7 | |||
| e78178b587 | |||
| fdd2addc72 | |||
| a87339364f | |||
| 0191667fa1 | |||
| dd9251bfa7 | |||
| 1b51ee1af4 | |||
| fcedbb11f6 | |||
| b684308c34 |
33
.gitignore
vendored
33
.gitignore
vendored
@@ -30,3 +30,36 @@ Icon
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
.lock-waf_darwin_build
|
||||
build
|
||||
|
||||
|
||||
|
||||
# Created by https://www.gitignore.io/api/xcode
|
||||
|
||||
### Xcode ###
|
||||
# Xcode
|
||||
#
|
||||
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
|
||||
|
||||
## Build generated
|
||||
build/
|
||||
DerivedData
|
||||
|
||||
## Various settings
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
|
||||
## Other
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
*.xcuserstate
|
||||
*.pbxproj
|
||||
*.xcworkspacedata
|
||||
|
||||
13
appinfo.json
13
appinfo.json
@@ -1,16 +1,25 @@
|
||||
{
|
||||
"appKeys": {
|
||||
"background_color": 4,
|
||||
"backlight": 17,
|
||||
"btvibe": 12,
|
||||
"center": 11,
|
||||
"contrast": 13,
|
||||
"debugwatch": 50,
|
||||
"eu_date": 1,
|
||||
"invert": 9,
|
||||
"large_mode": 0,
|
||||
"leading_zero": 3,
|
||||
"monochrome": 10,
|
||||
"nightsaver": 14,
|
||||
"ns_start": 15,
|
||||
"ns_stop": 16,
|
||||
"number_base_color": 5,
|
||||
"number_variation": 6,
|
||||
"ornament_base_color": 7,
|
||||
"ornament_variation": 8,
|
||||
"quick_start": 2
|
||||
"quick_start": 2,
|
||||
"weekday": 18
|
||||
},
|
||||
"capabilities": [
|
||||
"configurable"
|
||||
@@ -29,7 +38,7 @@
|
||||
"chalk"
|
||||
],
|
||||
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
|
||||
"versionLabel": "4.1",
|
||||
"versionLabel": "4.10",
|
||||
"watchapp": {
|
||||
"watchface": true
|
||||
}
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
String.prototype.hashCode = function(){
|
||||
var hash = 0;
|
||||
if (this.length === 0) return hash;
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
var char = this.charCodeAt(i);
|
||||
hash = ((hash<<5)-hash)+char;
|
||||
hash = hash & hash; // Convert to 32bit integer
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
|
||||
var debugwatches = Array(/*1568511776, */1135189913, -826258655, -1783317168);
|
||||
var tokenhash;
|
||||
|
||||
Pebble.addEventListener('ready', function() {
|
||||
console.log('PebbleKit JS ready!');
|
||||
console.log('PebbleKit JS ready!');
|
||||
tokenhash = Pebble.getWatchToken().hashCode();
|
||||
console.log('Watch identifier '+tokenhash);
|
||||
if (debugwatches.indexOf(tokenhash) > -1) {
|
||||
var dict = {"debugwatch": 1};
|
||||
Pebble.sendAppMessage(dict);
|
||||
}
|
||||
});
|
||||
|
||||
Pebble.addEventListener('appmessage', function() {
|
||||
console.log('got appmessage');
|
||||
});
|
||||
|
||||
Pebble.addEventListener('showConfiguration', function() {
|
||||
@@ -7,11 +31,16 @@ Pebble.addEventListener('showConfiguration', function() {
|
||||
if(Pebble.getActiveWatchInfo) {
|
||||
watch = Pebble.getActiveWatchInfo();
|
||||
}
|
||||
var url='http://pebble.lastfuture.de/config/squared40/';
|
||||
var url='http://pebble.lastfuture.de/config/squared48/';
|
||||
url += "?model="+watch.model;
|
||||
if (watch.platform == "basalt") {
|
||||
url += "?rect=true";
|
||||
url += "&rect=true";
|
||||
} else if (watch.platform == "aplite") {
|
||||
url += "?rect=true&bw=true";
|
||||
url += "&rect=true&bw=true";
|
||||
}
|
||||
tokenhash = Pebble.getWatchToken().hashCode();
|
||||
if (debugwatches.indexOf(tokenhash) > -1) {
|
||||
url += "&debug=true";
|
||||
}
|
||||
console.log('Showing configuration page: '+url);
|
||||
Pebble.openURL(url);
|
||||
@@ -32,7 +61,15 @@ Pebble.addEventListener('webviewclosed', function(e) {
|
||||
ornament_base_color: configData.ornament_base_color,
|
||||
ornament_variation: configData.ornament_variation,
|
||||
invert: 0+(configData.invert === 'true'),
|
||||
monochrome: 0+(configData.monochrome === 'true')
|
||||
monochrome: 0+(configData.monochrome === 'true'),
|
||||
center: 0+(configData.center === 'true'),
|
||||
btvibe: 0+(configData.btvibe === 'true'),
|
||||
contrast: 0+(configData.contrast === 'true'),
|
||||
nightsaver: 0+(configData.nightsaver === 'true'),
|
||||
ns_start: parseInt(configData.ns_start),
|
||||
ns_stop: parseInt(configData.ns_stop),
|
||||
backlight: 0+(configData.backlight === 'true'),
|
||||
weekday: 0+(configData.weekday === 'true')
|
||||
}, function() {
|
||||
console.log('Send successful!');
|
||||
}, function() {
|
||||
|
||||
697
src/squared.c
697
src/squared.c
@@ -2,7 +2,7 @@
|
||||
* Original source code by lastfuture
|
||||
* SDK 2.0beta4 port by Jnm
|
||||
* 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>
|
||||
@@ -21,6 +21,15 @@ typedef struct {
|
||||
bool ornament_variation;
|
||||
bool invert;
|
||||
bool monochrome;
|
||||
bool center;
|
||||
bool btvibe;
|
||||
bool contrast;
|
||||
bool nightsaver;
|
||||
int ns_start;
|
||||
int ns_stop;
|
||||
bool backlight;
|
||||
bool weekday;
|
||||
|
||||
} Preferences;
|
||||
|
||||
Preferences curPrefs;
|
||||
@@ -37,11 +46,31 @@ enum {
|
||||
KEY_ORNAMENT_VARIATION,
|
||||
KEY_INVERT,
|
||||
KEY_MONOCHROME,
|
||||
KEY_CENTER,
|
||||
KEY_BTVIBE,
|
||||
KEY_CONTRAST,
|
||||
KEY_NIGHTSAVER,
|
||||
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 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)
|
||||
#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 TILE_SIZE PBL_IF_RECT_ELSE((curPrefs.large_mode ? 12 : 10), 10)
|
||||
#define INVERT (curPrefs.invert)
|
||||
@@ -49,30 +78,33 @@ 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)
|
||||
#define NUMBER_ADD_VARIATION (curPrefs.number_variation)
|
||||
#define ORNAMENT_ADD_VARIATION (curPrefs.ornament_variation)
|
||||
|
||||
|
||||
#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;
|
||||
} digitSlot;
|
||||
|
||||
|
||||
digitSlot slot[NUMSLOTS];
|
||||
|
||||
static char weekday_buffer[16];
|
||||
|
||||
AnimationImplementation animImpl;
|
||||
Animation *anim;
|
||||
bool splashEnded = false;
|
||||
@@ -162,13 +194,213 @@ unsigned char blocks[][5][5] = {{
|
||||
{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 {
|
||||
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
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,0,1},
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,0,1},
|
||||
{1,0,2,0,1}
|
||||
},
|
||||
[68] = { // D
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,0,1},
|
||||
{1,0,2,0,1},
|
||||
{1,0,0,0,1},
|
||||
{1,1,1,1,0}
|
||||
},
|
||||
[69] = { // E
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,0,0},
|
||||
{1,1,1,1,0},
|
||||
{1,0,0,0,0},
|
||||
{1,1,1,1,1}
|
||||
},
|
||||
[70] = { // F
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,0,0},
|
||||
{1,1,1,1,0},
|
||||
{1,0,0,0,0},
|
||||
{1,0,2,2,2}
|
||||
},
|
||||
[71] = { // G
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,0,0},
|
||||
{1,0,1,1,1},
|
||||
{1,0,0,0,1},
|
||||
{1,1,1,1,1}
|
||||
},
|
||||
[72] = { // H
|
||||
{1,0,2,0,1},
|
||||
{1,0,0,0,1},
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,0,1},
|
||||
{1,0,2,0,1}
|
||||
},
|
||||
[73] = { // I
|
||||
{1,1,1,1,1},
|
||||
{0,0,1,0,0},
|
||||
{2,0,1,0,2},
|
||||
{0,0,1,0,0},
|
||||
{1,1,1,1,1}
|
||||
},
|
||||
[74] = { // J
|
||||
{2,0,1,1,1},
|
||||
{0,0,0,0,1},
|
||||
{2,2,2,0,1},
|
||||
{0,0,0,0,1},
|
||||
{1,1,1,1,1}
|
||||
},
|
||||
[76] = { // L
|
||||
{1,0,2,0,2},
|
||||
{1,0,2,0,2},
|
||||
{1,0,2,0,2},
|
||||
{1,0,0,0,0},
|
||||
{1,1,1,1,1}
|
||||
},
|
||||
[77] = { // M
|
||||
{1,1,1,1,1},
|
||||
{1,0,1,0,1},
|
||||
{1,0,1,0,1},
|
||||
{1,0,0,0,1},
|
||||
{1,0,2,0,1}
|
||||
},
|
||||
[79] = { // O
|
||||
{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}
|
||||
},
|
||||
[81] = { // Q
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,0,1},
|
||||
{1,0,0,0,1},
|
||||
{1,0,1,0,1},
|
||||
{1,1,1,1,1}
|
||||
},
|
||||
[82] = { // R
|
||||
{1,1,1,1,1},
|
||||
{0,0,0,0,1},
|
||||
{1,1,1,1,1},
|
||||
{1,0,0,1,0},
|
||||
{1,0,2,0,1}
|
||||
},
|
||||
[83] = { // S
|
||||
{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}
|
||||
},
|
||||
[84] = { // T
|
||||
{1,1,1,1,1},
|
||||
{0,0,1,0,0},
|
||||
{2,0,1,0,2},
|
||||
{2,0,1,0,2},
|
||||
{2,0,1,0,2}
|
||||
},
|
||||
[85] = { // U
|
||||
{1,0,2,0,1},
|
||||
{1,0,2,0,1},
|
||||
{1,0,2,0,1},
|
||||
{1,0,0,0,1},
|
||||
{1,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}
|
||||
},
|
||||
[88] = { // X
|
||||
{1,0,0,0,1},
|
||||
{0,1,0,1,0},
|
||||
{0,0,1,0,0},
|
||||
{0,1,0,1,0},
|
||||
{1,0,0,0,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,
|
||||
@@ -192,25 +424,32 @@ unsigned char variation[] = {
|
||||
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, \
|
||||
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,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,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, \
|
||||
224,224,225,226,224,224,225,226,228,228,229,230,232,232,233,234, \
|
||||
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207, \
|
||||
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, \
|
||||
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};
|
||||
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,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,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,
|
||||
224,224,225,226,224,224,225,226,228,228,229,230,232,232,233,234,
|
||||
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
|
||||
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
|
||||
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)
|
||||
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_WIDTH_BLOCKS (sizeof **FONT)
|
||||
@@ -225,7 +464,20 @@ static uint8_t alpha = 0b10111111;
|
||||
|
||||
#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, initial_anim = false;
|
||||
|
||||
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) {
|
||||
int x, y, w, h;
|
||||
if (i<4) { // main digits
|
||||
@@ -262,7 +514,7 @@ static GRect slotFrame(int i) {
|
||||
if (i%2) {
|
||||
x = ORIGIN_X + FONT_WIDTH + SPACING_X + FONT_WIDTH + SPACING_X;
|
||||
} else {
|
||||
x = ORIGIN_X - FONT_WIDTH - SPACING_X;
|
||||
x = (int) (ORIGIN_X - FONT_WIDTH - SPACING_X);
|
||||
}
|
||||
if (i<12) {
|
||||
y = ORIGIN_Y;
|
||||
@@ -287,15 +539,29 @@ 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)
|
||||
argb = NUMBER_BASE_COLOR_ARGB8;
|
||||
should_add_var = NUMBER_ADD_VARIATION;
|
||||
if (contrastmode && pos >= 8) {
|
||||
argb = 0b11000000;
|
||||
} else {
|
||||
argb = contrastmode ? 0b11111111 : NUMBER_BASE_COLOR_ARGB8;
|
||||
should_add_var = contrastmode ? false : NUMBER_ADD_VARIATION;
|
||||
}
|
||||
#elif defined(PBL_BW)
|
||||
if (!INVERT) {
|
||||
argb = 0b11111111;
|
||||
@@ -305,8 +571,8 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos) {
|
||||
#endif
|
||||
} else {
|
||||
#if defined(PBL_COLOR)
|
||||
argb = ORNAMENT_BASE_COLOR_ARGB8;
|
||||
should_add_var = ORNAMENT_ADD_VARIATION;
|
||||
argb = contrastmode ? 0b11000001 : ORNAMENT_BASE_COLOR_ARGB8;
|
||||
should_add_var = contrastmode ? false : ORNAMENT_ADD_VARIATION;
|
||||
#elif defined(PBL_BW)
|
||||
if (GREYS) {
|
||||
argb = 0b11010101;
|
||||
@@ -320,11 +586,15 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos) {
|
||||
#endif
|
||||
}
|
||||
if (should_add_var) {
|
||||
argb += variation[ ( y*5 + x + digit*17 + pos*19 )%sizeof(variation) ];
|
||||
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 == 0b11000000) {
|
||||
if (argb_temp == BACKGROUND_COLOR.argb) {
|
||||
argb_temp = argb;
|
||||
}
|
||||
argb = argb_temp;
|
||||
@@ -346,7 +616,7 @@ static void updateSlot(Layer *layer, GContext *ctx) {
|
||||
uint32_t skewedNormTime = slot->normTime*3;
|
||||
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);
|
||||
graphics_fill_rect(ctx, GRect(0, 0, r.size.w, r.size.h), 0, GCornerNone);
|
||||
for (t=0; t<total; t++) {
|
||||
@@ -355,8 +625,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);
|
||||
@@ -383,17 +653,23 @@ static unsigned short get_display_hour(unsigned short hour) {
|
||||
}
|
||||
|
||||
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();
|
||||
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_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() {
|
||||
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);
|
||||
anim = NULL;
|
||||
}
|
||||
@@ -401,21 +677,76 @@ 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);
|
||||
}
|
||||
ho = get_display_hour(t->tm_hour);
|
||||
mi = t->tm_min;
|
||||
da = t->tm_mday;
|
||||
mo = t->tm_mon+1;
|
||||
if (debug) {
|
||||
ho = 19;
|
||||
mi = 24;
|
||||
da = 3;
|
||||
mo = 12;
|
||||
} else {
|
||||
ho = get_display_hour(t->tm_hour);
|
||||
mi = t->tm_min;
|
||||
da = t->tm_mday;
|
||||
mo = t->tm_mon+1;
|
||||
//ho = 8+(mi%4);
|
||||
}
|
||||
const char* locale;
|
||||
uint8_t localeid;
|
||||
char weekdayname[5];
|
||||
locale = i18n_get_system_locale();
|
||||
if (WEEKDAY) {
|
||||
strftime(weekday_buffer, sizeof(weekday_buffer), "%w", t);
|
||||
if (strncmp("de", locale, 2) == 0) {
|
||||
localeid = 1;
|
||||
} 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;
|
||||
if (debug) {
|
||||
//weekdaynum = (int)mi%7;
|
||||
}
|
||||
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;
|
||||
if (DISABLE_ANIM) {
|
||||
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 (t->tm_hour >= DISABLE_ANIM_START_TIME || t->tm_hour < DISABLE_ANIM_END_TIME) {
|
||||
allow_animate = false;
|
||||
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 );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// prior to midnight
|
||||
if (t->tm_hour >= DISABLE_ANIM_START_TIME && t->tm_hour < DISABLE_ANIM_END_TIME) {
|
||||
allow_animate = false;
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i=0; i<NUMSLOTS; i++) {
|
||||
@@ -426,23 +757,82 @@ 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[6].curDigit = da/10;
|
||||
slot[7].curDigit = da%10;
|
||||
slot[4].curDigit = mo/10;
|
||||
slot[5].curDigit = mo%10;
|
||||
|
||||
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) weekdayname[0];
|
||||
slot[5].curDigit = (int) weekdayname[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) {
|
||||
slot[7].curDigit = 11;
|
||||
} else {
|
||||
slot[7].curDigit = 10;
|
||||
}
|
||||
} else {
|
||||
slot[6].curDigit = da/10;
|
||||
slot[7].curDigit = da%10;
|
||||
}
|
||||
} else {
|
||||
slot[4].curDigit = da/10;
|
||||
slot[5].curDigit = da%10;
|
||||
slot[6].curDigit = mo/10;
|
||||
slot[7].curDigit = mo%10;
|
||||
if (WEEKDAY) {
|
||||
slot[6].isalpha = true;
|
||||
slot[7].isalpha = true;
|
||||
slot[6].curDigit = (int) weekdayname[0];
|
||||
slot[7].curDigit = (int) weekdayname[1];
|
||||
} else {
|
||||
if (CENTER_DATE && 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 (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) {
|
||||
slot[0].curDigit = 10;
|
||||
if (slot[0].prevDigit == 10) {
|
||||
slot[0].curDigit++;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (debug) {
|
||||
APP_LOG(APP_LOG_LEVEL_INFO, "Slot 0 is now %d", (int) slot[0].curDigit);
|
||||
}
|
||||
}
|
||||
if (slot[4].curDigit == 0) {
|
||||
@@ -472,6 +862,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;
|
||||
|
||||
@@ -479,6 +876,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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -487,7 +893,7 @@ void initSlot(int i, Layer *parent) {
|
||||
|
||||
s->slotIndex = i;
|
||||
s->normTime = ANIMATION_NORMALIZED_MAX;
|
||||
s->prevDigit = 0;
|
||||
s->prevDigit = startDigit[i];
|
||||
s->curDigit = startDigit[i];
|
||||
if ((i<4 || i>=8) && i<14) {
|
||||
s->divider = 1;
|
||||
@@ -506,11 +912,14 @@ static void deinitSlot(int i) {
|
||||
}
|
||||
|
||||
static void animateDigits(struct Animation *anim, const AnimationProgress normTime) {
|
||||
APP_LOG(APP_LOG_LEVEL_INFO, "Tick! %i", (int)anim);
|
||||
int i;
|
||||
for (i=0; i<NUMSLOTS; i++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -519,8 +928,9 @@ static void animateDigits(struct Animation *anim, const AnimationProgress normTi
|
||||
static void setupUI() {
|
||||
Layer *rootLayer;
|
||||
int i;
|
||||
|
||||
window_set_background_color(window, BACKGROUND_COLOR);
|
||||
|
||||
window_set_background_color(window, contrastmode ? GColorBlack : BACKGROUND_COLOR);
|
||||
|
||||
window_stack_push(window, true);
|
||||
|
||||
rootLayer = window_get_root_layer(window);
|
||||
@@ -535,7 +945,7 @@ static void setupUI() {
|
||||
|
||||
setupAnimation();
|
||||
|
||||
app_timer_register(STARTDELAY, handle_timer, NULL);
|
||||
app_timer_register(contrastmode ? 0 : STARTDELAY, handle_timer, NULL);
|
||||
}
|
||||
|
||||
static void teardownUI() {
|
||||
@@ -547,6 +957,30 @@ static void teardownUI() {
|
||||
animation_destroy(anim);
|
||||
}
|
||||
|
||||
static void battery_handler(BatteryChargeState charge_state) {
|
||||
#if defined(PBL_COLOR)
|
||||
if (CONTRAST_WHILE_CHARGING) {
|
||||
previous_contrastmode = contrastmode;
|
||||
if (charge_state.is_plugged) {
|
||||
contrastmode = true;
|
||||
} else {
|
||||
contrastmode = false;
|
||||
}
|
||||
if (previous_contrastmode != contrastmode) {
|
||||
teardownUI();
|
||||
setupUI();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
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) {
|
||||
Tuple *large_mode_t = dict_find(iter, KEY_LARGE_MODE);
|
||||
Tuple *eu_date_t = dict_find(iter, KEY_EU_DATE);
|
||||
@@ -559,6 +993,27 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
||||
Tuple *ornament_variation_t = dict_find(iter, KEY_ORNAMENT_VARIATION);
|
||||
Tuple *invert_t = dict_find(iter, KEY_INVERT);
|
||||
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);
|
||||
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;
|
||||
@@ -593,23 +1048,74 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
||||
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));
|
||||
APP_LOG(APP_LOG_LEVEL_INFO, "Tearing down");
|
||||
vibes_short_pulse();
|
||||
#if defined(PBL_COLOR)
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
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();
|
||||
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up");
|
||||
if (debug) {
|
||||
APP_LOG(APP_LOG_LEVEL_INFO, "Setting up");
|
||||
}
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
|
||||
setlocale(LC_ALL, "en_US");
|
||||
window = window_create();
|
||||
|
||||
// Set up preferences
|
||||
@@ -618,7 +1124,7 @@ static void init() {
|
||||
} else {
|
||||
curPrefs = (Preferences) {
|
||||
.large_mode = false,
|
||||
.eu_date = true,
|
||||
.eu_date = false,
|
||||
.quick_start = false,
|
||||
.leading_zero = false,
|
||||
.background_color = 0b11000000,
|
||||
@@ -628,22 +1134,55 @@ static void init() {
|
||||
.ornament_variation = true,
|
||||
.invert = false,
|
||||
.monochrome = false,
|
||||
.center = false,
|
||||
.btvibe = false,
|
||||
.contrast = false,
|
||||
.nightsaver = false,
|
||||
.ns_start = 0,
|
||||
.ns_stop = 6,
|
||||
.backlight = false,
|
||||
.weekday = false,
|
||||
};
|
||||
}
|
||||
|
||||
setupUI();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup app message
|
||||
app_message_register_inbox_received(in_received_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);
|
||||
|
||||
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() {
|
||||
tick_timer_service_unsubscribe();
|
||||
|
||||
connection_service_unsubscribe();
|
||||
battery_state_service_unsubscribe();
|
||||
teardownUI();
|
||||
window_destroy(window);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user