prepared for new settings page
parent
ad4702bfd3
commit
31aae1f01f
|
@ -1,14 +1,15 @@
|
||||||
{
|
{
|
||||||
"appKeys": {
|
"appKeys": {
|
||||||
"background_color": 4,
|
"background_color": 4,
|
||||||
|
"eu_date": 1,
|
||||||
|
"invert": 9,
|
||||||
"large_mode": 0,
|
"large_mode": 0,
|
||||||
"leading_zero": 3,
|
"leading_zero": 3,
|
||||||
"number_base_color": 5,
|
"number_base_color": 5,
|
||||||
"number_variation": 6,
|
"number_variation": 6,
|
||||||
"ornament_base_color": 7,
|
"ornament_base_color": 7,
|
||||||
"ornament_variation": 8,
|
"ornament_variation": 8,
|
||||||
"quick_start": 2,
|
"quick_start": 2
|
||||||
"us_date": 1
|
|
||||||
},
|
},
|
||||||
"capabilities": [
|
"capabilities": [
|
||||||
"configurable"
|
"configurable"
|
||||||
|
|
|
@ -1,11 +1,41 @@
|
||||||
Pebble.addEventListener('showConfiguration', function(e) {
|
Pebble.addEventListener('ready', function() {
|
||||||
Pebble.openURL('http://hexahedria.com/misc/squared3config');
|
console.log('PebbleKit JS ready!');
|
||||||
});
|
});
|
||||||
|
|
||||||
Pebble.addEventListener('webviewclosed',
|
Pebble.addEventListener('showConfiguration', function() {
|
||||||
function(e) {
|
var watch;
|
||||||
var configuration = JSON.parse(decodeURIComponent(e.response));
|
if(Pebble.getActiveWatchInfo) {
|
||||||
console.log('Configuration window returned: ', JSON.stringify(configuration));
|
watch = Pebble.getActiveWatchInfo();
|
||||||
Pebble.sendAppMessage(configuration);
|
|
||||||
}
|
}
|
||||||
);
|
var url='http://pebble.lastfuture.de/config/squared40/';
|
||||||
|
if (watch.platform == "basalt") {
|
||||||
|
url += "?rect=true";
|
||||||
|
} else if (watch.platform == "aplite") {
|
||||||
|
url += "?rect=true&bw=true";
|
||||||
|
}
|
||||||
|
console.log('Showing configuration page: '+url);
|
||||||
|
Pebble.openURL(url);
|
||||||
|
});
|
||||||
|
|
||||||
|
Pebble.addEventListener('webviewclosed', function(e) {
|
||||||
|
var configData = JSON.parse(decodeURIComponent(e.response));
|
||||||
|
console.log('Configuration page returned: '+JSON.stringify(configData));
|
||||||
|
if (configData.background_color) {
|
||||||
|
Pebble.sendAppMessage({
|
||||||
|
large_mode: 0+(configData.large_mode === 'true'),
|
||||||
|
eu_date: 0+(configData.eu_date === 'true'),
|
||||||
|
quick_start: 0+(configData.quick_start === 'true'),
|
||||||
|
leading_zero: 0+(configData.leading_zero === 'true'),
|
||||||
|
background_color: configData.background_color,
|
||||||
|
number_base_color: configData.number_base_color,
|
||||||
|
number_variation: configData.number_variation,
|
||||||
|
ornament_base_color: configData.ornament_base_color,
|
||||||
|
ornament_variation: configData.ornament_variation,
|
||||||
|
invert: 0+(configData.invert === 'true')
|
||||||
|
}, function() {
|
||||||
|
console.log('Send successful!');
|
||||||
|
}, function() {
|
||||||
|
console.log('Send failed!');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -11,7 +11,7 @@ Window *window;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
bool large_mode;
|
bool large_mode;
|
||||||
bool us_date;
|
bool eu_date;
|
||||||
bool quick_start;
|
bool quick_start;
|
||||||
bool leading_zero;
|
bool leading_zero;
|
||||||
int background_color;
|
int background_color;
|
||||||
|
@ -19,13 +19,14 @@ typedef struct {
|
||||||
bool number_variation;
|
bool number_variation;
|
||||||
int ornament_base_color;
|
int ornament_base_color;
|
||||||
bool ornament_variation;
|
bool ornament_variation;
|
||||||
|
bool invert;
|
||||||
} Preferences;
|
} Preferences;
|
||||||
|
|
||||||
Preferences curPrefs;
|
Preferences curPrefs;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
KEY_LARGE_MODE,
|
KEY_LARGE_MODE,
|
||||||
KEY_US_DATE,
|
KEY_EU_DATE,
|
||||||
KEY_QUICK_START,
|
KEY_QUICK_START,
|
||||||
KEY_LEADING_ZERO,
|
KEY_LEADING_ZERO,
|
||||||
KEY_BACKGROUND_COLOR,
|
KEY_BACKGROUND_COLOR,
|
||||||
|
@ -33,13 +34,15 @@ enum {
|
||||||
KEY_NUMBER_VARIATION,
|
KEY_NUMBER_VARIATION,
|
||||||
KEY_ORNAMENT_BASE_COLOR,
|
KEY_ORNAMENT_BASE_COLOR,
|
||||||
KEY_ORNAMENT_VARIATION,
|
KEY_ORNAMENT_VARIATION,
|
||||||
|
KEY_INVERT,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PREFERENCES_KEY 0
|
#define PREFERENCES_KEY 0
|
||||||
|
|
||||||
#define US_DATE (curPrefs.us_date) // true == MM/DD, false == DD/MM
|
#define US_DATE (!curPrefs.eu_date) // true == MM/DD, false == DD/MM
|
||||||
#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 (curPrefs.large_mode ? 12 : 10)
|
#define TILE_SIZE PBL_IF_RECT_ELSE((curPrefs.large_mode ? 12 : 10), 10)
|
||||||
|
#define INVERT (curPrefs.invert)
|
||||||
#define NUMSLOTS PBL_IF_RECT_ELSE(8, 18)
|
#define NUMSLOTS PBL_IF_RECT_ELSE(8, 18)
|
||||||
#define SPACING_X TILE_SIZE
|
#define SPACING_X TILE_SIZE
|
||||||
#define SPACING_Y (curPrefs.large_mode ? TILE_SIZE - 1 : TILE_SIZE)
|
#define SPACING_Y (curPrefs.large_mode ? TILE_SIZE - 1 : TILE_SIZE)
|
||||||
|
@ -51,7 +54,7 @@ enum {
|
||||||
#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 ((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
|
||||||
|
|
||||||
|
@ -290,7 +293,11 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos) {
|
||||||
argb = NUMBER_BASE_COLOR_ARGB8;
|
argb = NUMBER_BASE_COLOR_ARGB8;
|
||||||
should_add_var = NUMBER_ADD_VARIATION;
|
should_add_var = NUMBER_ADD_VARIATION;
|
||||||
#elif defined(PBL_BW)
|
#elif defined(PBL_BW)
|
||||||
|
if (!INVERT) {
|
||||||
argb = 0b11111111;
|
argb = 0b11111111;
|
||||||
|
} else {
|
||||||
|
argb = 0b11000000;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if defined(PBL_COLOR)
|
#if defined(PBL_COLOR)
|
||||||
|
@ -525,7 +532,7 @@ static void teardownUI() {
|
||||||
static void in_received_handler(DictionaryIterator *iter, void *context) {
|
static void in_received_handler(DictionaryIterator *iter, void *context) {
|
||||||
curPrefs = (Preferences) {
|
curPrefs = (Preferences) {
|
||||||
.large_mode = dict_find(iter, KEY_LARGE_MODE)->value->int8,
|
.large_mode = dict_find(iter, KEY_LARGE_MODE)->value->int8,
|
||||||
.us_date = dict_find(iter, KEY_US_DATE)->value->int8,
|
.eu_date = dict_find(iter, KEY_EU_DATE)->value->int8,
|
||||||
.quick_start = dict_find(iter, KEY_QUICK_START)->value->int8,
|
.quick_start = dict_find(iter, KEY_QUICK_START)->value->int8,
|
||||||
.leading_zero = dict_find(iter, KEY_LEADING_ZERO)->value->int8,
|
.leading_zero = dict_find(iter, KEY_LEADING_ZERO)->value->int8,
|
||||||
.background_color = dict_find(iter, KEY_BACKGROUND_COLOR)->value->int32,
|
.background_color = dict_find(iter, KEY_BACKGROUND_COLOR)->value->int32,
|
||||||
|
@ -533,6 +540,7 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
|
||||||
.number_variation = dict_find(iter, KEY_NUMBER_VARIATION)->value->int8,
|
.number_variation = dict_find(iter, KEY_NUMBER_VARIATION)->value->int8,
|
||||||
.ornament_base_color = dict_find(iter, KEY_ORNAMENT_BASE_COLOR)->value->int32,
|
.ornament_base_color = dict_find(iter, KEY_ORNAMENT_BASE_COLOR)->value->int32,
|
||||||
.ornament_variation = dict_find(iter, KEY_ORNAMENT_VARIATION)->value->int8,
|
.ornament_variation = dict_find(iter, KEY_ORNAMENT_VARIATION)->value->int8,
|
||||||
|
.invert = dict_find(iter, KEY_INVERT)->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");
|
APP_LOG(APP_LOG_LEVEL_INFO, "Tearing down");
|
||||||
|
@ -555,7 +563,7 @@ static void init() {
|
||||||
} else {
|
} else {
|
||||||
curPrefs = (Preferences) {
|
curPrefs = (Preferences) {
|
||||||
.large_mode = false,
|
.large_mode = false,
|
||||||
.us_date = true,
|
.eu_date = true,
|
||||||
.quick_start = false,
|
.quick_start = false,
|
||||||
.leading_zero = false,
|
.leading_zero = false,
|
||||||
.background_color = 0b11000000,
|
.background_color = 0b11000000,
|
||||||
|
@ -563,6 +571,7 @@ static void init() {
|
||||||
.number_variation = true,
|
.number_variation = true,
|
||||||
.ornament_base_color = 0b11100010,
|
.ornament_base_color = 0b11100010,
|
||||||
.ornament_variation = true,
|
.ornament_variation = true,
|
||||||
|
.invert = false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue