HELLO Lesept,
j 'ai réussi
j'ai bien galéré avec les tableaux, les variables"i" et "j" etc....mais je m'en suis sorti!
Je te remercie pour tes précieux conseils.
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
// Library only supports hardware SPI at this time
// Connect SCLK to UNO Digital #13 (Hardware SPI clock)
// Connect MISO to UNO Digital #12 (Hardware SPI MISO)
// Connect MOSI to UNO Digital #11 (Hardware SPI MOSI)
#define RA8875_INT 3
#define RA8875_CS 10
#define RA8875_RESET 9
Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;
int i =0;
int j =0;
void setup()
{
Serial.begin(9600);
Serial.println("RA8875 start");
/* Initialize the display using 'RA8875_480x80', 'RA8875_480x128', 'RA8875_480x272' or 'RA8875_800x480' */
if (!tft.begin(RA8875_800x480)) {
Serial.println("RA8875 Not Found!");
while (1);
}
tft.displayOn(true);
tft.GPIOX(true); // Enable TFT - display enable tied to GPIOX
tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
tft.PWM1out(255);
tft.fillScreen(RA8875_WHITE);
/* Switch to text mode */
tft.textMode();
tft.cursorBlink(32);
}
void loop()
{
tft.textTransparent(RA8875_BLACK);
tft.textEnlarge(2);
char string[15] = "POS.";
char string1[15] = "TRACK";
char string2[15] = "TIME";
char string3[15] = "SPEED";
tft.textSetCursor(50, 24);
tft.textWrite(string);
tft.textSetCursor(250, 24);
tft.textWrite(string1);
tft.textSetCursor(450, 24);
tft.textWrite(string2);
tft.textSetCursor(650, 24);
tft.textWrite(string3);
//LIGNE
tft.drawLine(20, 96, 800, 96, RA8875_BLACK);
tft.drawLine(20, 192, 800, 192, RA8875_BLACK);
tft.drawLine(20, 288, 800, 288, RA8875_BLACK);
tft.drawLine(20, 384, 800, 384, RA8875_BLACK);
// COLONNE
tft.drawLine(200, 20, 200, 480, RA8875_BLACK);
tft.drawLine(400, 20, 400, 480, RA8875_BLACK);
tft.drawLine(600, 20, 600, 480, RA8875_BLACK);
// COLORIAGE DE LA CELLULE
// tft.fillRect(0, 88, 200, 88, RA8875_BLACK);
int piste [4]= {1,2,3,4};
char racechar [6];
float race [4][4] {
{1,2,3,4}, // classement
{4,2,1,3}, // numero des pistes
{5.022, 6.543, 8.876, 9.644}, // ecart
{645, 630,520,450}, // vitesse
} ;
// couleurs des afficheurs
int couleur[4] = {RA8875_RED, RA8875_YELLOW, RA8875_CYAN, RA8875_GREEN};
for (j =0; j<4;j++) // j permet de passer d'une voiture a une autre et de passer a la ligne suivante sur l'ecran
{
for (i=0; i<1;i++) // i permet d ecrire les données d'une voiture horizontalement à l'ecran
{
// faire un if si race 0/j est nul alors la voiture n est pas arrivée et donc ecire qquelque chose
// AFFICHAGE RESULT
tft.textTransparent(RA8875_BLACK);
tft.textSetCursor(60,100+(j*100));
tft.textEnlarge(2);
dtostrf(race[i][j], 2, 0, racechar);
tft.textWrite(racechar);
for (int k=0; k<4; k++)
{
if (race[i+1][j] == piste [k])
{ tft.fillRect(200,(race[0][j]*96), 200, 96, couleur[k]);
}}
// AFFICHAGE TRACK
tft.textTransparent(RA8875_BLACK);
tft.textSetCursor(280,100+(j*100));
tft.textEnlarge(2);
dtostrf(race[i+1][j], 1, 0, racechar);
tft.textWrite(racechar);
// AFFICHAGE CHRONO
tft.textTransparent(RA8875_BLACK);
tft.textSetCursor(440,100+(j*100));
tft.textEnlarge(2);
dtostrf(race[i+2] [j], 5, 3, racechar);
tft.textWrite(racechar);
// AFFICHAGE VITESSE
tft.textTransparent(RA8875_BLACK);
tft.textSetCursor(650,100+(j*100));
tft.textEnlarge(2);
dtostrf(race[i+3] [j], 3, 0, racechar);
tft.textWrite(racechar);
}
}
}