Skip to content

Commit

Permalink
Updated test loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
markusk committed Sep 5, 2017
1 parent 014fb1b commit 2b323a1
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions test/lcd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@
# ------------
# test voltage
# ------------
measuredVoltage = 11.25


# percent calculation
convertedVoltage = measuredVoltage - minVoltage
percent = convertedVoltage / (maxVoltage-minVoltage) * 100
if percent < 0:
percent = 0
measuredVoltage = minVoltage


# the battery symbols
Expand All @@ -60,11 +53,28 @@

# battery level (white rectangle in empty battery symbol
maxRectLength = 16
rectLength = round(percent * maxRectLength / 100, 0)


# endless loop
while (1):
# --------------
# TEST TEST TEST
#
measuredVoltage = measuredVoltage + 0.1
if measuredVoltage > maxVoltage:
measuredVoltage = minVoltage
#
# --------------


# percent calculation
convertedVoltage = measuredVoltage - minVoltage
percent = convertedVoltage / (maxVoltage-minVoltage) * 100
if percent < 0:
percent = 0
# rectangle in battery symbol
rectLength = round(percent * maxRectLength / 100, 0)

# Draw a black filled box to clear the image.
draw.rectangle((0,0,width,height), outline=0, fill=0)

Expand Down Expand Up @@ -92,9 +102,3 @@

# wait a bit
time.sleep(0.5)

# next time in this loop
# if rectLength < maxRectLength:
# rectLength = rectLength + 1
# else:
# rectLength = 0

0 comments on commit 2b323a1

Please sign in to comment.