ILI9163C 128x128 TFT driver

Status
Not open for further replies.
I have a little problem, when I clear the screen it seems like a blinking delay maybe because the processor of the screen is too slow ? In other screen doesn't occur this.
What do you think about this?

Code:
#include <SPI.h>
#include <TFT_ILI9163C.h>
#define __CS  10
#define __DC  6
#define __RST 23
TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST);

void setup() {
  tft.begin();
}

void loop(void) {
        InicioLcd();
        tft.setCursor(45,60);
        tft.println("Todo OK");
        tft.println("Reposiciones");
        tft.setCursor(70,70);
        tft.println("0");
        tft.println("Skimmer ON");
}

void InicioLcd() {
  tft.clearScreen();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);  
  tft.setTextSize(1);
}
See that


 
That is a very odd test - it doesn't show what is happening.

The tft.println("0"); should be tft.println(millis()); or something so you can see how fast the screen is updating.

I suspect you are updating the screen too fast and the flash is a side effect of that. Looking at the video image the bottom edge of the screen the black is GRAY (the backlight is bleeding through) - which is what I saw when updating the screen at 100 FPS instead of a more reasonable 20 fps with the bar graph test.

Put a delay(40); in loop or use an elapsedMicros() to limit the update rate.

Also doing a clearScreen() is generally one of the slower things as the entire screen is refreshed, it may be okay on this device with sumotoy code - but most larger screens that is painfully slow way to update small areas.
 
Thank you defragster. I undestand the clearscreen function is not the best to refresh the data.
What function of the library you think is better to refresh the data on some area in the screen.
If i not clean before i print the value the screen area it seem overwriter for the new value that i want to show.
In others library with others screen i clean one time and then when i use print the values clean the pixel position for the new.
I hope i can explain my point.
Best Regards
 
Step One::
The code below only shows that the screen is being over updated at over 50 times per second running as it is, I see 52 at 96 Mhz. It uses a really cool way to control updates to the screen or anything using the elapsedMillis as shown - with NO DELAY() calls.

Modifying value on this line will limit screen updates per second as noted, try MAXVAL = 100:
uint32_t MAXVAL = 0; // Set this to the number of milliseconds between screen updates : ZERO causes NO DELAY!!!!

Step two::
Would be to stop the clearScreen call that is guaranteed to cause the most FLASH possible - but just clear the rectangle area where you will have changing data - or to remember the prior value - index to the same screen location - overwrite the old data value in the background color - then relocate and write the NEW value when it changes. I and other have shown this on the forum a couple times. You might find it - or I might post an updated example if you work with this and make progress. This will involve more code - but actually run FASTER AND SMOOTHER. BTW - there may be functions and features in this new sumotoy code I don't know about that would make this step easier.

Code:
#include <SPI.h>
#include <TFT_ILI9163C.h>
#define __CS  10

//#define __DC  6
//#define __RST 23

#define __DC  9
#define __RST   14

TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST);

// https://forum.pjrc.com/threads/25862-ILI9163C-128x128-TFT-driver?p=104349&viewfull=1#post104349

elapsedMillis timerEM;
elapsedMillis timerLimit;

uint32_t MAXVAL = 0; // Set this to the number of milliseconds between screen updates : ZERO causes NO DELAY!!!!

void setup() {
  tft.begin();
  timerEM = 0;
}

int CountedLoops = 0;
int LastCountedLoops = 0;

void loop(void) {
  if ( MAXVAL < timerLimit ) {
    InicioLcd();
    tft.setCursor(45, 30);
    tft.println("Todo OK");
    tft.println("Reposiciones");
    tft.setCursor(70, 40);
    tft.println(timerEM);
    tft.println("Skimmer ON");
    if ( 1000 > timerEM )
      CountedLoops++;
    else {
      timerEM = 0;
      LastCountedLoops = CountedLoops;
      CountedLoops = 0;
    }
    tft.print("LOOPS per sec =");
    tft.println(LastCountedLoops);
    timerLimit = 0;
  }
}

void InicioLcd() {
  tft.clearScreen();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);
  tft.setTextSize(1);
}
 
UPDATE - sumotoy - I just dropped in the SPI speedup noted in POST #99 It runs well and 50% faster - at 96 and 120 MHz. Here is the code above modified for that change - just one line in setup() and I set MAXVAL to 1 as at 120MHz it went all white after a minute. The screen update goes to 90 and 111 FPS at 96 and 120 MHz - up from 52 FPS! And the flicker is greatly reduced because the update takes so much less time!

<EDIT> : just updated the code to minimize Serial.Print abuse to once per second and showed run time as well in seconds.

Code:
#include <SPI.h>
#include <TFT_ILI9163C.h>
#define __CS  10

//#define __DC  6
//#define __RST 23

#define __DC  9
#define __RST   14

TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST);

// VIDEO SOURCE CODE HERE - Sumotoy ILI9163C
// https://forum.pjrc.com/threads/25862-ILI9163C-128x128-TFT-driver?p=104349&viewfull=1#post104349
// SPI SPEEDUP CODE HERE - Teensy-3-2-SPI-Clock-over-30-MHz
// https://forum.pjrc.com/threads/34406-Teensy-3-2-SPI-Clock-over-30-MHz?p=104374&viewfull=1#post104374

elapsedMillis timerEM;
elapsedMillis timerLimit;

uint32_t MAXVAL = 1; // Set this to the number of milliseconds between screen updates

void setup() {
  SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(0) | SIM_CLKDIV1_OUTDIV4(3); //SIM_CLKDIV1_OUTDIV2(0) war auf 2!!

  Serial.begin(38400);
  while (!Serial && (millis() < 2000)) ;

  tft.begin();
  timerEM = 0;
}

int CountedLoops = 0;
int LastCountedLoops = 0;
uint runseconds = 0;

void loop(void) {
  if ( MAXVAL < timerLimit ) {
    InicioLcd();
    tft.setCursor(45, 30);
    tft.println("Todo OK");
    tft.println("Reposiciones");
    tft.setCursor(70, 40);
    tft.println(timerEM);
    tft.println("Skimmer ON");
    if ( 1000 > timerEM )
      CountedLoops++;
    else {
      timerEM = 0;
      LastCountedLoops = CountedLoops;
      runseconds++;
      CountedLoops = 0;
      Serial.print("LOOPS per sec =");
      Serial.println(LastCountedLoops);
      Serial.print("seconds running =");
      Serial.println(runseconds);
    }
    tft.print("LOOPS per sec =");
    tft.println(LastCountedLoops);

    timerLimit = 0;
  }
}

void InicioLcd() {
  tft.clearScreen();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);
  tft.setTextSize(1);
}
 
Last edited:
Thank you defragster !
Have a nice weekend !:)

Thanks, you too.

I'm not sure what 'Reposiciones' is in your case and what is being SKIMMED - but he other thing you might do is depending on what you are putting out - IN addition to adjusting the output rate as the code above will do - you can compare the current value at that time to the last value - and skip the update if there is no changed information.
 
I'll packing a beta in a couple of hours, unfortunatly I'm actually using visualMicro (to avoid the complete recompiling all the times) and it put a lot of garbage allover.
I was planning to send you a new beta a couple of days ago but had to a unplanned trip, sorry for delay.
 
No problem sumotoy - I've been keeping busy.

Not sure why so many get complete recompile in IDE - I don't see that. Except with TOOLS change, or using a sketch saved in a ReadOnly Library directory.
 
Here's a a test version.
Link
It's not the release one, still have to fix scrolling and a small bug in font rendering with background.
I will fix the last issues tomorrow night I hope, sorry for delay but was busy and library changed a lot.
Apart that, here's the current features:
(there's a lot of changes underneat, please refere to this list)
Link
 
Last edited:
Just caught this post - it works.

BATMAN WORKS!!!!!

and tft.setTextScale(1); works instead of tft.setTextSize(1);

My modified SomeBars works. All seems to be as fast as before, the SPI speed up works up through 120 MHz - but total fail on 140 Mhz - maybe the display.

Now I need to try my own bitmap - that image tool didn't speak to me - not sure of the settings? Need to scan the github again. I did find that:

>> OPTIONS / CONVERSION / SHOW PREVIEW

That did give the data stream I needed without saving anything!

Sumotoy - a note on image conversion might help me?
I see something of my EAGLE avatar on my screen when I select the 565 color format - but it is doubled side by side and has garbage below? Not sure if the colors are true - maybe that is the mapping to 565 color space and maybe I have the wrong dimensions - or some other setting?
 
Last edited:
Hi defragster,
first, thanks for testings, really appreciate!
You should give a try to Icon support, much simplier and powerful! The drawColorBitmap,drawBitmap are old and soon obsolete.
Here's a wiki for convert images -> Icons.
Load and show an icon can't be simplier since you just need to load the .c file converted by lcd-image-converter.
Code:
#include "_icons/myImage.c"

//to show, just need this
tft.drawIcon(0, 0, &myImage);

Icons support is beta but work pretty well and flexible, final version will have color conversion, background replacement, transparency and more.
I can send you an updated library with definitive drawIcon than has 2 more parameters that allow background transparency, replace or colorizing, really useful!
There's a demo with a small animation, try the icon_eyeAnimation.ino.
The icon file format (actually format is definitive but still have to add some code in library) will let you handle icons in 2/8/16/24 bit.
Here's last version of the custom tools for LCD Image Converter
View attachment tools1.1.zip

Since I really would like release a 1.0 soon, I'm try to optimize code as much as possible and get rid of useless stuff. Speed optimizations are always possible but the Teensy side touched device limits, cannot be faster I think.
There's a lot of code needs some magic, the arc stuff it's massive and uses tons of variables, is so heavy that tiny CPU like UNO suffer, so actually I'm try to simplify and optimize.
I'm changing some keywords with something that have more sense, many names come from GFX (to have a kinda standard) but have nonsense now like setTextSize (that is setTextScale!)

About refreshing screen...
The screen refresh uses 128*128=16384 + 7 - > 16391 SPI calls (and 99% are 16 bit transfer!), using Defragster trick will result in almost 2Mbytes sec!. Refreshing data by clearing screen is not the best way to go!
Thanks Defragster for tip, didn't know it! Btw the bes approach is create a 'safety' zone for fixed text and erase the refreshing data zone by filledRect or using text with background, by default text is transparent.
Some controller has hardware accelleration for that (RA8875 as an example), results in much less SPI calls, but ILI9163c uses brute force and thanks god it has an internal ram, there's other controllers out there that doesn't have ram (like SSD1306) or even worst the Sharp display that needs constant refresh as well!
 
Last edited:
elricho - I just stumbled across the post I made for doing a background overwrite of old text versus clear screen or larger rectangle wipe:

Highly-optimized-ILI9341-(320x240-TFT-color-display)-library

That works well on the ILI9341 - I have not tried it on this ILI9163C. It should work assuming all the used functions are supported.

You pass in the OLD text - first time on blank area doesn't matter what it is. Also pass in a pointer to string storage area for the NEW text to be newly written. On the next call you send that text in as the OLD.

If you are writing numbers instead of text - modify/duplicate the function to take the proper data type and adjust for printing numbers.
Ideally I'll update and post a faster example showing this.

sumotoy:
> Glad I saw the SPI clock speedup trick and related it to this! It is faster. Is the ILI9163C not able to process 72 MHz SPI clocked data? Not that anyone should run the Teensy at 144MHz - something else will likely fail if not the display.
> I got the new tools1.1 - will look at the wiki and give it a try.

<edit>
> I finally saw why the ILI9341 has 9 pins and the ILI9163C has only 8 - the END MISO pin is missing (luckily everything else lines up!). The 9163C must not support screen reading that the 9341 does?
 
Last edited:
Here is the SelfCleaning ScreenPrint code updated to work on the 9361C ( sumotoy I see two small glitches - is it me? )

<edit> glitches were simple code error fixed below

Update speed was originally just over 50 and went to 111 with the "SIM_CLKDIV1" SPI speedup. Now as edited below it seems there is so little SPI each loop - it is updating the screen with no screen pulsing (or the gray bleed through on the bottom) at 199 times per second without the SPI speedup and 200 times per second WITH the speedup! ( with MAXVAL =0 )

I stopped the clearscreen() and stopped some of the static prints that persist when the screen doesn't clear. elricho - there are two bonus speedups here not suggested above in P#104.

glitch 1: for some reason I see a flash around the areas that are not being updated each refresh?
glitch 2: if you run the sketch for some reason the 'over write' to background is not always clearing beyond the end when the new value is shorter ( watch for a '1' to come up after a zero ). I only see an error on the end? Adjust MAXVAL = to 100 or higher to slow it down.

Here is the code I'm running - making it cleaner on the screen with less updates to static text is faster - but makes the code more involved:
Code:
// [URL="https://forum.pjrc.com/threads/25862-ILI9163C-128x128-TFT-driver?p=104747&viewfull=1#post104747"]Bug fixed version below[/URL]
 
Last edited:
The yellowPin RED pcb display probably need some init fine tuning, I just discovered that it simply ignore any setting of VCOM output of non display area in partial mode, however colors are better than old ones. It' flickers a bit so must be some more tuning to do!
I also just got 2 old REDpcb display that looks almost cyan, no matter settings, looks like they use a colored plastic as glue between backlight and TFT, sigh...
Since ILI9163c is mounted on the flexible pcb that connect to real PCB, chinese vendor reuse the mounting PCB but display change quality continuosly...
About MISO. ILI9163C has MISO but none vendor exposed so it's impossible read memory or registers. And since chip is mounted on flexible PCB not documented and different for any vendor it's a almost impossible access it.
The speedup it's only for Teensy 3.2? I'm actually mount a Teensy 3.0 but don't noticed any difference....
 
Last edited:
My s,artwatch face using sumotoy's optimized library for teensy:
[video]https://z-1-scontent-lax3-1.xx.fbcdn.net/v/t1.0-9/13260173_10154208385873679_8208934222377606977_n.j pg?oh=f34470f916ddce313ae3a90bb3935164&oe=57D3BA85[/video]
 
My smartwatch face using sumotoy's library optimized for teensy:
13260173_10154208385873679_8208934222377606977_n.jpg
 
CODE UPDATE ... Added example usage of text write with over write.

sumotoy - it was MY code that was BAD !!!! Causing both 'glitches' Here it is right running at 470 screen updates/second with SPI OC and only 343 updates/sec without the SPI OC:

Code:
#include <SPI.h>
#include <TFT_ILI9163C.h>
#define __CS  10

//#define __DC  6
//#define __RST 23

#define __DC  9
#define __RST   14

TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST);

// VIDEO SOURCE CODE HERE - Sumotoy ILI9163C
// https://forum.pjrc.com/threads/25862-ILI9163C-128x128-TFT-driver?p=104349&viewfull=1#post104349
// SPI SPEEDUP CODE HERE - Teensy-3-2-SPI-Clock-over-30-MHz
// https://forum.pjrc.com/threads/34406-Teensy-3-2-SPI-Clock-over-30-MHz?p=104374&viewfull=1#post104374

elapsedMillis timerEM;
elapsedMillis timerLimit;

char szlsTest[5][15] = {"BIG888888", "small==", "```HI```", "...__lo__...", "BIG888888" };
uint8_t lsTii = 0;

void tftSCprint( char *oldV, char *newV, uint16_t fgc, uint16_t bgc );
uint32_t tftSCprint( uint32_t oldV, uint32_t newV, uint16_t fgc, uint16_t bgc );

uint32_t MAXVAL = 0; // Set this to the number of milliseconds between screen updates

void setup() {
  SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(0) | SIM_CLKDIV1_OUTDIV4(3); //SIM_CLKDIV1_OUTDIV2(0) war auf 2!! // Good for OC Teensy less than 144 MHz
  Serial.begin(38400);
  while (!Serial && (millis() < 2000)) ;
  tft.begin();
  InicioLcd();
  timerEM = 0;
}

int CountedLoops = 0;
uint32_t LastCountedLoops = 0;
uint32_t runseconds = 0;
uint32_t old_LastCountedLoops = 0;
uint32_t old_runseconds = 0xFFFFF;
uint32_t old_val_timerEM = 0;
bool   screenCleared = true;

void loop(void) {
  if ( MAXVAL < timerLimit ) {
    if ( screenCleared ) {
      tft.setTextColor(WHITE, BLACK);
      tft.setCursor(5, 3);
      tft.print("secs running =");
    }
    if (old_runseconds != runseconds) {
      tft.setCursor(68, 3);
      old_runseconds = tftSCprint( old_runseconds, runseconds, WHITE, BLACK );
      tft.setCursor(10, 86);
      tft.setTextColor(WHITE, BLACK);
      uint8_t old_lsTii = lsTii++;
      tftSCprint( szlsTest[old_lsTii], szlsTest[lsTii], WHITE, BLACK );
      if (3 < lsTii) lsTii = 0;
    }
    if (   screenCleared ) {
      tft.setTextColor(WHITE, BLACK);
      tft.setCursor(45, 30);
      tft.println("Todo OK");
      tft.println("Reposiciones");
    }
    tft.setCursor(70, 40);
    //val_timeEM = timerEM;
    // tft.println(val_timeEM);
    old_val_timerEM = tftSCprint( old_val_timerEM, timerEM, WHITE, BLACK );
    tft.println("\nSkimmer ON");
    if ( 1000 > timerEM )
      CountedLoops++;
    else {
      timerEM = 0;
      LastCountedLoops = CountedLoops;
      runseconds++;
      CountedLoops = 0;
      Serial.print("LOOPS per sec =");
      Serial.println(LastCountedLoops);
      Serial.print("seconds running =");
      Serial.println(runseconds);
    }
    if ( old_LastCountedLoops != LastCountedLoops ) {
      tft.setCursor(10, 100);
      tft.setTextColor(WHITE, BLACK);
      tft.print("LOOPS per sec =");
      old_LastCountedLoops = tftSCprint( old_LastCountedLoops, LastCountedLoops, WHITE, BLACK );
    }
    timerLimit = 0;
  }
  screenCleared = false;
}

void InicioLcd() {
  tft.clearScreen();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE, BLACK);
  tft.setTextScale(1);
  screenCleared = true;
}


// tft. Self Cleaning String print
void tftSCprint( char *oldV, char *newV, uint16_t fgc, uint16_t bgc ) {
  int16_t xxt, yyt;
  tft.getCursor(xxt, yyt); //   xxt = tft.getCursorX();   yyt = tft.getCursorY();
  tft.setTextColor(bgc, bgc);
  //tft.setTextColor(RED, RED);
  tft.print(oldV);
  tft.setCursor(xxt, yyt);
  tft.setTextColor(fgc, bgc);
  tft.print(newV);
  return;
}
uint32_t tftSCprint( uint32_t oldV, uint32_t newV, uint16_t fgc, uint16_t bgc ) {
  int16_t xxt, yyt;
  tft.getCursor(xxt, yyt); //   xxt = tft.getCursorX();   yyt = tft.getCursorY();
  tft.setTextColor(bgc, bgc);
  tft.print(oldV);
  tft.setCursor(xxt, yyt);
  tft.setTextColor(fgc, bgc);
  tft.print(newV);
  return (newV);
}
 
elricho - 'small graph' is very non specific, what value is being graphed and how? And how often does it update in what direction? Give it a try yourself perhaps and post your code if you get stuck. Perhaps you could define a SCROLL area and fill it with a colored bar in some fashion? I have not looked at the scroll code yet.

I Updated the above code - it is more 'realistic' - I assume - putting the changing text value by the word SKIMMER - even did changing colors!

It shows a character type 'progress' style spinner too. Slowed to 82 updates per sec with MAXVAL=10, still hits 470/sec with MAXVAL=0. Very ugly code - that works fast and clean - and in a convoluted way. It begs for a 'struct' per output item to hold the related info. The small screen is great, if only it were bigger :)

Code:
#include <SPI.h>
#include <TFT_ILI9163C.h>
#define __CS  10

//#define __DC  6
//#define __RST 23

#define __DC  9
#define __RST   14

TFT_ILI9163C tft = TFT_ILI9163C(__CS, __DC, __RST);

// VIDEO SOURCE CODE HERE - Sumotoy ILI9163C
// https://forum.pjrc.com/threads/25862-ILI9163C-128x128-TFT-driver?p=104349&viewfull=1#post104349
// SPI SPEEDUP CODE HERE - Teensy-3-2-SPI-Clock-over-30-MHz
// https://forum.pjrc.com/threads/34406-Teensy-3-2-SPI-Clock-over-30-MHz?p=104374&viewfull=1#post104374

elapsedMillis timerEM;
elapsedMillis timerLimit;

char szAct[] = " |/-~\\|/-=\\";
char lastAction = 0;
int actionV = 0;
char szlsTest[5][15] = {"BIG888888", "small==", "```HI```", "...__lo__...", "BIG888888" };
uint16_t lsTestColor[5] = { CYAN, GREEN, RED, YELLOW, CYAN };
uint8_t lsTii = 0;
int16_t SkimX = 255, SkimY = 0;
int16_t RunX = 255, RunY = 0;

void tftSCprint( char *oldV, char *newV, uint16_t fgc, uint16_t bgc );
uint32_t tftSCprint( uint32_t oldV, uint32_t newV, uint16_t fgc, uint16_t bgc );
char tftSCprint( char oldV, char newV, uint16_t fgc, uint16_t bgc );

uint32_t MAXVAL = 10; // Set this to the number of milliseconds between screen updates

void setup() {
  SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(0) | SIM_CLKDIV1_OUTDIV4(3); //SIM_CLKDIV1_OUTDIV2(0) war auf 2!! // Good for OC Teensy less than 144 MHz
  Serial.begin(38400);
  while (!Serial && (millis() < 2000)) ;
  tft.begin();
  InicioLcd();
  timerEM = 0;
}

int CountedLoops = 0;
uint32_t LastCountedLoops = 0;
uint32_t runseconds = 0xFFFFFFF0;
uint32_t old_LastCountedLoops = 0;
uint32_t old_runseconds = 0xFFFFF;
uint32_t old_val_timerEM = 0;
bool   screenCleared = true;

void loop(void) {
  if ( MAXVAL < timerLimit ) {
    if ( screenCleared ) {
      tft.setTextColor(WHITE, BLACK);
      tft.setCursor(5, 3);
      tft.print("Run Secs=");
      tft.getCursor(RunX, RunY);
    }
    if (old_runseconds != runseconds) {
      if ( 250 > RunX ) {
        tft.setCursor(RunX, RunY);
        old_runseconds = tftSCprint( old_runseconds, runseconds, WHITE, BLACK );
      }
      if ( 250 > SkimX ) {
        tft.setCursor( SkimX, SkimY );
        tft.setTextColor(WHITE, BLACK);
        uint8_t old_lsTii = lsTii++;
        tftSCprint( szlsTest[old_lsTii], szlsTest[lsTii], lsTestColor[lsTii], BLACK );
        if (3 < lsTii) lsTii = 0;
      }
    }
    if (   screenCleared ) {
      tft.setTextColor(WHITE, BLACK);
      tft.setCursor(45, 30);
      tft.println("Todo OK");
      tft.println("Reposiciones");
    }

    if ( !( CountedLoops % 8)) {
      tft.setCursor(114, 0);
      tft.setTextScale(2);
      lastAction = tftSCprint( lastAction, szAct[actionV], CYAN, BLACK );
      tft.setTextScale(1);
      if ( !szAct[++actionV] ) actionV = 1;
    }

    tft.setCursor(70, 40);
    old_val_timerEM = tftSCprint( old_val_timerEM, timerEM, WHITE, BLACK );
    tft.setCursor(0, 54);
    tft.print("Skimmer ");
    tft.getCursor(SkimX, SkimY);

    if ( 1000 > timerEM )
      CountedLoops++;
    else {
      timerEM = 0;
      LastCountedLoops = CountedLoops;
      runseconds++;
      CountedLoops = 0;
      Serial.print("LOOPS per sec =");
      Serial.println(LastCountedLoops);
      Serial.print("Run Secs=");
      Serial.print(runseconds);
    }
    if ( old_LastCountedLoops != LastCountedLoops ) {
      tft.setCursor(10, 100);
      tft.setTextColor(WHITE, BLACK);
      tft.print("LOOPS per sec =");
      old_LastCountedLoops = tftSCprint( old_LastCountedLoops, LastCountedLoops, WHITE, BLACK );
    }
    timerLimit = 0;
  }
  screenCleared = false;
}

void InicioLcd() {
  tft.clearScreen();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE, BLACK);
  tft.setTextScale(1);
  screenCleared = true;
}


// tft. Self Cleaning String print
void tftSCprint( char *oldV, char *newV, uint16_t fgc, uint16_t bgc ) {
  int16_t xxt, yyt;
  tft.getCursor(xxt, yyt); //   xxt = tft.getCursorX();   yyt = tft.getCursorY();
  tft.setTextColor(bgc, bgc);
  //tft.setTextColor(RED, RED);
  tft.print(oldV);
  tft.setCursor(xxt, yyt);
  tft.setTextColor(fgc, bgc);
  tft.print(newV);
  return;
}
uint32_t tftSCprint( uint32_t oldV, uint32_t newV, uint16_t fgc, uint16_t bgc ) {
  int16_t xxt, yyt;
  tft.getCursor(xxt, yyt); //   xxt = tft.getCursorX();   yyt = tft.getCursorY();
  tft.setTextColor(bgc, bgc);
  tft.print(oldV);
  tft.setCursor(xxt, yyt);
  tft.setTextColor(fgc, bgc);
  tft.print(newV);
  return (newV);
}
char tftSCprint( char oldV, char newV, uint16_t fgc, uint16_t bgc ) {
  int16_t xxt, yyt;
  tft.getCursor(xxt, yyt); //   xxt = tft.getCursorX();   yyt = tft.getCursorY();
  tft.setTextColor(bgc, bgc);
  tft.print(oldV);
  tft.setCursor(xxt, yyt);
  tft.setTextColor(fgc, bgc);
  tft.print(newV);
  return (newV);
}
 
I 'm sorry defragster . The library works excelent with the graphs and your routine is very usefull too.
I show the screen working ! thank's a lot !



20160518_151312.jpg
 
Last edited:
The source files show this - seems to define a scrollable field - not a self scrolling message :

Code:
	void 		defineScrollArea(int16_t tfa, int16_t bfa);
	boolean		scroll(uint16_t adrs);
	int16_t		getScrollTop(void);
	int16_t		getScrollBottom(void);
 
Made a short video of the above code - starts up running MAXVAL=0 until the clock rolls over - then slows from 470 updates/sec to a mere 82.

Only the one field updates each time - the rest are selectively delayed and the Teensy just loops waiting for time to pass . . .
 
Status
Not open for further replies.
Back
Top