Problem with M5TextBox
-
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 curLetterif 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)
passsetScreenColor(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) -
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.
-
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.
-
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 -
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.
-
@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.
-
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 -
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