You didn't publish code with your issue.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Fonts/FreeSans24pt7b.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
float trip = 10.00;
float trip1 = 10.00;
/*
LED to 3.3V
SCK to D13
SDA to D11
A0 to D8
RST to D9
CS to D10
GND to GND
VCC to 3.3V
*/
#define CS 10
#define DC 9
TFT_ILI9163C tft = TFT_ILI9163C(CS, 8, DC);
void setup()
{
tft.begin();
tft.fillScreen(WHITE);
tft.setFont(&FreeSans24pt7b);
}
void loop()
{
trip = trip +0.01;
trip1 = trip1 +0.01;
tft.setTextColor(RED);
tft.setCursor(10,40);
tft.print (trip);
tft.setTextColor(MAGENTA);
tft.fillRect(10,55, 115, 40,BLUE);
tft.setCursor(10,90);
tft.println(trip1);
delay(19);
}
NOTE: you double posted this here and there is already similar advice on the other thread,
https://forum.pjrc.com/threads/25862-ILI9163C-128x128-TFT-driver?p=126806&viewfull=1#post126806
I assume driver supports opaque text, so supply the desired background color as second parameter, and it will redraw in place.
However if your problem with this is that the font spacing is to large such that when you draw top line it overwrites second line, not sure what to tell you.
In my current ili99341 driver code in ili9341_t3n so wrong driver and not main lined, I integrated some code to set clipping rectangle for cases like that, but that functionality is probably not in this library.
Other options would be to create new font with just the number stuff and set up smaller spacing. Or build yourself a set of bitmap a for each number and draw your own numbers.
void loop()
{
trip = trip +0.01;
trip1 = trip1 +0.01;
tft.setTextColor(RED, WHITE);
tft.setCursor(10,40);
tft.print (trip);
tft.setTextColor(MAGENTA, BLUE);
tft.fillRect(10,55, 115, 40,BLUE);
tft.setCursor(10,90);
tft.println(trip1);
delay(19);
}
void loop()
{
tft.setTextColor(WHITE);
tft.setCursor(10,40);
tft.print (trip);
tft.setTextColor(BLUE);
// tft.fillRect(10,55, 115, 40,BLUE); // maybe can live in Setup?
tft.setCursor(10,90);
tft.println(trip1);
trip = trip +0.01;
trip1 = trip1 +0.01;
tft.setTextColor(RED);
tft.setCursor(10,40);
tft.print (trip);
tft.setTextColor(MAGENTA);
// tft.fillRect(10,55, 115, 40,BLUE);
tft.setCursor(10,90);
tft.println(trip1);
delay(19);
}
What happens if you do something like:
Code:void loop() { trip = trip +0.01; trip1 = trip1 +0.01; tft.setTextColor(RED, WHITE); tft.setCursor(10,40); tft.print (trip); tft.setTextColor(MAGENTA, BLUE); tft.fillRect(10,55, 115, 40,BLUE); tft.setCursor(10,90); tft.println(trip1); delay(19); }
What happens if you do something like:
Another option is to do something like:
Code:void loop() { tft.setTextColor(WHITE); tft.setCursor(10,40); tft.print (trip); tft.setTextColor(BLUE); // tft.fillRect(10,55, 115, 40,BLUE); // maybe can live in Setup? tft.setCursor(10,90); tft.println(trip1); trip = trip +0.01; trip1 = trip1 +0.01; tft.setTextColor(RED); tft.setCursor(10,40); tft.print (trip); tft.setTextColor(MAGENTA); // tft.fillRect(10,55, 115, 40,BLUE); tft.setCursor(10,90); tft.println(trip1); delay(19); }
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Fonts/FreeSans24pt7b.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
float trip = 10.00;
float trip1 = 10.00;
/*
LED to 3.3V
SCK to D13
SDA to D11
A0 to D8
RST to D9
CS to D10
GND to GND
VCC to 3.3V
*/
#define CS 10
#define DC 9
TFT_ILI9163C tft = TFT_ILI9163C(CS, 8, DC);
void setup()
{
tft.begin();
tft.fillScreen(WHITE);
tft.setFont(&FreeSans24pt7b);
}
void loop()
{
tft.setTextColor(WHITE);
tft.setCursor(10,40);
tft.print (trip);
trip = trip +0.01;
tft.setTextColor(RED);
tft.setCursor(10,40);
tft.print (trip);
tft.setTextColor(WHITE);
tft.setCursor(10,90);
tft.println(trip1);
trip1 = trip1 +0.01;
tft.setTextColor(MAGENTA);
tft.setCursor(10,90);
tft.println(trip1);
}
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
float trip = 10.00;
float trip1 = 10.00;
/*
LED to 3.3V
SCK to D13
SDA to D11
A0 to D8
RST to D9
CS to D10
GND to GND
VCC to 3.3V
*/
#define CS 10
#define DC 9
TFT_ILI9163C tft = TFT_ILI9163C(CS, 8, DC);
void setup()
{
tft.begin();
tft.fillScreen(WHITE);
tft.setTextSize(3);
}
void loop()
{
tft.setTextColor(WHITE);
tft.setCursor(10,40);
tft.print (trip);
trip = trip +0.01;
tft.setTextColor(RED);
tft.setCursor(10,40);
tft.print (trip);
tft.setTextColor(WHITE);
tft.setCursor(10,90);
tft.print(trip1);
trip1 = trip1 +0.01;
tft.setTextColor(MAGENTA);
tft.setCursor(10,90);
tft.print(trip1);
}
have hadpublish the code in #197
but obviously that has changed little
// tft. Self Cleaning String print
uint32_t tftSCprint( uint32_t oldV, uint32_t newV, uint16_t fgc, uint16_t bgc )
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Fonts/FreeSans24pt7b.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
float tal1 = 0;
int Plus1 = 4;
/*
LED to 3.3V
SCK to D13
SDA to D11
A0 to D8
RST to D9
CS to D10
GND to GND
VCC to 3.3V
*/
#define CS 10
#define DC 9
TFT_ILI9163C tft = TFT_ILI9163C(CS, 8, DC);
void setup()
{
// Serial.begin(9600);
tft.begin();
tft.fillScreen(WHITE);
tft.setFont(&FreeSans24pt7b);
tft.setTextColor(RED);
tft.setCursor(10,40);
tft.print (tal1);
Serial.print("TAL 1 : "); Serial.println(tal1);
}
void loop()
{
if (digitalRead(Plus1)== HIGH)
{
tft.setTextColor(WHITE);
tft.setCursor(10,40);
tft.print (tal1);
tal1 = tal1+0.01;
tft.setTextColor(RED);
tft.setCursor(10,40);
tft.print (tal1);
// Serial.print("TAL 1 : "); Serial.println(tal1);
// delay(300);
}
}
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Fonts/FreeSans24pt7b.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
int cif1 = 100;
int cif2 = 74;
int cif3 = 35;
int cif4 = 10;
int tal1 = 0;
int tal2 = 0;
int tal3 = 0;
int tal4 = 0;
int Plus1 = 4;
/*
LED to 3.3V
SCK to D13
SDA to D11
A0 to D8
RST to D9
CS to D10
GND to GND
VCC to 3.3V
*/
#define CS 10
#define DC 9
TFT_ILI9163C tft = TFT_ILI9163C(CS, 8, DC);
void setup()
{
tft.begin();
tft.fillScreen(WHITE);
tft.setFont(&FreeSans24pt7b);
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
tft.setTextColor(RED);
tft.setCursor(63,40);
tft.print (".");
/*
Serial.begin(9600);
Serial.print("TAL 1 : "); Serial.println(tal1);
Serial.print("TAL 2 : "); Serial.println(tal2);
Serial.print("TAL 3 : "); Serial.println(tal3);
Serial.print("TAL 4 : "); Serial.println(tal4);
Serial.println("");
Serial.println("");
*/
}
void loop()
{
if (digitalRead(Plus1)== HIGH)
{
tft.setTextColor(WHITE);
tft.setCursor(cif1,40);
tft.print (tal1);
tal1 = tal1+1;
if (tal1 < 9)
{
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
}
if (tal1==9)
{
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
}
if (tal1 > 9)
{
tft.setTextColor(WHITE);
tft.setCursor(cif1,40);
tft.print (tal1);
tal1 =0;
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
tft.setTextColor(WHITE);
tft.setCursor(cif2,40);
tft.print (tal2);
tal2 = tal2+1;
tft.setTextColor(WHITE);
tft.setCursor(cif2,40);
tft.print (tal2);
if (tal2 < 9)
{
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
}
if (tal2==9)
{
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
}
if (tal2 > 9)
{
tft.setTextColor(WHITE);
tft.setCursor(cif2,40);
tft.print (tal2);
tal2 =0;
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
tft.setTextColor(WHITE);
tft.setCursor(cif3,40);
tft.print (tal3);
tal3 = tal3+1;
tft.setTextColor(WHITE);
tft.setCursor(cif3,40);
tft.print (tal3);
if (tal3 < 9)
{
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
}
if (tal3==9)
{
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
}
if (tal3 > 9)
{
tft.setTextColor(WHITE);
tft.setCursor(cif3,40);
tft.print (tal3);
tal3 =0;
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
tft.setCursor(63,40);
tft.print (".");
tft.setTextColor(WHITE);
tft.setCursor(cif4,40);
tft.print (tal4);
tal4 = tal4+1;
tft.setTextColor(WHITE);
tft.setCursor(cif4,40);
tft.print (tal4);
if (tal4 < 9)
{
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
}
if (tal4==9)
{
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
}
if (tal4 > 9)
{
tft.setTextColor(WHITE);
tft.setCursor(cif4,40);
tft.print (tal4);
tal4 =0;
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
}
}
}
}
/* Serial.print("TAL 1 : "); Serial.println(tal1);
Serial.print("TAL 2 : "); Serial.println(tal2);
Serial.print("TAL 3 : "); Serial.println(tal3);
Serial.print("TAL 4 : "); Serial.println(tal4);
Serial.println("");
Serial.println("");
*/
// delay(300);
}
}
opps - I saw post at top of page not seeing it as mid thread - so didn't read history.
Is the sketch your actual desired output? One or more large sized number displays? Where leading digits change less than trailing digits? Large area digits are lots of spi data to clear and draw for.
If that is what desired code could be written to minimize what is sent to the display - balancing between not writing what doesn't change and using code to track what was written last and re-write that in background before the new digits.
There is a >> TFT_ILI9163C::getCursor(int16_t &x, int16_t &y)
There is example usage I posted to this thread in May - post #119 and #121
Look for the function:
If the sketch provided shows your desired usage it would be best to print the print before and after the decimal as two numbers - so only half will flash at a time and only when changed and never leave behind 'old' pixels. With less area changing the flash will be much faster too.
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Fonts/FreeSans24pt7b.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
int cif1 = 100;
int cif2 = 74;
int cif3 = 35;
int cif4 = 10;
int tal1 = 0;
int tal2 = 0;
int tal3 = 0;
int tal4 = 0;
int Plus1 = 4;
/*
LED to 3.3V
SCK to D13
SDA to D11
A0 to D8
RST to D9
CS to D10
GND to GND
VCC to 3.3V
*/
#define CS 10
#define DC 9
TFT_ILI9163C tft = TFT_ILI9163C(CS, 8, DC);
void setup()
{
tft.begin();
tft.fillScreen(WHITE);
tft.setFont(&FreeSans24pt7b);
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
tft.setTextColor(RED);
tft.setCursor(63,40);
tft.print (".");
}
void loop()
{
if (digitalRead(Plus1)== HIGH)
{
tft.setTextColor(WHITE);
tft.setCursor(cif1,40);
tft.print (tal1);
tal1 = tal1+1;
if (tal1 < 9)
{
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
}
if (tal1==9)
{
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
}
if (tal1 > 9)
{
tft.setTextColor(WHITE);
tft.setCursor(cif1,40);
tft.print (tal1);
tal1 =0;
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
tft.setTextColor(WHITE);
tft.setCursor(cif2,40);
tft.print (tal2);
tal2 = tal2+1;
tft.setTextColor(WHITE);
tft.setCursor(cif2,40);
tft.print (tal2);
if (tal2 < 9)
{
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
}
if (tal2==9)
{
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
}
if (tal2 > 9)
{
tft.setTextColor(WHITE);
tft.setCursor(cif2,40);
tft.print (tal2);
tal2 =0;
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
tft.setTextColor(WHITE);
tft.setCursor(cif3,40);
tft.print (tal3);
tal3 = tal3+1;
tft.setTextColor(WHITE);
tft.setCursor(cif3,40);
tft.print (tal3);
if (tal3 < 9)
{
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
}
if (tal3==9)
{
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
}
if (tal3 > 9)
{
tft.setTextColor(WHITE);
tft.setCursor(cif3,40);
tft.print (tal3);
tal3 =0;
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
tft.setCursor(63,40);
tft.print (".");
tft.setTextColor(WHITE);
tft.setCursor(cif4,40);
tft.print (tal4);
tal4 = tal4+1;
tft.setTextColor(WHITE);
tft.setCursor(cif4,40);
tft.print (tal4);
if (tal4 < 9)
{
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
}
if (tal4==9)
{
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
}
if (tal4 > 9)
{
tft.setTextColor(WHITE);
tft.setCursor(cif4,40);
tft.print (tal4);
tal4 =0;
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
}
}
}
}
// delay(300);
}
}
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Fonts/FreeSans24pt7b.h>
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
int cif1 = 10;
int cif2 = 35;
int cif3 = 74;
int cif4 = 100;
int total = 0;
int Plus1 = 4;
long tal1 = 0;
int Lasttal1State = 0;
long tal2 = 0;
int Lasttal2State = 0;
long tal3 = 0;
int Lasttal3State = 0;
long tal4 = 0;
int Lasttal4State = 0;
/*
LED to 3.3V
SCK to D13
SDA to D11
A0 to D8
RST to D9
CS to D10
GND to GND
VCC to 3.3V
*/
#define CS 10
#define DC 9
TFT_ILI9163C tft = TFT_ILI9163C(CS, 8, DC);
void setup()
{
tft.begin();
tft.fillScreen(WHITE);
tft.setFont(&FreeSans24pt7b);
tal1 = (total/1000)-((total/10000)*10);
tal2 = (total/100)-((total/1000)*10);
tal3 = (total/10)-((total/100)*10);
tal4 = total-((total/10)*10);
Lasttal1State = tal1;
Lasttal2State = tal2;
Lasttal3State = tal3;
Lasttal4State = tal4;
Lasttal4State = tal4;
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
tft.setTextColor(RED);
tft.setCursor(63,40);
tft.print (".");
}
void loop()
{
if (digitalRead(Plus1)== HIGH)
{
total = total+1;
// delay(400);
}
if (total > 9999)
{
total = 0;
}
tal1 = (total/1000)-((total/10000)*10);
tal2 = (total/100)-((total/1000)*10);
tal3 = (total/10)-((total/100)*10);
tal4 = total-((total/10)*10);
if (tal1 != Lasttal1State)
{
tft.setTextColor(WHITE);
tft.setCursor(cif1,40);
tft.print (Lasttal1State);
tft.setTextColor(RED);
tft.setCursor(cif1,40);
tft.print (tal1);
Lasttal1State = tal1;
}
if (tal2 != Lasttal2State)
{
tft.setTextColor(WHITE);
tft.setCursor(cif2,40);
tft.print (Lasttal2State);
tft.setTextColor(RED);
tft.setCursor(cif2,40);
tft.print (tal2);
Lasttal2State = tal2;
}
if (tal3 != Lasttal3State)
{
tft.setTextColor(WHITE);
tft.setCursor(cif3,40);
tft.print (Lasttal3State);
tft.setTextColor(RED);
tft.setCursor(cif3,40);
tft.print (tal3);
Lasttal3State = tal3;
}
if (tal4 != Lasttal4State)
{
tft.setTextColor(WHITE);
tft.setCursor(cif4,40);
tft.print (Lasttal4State);
tft.setTextColor(RED);
tft.setCursor(cif4,40);
tft.print (tal4);
Lasttal4State = tal4;
}
}
Not sure who else uses the ILI9163C boards, but thought I would try to get a little more info on what these displays are actually... If I screw one up only lose $5+
So I pried the display up from the backing board:
The lettering on the White (display) side I believe says:
BL14S26A2
RX167/12/07 (maybe)
The cable part show:
HYM
H144TC215A-V0
20151117
XYL
My guess is it could be something else...
#define __144_BLACK_PCB__//128x128