Avoid LCD Flicker When Updating Text on M5StickC?



  • I measure quantities and display them every tenth of a second or so. The screen flickers annoyingly.

    I have tried lcd.clear() and overwriting with the previous text with lcd.Black color in between writes but they both flicker the same way. printing '\r' on each line before writing text doesn't work either.

    Other suggestions?


  • M5Stack

    try use M5.Lcd.fillRect(x,y,w,h,color); to cover display the value. don't need clear whole screen



  • Hello @JackH

    Here is my attempt to reduce flicker for a simple counter. The code separates the digits and only updates the ones which are necessary. The flicker isn't completely gone, but at least only the digit which changes flickers a little bit.

    from m5stack import *
    from m5ui import *
    from uiflow import *
    import time
    
    setScreenColor(0x000000)
    
    count0 = None
    oldten0 = None
    one0 = None
    ten0 = None
    
    from numbers import Number
    import math
    
    count0 = 0
    oldten0 = 0
    for count in range(30):
      one0 = count0 % 10
      lcd.print(one0, 20, 5, 0x000000)
      count0 = (count0 if isinstance(count0, Number) else 0) + 1
      one0 = count0 % 10
      lcd.print(one0, 20, 5, 0xff0000)
      ten0 = math.floor(count0 / 10)
      if ten0 != oldten0:
        lcd.print(oldten0, 5, 5, 0x000000)
        lcd.print(ten0, 5, 5, 0xff0000)
        oldten0 = ten0
      wait_ms(300)
    

    BTW: In the Arduino environment a solution to reduce flicker is to use sprites, but I have no idea if sprites exist in M5Stack's MicroPython implementation.

    Cheers
    Felix



  • I am using the lcd.print function. I add one or two spaces to the displayed value and display in the same place. In firmware version 1.4.5 UiFlow, this function displays text with a black background (default), blurring previously displayed text completely. And there is no display flickering effect. Unfortunately, in version 1.5 the background of the text is transparent and the following text overlaps. I don't know how it is solved from version 1.6 and higher.

    or try below commands in execute block
    Print text on screen, x and y is beginning cursor , use current foreground color is not given
    lcd.print(text, x, y, [,color])
    Set the default foreground color
    lcd.set_fg(color)

    On 1.4.5 firmware looks like:
    https://youtu.be/EzupP4tXkZA



  • Thanks @felmue and @robalstona , I will try your suggestions tomorrow.
    Jack