🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    M5Paper V1.1 - Simple loop stops counting

    UIFlow
    1
    1
    8
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RIDDSprojectsR
      RIDDSprojects
      last edited by

      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

      uiflow_block_1768590699927.png

      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()
      

      ATOM LITE | ATOM MATRIX | CORE | CORE2 | STAMP-PICO | CORE.INK | PAPER V1.1
      RESEARCH | INNOVATION | DEVELOPMENT | DESIGN | SUSTAINABILITY
      and electronics

      Nederland

      1 Reply Last reply Reply Quote 0
      • First post
        Last post