// *** TFT_Mesure : Exemple de programme d’utilisation de l’afficheur TFT ***
// *** L’afficheur affiche l’équivalent d’une jauge d’un voltage venant d’un pin analogique ***
// *******************************************************************************
#include <Adafruit_GFX.h> // include Adafruit graphics library
#include <Adafruit_ILI9341.h> // include Adafruit ILI9341 TFT library
#define ENTREE A0
#define TFT_CS 8 // TFT CS pin is connected to arduino pin 8
#define TFT_RST 9 // TFT RST pin is connected to arduino pin 9
#define TFT_DC 10 // TFT DC pin is connected to arduino pin 10
// Initialisation de la librairie ILI9341 TFT
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(9600);
Serial.println(“Jauge TFT”);
tft.begin();
tft.drawLine(20,20,220,20,ILI9341_GREEN);
tft.drawLine(20,21,220,21,ILI9341_GREEN);
tft.drawLine(20,20,20,60,ILI9341_GREEN);
tft.drawLine(21,20,21,60,ILI9341_GREEN);
tft.drawLine(20,60,220,60, ILI9341_GREEN);
tft.drawLine(20,59,220,59, ILI9341_GREEN);
tft.drawLine(220,20,220,60, ILI9341_GREEN);
tft.drawLine(219,20,219,60, ILI9341_GREEN);
pinMode(ENTREE, INPUT);
}
void loop(void) {
int nValue;
int nVal_Aff;
int nCpt;
nValue = analogRead(ENTREE);
nVal_Aff = map(nValue, 0, 1023, 20,219);
Serial.print(“Valeur lue : “);
Serial.println(nValue);
for(nCpt=20; nCpt < nVal_Aff; nCpt ++)
tft.drawLine (nCpt, 21, nCpt, 59, ILI9341_GREEN);
for(;nCpt < 219; nCpt ++)
tft.drawLine(nCpt, 21,nCpt, 59, ILI9341_BLACK);
}