Arduino tft variables flickering

Hi everybody,

As a beginning programmer i'm testing the functions of the arduino tft. Displa constant figures are no problem but when i start to display variables all the problem starts.

I use the example from the arduino website in my main program to display the value measured on analog pin A0

My background is black and the color of the value of A0 is red.

But it seems like the value is shaking or flickering very fast...

I thought the cause would be an delay but i only use a 1ms delay in the whole program...

Sombody had eny experience with this or knows a better way for clearing a screen so values displayed don't overwrite eachother?

Best regards

Jazzy g

Hi,

I have a counter, the value of that counter can be raised or lowered in steps from one.
I want to display this value on the arduino tft. I used the method of putting this variable in a char array shown on the aduino website. But when i startup my arduino the whole tft flickers and i can do nothing.

What is the right procedure go display an int value?

Best regards

Jazzy

Can you post your code you have sofar?

Probably you try to refresh too fast?

Threads merged.

Oke thanks for the heads up and merging!

Best regards!

hey,

this is an example code of the principle i want to use.

(forget setup, include etc ect)

int count = 0;
char countPrintout[4];

void loop{

count = count++;

String CHARVal = String(count);

sensorVal.toCharArray(countPrintout, 4);

TFTscreen.stroke(255,255,255);

TFTscreen.text(countPrintout, 0, 20);

delay(1);

TFTscreen.stroke(0,0,0);

TFTscreen.text(countPrintout, 0, 20);
}

this dont seem to work when i use an int, if i replace count with "analogRead(0)" everything is ok.

an other question (again).

i want to display figures sucht as a triangle, arrows, etc... do you people have any hint to contruct and fill them?

best regards!

First thing I would suggest is to change

delay(1);

To

delay(1000);

For testing.
Did that stop the flickering?

#2. In the IDE, Tools , Auto Format to give easier to read code. And take out all (most) of those blank likes.
#3. If you want to display an integer, just do it. Don't try to convert it to something else. I think your display will accept that.
#4. After you have your sketch reformatted, show it us again. This time put it in the code brackets The forum editor has a icon for that #

Jazzy,

I recently encountered the same problem and have to thank enhzflep for helping out (http://forum.arduino.cc/index.php?topic=185056.0).

The flickering you're seeing is because you're wiping the area, then overwriting it with fresh text. For me, the solution was to instead get your library functions etc to overwrite the old text with the new text AND a background at the same time.

In the adafruit library thats done by a setcolor command that sets foreground and background in one hit tft.setTextColor(ST7735_GREEN, ST7735_BLACK);

1 Like

Hi,

Oke thanks i will take a look at it!

I really can't get rid of this fenomenom and its driving me crazy!

Hope this work!!!!

Thanks!

Hi,

I took a look to the example from scrumfled but to be onhest my programming experience is not great enough to understand this code.

If i listen to scrumfled's solution i just have to clear the display and set background.

So with the arduino tft library i just have to call in my loop:

TFTscreen.begin() //to clear the display
TFTscreen.background(0,0,0) //i use a black background in my project
//rest of my program which write my variables to tft etc...

What procedure you people use?

My second idea is only to overwrite the old value when the value changes and then overwrite it with the new one. I couldn't manage to write a code for that mayby you guys have any starting tips?

To be ohnest a 16MHz chip refreshes 16.10^6 times per second i tought this flickering would 't be visible when using no delay.

Thanks and best regards

Jazzy

jackwp:
First thing I would suggest is to change

delay(1);

To

delay(1000);

For testing.
Did that stop the flickering?

Hi the flickering is inderdeed less but now every second my display turns black for a moment.
And thast doesn't look very professional. :slight_smile:

Thanks 4 the hint!

Jazzy, maybe i didnt explain myself very well. The way I was fixing it was to overwrite the new data, including the background colour behind the text (not the entire background of the screen) in a single command.

Maybe if you could include a nicely formatted sketch, we could notice something.

scrumfled:
Jazzy, maybe i didnt explain myself very well. The way I was fixing it was to overwrite the new data, including the background colour behind the text (not the entire background of the screen) in a single command.

Can you maybe give an example code?

Let say something with a counter that counts and displays the value or something you thinkd that's good...

Thanks

Why not see if the variable changes first, then if it does change, clear that segment of the screen and display the new number. This way you will get rid of the flicker and make it look much smoother and professional.

HazardsMind:
Why not see if the variable changes first, then if it does change, clear that segment of the screen and display the new number. This way you will get rid of the flicker and make it look much smoother and professional.

That is what i want to do but i can't figure out where to start...

Tonight after work i will try to set up some code so we have at least something to start!

Best regards!

int current_value, old_value; //set globally

current_value = analogRead(A0); // Read a value from analogpin 0

if(current_value != old_value) // Check to see if anything changed, if it did change show it, otherwise don't.
{
  //print("     ", X, Y); // clear that section of the lcd
  //print(current_value, X, Y); // show the new value
}
old_value = current_value; // Update old_value

minimal variation on the code of HazardsMind - update the old value only when there is a other one.

int current_value = 0, old_value =-1; //set globally

current_value = analogRead(A0); // Read a value from analogpin 0

if (current_value != old_value) // Check to see if anything changed, if it did change show it, otherwise don't.
{
  //print("     ", X, Y); // clear that section of the lcd
  //print(current_value, X, Y); // show the new value
  old_value = current_value;   // Update old_value only if it is changed
}

I believe you have problem I've encountered and posted fix for it.

You probably using 5V system with 3.3V display.
See my original post here:
http://forum.arduino.cc/index.php?topic=177021.0