summaryrefslogtreecommitdiff
path: root/wasp/apps/settings.py
diff options
context:
space:
mode:
authorTait Berlette <54515877+taitberlette@users.noreply.github.com>2021-08-18 17:13:49 (GMT)
committerDaniel Thompson <daniel.thompson@linaro.org>2021-08-23 19:09:02 (GMT)
commitdc40430faaa5d9911e2dd46c414d790e28560cf8 (patch)
treeb0a18764d0835157111f123ec8f4b2e6007b421b /wasp/apps/settings.py
parenta28a2cd7f462a217ab5598853835e806c83967f7 (diff)
apps: Fixed weather app with GadgetBridge.
When I created the weather app I didn't have GadgetBridge installed, so I tried to follow the protocol on the [espurino website](https://www.espruino.com/Gadgetbridge), but it wasn't very helpful and I made some mistakes. This commit should fix these mistakes to stop the weather app from crashing, and so it displays the correct values. I have also added a new settings option called "Units", where apps can see what units the user would prefer (metric/imperial). Signed-off-by: Tait Berlette <54515877+taitberlette@users.noreply.github.com>
Diffstat (limited to 'wasp/apps/settings.py')
-rw-r--r--wasp/apps/settings.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/wasp/apps/settings.py b/wasp/apps/settings.py
index 6c5b664..7afd7ef 100644
--- a/wasp/apps/settings.py
+++ b/wasp/apps/settings.py
@@ -37,7 +37,9 @@ class SettingsApp():
self._dd = wasp.widgets.Spinner(20, 60, 1, 31, 1)
self._mm = wasp.widgets.Spinner(90, 60, 1, 12, 1)
self._yy = wasp.widgets.Spinner(160, 60, 20, 60, 2)
- self._settings = ['Brightness', 'Notification Level', 'Time', 'Date']
+ self._units = ['Metric', 'Imperial']
+ self._units_toggle = wasp.widgets.Button(32, 90, 176, 48, "Change")
+ self._settings = ['Brightness', 'Notification Level', 'Time', 'Date', 'Units']
self._sett_index = 0
self._current_setting = self._settings[0]
@@ -68,6 +70,9 @@ class SettingsApp():
now[1] = self._mm.value
now[2] = self._dd.value
wasp.watch.rtc.set_localtime(now)
+ elif self._current_setting == 'Units':
+ if self._units_toggle.touch(event):
+ wasp.system.units = self._units[(self._units.index(wasp.system.units) + 1) % len(self._units)]
self._update()
def swipe(self, event):
@@ -115,6 +120,8 @@ class SettingsApp():
self._dd.draw()
draw.set_font(fonts.sans24)
draw.string('DD MM YY',0,180, width=240)
+ elif self._current_setting == 'Units':
+ self._units_toggle.draw()
self._scroll_indicator.draw()
self._update()
mute(False)
@@ -140,3 +147,5 @@ class SettingsApp():
say = "Silent"
self._nfy_slider.update()
draw.string(say, 0, 150, width=240)
+ elif self._current_setting == 'Units':
+ draw.string(wasp.system.units, 0, 150, width=240)