Probleme avec logiciel arduino et codes exemples tft

Bonjour a tous

Je débute dans la programmation sur arduino et je rencontre un problème sur un code fournis en exemple avec la carte TFT 1.8

http://www.ebay.com/itm/1-8-TFT-LCD-module-TF-Card-socket-break-out-for-arduino-/270866804157

// Pins SCLK and MOSI are fixed in hardware, and pin 10 (or 53)
// must be an output
//#define sclk 13 // for MEGAs use pin 52
//#define mosi 11 // for MEGAs use pin 51
#define cs 10 // for MEGAs you probably want this to be pin 53
#define dc 9
#define rst 8 // you can also connect this to the Arduino reset

// 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

#include <ST7735.h>
#include <SPI.h>

// Option 1: use any pins but a little slower
//ST7735 tft = ST7735(cs, dc, mosi, sclk, rst);

// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
ST7735 tft = ST7735(cs, dc, rst);

void fillpixelbypixel(uint16_t color) {
for (uint8_t x=0; x < tft.width; x++) {
for (uint8_t y=0; y < tft.height; y++) {
tft.drawPixel(x, y, color);
}
}
delay(100);
}

void setup(void) {
Serial.begin(9600);
Serial.print("hello!");
tft.initR(); // initialize a ST7735R chip

Serial.println("init");
tft.writecommand(ST7735_DISPON);

uint16_t time = millis();
tft.fillScreen(BLACK);
time = millis() - time;

Serial.println(time, DEC);
delay(500);

//
tft.fillScreen(BLACK);
testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", WHITE);
delay(10000);

//a single pixel
tft.drawPixel(tft.width/2, tft.height/2, GREEN);
delay(500);

// line draw test
testlines(YELLOW);
delay(500);

// optimized lines
testfastlines(RED, BLUE);
delay(500);

testdrawrects(GREEN);
delay(500);

testfillrects(YELLOW, MAGENTA);
delay(500);

tft.fillScreen(BLACK);
testfillcircles(10, BLUE);
testdrawcircles(10, WHITE);

Serial.println("done");
delay(1000);
}

void loop() {
tft.writecommand(ST7735_INVON);
delay(500);
tft.writecommand(ST7735_INVOFF);
delay(500);
}

void testlines(uint16_t color) {
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width; x+=6) {
tft.drawLine(0, 0, x, tft.height-1, color);
}
for (uint16_t y=0; y < tft.height; y+=6) {
tft.drawLine(0, 0, tft.width-1, y, color);
}

tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width; x+=6) {
tft.drawLine(tft.width-1, 0, x, tft.height-1, color);
}
for (uint16_t y=0; y < tft.height; y+=6) {
tft.drawLine(tft.width-1, 0, 0, y, color);
}

tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width; x+=6) {
tft.drawLine(0, tft.height-1, x, 0, color);
}
for (uint16_t y=0; y < tft.height; y+=6) {
tft.drawLine(0, tft.height-1, tft.width-1, y, color);
}

tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width; x+=6) {
tft.drawLine(tft.width-1, tft.height-1, x, 0, color);
}
for (uint16_t y=0; y < tft.height; y+=6) {
tft.drawLine(tft.width-1, tft.height-1, 0, y, color);
}

}

void testdrawtext(char *text, uint16_t color) {
tft.drawString(0, 0, text, color);
}

void testfastlines(uint16_t color1, uint16_t color2) {
tft.fillScreen(BLACK);
for (uint16_t y=0; y < tft.height; y+=5) {
tft.drawHorizontalLine(0, y, tft.width, color1);
}
for (uint16_t x=0; x < tft.width; x+=5) {
tft.drawVerticalLine(x, 0, tft.height, color2);
}
}

void testdrawrects(uint16_t color) {
tft.fillScreen(BLACK);
for (uint16_t x=0; x < tft.width; x+=6) {
tft.drawRect(tft.width/2 -x/2, tft.height/2 -x/2 , x, x, color);
}
}

void testfillrects(uint16_t color1, uint16_t color2) {
tft.fillScreen(BLACK);
for (uint16_t x=tft.width-1; x > 6; x-=6) {
tft.fillRect(tft.width/2 -x/2, tft.height/2 -x/2 , x, x, color1);
tft.drawRect(tft.width/2 -x/2, tft.height/2 -x/2 , x, x, color2);
}
}

void testfillcircles(uint8_t radius, uint16_t color) {
for (uint8_t x=radius; x < tft.width; x+=radius2) {
for (uint8_t y=radius; y < tft.height; y+=radius
2) {
tft.fillCircle(x, y, radius, color);
}
}
}

void testdrawcircles(uint8_t radius, uint16_t color) {
for (uint8_t x=0; x < tft.width+radius; x+=radius2) {
for (uint8_t y=0; y < tft.height+radius; y+=radius
2) {
tft.drawCircle(x, y, radius, color);
}
}
}

Après vérification du code par le logiciel j'ai en réponse: No matching function for call to 'ST7735::ST7735(int, int, int)'

J'ai bien installer la bibliothèque; j'ai fait de même avec le code de ladyada, et même réponse.

J'ai également essayer avec la version 1.5.2 et même réponse.
Quelqu'un aurait-il une idée pour résoudre le problème?

Merci d'avance.

seul erreur que je peut voir c'est ça :

ST7735 tft = ST7735(cs, dc, rst);

cs => define
dc => define
rst => define

Alors que la fonction te parle de ST7735::ST7735(int, int, int) avec des int...

Sa parait bien léger pour toute cette histoire mais bon xD

Si ce n'est pas ça j'en ai aucune idée ^^'

navré :grin:

Skizo !

Bonjour,

Donne le message d'erreur complet, à mon avis tu as juste installé la librairie de la mauvaise façon :wink:

Ps: mettre ton code entre balise code (bouton #)
PPs: skizoh, aurais-tu oublié qu'en C/C++ tout les nombres ce cast en int implicitement ? :wink:

Je m'appel pas B@TTO ! :astonished:

lol, et c'est pas que j'ai oublié, c'est que je voyais vraiment rien d'autre alors dans le doute sait-on jamais :grin:

SKIZO !

Humm, zut.
Tu n'as rien vue, nooon, tu n'as rien vue :grin:
(moi je dis c'est la faute de B@tto et puis voila :grin:)

Voici le résultat du message d'erreur avec le premier code du post:

In file included from sketch_jul11a.ino:19:
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:57: error: expected `)' before 'CS'
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:59: error: expected `)' before 'CS'
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:64: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:65: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:65: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:65: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:66: error: 'int16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:66: error: 'int16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:66: error: 'int16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:66: error: 'int16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:66: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:67: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:68: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:68: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:69: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:69: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:70: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:70: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:71: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:71: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:72: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:72: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:72: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:73: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:73: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:74: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:74: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:74: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:74: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:75: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:76: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:76: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:76: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:76: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:77: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:78: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:78: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:78: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:79: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:80: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:80: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:80: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:81: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:83: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:83: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:84: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:84: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:85: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:85: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:86: error: 'uint16_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:86: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:88: error: 'uint8_t' does not name a type
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:89: error: 'uint8_t' does not name a type
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:91: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:91: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:91: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:91: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:92: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:93: error: 'uint8_t' does not name a type
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:96: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:97: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:107: error: 'uint8_t' has not been declared
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:110: error: 'uint8_t' does not name a type
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:111: error: 'uint8_t' does not name a type
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:112: error: 'uint8_t' does not name a type
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:114: error: 'uint8_t' does not name a type

avec la version 1.0.2
idem avec la version 1.5.2.

Suite du message d'erreur:

sketch_jul11a:29: error: no matching function for call to 'ST7735::ST7735(int, int, int)'
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:55: note: candidates are: ST7735::ST7735()
C:\Users\md174161\Documents\Arduino\libraries\ST7735R/ST7735.h:55: note:                 ST7735::ST7735(const ST7735&)
sketch_jul11a.ino: In function 'void fillpixelbypixel(uint16_t)':
sketch_jul11a:32: error: 'class ST7735' has no member named 'width'
sketch_jul11a:33: error: 'class ST7735' has no member named 'height'
sketch_jul11a.ino: In function 'void setup()':
sketch_jul11a:61: error: 'class ST7735' has no member named 'width'
sketch_jul11a:61: error: 'class ST7735' has no member named 'height'
sketch_jul11a.ino: In function 'void testlines(uint16_t)':
sketch_jul11a:95: error: 'class ST7735' has no member named 'width'
sketch_jul11a:96: error: 'class ST7735' has no member named 'height'
sketch_jul11a:98: error: 'class ST7735' has no member named 'height'
sketch_jul11a:99: error: 'class ST7735' has no member named 'width'
sketch_jul11a:103: error: 'class ST7735' has no member named 'width'
sketch_jul11a:104: error: 'class ST7735' has no member named 'width'
sketch_jul11a:104: error: 'class ST7735' has no member named 'height'
sketch_jul11a:106: error: 'class ST7735' has no member named 'height'
sketch_jul11a:107: error: 'class ST7735' has no member named 'width'
sketch_jul11a:111: error: 'class ST7735' has no member named 'width'
sketch_jul11a:112: error: 'class ST7735' has no member named 'height'
sketch_jul11a:114: error: 'class ST7735' has no member named 'height'
sketch_jul11a:115: error: 'class ST7735' has no member named 'height'
sketch_jul11a:115: error: 'class ST7735' has no member named 'width'
sketch_jul11a:119: error: 'class ST7735' has no member named 'width'
sketch_jul11a:120: error: 'class ST7735' has no member named 'width'
sketch_jul11a:120: error: 'class ST7735' has no member named 'height'
sketch_jul11a:122: error: 'class ST7735' has no member named 'height'
sketch_jul11a:123: error: 'class ST7735' has no member named 'width'
sketch_jul11a:123: error: 'class ST7735' has no member named 'height'
sketch_jul11a.ino: In function 'void testfastlines(uint16_t, uint16_t)':
sketch_jul11a:134: error: 'class ST7735' has no member named 'height'
sketch_jul11a:135: error: 'class ST7735' has no member named 'width'
sketch_jul11a:137: error: 'class ST7735' has no member named 'width'
sketch_jul11a:138: error: 'class ST7735' has no member named 'height'
sketch_jul11a.ino: In function 'void testdrawrects(uint16_t)':
sketch_jul11a:144: error: 'class ST7735' has no member named 'width'
sketch_jul11a:145: error: 'class ST7735' has no member named 'width'
sketch_jul11a:145: error: 'class ST7735' has no member named 'height'
sketch_jul11a.ino: In function 'void testfillrects(uint16_t, uint16_t)':
sketch_jul11a:151: error: 'class ST7735' has no member named 'width'
sketch_jul11a:152: error: 'class ST7735' has no member named 'width'
sketch_jul11a:152: error: 'class ST7735' has no member named 'height'
sketch_jul11a:153: error: 'class ST7735' has no member named 'width'
sketch_jul11a:153: error: 'class ST7735' has no member named 'height'
sketch_jul11a.ino: In function 'void testfillcircles(uint8_t, uint16_t)':
sketch_jul11a:158: error: 'class ST7735' has no member named 'width'
sketch_jul11a:159: error: 'class ST7735' has no member named 'height'
sketch_jul11a.ino: In function 'void testdrawcircles(uint8_t, uint16_t)':
sketch_jul11a:166: error: 'class ST7735' has no member named 'width'
sketch_jul11a:167: error: 'class ST7735' has no member named 'height'

J'ai essaye un autre code avec une autre bibliothèque issue du site arduino.cc

Voici le code:

/*
  Arduino TFT text example
  
  This example demonstrates how to draw text on the 
  TFT with an Arduino. The Arduino reads the value 
  of an analog sensor attached to pin A0, and writes 
  the value to the LCD screen, updating every
  quarter second.
  
  This example code is in the public domain

  Created 15 April 2013 by Scott Fitzgerald
 
  http://arduino.cc/en/Tutorial/TFTDisplayText
 
 */

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

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8  

// pin definition for the Leonardo
// #define cs   7
// #define dc   0
// #define rst  1 

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// char array to print to the screen
char sensorPrintout[4];

void setup() {
  
  // Put this line at the beginning of every sketch that uses the GLCD:
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);
  
  // write the static text to the screen
  // set the font color to white
  TFTscreen.stroke(255,255,255);
  // set the font size
  TFTscreen.setTextSize(2);
  // write the text to the top left corner of the screen
  TFTscreen.text("Sensor Value :\n ",0,0);
  // ste the font size very large for the loop
  TFTscreen.setTextSize(5);
}

void loop() {

  // Read the value of the sensor on A0
  String sensorVal = String(analogRead(A0));
 
  // convert the reading to a char array
  sensorVal.toCharArray(sensorPrintout, 4);

  // set the font color
  TFTscreen.stroke(255,255,255);
  // print the sensor value
  TFTscreen.text(sensorPrintout, 0, 20);
  // wait for a moment
  delay(250);
  // erase the text you just wrote
  TFTscreen.stroke(0,0,0);
  TFTscreen.text(sensorPrintout, 0, 20);
}

et voici le message d'erreur obtenue:

TFTDisplayText.ino: In function 'void setup()':
TFTDisplayText:45: error: 'class TFT' has no member named 'background'
TFTDisplayText:49: error: 'class TFT' has no member named 'stroke'
TFTDisplayText:53: error: 'class TFT' has no member named 'text'
TFTDisplayText.ino: In function 'void loop()':
TFTDisplayText:67: error: 'class TFT' has no member named 'stroke'
TFTDisplayText:69: error: 'class TFT' has no member named 'text'
TFTDisplayText:73: error: 'class TFT' has no member named 'stroke'
TFTDisplayText:74: error: 'class TFT' has no member named 'text'

merci de votre aide.

Dans le tout premier lien ebay que tu as donné, la librairie qui est proposée au téléchargement semble assez vieille et n'est pas prévue pour fonctionner avec l'IDE >= 1.

Essaie de remplacer #include <WProgram.h> par #include <Arduino.h> à la sixième ligne du fichier ST7735.h pour voir si ça suffit à résoudre le problème.

Je sais pas si tu as déjà tester avec cette lib, mais je l'utilise sans problème avec un lcd similaire au tiens :
http://henningkarlsen.com/electronics/library.php?id=52