Skip to content

Commit

Permalink
Always convert to str for draw_text
Browse files Browse the repository at this point in the history
After all ... it's draw *text*
  • Loading branch information
waveform80 committed Dec 22, 2018
1 parent 083fe6a commit 94cd664
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/examples/monitor_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def thermometer(offset, reading):
for i in range(64)
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text(str(int(round(reading.temperature))),
text = image_to_rgb(draw_text(int(round(reading.temperature)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 0, 3)))
screen[:text.shape[0], :text.shape[1]] += text
Expand All @@ -32,7 +32,7 @@ def hygrometer(offset, reading):
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text('^^' if reading.humidity > 99 else
str(int(round(reading.humidity))),
int(round(reading.humidity)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 0, 3)))
screen[:text.shape[0], :text.shape[1]] += text
Expand All @@ -48,7 +48,7 @@ def barometer(offset, reading):
for i in range(64)
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text(str(int(round(reading.pressure))),
text = image_to_rgb(draw_text(int(round(reading.pressure)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 8, 3)))
screen[:text.shape[0], :] += text[:, offset:offset + 8]
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/monitor_fancy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def thermometer(offset, reading):
for i in range(64)
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text(str(int(round(reading.temperature))),
text = image_to_rgb(draw_text(int(round(reading.temperature)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 0, 3)))
screen[:text.shape[0], :text.shape[1]] += text
Expand All @@ -32,7 +32,7 @@ def hygrometer(offset, reading):
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text('^^' if reading.humidity > 99 else
str(int(round(reading.humidity))),
int(round(reading.humidity)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 0, 3)))
screen[:text.shape[0], :text.shape[1]] += text
Expand All @@ -48,7 +48,7 @@ def barometer(offset, reading):
for i in range(64)
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text(str(int(round(reading.pressure))),
text = image_to_rgb(draw_text(int(round(reading.pressure)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 8, 3)))
screen[:text.shape[0], :] += text[:, offset:offset + 8]
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/monitor_final.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def thermometer(offset, reading):
for i in range(64)
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text(str(int(round(reading.temperature))),
text = image_to_rgb(draw_text(int(round(reading.temperature)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 0, 3)))
screen[:text.shape[0], :text.shape[1]] += text
Expand All @@ -34,7 +34,7 @@ def hygrometer(offset, reading):
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text('^^' if reading.humidity > 99 else
str(int(round(reading.humidity))),
int(round(reading.humidity)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 0, 3)))
screen[:text.shape[0], :text.shape[1]] += text
Expand All @@ -50,7 +50,7 @@ def barometer(offset, reading):
for i in range(64)
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text(str(int(round(reading.pressure))),
text = image_to_rgb(draw_text(int(round(reading.pressure)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 8, 3)))
screen[:text.shape[0], :] += text[:, offset:offset + 8]
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/monitor_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def thermometer(offset, reading):
for i in range(64)
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text(str(int(round(reading.temperature))),
text = image_to_rgb(draw_text(int(round(reading.temperature)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 0, 3)))
screen[:text.shape[0], :text.shape[1]] += text
Expand All @@ -32,7 +32,7 @@ def hygrometer(offset, reading):
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text('^^' if reading.humidity > 99 else
str(int(round(reading.humidity))),
int(round(reading.humidity)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 0, 3)))
screen[:text.shape[0], :text.shape[1]] += text
Expand All @@ -48,7 +48,7 @@ def barometer(offset, reading):
for i in range(64)
])
screen = np.flipud(screen)
text = image_to_rgb(draw_text(str(int(round(reading.pressure))),
text = image_to_rgb(draw_text(int(round(reading.pressure)),
'small.pil', foreground=Color('gray'),
padding=(0, 0, 8, 3)))
screen[:text.shape[0], :] += text[:, offset:offset + 8]
Expand Down
1 change: 1 addition & 0 deletions pisense/anim.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def draw_text(text, font='default.pil', size=8, foreground=Color('white'),
worrying about the vertical slicing.
"""
# pylint: disable=too-many-arguments,too-many-locals
text = str(text)
if not isinstance(foreground, Color):
foreground = Color(*foreground)
if not isinstance(background, Color):
Expand Down

0 comments on commit 94cd664

Please sign in to comment.