🤖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
    3
    3
    62
    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

      V robskiR 2 Replies Last reply Reply Quote 0
      • V
        veryalien @RIDDSprojects
        last edited by

        @RIDDSprojects I think you need to change your second loop to loop to a value of 960 - (125 + 54)) not 30. I think, without trying it myself, the second loop ends too soon because you are starting at offset 54, not at 30.

        1 Reply Last reply Reply Quote 1
        • robskiR
          robski @RIDDSprojects
          last edited by

          @RIDDSprojects your Ynext end2 (805) must be diff to Ynext end (805) ... add 24?

          M5StickC, M5StickCPlus, M5StickCplus2,M5GO, M5Core, M5Tough, M5Core2, M5 Demo Board, M5Dial, M5Paper, M5Atom, M5Cardputer, M5StampS3, CoreMP135, StamPLC, AirQ, M5Tab, M5CardputerAdv

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