Skip to content

Commit a586287

Browse files
committed
Loading glyphs beforehand, better truncation
1 parent 6ae14da commit a586287

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

CircuitPython_Pyloton/pyloton.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ def show_splash(self):
162162
"""
163163
if self.debug:
164164
return
165+
glyphs = b'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-!,. "\'?!'
166+
self.arial16.load_glyphs(glyphs)
167+
self.arial12.load_glyphs(glyphs)
165168
with open('blinka-pyloton.bmp', 'rb') as bitmap_file:
166169
bitmap1 = displayio.OnDiskBitmap(bitmap_file)
167170

@@ -383,11 +386,9 @@ def read_s_and_c(self):
383386
cadence = self._compute_cadence(values, cadence)
384387

385388
if speed:
386-
if len(str(speed)) > 8:
387-
speed = str(speed)[:8]
389+
speed = str(speed)[:8]
388390
if cadence:
389-
if len(str(cadence)) > 8:
390-
cadence = str(cadence)[:8]
391+
cadence = str(cadence)[:8]
391392
return speed, cadence
392393

393394

@@ -402,8 +403,7 @@ def read_heart(self):
402403
heart = measurement.heart_rate
403404
self._previous_heart = measurement.heart_rate
404405
if heart:
405-
if len(str(heart)) > 4:
406-
heart = str(heart)[:4]
406+
heart = str(heart)[:4]
407407
return heart
408408

409409

@@ -425,8 +425,7 @@ def read_ams(self):
425425
data = None
426426

427427
if data:
428-
if len(data) > 20:
429-
data = data[:20]
428+
data = data[:16] + (data[16:] and '..')
430429
return data
431430

432431

0 commit comments

Comments
 (0)