first commit

This commit is contained in:
Jérôme Delacotte
2025-03-06 11:15:32 +01:00
commit 7b30d6e298
5276 changed files with 2108927 additions and 0 deletions

145
TFT_ESSAI/TFT_ESSAI.ino Executable file
View File

@@ -0,0 +1,145 @@
//Analog Clock Sketch created by Embedded Downloads LTD
//To view the full tutorial go to www.embeddeddownloads.com
#include <Adafruit_GFX_AS.h> // Core graphics library
#include <Adafruit_ILI9341_8bit_AS.h>// Hardware-specific library
#include <TouchScreen.h>
// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the tft paint example).
#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin
// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).
// These are the pins for the shield!
#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 MINPRESSURE 10
#define MAXPRESSURE 1000
// 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);
// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
Adafruit_ILI9341_8bit_AS tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
int x = 0;
int y = 0;
void setup() {
Serial.begin(9600);
tft.reset();
delay(10);
tft.begin(0x9341);
uint16_t identifier = tft.readID();
Serial.println(identifier, HEX);
tft.fillScreen(BLACK);
Serial.println("tft LCD test");
Serial.print("tft size is ");
Serial.print(tft.width());
Serial.print("x");
Serial.println(tft.height());
tft.fillCircle(120, 160, 10, BLUE);
}
void loop(void) {
int x1, y1, x2, y2,
w = tft.width(),
h = tft.height();
// // a point object holds x y and z coordinates
// TSPoint p = ts.getPoint();
//
// // we have some minimum pressure we consider 'valid'
// // pressure of 0 means no pressing!
// if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
//
//
// Serial.print("X = "); Serial.print(p.x);
// Serial.print("\tY = "); Serial.print(p.y);
// Serial.print("\tPressure = "); Serial.println(p.z);
//
// tft.reset();
// delay(10);
// tft.begin(0x9341);
// tft.fillScreen(BLACK);
////
////
// tft.fillCircle(50, 50, 10, RED);
// }
delay(100);
//tft.begin(0x9341);
testCircles(10, BLUE);
}
unsigned long testCircles(uint8_t radius, uint16_t color) {
unsigned long start;
int x, y, r2 = radius * 2,
w = tft.width() + radius,
h = tft.height() + radius;
// Screen is not cleared for this one -- this is
// intentional and does not affect the reported time.
start = micros();
tft.fillScreen(BLACK);
for(x=0; x<w; x+=r2) {
for(y=0; y<h; y+=r2) {
// tft.fillScreen(BLACK);
tft.drawCircle(x, y, radius, color);
}
}
delay(1000);
tft.fillRect(0,11,140,11,WHITE);
tft.fillRect(0,43,140,11,WHITE);
tft.fillRect(0,59,140,11,WHITE);
tft.fillRect(0,75,140,11,WHITE);
tft.fillRect(0,107,140,11,WHITE);
tft.fillRect(0,123,140,11,WHITE);
tft.fillRect(0,155,140,11,WHITE);
tft.fillRect(0,171,140,11,WHITE);
tft.fillRect(0,187,140,11,WHITE);
tft.fillRect(0,219,140,11,WHITE);
tft.fillRect(0,235,140,11,WHITE);
tft.fillRect(0,267,140,11,WHITE);
tft.fillRect(0,283,140,11,WHITE);
tft.fillRect(0,299,140,11,WHITE);
delay(1000);
return micros() - start;
}