From 2b323a1f0d3b782faa39c85771031d29d3e95311 Mon Sep 17 00:00:00 2001 From: Markus Knapp Date: Tue, 5 Sep 2017 23:45:45 +0200 Subject: [PATCH] Updated test loop. --- test/lcd_test.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/test/lcd_test.py b/test/lcd_test.py index ca63855..a1dbec5 100755 --- a/test/lcd_test.py +++ b/test/lcd_test.py @@ -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 @@ -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) @@ -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