🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    old text line visible under new one

    Micropython
    3
    4
    3.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      margel
      last edited by

      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.
      0_1678547183541_2023-03-11_15h58_52.png
      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
      lcd.clear(lcd.BLACK)
      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)
          else:
              lcd.print("Bezug: {:.2f} kW".format(p_grid/1000), lcd.CENTER, 150, lcd.RED)
          
          # Kurze Pause einlegen
          utime.sleep(2)
      

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

      thx!

      teastainT 1 Reply Last reply Reply Quote 0
      • teastainT
        teastain @margel
        last edited by

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

        Cheers, Terry!

        100% M5Stack addict with several drawers full of product!

        1 Reply Last reply Reply Quote 0
        • M
          margel
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • M
            macsbug
            last edited by macsbug

            Hello@margel

            The description in m5-docs is done with setTextColor.

            https://github.com/m5stack/m5-docs/blob/master/docs/en/api/lcd.md
            setTextColor( color, backgroundcolor )

            1 Reply Last reply Reply Quote 0
            • First post
              Last post