1
1
Fork 0

fixed settings causing crash on black and white

squarelines 4.2
Alina Marquardt 2016-01-09 03:57:09 +01:00
parent fe4982f178
commit 854fdd3a93
3 changed files with 86 additions and 28 deletions

View File

@ -5,6 +5,7 @@
"invert": 9, "invert": 9,
"large_mode": 0, "large_mode": 0,
"leading_zero": 3, "leading_zero": 3,
"monochrome": 10,
"number_base_color": 5, "number_base_color": 5,
"number_variation": 6, "number_variation": 6,
"ornament_base_color": 7, "ornament_base_color": 7,
@ -28,7 +29,7 @@
"chalk" "chalk"
], ],
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8", "uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
"versionLabel": "4.0", "versionLabel": "4.1",
"watchapp": { "watchapp": {
"watchface": true "watchface": true
} }

View File

@ -31,7 +31,8 @@ Pebble.addEventListener('webviewclosed', function(e) {
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')
}, function() { }, function() {
console.log('Send successful!'); console.log('Send successful!');
}, function() { }, function() {

View File

@ -20,6 +20,7 @@ typedef struct {
int ornament_base_color; int ornament_base_color;
bool ornament_variation; bool ornament_variation;
bool invert; bool invert;
bool monochrome;
} Preferences; } Preferences;
Preferences curPrefs; Preferences curPrefs;
@ -35,6 +36,7 @@ enum {
KEY_ORNAMENT_BASE_COLOR, KEY_ORNAMENT_BASE_COLOR,
KEY_ORNAMENT_VARIATION, KEY_ORNAMENT_VARIATION,
KEY_INVERT, KEY_INVERT,
KEY_MONOCHROME,
}; };
#define PREFERENCES_KEY 0 #define PREFERENCES_KEY 0
@ -43,6 +45,7 @@ enum {
#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)
#define GREYS (curPrefs.monochrome)
#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)
@ -73,6 +76,7 @@ digitSlot slot[NUMSLOTS];
AnimationImplementation animImpl; AnimationImplementation animImpl;
Animation *anim; Animation *anim;
bool splashEnded = false; bool splashEnded = false;
static bool debug = false;
unsigned char blocks[][5][5] = {{ unsigned char blocks[][5][5] = {{
{1,1,1,1,1}, {1,1,1,1,1},
@ -304,7 +308,15 @@ static GColor8 getSlotColor(int x, int y, int digit, int pos) {
argb = ORNAMENT_BASE_COLOR_ARGB8; argb = ORNAMENT_BASE_COLOR_ARGB8;
should_add_var = ORNAMENT_ADD_VARIATION; should_add_var = ORNAMENT_ADD_VARIATION;
#elif defined(PBL_BW) #elif defined(PBL_BW)
argb = 0b11010101; if (GREYS) {
argb = 0b11010101;
} else {
if (!INVERT) {
argb = 0b11111111;
} else {
argb = 0b11000000;
}
}
#endif #endif
} }
if (should_add_var) { if (should_add_var) {
@ -394,11 +406,17 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
animation_unschedule(anim); animation_unschedule(anim);
animation_destroy(anim); animation_destroy(anim);
} }
if (debug) {
ho = get_display_hour(t->tm_hour); ho = 19;
mi = t->tm_min; mi = 24;
da = t->tm_mday; da = 3;
mo = t->tm_mon+1; mo = 12;
} else {
ho = get_display_hour(t->tm_hour);
mi = t->tm_min;
da = t->tm_mday;
mo = t->tm_mon+1;
}
for (i=0; i<NUMSLOTS; i++) { for (i=0; i<NUMSLOTS; i++) {
slot[i].prevDigit = slot[i].curDigit; slot[i].prevDigit = slot[i].curDigit;
@ -439,13 +457,13 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
slot[6].curDigit++; slot[6].curDigit++;
} }
} }
if (NUMSLOTS > 8) { }
for(int dig = 8; dig < NUMSLOTS; dig++) { if (NUMSLOTS > 8) {
if (slot[dig].prevDigit == 10 || slot[dig].prevDigit == 12) { for(int dig = 8; dig < NUMSLOTS; dig++) {
slot[dig].curDigit = 11; if (slot[dig].prevDigit == 10 || slot[dig].prevDigit == 12) {
} else { slot[dig].curDigit = 11;
slot[dig].curDigit = 10; } else {
} slot[dig].curDigit = 10;
} }
} }
} }
@ -530,18 +548,51 @@ static void teardownUI() {
} }
static void in_received_handler(DictionaryIterator *iter, void *context) { static void in_received_handler(DictionaryIterator *iter, void *context) {
curPrefs = (Preferences) { Tuple *large_mode_t = dict_find(iter, KEY_LARGE_MODE);
.large_mode = dict_find(iter, KEY_LARGE_MODE)->value->int8, Tuple *eu_date_t = dict_find(iter, KEY_EU_DATE);
.eu_date = dict_find(iter, KEY_EU_DATE)->value->int8, Tuple *quick_start_t = dict_find(iter, KEY_QUICK_START);
.quick_start = dict_find(iter, KEY_QUICK_START)->value->int8, Tuple *leading_zero_t = dict_find(iter, KEY_LEADING_ZERO);
.leading_zero = dict_find(iter, KEY_LEADING_ZERO)->value->int8, Tuple *background_color_t = dict_find(iter, KEY_BACKGROUND_COLOR);
.background_color = dict_find(iter, KEY_BACKGROUND_COLOR)->value->int32, Tuple *number_base_color_t = dict_find(iter, KEY_NUMBER_BASE_COLOR);
.number_base_color = dict_find(iter, KEY_NUMBER_BASE_COLOR)->value->int32, Tuple *number_variation_t = dict_find(iter, KEY_NUMBER_VARIATION);
.number_variation = dict_find(iter, KEY_NUMBER_VARIATION)->value->int8, Tuple *ornament_base_color_t = dict_find(iter, KEY_ORNAMENT_BASE_COLOR);
.ornament_base_color = dict_find(iter, KEY_ORNAMENT_BASE_COLOR)->value->int32, Tuple *ornament_variation_t = dict_find(iter, KEY_ORNAMENT_VARIATION);
.ornament_variation = dict_find(iter, KEY_ORNAMENT_VARIATION)->value->int8, Tuple *invert_t = dict_find(iter, KEY_INVERT);
.invert = dict_find(iter, KEY_INVERT)->value->int8, Tuple *monochrome_t = dict_find(iter, KEY_MONOCHROME);
};
if (large_mode_t) {
curPrefs.large_mode = large_mode_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 (leading_zero_t) {
curPrefs.leading_zero = leading_zero_t->value->int8;
}
if (background_color_t) {
curPrefs.background_color = background_color_t->value->int32;
}
if (number_base_color_t) {
curPrefs.number_base_color = number_base_color_t->value->int32;
}
if (number_variation_t) {
curPrefs.number_variation = number_variation_t->value->int8;
}
if (ornament_base_color_t) {
curPrefs.ornament_base_color = ornament_base_color_t->value->int32;
}
if (ornament_variation_t) {
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;
}
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");
teardownUI(); teardownUI();
@ -555,6 +606,10 @@ static void in_dropped_handler(AppMessageResult reason, void *context) {
} }
static void init() { static void init() {
if (watch_info_get_model()==WATCH_INFO_MODEL_UNKNOWN) {
debug = true;
}
window = window_create(); window = window_create();
// Set up preferences // Set up preferences
@ -572,6 +627,7 @@ static void init() {
.ornament_base_color = 0b11100010, .ornament_base_color = 0b11100010,
.ornament_variation = true, .ornament_variation = true,
.invert = false, .invert = false,
.monochrome = false,
}; };
} }
@ -580,7 +636,7 @@ static void init() {
// Setup app message // Setup app message
app_message_register_inbox_received(in_received_handler); app_message_register_inbox_received(in_received_handler);
app_message_register_inbox_dropped(in_dropped_handler); app_message_register_inbox_dropped(in_dropped_handler);
app_message_open(100,0); app_message_open(150,0);
tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
} }