M5Paper V1.1 - Simple loop stops counting
-
I created a simple loop to draw several squares (touch buttons) with text. However, the last square (the second loop) isn't filled with text, and the loop only loops 5 times.
What am I missing?Note:
UIFlow 1.0
I am using the screen horizontally.
960 pixels total (Y)
6 buttons, 125 pixels
30 pixels spacing
from m5stack import * from m5ui import * from uiflow import * setScreenColor(15) Ynext = None Counter = None from numbers import Number def upRange(start, stop, step): while start <= stop: yield start start += abs(step) def downRange(start, stop, step): while start >= stop: yield start start -= abs(step) Ynext = 0 Counter = 0 Ynext_end = float(960 - (125 + 30)) Ynext_inc = float(125 + 30) for Ynext in (30 <= Ynext_end) and upRange(30, Ynext_end, Ynext_inc) or downRange(30, Ynext_end, Ynext_inc): lcd.rect(380, int(Ynext), 125, 125, color=0) Ynext_end2 = float(960 - (125 + 30)) Ynext_inc2 = float(125 + 30) for Ynext in (54 <= Ynext_end2) and upRange(54, Ynext_end2, Ynext_inc2) or downRange(54, Ynext_end2, Ynext_inc2): Counter = (Counter if isinstance(Counter, Number) else 0) + 1 lcd.font(lcd.FONT_DejaVu40) lcd.print(((str('AC') + str(Counter))), 470, int(Ynext), 0, rotate=90) lcd.show()