Go Down

Topic: noob: Shield w/ spfd5408 controller 240x320 - I don't know which library (Read 37937 times) previous topic - next topic

bricofoy

Hi

I have two of these 2.4" lcd shields, wich should be with a spfd5408 driver chip inside.

With the modified UTFT or with this TFTLCD library, I got a similar problem on both displays : One is displaying the graphics OK, but displays also horizontal lines wich covers the displayed graphics.
The other one is displaying graphics but with missing segments.
Maybe in both case it can be a connection hardware, e.g. two pins inverted, or something like that. But I can't find out where.
Can someone help me on this, please ?
-tu savais que si tu passe le CD de windows à l'envers, tu entends une chanson satanique ?
-non, mais il y a pire : à l'endroit, ça l'installe !

Viktor86

Hello,

I also bought this type of TFT-LCD.

My problem is, that I can not compile the graphicstest.ino File of the example folder.

I included the files.

But by clicking on compile I receive an error message:


What is wrong???

Arduino: 1.6.0 (Windows 7), Platine: "Arduino Nano, ATmega328"

graphicstest.cpp.o: In function `testFillRoundRect()':
/Arduino/graphicstest.ino:66: undefined reference to `TFTLCD::fillScreen(unsigned int)'
/Arduino/graphicstest.ino:68: undefined reference to `TFTLCD::width()'
/Arduino/graphicstest.ino:69: undefined reference to `TFTLCD::Color565(unsigned char, unsigned char, unsigned char)'
/Arduino/graphicstest.ino:69: undefined reference to `TFTLCD::height()'
/Arduino/graphicstest.ino:69: undefined reference to `TFTLCD::width()'
/Arduino/graphicstest.ino:69: undefined reference to `TFTLCD::fillRoundRect(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)'
graphicstest.cpp.o: In function `testRoundRect()':

.......

Viktor86

I found that I must copy the Folder TFTLCD with  the files TFTLCD.h and TFTLCD.cpp and glcdfont.c to
Arduino/libraries.

After this, I receive another error:


C:\Program Files\Arduino\libraries\TFTLCD\glcdfont.c:9:23: error: variable 'font' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 static unsigned char  font[] PROGMEM = {
                       ^
Fehler beim Kompilieren.

What is the problem?

Viktor86

Ok, everything is working fine!

I used the code from http://www.smokeandwires.co.nz/blog/a-2-4-tft-touchscreen-shield-for-arduino/.

my_legend_mm

Hi every one .
Viktor86 how you solve this error .
Code: [Select]

C:\Program Files\Arduino\libraries\TFTLCD\glcdfont.c:9:23: error: variable 'font' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 static unsigned char  font[] PROGMEM = {


the is some library compile and load in Arduino Uno but the LCD still only white :( , and the serial monitor  find LCD Identifier is 139 .
any one can help me .


hikko

Hello everybody, this is my first post here, I really felt the need to help those who have been struggling with this kind of LCD displays like me. Finally, and thanks to the replies in this topic and further research, I found out how to get the paint example to work:

First of all, I downloaded the libraries linked in this post:
let me know if this works

https://docs.google.com/a/cxo-on-demand.com/file/d/0By0GEVVJbBtSZktxaEtJZGNlcGM/edit

After that, I had the same problem that My_legend_mm and Viktor86:
Hi every one .
Viktor86 how you solve this error .
Code: [Select]

C:\Program Files\Arduino\libraries\TFTLCD\glcdfont.c:9:23: error: variable 'font' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 static unsigned char  font[] PROGMEM = {


the is some library compile and load in Arduino Uno but the LCD still only white :( , and the serial monitor  find LCD Identifier is 139 .
any one can help me .


So, in order to fix that, I opened the glcdfont.c file, and changed this line:
Code: [Select]
static unsigned char  font[] PROGMEM = {
to this:
Code: [Select]
static const unsigned char  font[] PROGMEM = {

Then, I proceeded to change the code into what Prankster posted (I'm still trying to figure out what did he exactly change)
I managed to get the SPFD5408 2.4" TFT display working with the libraries that were listed in this topic located on the google code site. I had to make some minor changes to the tftpaint sketch to get it working semi-ok..  I cannot seem to figure out why the x,y coordinates move in the opposite direction that I am drawing in.  eg. if I try to draw a line from top to bottom, it starts at the bottom and goes up instead.. same with side to side. Not sure if something is wrong with the libraries or the sketch.  I posted the sketch code for review..

Thanks.

Code: [Select]
#include "TFTLCD.h"
#include "TouchScreen.h"

//Duemilanove/Diecimila/UNO/etc ('168 and '328 chips) microcontoller:

#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

#define LCD_CS A3
#define LCD_RS A2
#define LCD_WR A1
#define LCD_RD A0
// optional
#define LCD_RESET A4

// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0
#define WHITE           0xFFFF



TFTLCD tft(LCD_CS, LCD_RS, LCD_WR, LCD_RD, LCD_RESET);

#define BOXSIZE 40
#define PENRADIUS 6

int oldcolor, currentcolor;

void setup(void) {
  Serial.begin(9600);
  Serial.println("Paint!");
  
  tft.reset();

  tft.initDisplay();
  tft.fillScreen(BLACK);
  
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, BLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA);
 // tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, WHITE);
 
 tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
 currentcolor = RED;
 
  pinMode(13, OUTPUT);
}

#define MINPRESSURE 10
// #define MAXPRESSURE 1000

void loop()
{
  digitalWrite(13, HIGH);
  Point p = ts.getPoint();
  digitalWrite(13, LOW);


  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //pinMode(YM, OUTPUT);

  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  //if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
  if (p.z > MINPRESSURE) {  
    Serial.print("X = "); Serial.print(p.x);
    Serial.print("\tY = "); Serial.print(p.y);
    Serial.print("\tPressure = "); Serial.println(p.z);
    
    if (p.y > (TS_MAXY-5)) {
      Serial.println("erase");
     // press the bottom of the screen to erase
      tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
    }
    // turn from 0->1023 to tft.width
    p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
    p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);

    if (p.y < BOXSIZE) {
       oldcolor = currentcolor;
 
       if (p.x < BOXSIZE) {
         currentcolor = RED;
         tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*2) {
         currentcolor = YELLOW;
         tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*3) {
         currentcolor = GREEN;
         tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*4) {
         currentcolor = CYAN;
         tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*5) {
         currentcolor = BLUE;
         tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, WHITE);
       }
       else if (p.x < BOXSIZE*6) {
         currentcolor = MAGENTA;
         tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE);
       }
      
       if (oldcolor != currentcolor) {
          if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
          if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
          if (oldcolor == GREEN) tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, GREEN);
          if (oldcolor == CYAN) tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, CYAN);
          if (oldcolor == BLUE) tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, BLUE);
          if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, MAGENTA);
       }
    }
    if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
      tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
    }
  }
}

But still had the weird coordinates bug, so, following the advise from iracso59, on the tftpaint.ino file, i had to change this:
Code: [Select]
   p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
    p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);


to this:
Code: [Select]
   p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
    p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());


And now it is working properly. I hope this helps you all.

Greetings and thank you for everything!

JoaoLopesF

Hi,

After trying for several days trying the solutions thats I found in the web.
None works 100 % for my TFT 2.4.

So I decided to make a specific library for this controller.

It is available on GitHub: https://github.com/JoaoLopesF/SPFD5408

Please notify me if there are questions or problems.

Regards
Joao Lopes

jirakst

Hello,

I have this 2.4" TFT LCD with SPFD5408 controller http://www.banggood.com/2_4-Inch-TFT-LCD-Shield-Touch-Board-Display-Module-For-Arduino-UNO-p-940735.html.
I've tried all libraries I've found on the web including the one that JoaoLopesF just posted but none of them works for me.
Beside that, my entirely brand new (Arduino) Uno R3 from eBay seems to be not working now (it has been powered from USB and only the LCD shield has been connected, have had it for 2 hours until now).
Quote
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xb3
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xb3
Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.
avrdude: ser_send(): write error: sorry no info avail

treereaver

I have two of these screens and a number of Arduinos, both genuine and clone (Uno and Mega),  neither screen does anything except show a plain white field.  The 4wire touch screen library and example occasionally gives one reading, never more,  then needs a reset to perhaps show another x,y, pressure reading.  Is there any, simple way to check the functionality of this device?  I am not happy to ask for a replacement if the problem is in the software; on the other hand I don't want to spend days/weeks trying to get a dodgy screen working.  Any help would be greatly appreciated.

Go Up