m5stack / M5Unified

Unified library for M5Stack series
MIT License
302 stars 54 forks source link

Setting text color on LCD prevents breaks text output #105

Closed LukeSkaff closed 6 months ago

LukeSkaff commented 6 months ago

If you set the display text color then when you output text to the display in the same cursor location the display code does not clear the previous written text when overwriting the text. See below sample code an pictures.

#include "Arduino.h"
#include <M5Unified.h>

int counter1 = 0;
int counter2 = 209;

void setup() {
  auto cfg = M5.config();
  M5.begin(cfg);
  delay(500);
  M5.Display.clear();
  delay(100);
}

void loop() {
  M5.update();

  M5.Display.setTextColor(TFT_GREEN); //--COMMENT OUT THIS LINE AND IT WILL WORK--

  M5.Display.setCursor(0, 20);
  M5.Display.print( "C1: ");
  M5.Display.print( counter1);

  M5.Display.setCursor(0, 30);
  M5.Display.print( "C2: ");
  M5.Display.print( counter2);

  counter1++;
  counter2++;
  delay(100);
}

Without color set M5 text color NOT set

With color set M5 text color set

LukeSkaff commented 6 months ago

it was of course me doing something stupid, you have to set the background color, below fixed it M5.Display.setTextColor(TFT_GREEN, TFT_BLACK);