ILI9488 - Text Color issue

i have read following link :slight smile:

i having the text color and back ground color selection problem .

Only color text is happening and not back ground color is not happening .

i am trying to display the hour , minutes , seconds .

please have the look on code and display

#include "SPI.h"
#include <Adafruit_GFX.h>
#include <ILI9488.h>
#include <RTClock.h>
#include <Fonts/FreeMonoBold18pt7b.h>

RTClock rtclock(RTCSEL_LSE);
tm_t curTime;
const char *months[] = {"???", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
const char *delim = " :";
char bld[40];

uint8_t str2month(const char * d)
{
  uint8_t i = 13;
  while((--i) && strcmp(months[i], d));
  return i;
}

#define TFT_CS         PA4
#define TFT_DC         PB3
#define TFT_LED        PB0
#define TFT_RST        PB4

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
ILI9488 tft = ILI9488(TFT_CS, TFT_DC, TFT_RST);
// If using the breakout, change pins as desired
//Adafruit_ILI9488 tft = Adafruit_ILI9488(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

void setup() {
  Serial.begin(9600);
  Serial.println("ILI9488 Test!");
  rtclock.breakTime(rtclock.now(), curTime);
//  if(curTime.year+1970<2019) setBuildTime(curTime);

  tft.begin();
  testFilledRoundRects();
  tft.setRotation(3);
  tft.setFont(&FreeMonoBold18pt7b);
  tft.fillScreen(ILI9488_WHITE);
  unsigned long start = micros();
  delay(500);

  

}
char buf[25];
char *dowTxt[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", "??"};
char *dowLongTxt[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "??"};



void loop(void) {
 
  tft.setCursor(0,0+50);
  
  tft.setTextColor(ILI9488_BLUE, ILI9488_WHITE);  tft.setTextSize(1);
  tft.println("LIGHTING PROJECT");  
  
  showClock(1);
  delay(1000);

}
unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(ILI9488_BLACK);
  tft.fillScreen(ILI9488_RED);
  tft.fillScreen(ILI9488_GREEN);
  tft.fillScreen(ILI9488_BLUE);
  tft.fillScreen(ILI9488_BLACK);
  return micros() - start;
}

unsigned long testFilledRoundRects() {
  unsigned long start;
  int           i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9488_WHITE);
  start = micros();
  for(i=min(tft.width(), tft.height()); i>20; i-=6) {
    i2 = i / 2;
    tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
  }

  return micros() - start;
}
void showClock(int seconds)
{
  rtclock.breakTime(rtclock.now(), curTime);
  tft.setTextColor(ILI9488_RED, ILI9488_WHITE); tft.setTextSize(1);
  
  if(seconds)
    snprintf(buf, 25, " %d:%02d:%02d ", curTime.hour, curTime.minute, curTime.second);
  else
    snprintf(buf, 25, " %d:%02d ", curTime.hour, curTime.minute);
  tft.println(buf);
  
  snprintf(buf, 25, "% 02d.%02d.%d ", curTime.day, curTime.month, curTime.year+1970);
  tft.println(buf);
  
  snprintf(buf, 25, "  %s  ", dowLongTxt[curTime.weekday]);
  
  tft.println(buf);
}
![IMG_20210614_101337|666x500](upload://nKsC60JjX2MNXP5h42ta4CilX9e.jpeg)

Thanks for posting a link to your screen and for pasting your sketch.

The 5x7 "system" font can print in both replacement and transparent mode.
FreeFonts can only print in transparent mode.

You can either use the default 5x7 font
Or draw the background colour every time you update some text.
Or draw the old text in the background colour to "rub it out"

Your "sketch" refers to "ILI9488.h" which is a 320x480 TFT controller.
Your "link" shows a 1.77 inch display which uses a 132x162 ST7735 controller.

David.

thanks david .. after removing the set font ...it's perfect but display letter look is crazy by default font ...if i do back ground screen fill by white color then it's creating display flicking .. ... there is any other possibility to bring the font with real time value display ..

system font is drawn from top raster line e.g. horiz bar in T
Free Fonts are drawn from the base line e.g. bar in L

Seriously, Free Fonts look nicer. You just write a single helper function to do the "background erase" when drawing text.

If you try to write inline code everywhere your brain will start hurting.

David.

fine ... there is option for particular cursor line is with default font .... rest of cursor line is with free font selection is possible .

The ILI9488 in SPI mode is SLOW. You need 3 SPI per pixel.

There are several techniques for erase and draw. With the ILI9488 you will notice a slight flicker.
If you write a helper that draws each letter with background your eyes do not notice any flicker.

David.

hi, after filling with rectangle ..problem seems to ok but there flicker it's ok .

Now i am facing the another problem reading the data from external eeprom data's and displaying . now display the printing data in vertically .. i am expecting the display need to display horizontally . Correct my code for horizontal printing from the eeprom data's .please have look on code and display picture

#include "SPI.h"
#include"Wire.h"
#include <Adafruit_GFX.h>
#include <ILI9488.h>
#include <Fonts/FreeMonoBold18pt7b.h>


char somedata[ ] = "Name:Mr.Bean"; // data to write


TwoWire WIRE2 (2,I2C_FAST_MODE);
#define Wire WIRE2


#define TFT_CS         PA4
#define TFT_DC         PB3
#define TFT_LED        PB0
#define TFT_RST        PB4

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
ILI9488 tft = ILI9488(TFT_CS, TFT_DC, TFT_RST);
// If using the breakout, change pins as desired
//Adafruit_ILI9488 tft = Adafruit_ILI9488(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

void setup() {
 
  tft.begin();
  testFilledRoundRects();
  tft.setRotation(3);
  tft.setFont(&FreeMonoBold18pt7b);    
  tft.fillScreen(ILI9488_WHITE);
  unsigned long start = micros();
  delay(500);
  Wire.begin();
  
  //i2c_eeprom_write_page(0x50, 0, (byte *)somedata, sizeof(somedata));
 

  

}



void loop(void) {
 
 
  int addr=0; //first address
  byte b = i2c_eeprom_read_byte(0x50, 0); // access the first address from the memory
  tft.setCursor(0,0);   
  tft.setTextColor(ILI9488_BLUE);  tft.setTextSize(1);
  
  while (b!=0)
    {
        
        tft.println((char)b); //print content to serial port
        addr++; //increase address
        b = i2c_eeprom_read_byte(0x50, addr); //access an address from the memory
    }
  
  


}
unsigned long testFillScreen() {
  unsigned long start = micros();
  tft.fillScreen(ILI9488_BLACK);
  tft.fillScreen(ILI9488_RED);
  tft.fillScreen(ILI9488_GREEN);
  tft.fillScreen(ILI9488_BLUE);
  tft.fillScreen(ILI9488_BLACK);
  return micros() - start;
}

unsigned long testFilledRoundRects() {
  unsigned long start;
  int           i, i2,
                cx = tft.width()  / 2 - 1,
                cy = tft.height() / 2 - 1;

  tft.fillScreen(ILI9488_WHITE);
  start = micros();
  for(i=min(tft.width(), tft.height()); i>20; i-=6) {
    i2 = i / 2;
    tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
  }

  return micros() - start;
}

void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data ) {
    int rdata = data;
    Wire.beginTransmission(deviceaddress);
    Wire.write((int)(eeaddress >> 8)); // MSB
    Wire.write((int)(eeaddress & 0xFF)); // LSB
    Wire.write(rdata);
    Wire.endTransmission();
    delay(10);
}

// WARNING: address is a page address, 6-bit end will wrap around
// also, data can be maximum of about 30 bytes, because the Wire library has a buffer of 32 bytes
void i2c_eeprom_write_page( int deviceaddress, unsigned int eeaddresspage, byte* data, byte length ) {
    Wire.beginTransmission(deviceaddress);
    Wire.write((int)(eeaddresspage >> 8)); // MSB
    Wire.write((int)(eeaddresspage & 0xFF)); // LSB
    byte c;
    for ( c = 0; c < length; c++)
        Wire.write(data[c]);
    Wire.endTransmission();
    delay(10);
}

byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress ) {
    byte rdata = 0xFF;
    Wire.beginTransmission(deviceaddress);
    Wire.write((int)(eeaddress >> 8)); // MSB
    Wire.write((int)(eeaddress & 0xFF)); // LSB
    Wire.endTransmission();
    Wire.requestFrom(deviceaddress,1);
    if (Wire.available()) rdata = Wire.read();
    return rdata;
}
type or paste code here

Probably because you rewrite the same content to the display continuously. In general, I'd prevent writing variables to a display if they're unchanged compared to the most recent display update.

It's because you print using a println() command. At the start of the sequence you set the cursor position to (0,0) and then print a character on a new line each time.
Try adjusting your code so that the cursor is set to the appropriate position before writing a character, and use print() instead of println().

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.