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

    Problem with M5TextBox

    Scheduled Pinned Locked Moved M5 Stick/StickC
    8 Posts 3 Posters 15.6k Views 1 Watching
    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.
    • N Offline
      noiseislife
      last edited by noiseislife

      I'm having an odd problem displaying text. Certain coordinates do not display certain characters, etc.

      See the code below. The D does not display in label1. This came up initially when I was trying to position text to be correctly centered at 90 degree rotation.

      from m5stack import *
      from m5ui import *
      from uiflow import *

      @timerSch.event('timer1')
      def ttimer1():
      global curLetter

      if curLetter == "A":
      curLetter = "B"
      else:
      if curLetter == "B":
      curLetter = "C"
      else:
      if curLetter == "C":
      curLetter = "D"
      else:
      if curLetter == "D":
      curLetter = "A"
      label0.setText(curLetter)
      label1.setText(curLetter)
      pass

      setScreenColor(0x000000)
      curLetter = "A"
      label0 = M5TextBox(25, 20, curLetter, lcd.FONT_DejaVu72,0xFFFFFF, rotate=0)
      label1 = M5TextBox(29, 80, curLetter, lcd.FONT_DejaVu72,0xFFFFFF, rotate=0)
      timerSch.run('timer1', 500, 0x00)

      M5StickFreaklerM 1 Reply Last reply Reply Quote 0
      • m5stackM Online
        m5stack
        last edited by

        I tested it and when it runs, the two texts can go from A-> B-> C-> D, and it looks like there is no problem.

        1 Reply Last reply Reply Quote 0
        • N Offline
          noiseislife
          last edited by noiseislife

          Here's a video of my output.

          https://www.youtube.com/watch?v=nYwlS4ADqOg&feature=youtu.be

          I tried firmware versions 1.4.4, 1.4.5, and 1.4.5.1 thinking maybe that's related but they all behaved the same.

          I'm not really sure what else I can do to troubleshoot this since it seems unique to my device.

          1 Reply Last reply Reply Quote 0
          • M5StickFreaklerM Offline
            M5StickFreakler @noiseislife
            last edited by

            Hi @noiseislife

            The "problem" in your example is, that the letter D is to wide to display completely on the display.
            Unfortunately letters are suppressed if they have not enough space on screen.

            This Example works :-)

            from m5stack import *
            from m5ui import *
            from uiflow import *
            
            @timerSch.event('timer1')
            
            def ttimer1():
              
              global curLetter
            
              if curLetter == "A":
                curLetter = "B"
              else:
                if curLetter == "B":
                  curLetter = "C"
                else:
                  if curLetter == "C":
                    curLetter = "D"
                  else:
                    if curLetter == "D":
                      curLetter = "A"
                      
              label0.setText(curLetter)
              label1.setText(curLetter)
              pass
            
            setScreenColor(0x000000)
            curLetter = "A"
            label0 = M5TextBox(25, 20, curLetter, lcd.FONT_DejaVu72,0xFFFFFF, rotate=0)
            label1 = M5TextBox(25, 80, curLetter, lcd.FONT_DejaVu72,0xFFFFFF, rotate=0)
            
            timerSch.run('timer1', 500, 0x00)
            

            Best regards
            Thomas

            1 Reply Last reply Reply Quote 0
            • N Offline
              noiseislife
              last edited by

              What I was really trying to do was to center letters rotated 90 degrees, but even with that rotation the D disappears. You can change the angle in my code example to see this.

              m5stackM 1 Reply Last reply Reply Quote 0
              • m5stackM Online
                m5stack @noiseislife
                last edited by

                @noiseislife Because the rotation causes the coordinates to shift out of the screen, it cannot be total displayed. You only need to adjust the coordinates to display it completely.

                1 Reply Last reply Reply Quote 0
                • N Offline
                  noiseislife
                  last edited by noiseislife

                  I know what you're saying seems logical, but it is simply not the case.

                  from m5stack import *
                  from m5ui import *
                  from uiflow import *
                  
                  setScreenColor(0x111111)
                  label0 = M5TextBox(16, 38, "A", lcd.FONT_DejaVu72,0xFFFFFF, rotate=0)
                  angle = None
                  x = None
                  angle = 0
                  for count in range(90):
                    label0.setRotate(angle)
                    angle = (angle if isinstance(angle, int) else 0) + 1
                  x = 16
                  for count2 in range(25):
                    label0.setPosition(x=x)
                    x = (x if isinstance(x, int) else 0) + 1
                  

                  And the video:
                  https://youtu.be/qsKmaJEeI6A

                  M5StickFreaklerM 1 Reply Last reply Reply Quote 0
                  • M5StickFreaklerM Offline
                    M5StickFreakler @noiseislife
                    last edited by M5StickFreakler

                    @noiseislife

                    With a little "wait_ms()" its more clear what you mean :-)

                    from m5stack import *
                    from m5ui import *
                    from uiflow import *
                    
                    setScreenColor(0x111111)
                    label1 = M5TextBox(05, 05, "a", lcd.FONT_Default,0xFFFFFF, rotate=0)
                    label2 = M5TextBox(05, 20, "x", lcd.FONT_Default,0xFFFFFF, rotate=0)
                    label0 = M5TextBox(16, 50, "A", lcd.FONT_DejaVu72,0xFFFFFF, rotate=0)
                    
                    for angle in range(91):
                      label0.setRotate(angle)
                      label1.setText('angle:' + str(angle))
                      wait_ms(50)
                    
                    for posX in range(16, 256):
                      label0.setPosition(x=posX)
                      label2.setText('pos-x:' + str(posX))
                      wait_ms(100)
                    

                    I am sure it is ones more a bug :-)
                    You can check this, if you let the angle zero. You can see that the char disappears at pos-x = 33. And the same behavior occurs, if you have rotated the char. It is obviously one more of the uncountable bugs.

                    @M5Stack: Why does the M5Stack not draw a char if a small part is outside of the screen? We can display a char half way, if it is rotated, but not if it is at angle 0 degrees. That makes no sense. Maybe someone would like to program a scrolling text so that chars appears on the right and disappears on the left.

                    Best regards
                    Thomas

                    1 Reply Last reply Reply Quote 1

                    Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                    Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                    With your input, this post could be even better 💗

                    Register Login
                    • First post
                      Last post