From a54708a53395dd5f5d4b7b7e24366fc5995445f6 Mon Sep 17 00:00:00 2001 From: David Goodenough Date: Sat, 7 Oct 2023 18:24:55 -0700 Subject: [PATCH] Adding logic to make the current secondary zone the main watch zone, and adding timezone data for the Azores --- apps/travelwatch/app.js | 24 +++++++++++++++++------- apps/travelwatch/custom.html | 1 + apps/travelwatch/metadata.json | 2 +- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/apps/travelwatch/app.js b/apps/travelwatch/app.js index b320b51366..d552624f8d 100644 --- a/apps/travelwatch/app.js +++ b/apps/travelwatch/app.js @@ -1,5 +1,6 @@ var lastDow; var drawTimeout; +var watchIndex; var zoneIndex; Graphics.prototype.setFontOxaniumTime = function() { @@ -208,7 +209,7 @@ function ComputeOffsetAndChange(first, last) function draw() { - var date = GetDate(0); + var date = GetDate(watchIndex); var y = 66; @@ -286,22 +287,31 @@ function draw() function onTouch(button, xy) { - if (zones.length == 2) + if (xy.type == 2) { - // If we only have one extra timezone, there's nothing to do. Save the cost of - // a wasted draw call. - return; + // Long touch: make the current selected travel zone the main watch zone. + watchIndex = zoneIndex; + // Don't need to do anything else, the remaining logic will sort out the travel zone } - if (++zoneIndex >= zones.length) + else if (zones.length == 2) { - zoneIndex = 1; + // Short touch and we only have two zones. Nothing to do, so return immediately + return; } + do + { + if (++zoneIndex >= zones.length) + { + zoneIndex = 1; + } + } while (zoneIndex == watchIndex); clearTimeout(drawTimeout); draw(); } // Clear the screen once, at startup g.clear().setColor(0, 0, 0).fillRect(0, 0, 176, 176); +watchIndex = 0; zoneIndex = 1; Bangle.loadWidgets(); diff --git a/apps/travelwatch/custom.html b/apps/travelwatch/custom.html index 731e8fa789..7811a725ee 100644 --- a/apps/travelwatch/custom.html +++ b/apps/travelwatch/custom.html @@ -32,6 +32,7 @@ { "name": "America/Chicago", "offset": -360, "dst_month": 3, "dst_date": 8, "dst_dow": 0, "dst_hour": 2, "std_month": 11, "std_date": 1, "std_dow": 0, "std_hour": 2 }, { "name": "America/New_York", "offset": -300, "dst_month": 3, "dst_date": 8, "dst_dow": 0, "dst_hour": 2, "std_month": 11, "std_date": 1, "std_dow": 0, "std_hour": 2 }, { "name": "America/Sao_Paulo", "offset": -180, "dst_month": 0, "dst_date": 0, "dst_dow": 0, "dst_hour": 0, "std_month": 0, "std_date": 0, "std_dow": 0, "std_hour": 0 }, + { "name": "Atlantic/Azores", "offset": -60, "dst_month": 3, "dst_date": -7, "dst_dow": 0, "dst_hour": 0, "std_month": 10, "std_date": -7, "std_dow": 0, "std_hour": 1 }, { "name": "Europe/London", "offset": 0, "dst_month": 3, "dst_date": -7, "dst_dow": 0, "dst_hour": 1, "std_month": 10, "std_date": -7, "std_dow": 0, "std_hour": 2 }, { "name": "Europe/Lisbon", "offset": 0, "dst_month": 3, "dst_date": -7, "dst_dow": 0, "dst_hour": 1, "std_month": 10, "std_date": -7, "std_dow": 0, "std_hour": 2 }, { "name": "Europe/Berlin", "offset": 60, "dst_month": 3, "dst_date": -7, "dst_dow": 0, "dst_hour": 2, "std_month": 10, "std_date": -7, "std_dow": 0, "std_hour": 3 }, diff --git a/apps/travelwatch/metadata.json b/apps/travelwatch/metadata.json index 0969628fa6..f2c44de303 100644 --- a/apps/travelwatch/metadata.json +++ b/apps/travelwatch/metadata.json @@ -1,7 +1,7 @@ { "id": "travelwatch", "name": "Travel Watch", "icon": "app.png", - "version":"1.15", + "version":"1.16", "description": "Watch face that shows world wide time for travelers", "tags": "clock", "type": "clock",