diff options
author | Alexey 'Cluster' Avdyukhin <ClusterM@users.noreply.github.com> | 2015-10-13 11:34:04 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <ClusterM@users.noreply.github.com> | 2015-10-13 11:34:04 +0300 |
commit | 0a6144f10edcda677403b905c86adf1b7b6b86c9 (patch) | |
tree | 057915ba78ded46d17affad6931080037081f1c4 /src | |
parent | 64e2f4062e8c75bef08ad48e89911d2ec5f14f4f (diff) |
Hourly vibration, bugfixes
Diffstat (limited to 'src')
-rw-r--r-- | src/js/pebble-js-app.js | 6 | ||||
-rw-r--r-- | src/pebble-mario.c | 27 |
2 files changed, 29 insertions, 4 deletions
diff --git a/src/js/pebble-js-app.js b/src/js/pebble-js-app.js index 029fe08..827bf6b 100644 --- a/src/js/pebble-js-app.js +++ b/src/js/pebble-js-app.js @@ -6,6 +6,7 @@ var options = { "config_show_battery": true, "config_show_phone_battery": false, "config_vibe": false, + "config_vibe_hour": false, "config_background": 0, }; @@ -82,8 +83,9 @@ Pebble.addEventListener("showConfiguration", function() { var watch = null; } var platform = "&platform=" + ((watch != null) ? watch.platform : "unknown"); - console.log("showing configuration"); - Pebble.openURL("http://clusterrr.com/pebble_configs/mario_w.php" + cfg + platform); + var config_version = "&v=2"; + console.log("Showing configuration"); + Pebble.openURL("http://clusterrr.com/pebble_configs/mario_w.php" + cfg + platform + config_version); }); Pebble.addEventListener("webviewclosed", function(e) { diff --git a/src/pebble-mario.c b/src/pebble-mario.c index e6e4691..665469c 100644 --- a/src/pebble-mario.c +++ b/src/pebble-mario.c @@ -84,6 +84,7 @@ static bool config_show_weather = true; static bool config_vibe = false; static int config_background = 0; static int phone_battery_level = -1; +static bool config_vibe_hour = false; static time_t weather_last_update = 0; static int weather_icon_id = -1; @@ -124,6 +125,7 @@ static char digits[10][15] = {{1,1,1,1,0,1,1,0,1,1,0,1,1,1,1},{0,0,1,0,0,1,0,0,1 #define MSG_WEATHER_TEMPERATURE 11 #define MSG_WEATHER_REQUEST 12 #define ID_LEFT_INFO_MODE 13 +#define MSG_VIBE_HOUR 14 void handle_tick(struct tm *tick_time, TimeUnits units_changed); @@ -616,6 +618,14 @@ void in_received_handler(DictionaryIterator *received, void *context) { config_vibe = tuple->value->int8; persist_write_bool(MSG_VIBE, config_vibe); } + tuple = dict_find(received, MSG_VIBE_HOUR); + if (tuple) { + if (tuple->type == TUPLE_CSTRING) + config_vibe_hour = (strcmp(tuple->value->cstring, "true") == 0); + else + config_vibe_hour = tuple->value->int8; + persist_write_bool(MSG_VIBE_HOUR, config_vibe_hour); + } tuple = dict_find(received, MSG_BACKGROUND); if (tuple) { config_background = tuple->value->int8; @@ -658,6 +668,8 @@ void handle_init() config_show_weather = persist_read_bool(MSG_SHOW_WEATHER); if (persist_exists(MSG_VIBE)) config_vibe = persist_read_bool(MSG_VIBE); + if (persist_exists(MSG_VIBE_HOUR)) + config_vibe_hour = persist_read_bool(MSG_VIBE_HOUR); if (persist_exists(MSG_BACKGROUND)) config_background = persist_read_int(MSG_BACKGROUND); if (persist_exists(ID_WEATHER_LAST_UPDATE)) @@ -928,7 +940,7 @@ void handle_tick(struct tm *tick_time, TimeUnits units_changed) animation_schedule((Animation *)block_animation_beg); int weather_age = time(NULL)-weather_last_update; - if (units_changed | MINUTE_UNIT) + if (units_changed & MINUTE_UNIT) { if ((tick_time->tm_min % 30 == 0) || ((tick_time->tm_min % 5 == 0) && (weather_age > WEATHER_UPDATE_INTERVAL))) request_all(); @@ -942,8 +954,19 @@ void handle_tick(struct tm *tick_time, TimeUnits units_changed) layer_mark_dirty(phone_battery_layer); } - if (units_changed | HOUR_UNIT) + if (units_changed & HOUR_UNIT) + { need_update_background = 1; + if (config_vibe_hour) + { + static const uint32_t const segments[] = { 50, 100, 50, 100, 50, 100, 50, 100, 50 }; + VibePattern pat = { + .durations = segments, + .num_segments = ARRAY_LENGTH(segments), + }; + vibes_enqueue_custom_pattern(pat); + } + } } int main(void) |