Skip to content

Commit 83e754f

Browse files
committed
style: sync updated watch.py
1 parent 6dc9594 commit 83e754f

1 file changed

Lines changed: 22 additions & 17 deletions

File tree

assets/apps/watch.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -165,35 +165,40 @@ def _build_watch(self):
165165
_plain(self.face)
166166

167167
# 5. Roman Hour Numerals (XII, III, VI, IX) - Created on dial face
168-
numerals = {0: "XII", 3: "III", 6: "VI", 9: "IX"}
169-
num_radius = int(r * 0.76)
170168
num_font_size = int(dial_size * 0.065)
171-
for hour, label_text in numerals.items():
169+
num_inset = int(dial_size * 0.09)
170+
171+
cardinals = {
172+
"XII": (lv.ALIGN.TOP_MID, 0, num_inset),
173+
"III": (lv.ALIGN.RIGHT_MID, -num_inset, 0),
174+
"VI": (lv.ALIGN.BOTTOM_MID, 0, -num_inset),
175+
"IX": (lv.ALIGN.LEFT_MID, num_inset, 0),
176+
}
177+
for label_text, (align_type, ax, ay) in cardinals.items():
172178
lbl = lv.label(self.face)
173179
lbl.set_text(label_text)
174180
lbl.set_style_text_color(_color(0xE2E8F0), 0)
181+
lbl.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
175182
_set_scaled_font(lbl, num_font_size)
176-
angle = math.radians(hour * 30 - 90)
177-
nx = int(math.cos(angle) * num_radius)
178-
ny = int(math.sin(angle) * num_radius)
179-
lbl.align(lv.ALIGN.CENTER, nx, ny)
183+
lbl.align(align_type, ax, ay)
180184

181-
# 6. Brand Label (Top Half) - Calculated anchor point
182-
brand_y = -int(r * 0.38)
185+
# 6. Brand Label (Upper Dial Quadrant)
186+
brand_top_offset = int(dial_size * 0.25)
183187
self.brand_lbl = lv.label(self.face)
184188
self.brand_lbl.set_text("PYDEVICES")
185189
self.brand_lbl.set_style_text_color(_color(0xF54E00), 0)
190+
self.brand_lbl.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
186191
_set_scaled_font(self.brand_lbl, int(dial_size * 0.05))
187-
self.brand_lbl.align(lv.ALIGN.CENTER, 0, brand_y)
192+
self.brand_lbl.align(lv.ALIGN.TOP_MID, 0, brand_top_offset)
188193

189-
# 7. Digital Readout Sub-Dial (Lower Half) - Created on dial face behind hands
194+
# 7. Digital Readout Sub-Dial (Lower Dial Quadrant) - Created on dial face behind hands
190195
pill_w = int(dial_size * 0.46)
191196
pill_h = int(dial_size * 0.16)
192-
pill_y = int(r * 0.42)
197+
pill_bottom_offset = int(dial_size * 0.20)
193198

194199
self.pill = lv.obj(self.face)
195200
self.pill.set_size(pill_w, pill_h)
196-
self.pill.align(lv.ALIGN.CENTER, 0, pill_y)
201+
self.pill.align(lv.ALIGN.BOTTOM_MID, 0, -pill_bottom_offset)
197202
self.pill.set_style_radius(max(4, int(pill_h * 0.18)), 0)
198203
self.pill.set_style_bg_color(_color(0x080B0E), 0)
199204
self.pill.set_style_bg_opa(lv.OPA._90, 0)
@@ -205,19 +210,19 @@ def _build_watch(self):
205210
except AttributeError:
206211
pass
207212

208-
time_y = -int(pill_h * 0.18)
209213
self.digital_time = lv.label(self.pill)
210214
self.digital_time.set_text("00:00:00")
211215
self.digital_time.set_style_text_color(_color(0xF8FAFC), 0)
216+
self.digital_time.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
212217
_set_scaled_font(self.digital_time, int(pill_h * 0.38))
213-
self.digital_time.align(lv.ALIGN.CENTER, 0, time_y)
218+
self.digital_time.align(lv.ALIGN.TOP_MID, 0, int(pill_h * 0.10))
214219

215-
date_y = int(pill_h * 0.24)
216220
self.digital_date = lv.label(self.pill)
217221
self.digital_date.set_text("FRI OCT 24")
218222
self.digital_date.set_style_text_color(_color(0x94A3B8), 0)
223+
self.digital_date.set_style_text_align(lv.TEXT_ALIGN.CENTER, 0)
219224
_set_scaled_font(self.digital_date, int(pill_h * 0.28))
220-
self.digital_date.align(lv.ALIGN.CENTER, 0, date_y)
225+
self.digital_date.align(lv.ALIGN.BOTTOM_MID, 0, -int(pill_h * 0.12))
221226

222227
# 8. Scale for Ticks & Analog Needles - Created AFTER dial & digital sub-dial
223228
# This guarantees that the tick ring and all rotating hands draw in FRONT of the digital display!

0 commit comments

Comments
 (0)