Pages: [1]   Go Down
Author Topic: Flip/mirror a TFT LCD screen  (Read 327 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 3
Arduino Uno
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, long-time reader, first-time poster smiley

I've bought the Arduino 1.8" TFT LCD screen ( and am looking to develop a small HUD device for use in a car, to be reflected onto the windscreen by placing my unit on the dashboard beneath it. It's somewhat inspired by the Garmin HUD:

My current stumbling point is that the libraries do not have a built-in function that would flip/mirror the display in the same way that Processing offers the mirror function. I need to be able to flip the y-axis over so it can be read properly by the user.

I've had a good search across the internet and on the forum, and have found several people making HUDs or having problems where they initially have a flipped screen. The closest I've come to fixing it myself is this topic:, where the OP has started with a flipped screen, but then called a map to invert the axis to solve it for him. I have tried to do this myself byt haven't had much luck. I've looked into the adafruit gfx and st7735 libraries that the tft library is based on and can't find any functions to call on.

Here is the code I'm working with to try to flip the screen. It's just a counter at the moment as a timely reminder of how long I've been searching for a solution  smiley-razz The map part is in the setup area.

#include <TFT.h> // Hardware-specific library
#include <SPI.h>
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library

#define CS   10
#define DC   9
#define RESET  8 

// pin definition for the Leonardo
// #define CS   7
// #define DC   0
// #define RESET  1

TFT myScreen = TFT(CS, DC, RESET);

// variable to keep track of the elapsed time
unsigned long seconds = 0;
unsigned long newseconds = 0;
unsigned long minutes = 0;
unsigned long width = 160;
unsigned long height = 128;
// char array to print time
char printout[4];
char printout2[4];

void setup() {

//This is my test bed for trying to map a flip but failing miserably

   myScreen.width()= map(myScreen.width(),0,159,159,0);
   myScreen.height()= map(myScreen.height(),0,127,127,0);

//I'm aware this doesn't compile, I've tried a few things that don't work

  myScreen.background(0,0,0); // clear the screen
  // static text
  myScreen.text("Running for",0,0);
  // increase font size for text in loop()

void loop() {
     // get elapsed time
    seconds = millis();
    newseconds = (seconds - (minutes*60000));
    if (newseconds > 59999) {
    // convert to a string
    String elapsedMins = String(minutes);
    String elapsedSecs = String(newseconds/1000);
    // add to an array
    // print out and erase


Does anyone have any pointers as to where to go with this? Is mapping a good way about it?

Or is it something that could be written into the library?

Thanks for reading!

Pages: [1]   Go Up
Jump to: