old text line visible under new one

  • Hi!

    Please excuse the title, which probably does not give much. But I did not know how to describe my problem differently...

    I have with some help put together a script that displays data from my inverter. Depending on whether energy is being fed into the grid or drawn from the grid, the line of text changes. The text for drawing is shorter than the text for feeding. Now you can see "remnants" of the overshifted line.

    I upload a screenshot, a picture is worth 1000 words.
    The problem also affects the other lines if the new values are smaller than the previous ones.

    The code I use:

    # Endlosschleife zum Anzeigen der Leistungsdaten
    while True:
        # Leistungsdaten abrufen
        data = get_fronius_data(FRONIUS_IP)
        # Neue Leistungsdaten speichern
        pv_leistung = data["Site"]["P_PV"]
        verbrauch = data["Site"]["P_Load"]
        p_grid = data["Site"]["P_Grid"]
        # Nur die aktualisierten Werte auf dem Bildschirm anzeigen
        lcd.print("PV Leistung: {:.2f} kW".format(pv_leistung/1000), lcd.CENTER, 50, lcd.WHITE)
        lcd.print("Verbrauch: {:.2f} kW".format(verbrauch/1000), lcd.CENTER, 100, lcd.WHITE)
        # Textfarbe basierend auf dem Vorzeichen von p_grid setzen
        if p_grid < 0:
            lcd.print("Einspeisung: {:.2f} kW".format(-p_grid/1000), lcd.CENTER, 150, lcd.GREEN)
            lcd.print("Bezug: {:.2f} kW".format(p_grid/1000), lcd.CENTER, 150, lcd.RED)
        # Kurze Pause einlegen

    How can I change this so that this problem does not occur?


  • @margel the display does not refresh when new text appears and this requires a black “blanking” background.

  • I think I have already tried that. Then I have the "problem" that the screen seems to flicker. So all text disappears for half a second and then the image is rebuilt. This is very "unpleasant" to watch.

  • Hello@margel

    The description in m5-docs is done with setTextColor.

    setTextColor( color, backgroundcolor )