1
1
Fork 0

added list of debug watches and handling mechanism

squarelines
Alina Marquardt 2016-01-17 06:56:05 +01:00
parent 163f5ce393
commit aeebe1ef80
3 changed files with 56 additions and 16 deletions

View File

@ -5,6 +5,7 @@
"btvibe": 12, "btvibe": 12,
"center": 11, "center": 11,
"contrast": 13, "contrast": 13,
"debugwatch": 50,
"eu_date": 1, "eu_date": 1,
"invert": 9, "invert": 9,
"large_mode": 0, "large_mode": 0,

View File

@ -1,5 +1,28 @@
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);
Pebble.addEventListener('ready', function() { Pebble.addEventListener('ready', function() {
console.log('PebbleKit JS ready!'); console.log('PebbleKit JS ready!');
var 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() { Pebble.addEventListener('showConfiguration', function() {

View File

@ -54,6 +54,8 @@ enum {
KEY_BACKLIGHT, KEY_BACKLIGHT,
}; };
#define KEY_DEBUGWATCH 50
#define PREFERENCES_KEY 0 #define PREFERENCES_KEY 0
#define US_DATE (!curPrefs.eu_date) // true == MM/DD, false == DD/MM #define US_DATE (!curPrefs.eu_date) // true == MM/DD, false == DD/MM
@ -189,7 +191,6 @@ 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 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[] = { unsigned char variation[] = {
0b00000000, 0b00010000, 0b00000100, 0b00010000, 0b00000000, 0b00000000, 0b00010000, 0b00000100, 0b00010000, 0b00000000,
0b00010001, 0b00010000, 0b00000000, 0b00000101, 0b00010000, 0b00010001, 0b00010000, 0b00000000, 0b00000101, 0b00010000,
@ -465,21 +466,26 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
da = t->tm_mday; da = t->tm_mday;
mo = t->tm_mon+1; mo = t->tm_mon+1;
if (debug) { if (debug) {
ho = 9; //ho = 9;
} }
if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "It is now %d:%d %d.%d.", (int)ho, (int)mi, (int)da, (int)mo); APP_LOG(APP_LOG_LEVEL_INFO, "It is now %d:%d %d.%d.", (int)ho, (int)mi, (int)da, (int)mo);
}
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) {
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) { } else if (DISABLE_ANIM_START_TIME > DISABLE_ANIM_END_TIME) {
// across midnight // across midnight
if (ho >= DISABLE_ANIM_START_TIME || ho < DISABLE_ANIM_END_TIME) { if (ho >= DISABLE_ANIM_START_TIME || ho < DISABLE_ANIM_END_TIME) {
allow_animate = false; allow_animate = false;
if (debug) { if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Hour %d was after %d and before %d", (int)ho, (int)DISABLE_ANIM_START_TIME , (int)DISABLE_ANIM_END_TIME ); 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 { } else {
@ -487,7 +493,7 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
if (ho >= DISABLE_ANIM_START_TIME && ho < DISABLE_ANIM_END_TIME) { if (ho >= DISABLE_ANIM_START_TIME && ho < DISABLE_ANIM_END_TIME) {
allow_animate = false; allow_animate = false;
if (debug) { if (debug) {
APP_LOG(APP_LOG_LEVEL_INFO, "Hour %d was after %d and before %d", (int)ho, (int)DISABLE_ANIM_START_TIME , (int)DISABLE_ANIM_END_TIME ); 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 );
} }
} }
} }
@ -555,8 +561,10 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
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); 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;
if (slot[4].prevDigit == 10) { if (slot[4].prevDigit == 10) {
@ -706,6 +714,19 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
Tuple *ns_start_t = dict_find(iter, KEY_NS_START); Tuple *ns_start_t = dict_find(iter, KEY_NS_START);
Tuple *ns_stop_t = dict_find(iter, KEY_NS_STOP); Tuple *ns_stop_t = dict_find(iter, KEY_NS_STOP);
Tuple *backlight_t = dict_find(iter, KEY_BACKLIGHT); Tuple *backlight_t = dict_find(iter, KEY_BACKLIGHT);
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) { if (large_mode_t) {
curPrefs.large_mode = large_mode_t->value->int8; curPrefs.large_mode = large_mode_t->value->int8;
@ -794,17 +815,16 @@ static void in_received_handler(DictionaryIterator *iter, void *context) {
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 a message because %i", (int)reason);
} }
static void init() {
if (watch_info_get_model()==WATCH_INFO_MODEL_UNKNOWN) {
debug = true;
}
static void init() {
window = window_create(); window = window_create();
// Set up preferences // Set up preferences
@ -858,10 +878,6 @@ static void init() {
tick_timer_service_subscribe(MINUTE_UNIT, handle_tick); tick_timer_service_subscribe(MINUTE_UNIT, handle_tick);
if (debug) {
//light_enable(true);
}
handle_bluetooth(connection_service_peek_pebble_app_connection()); handle_bluetooth(connection_service_peek_pebble_app_connection());
battery_state_service_subscribe(battery_handler); battery_state_service_subscribe(battery_handler);