Hi all,
I've successfully connected a 1.8" tft display, and have it displaying almost everything I want. In addition, I've connected a Chinese bought rotary encoder, which displays perfectly through the serial monitor. To really round out the experience, I can even get the display to emulate the serial monitor. Wow! What a great time I'm having.....
But, the serial monitor emulation only goes so far. My objective is to have a static display of the encoders activity at x,y co-ordinate on the tft display. What happens instead is that as I rotate the encoder, the serial monitor continues to scroll off the screen and print fresh numbers at the bottom of the window. No such luck with the display. The display fills until the bottom of it's screen, then although it's probably still outputting, it has nowhere to go, and the new co-ordinates aren't seen.
void loop()
{
boolean encoderA = digitalRead(encoderPinA);
if ((encoderALast == HIGH) && (encoderA == LOW))
{
if (digitalRead(encoderPinB) == LOW)
{
encoderPos--;
}
else
{
encoderPos++;
}
angle=(encoderPos % encoderStepsPerRevolution)*360/encoderStepsPerRevolution;
Serial.print (encoderPos);
Serial.print (" ");
Serial.println (angle);
// tft.setCursor(10,10);
// tft.setTextColor(ST7735_RED);
tft.setTextSize(1);
tft.print (" ");
tft.print (encoderPos);
tft.print (" ");
tft.println (angle);
//tft.print (encoderPos);
}
I've attempted to write a blank section i.e. tft.print(" ") but this doesn't seem to help. I can make it print in the same place each time, using tft.setCursor(x,y), which works except that it simply prints on top of the previous reading.
This can't be that complicated, but I'm starting to get frustrated, having made it this far.
I'd include links to the hardware, but since it's all working fine, I don't see any point.
Update: I've since also tried writing in the screen colour over the existing numbers, (as in a bouncing ball type program). The problem with doing this is that when the encoder stops moving, I'm left with black on black, which is difficult to read...
Any suggestions.....
Please......