Hi, I like to put some values on the screen with LCD.DrawText( X.ToString(),MyFont1,blue,100,20);
X is an int. 1 to 255
It’s okay but if a new value is comming the old is still on the screen so on the end there is a big blue dot on the screen, with LCD.Clear(); the whole screen is to be clear so that is to good.
How can I solve that no all items disappear from the screen? :’(
Thanks
Normally, you just write the same text - at the same position - with background color to make it “disappear”.
So the background is black and the text color is red then I I write "LCD.DrawText( X.ToString(),MyFont1,red,100,20); like this.
If you wrote it the first time with red, then you write it the second time with black - the background color.
Hereby an examply code:
for (i = 10; i < 200; i += 4)
{
LCD.DrawText(i.ToString(), MyFont1, Colors. Red, 250, 175);
LCD.Flush();
Thread.Sleep(50);
LCD.DrawText(" ", MyFont1, Colors.Black, 250, 175);
//LCD.Clear();
LCD.Flush();
Thread.Sleep(22);
}
But nothing change, same big Red dot.
You must clear the lcd bitmap before the second drawtext
If you just want to remove that dot, write a dot in black over it. Drawing just a space will do nothing… spaces are not visible
I use now this code and it’s help but now the total TFT Display is clear.
LCD.Clear();
int i;
for (i = 1; i < 20; i += 1)
{
LCD.DrawText(i.ToString(), MyFont1, Colors.Orange, 250, 175);
LCD.Flush();
Thread.Sleep(50);
LCD.Clear();
LCD.Flush();
Thread.Sleep(22);
}
Thread.Sleep(-1);
Now replace LCD.Clear with:
LCD.DrawText(i.ToString(), MyFont1, Colors.Black, 250, 175);
This is better, DrawText “Value” is not blinking and variable i is running from 1 to 200
LCD.Clear();
while (true)
{
int i;
for (i = 1; i < 200; i += 1)
{ //Hor, Vert
LCD.DrawText("Value =", MyFont1, Colors.Green, 150, 175);
LCD.DrawText(i.ToString(), MyFont1, Colors.Orange, 250, 175);
LCD.Flush();
Thread.Sleep(500);
LCD.Clear();
LCD.DrawText("Value =", MyFont1, Colors.Green, 150, 175);
LCD.Flush();
Thread.Sleep(1);
}
i = 0;
Thread.Sleep(25);
}
}
}
But the point is, as was pointed out, if you don’t want to flush the screen (if you have a lot of other text for instance) then all you really need to do is replace the coloured text with the black text (same as background)
LCD.Clear();
int i;
LCD.DrawText("Value =", MyFont1, Colors.Green, 150, 175);
for (i = 1; i < 20; i += 1)
{
LCD.DrawText(i.ToString(), MyFont1, Colors.Orange, 250, 175);
LCD.Flush();
Thread.Sleep(50);
LCD.DrawText(i.ToString(), MyFont1, Colors.Black, 250, 175);
LCD.Flush();
Thread.Sleep(22);
}
oh look at that, code in a code block.
The above means you only write the placeholder text once not every loop
Or you could just draw a rect over the region w the proper backcolor…
What do you mean about "draw a rect over the region w the proper backcolor…"
Please make an example code.
Thanks
Hi Brett,
It’s run now better. The Text "Value = " is clear on the TFT screen and var. i change very nice.
thanks ;D