Skip to content

Commit 2fad6f2

Browse files
authored
Merge pull request #47 from tekktrik/dev/divide-by-zero
Guard against ZeroDivisionError
2 parents 1648158 + 825930b commit 2fad6f2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

adafruit_display_shapes/sparkline.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ def update(self):
146146
else:
147147
self.y_top = self.y_max
148148

149+
# Guard for y_top and y_bottom being the same
150+
if self.y_top == self.y_bottom:
151+
self.y_bottom -= 10
152+
self.y_top += 10
153+
149154
if len(self._spark_list) > 2:
150155
xpitch = (self.width - 1) / (
151156
len(self._spark_list) - 1

0 commit comments

Comments
 (0)