Go Down

Topic: Flip/mirror a TFT LCD screen (Read 2070 times) previous topic - next topic


Hi, long-time reader, first-time poster :)

I've bought the Arduino 1.8" TFT LCD screen (http://arduino.cc/en/Main/GTFT) 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: http://forum.arduino.cc/index.php?topic=215574.0, 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  :P The map part is in the setup area.

Code: [Select]
#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!


Have you found a solution yet?   I'm looking to do something very similar with CAN bus data.   


Please post a link to the actual display that you are using.   I suspect that it is a 128x160 ST7735S display.

On most controllers you just need to change a single bit in the Manufacturer Panel Register.
With the ST7735S you have to flip MY in the MADCTL User register.


Go Up