Using MQTT deletes UI elements on M5StickC Plus



  • I am using UI Flow V 1.7.5 in the browser.
    I am using an M5StickC Plus with the newest UI Firmware V1.7.5-plus

    When I use the M5mqtt - Library all my UI elements like labels disappear.
    When I switch from blockly to python code and move the UI-elements AFTER the mqtt block, this does not happen. That change gets lost every time I change back to blockly.

    I run very similar code on the M5Stack Fire and the problem does not appear there.

    Example 1: This is the generated code and it makes the three labels disappear

    from m5stack import *
    from m5ui import *
    from uiflow import *
    import wifiCfg
    from m5mqtt import M5mqtt

    setScreenColor(0x111111)

    wifiCfg.autoConnect(lcdShow=False)
    button_a = M5TextBox(45, 213, "Mqtt D", lcd.FONT_Default, 0xFFFFFF, rotate=0)
    mqtt_msg = M5TextBox(33, 84, "...", lcd.FONT_DejaVu72, 0xFFFFFF, rotate=0)
    button_b = M5TextBox(86, 35, "Mqtt E", lcd.FONT_Default, 0xFFFFFF, rotate=0)

    def fun_mirror_cmd_(topic_data):
    mqtt_msg.setText(str(topic_data))
    pass

    def buttonA_wasPressed():
    m5mqtt.publish(str('mirror/cmd'),str('D'))
    pass
    btnA.wasPressed(buttonA_wasPressed)

    def buttonB_wasPressed():
    m5mqtt.publish(str('mirror/cmd'),str('E'))
    pass
    btnB.wasPressed(buttonB_wasPressed)

    m5mqtt = M5mqtt('m5StickC', '192.168.1.106', 1883, '', '', 300)
    m5mqtt.subscribe(str('mirror/cmd'), fun_mirror_cmd_)
    m5mqtt.start()

    Example 2: This is the slightly altered code (the UI-Elements have been moved to the end) and the labels stay

    from m5stack import *
    from m5ui import *
    from uiflow import *
    import wifiCfg
    from m5mqtt import M5mqtt

    setScreenColor(0x111111)

    wifiCfg.autoConnect(lcdShow=False)

    def fun_mirror_cmd_(topic_data):
    mqtt_msg.setText(str(topic_data))
    pass

    def buttonA_wasPressed():
    m5mqtt.publish(str('mirror/cmd'),str('D'))
    pass
    btnA.wasPressed(buttonA_wasPressed)

    def buttonB_wasPressed():
    m5mqtt.publish(str('mirror/cmd'),str('E'))
    pass
    btnB.wasPressed(buttonB_wasPressed)

    m5mqtt = M5mqtt('m5StickC', '192.168.1.106', 1883, '', '', 300)
    m5mqtt.subscribe(str('mirror/cmd'), fun_mirror_cmd_)
    m5mqtt.start()

    button_a = M5TextBox(45, 213, "Mqtt D", lcd.FONT_Default, 0xFFFFFF, rotate=0)
    mqtt_msg = M5TextBox(33, 84, "...", lcd.FONT_DejaVu72, 0xFFFFFF, rotate=0)
    button_b = M5TextBox(86, 35, "Mqtt E", lcd.FONT_Default, 0xFFFFFF, rotate=0)