UIFlow wifi connect forces screen background to be white



  • When I use a wifi_connect block at the beginning of my code, and then a set screen background color right afterwards, the wifi connect block somehow overrides it and forces the screen to be white. It's super annoying.

    Does anyone know how to fix this?



  • This is the code. It works fine in development mode but as soon as I download to the device and try to run it the background is forced to white color

    0_1659321685322_121a0ff3-0fb3-4c32-aadf-09b249114790-image.png



  • Another odd thing I've noticed is that the first one or two lines of Lcd.print don't show up at all. What exactly is that wifi connect doing besides, well, connecting to wifi?

    I've annotated what is not printing to the screen:

    0_1659364291530_d071c4ab-90c7-44cf-8c2d-d5b782b8ebfd-image.png



  • Little more context for anyone reading this thread:

    • In UIFlow mode the screen does turn black, but none of the first Lcd.print statements work at all. I've tried adding delays, moving things around, nothing seems to fix it. As long as that wifi connect is up there at the top the first several Lcd.print lines don't work.

    • If I download the code onto the m5stack core2, then those lines do print but I'm stuck with a white background. The Set Screen backgroundColor command never works when I run the app standalone.

    Here is how the raw Python code looks for the sketch screenshot I posted:

    from m5stack import *
    from m5stack_ui import *
    from uiflow import *
    import wifiCfg
    import time
    import ntptime
    import urequests
    from easyIO import *
    import unit
    
    screen = M5Screen()
    screen.clean_screen()  # Why is this here?  I didn't put any clean_screen() block in my code...
    screen.set_screen_bg_color(0x000000)
    neopixel_0 = unit.get(unit.NEOPIXEL, (25,22), 10)
    
    try :
      wifiCfg.autoConnect(lcdShow=False)
      pass
    except:
      lcd.print('Unable to connect to wifi: CAROLAN', 0, 0, 0xcc0000)
      neopixel_0.setColorFrom(1, 10, 0xcc0000)
    wait(5)
    screen.set_screen_bg_color(0x000000)
    lcd.print('test test test', 0, 90, 0x33cc00)
    lcd.print('Welcome to M5Stack Core 2 AWS', 0, 15, 0x33cc00)
    lcd.print('Setting the time from us.pool.ntp.org...', 0, 30, 0x33cc00)
    try :
      ntp = ntptime.client(host='us.pool.ntp.org', timezone=(-5))
      lcd.print(((str('Current time:') + str((ntp.formatDatetime('-', ':'))))), 0, 45, 0x33cc00)
      pass
    except:
      lcd.print('Error setting time. Check your wifi settings.', 0, 45, 0xff0000)
    try :
      try:
        req = urequests.request(method='GET', url='https://www.google.com')
        lcd.print('Connect to www.google.com: SUCCESS', 0, 60, 0x33cc00)
        neopixel_0.setColorFrom(1, 10, 0x33cc00)
      except:
        lcd.print('Connect to www.google.com: FAILURE', 0, 60, 0xff0000)
      pass
    except:
      lcd.print('Internet connection test failed.', 0, 60, 0xff0000)
    lcd.print(((str(((str('Battery level: ') + str((map_value((power.getBatVoltage()), 3.7, 4.1, 0, 100)))))) + str('%'))), 0, 75, 0x33cc00)
    power.setPowerLED(False)
    


  • After some more troubleshooting I discovered that a 10ms wait after changing the screen color allows the first few lines to print when working in UIFlow. It appears that 'Set Screen backgroundColor' requires this delay before you can render text with Lcd.print.

    This doesn't solve the mystery of the white screen when running in app mode though. Maybe someone else knows what's going on here.