#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define TFT_DC1 4
#define TFT_CS1 5
Adafruit_ILI9341 tft1 = Adafruit_ILI9341(TFT_CS1, TFT_DC1);
int BtStartStop = 6;
int BtReset = 7;
bool EtatBtStartStop;
bool EtatBtReset;
int EtatBoutonAppuyer;
int EtatChronoOnOFF;
int TempsEcoule;
int Milliseconde;
int Seconde;
int Minute;
int Heure;
unsigned long currentTime = 0;
unsigned long previousTime = 0;
void setup() {
pinMode(BtStartStop, INPUT_PULLUP);
pinMode(BtReset, INPUT_PULLUP);
tft.begin();
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(21, 10);
tft.setTextColor(ILI9341_YELLOW,ILI9341_BLACK);
tft.setTextSize(3);
tft.println("CHRONOMETER");
tft1.begin();
tft1.fillScreen(ILI9341_BLACK);
tft1.setCursor(21, 10);
tft1.setTextColor(ILI9341_YELLOW,ILI9341_BLACK);
tft1.setTextSize(3);
tft1.println("BACKUP");
tft.setCursor(21, 46);
tft.setTextColor(ILI9341_WHITE,ILI9341_BLACK);
tft.setTextSize(2);
tft.println("test");
}
void loop()
{
EtatBtStartStop = digitalRead(BtStartStop);
EtatBtReset = digitalRead(BtReset);
if (EtatBtStartStop == LOW && EtatBoutonAppuyer == 0) {
EtatBoutonAppuyer = 1;
EtatChronoOnOFF = !EtatChronoOnOFF;
}
if (EtatBtReset == LOW && EtatChronoOnOFF == 0 && EtatBoutonAppuyer == 0) {
EtatBoutonAppuyer = 1;
Milliseconde = 0;
Seconde = 0;
Minute = 0;
Heure = 0;
}
if (EtatBtStartStop == HIGH && EtatBtReset == HIGH) {
EtatBoutonAppuyer = 0;
}
currentTime = millis();
TempsEcoule = currentTime - previousTime;
previousTime = millis();
if (EtatChronoOnOFF == 1) {
Milliseconde = Milliseconde + TempsEcoule;
if (Milliseconde > 999) {
Milliseconde = Milliseconde - 1000;
Seconde++;
}
if (Seconde > 59) {
Seconde = 0;
Minute++;
}
}
if (Milliseconde > 99) {
tft.setCursor(72, 72);
tft.println(Milliseconde);
}
else if (Milliseconde > 9 && Milliseconde < 100) {
tft.setCursor(72, 72);
tft.println("0");
tft.setCursor(84, 72);
tft.println(Milliseconde);
}
else if (Milliseconde > 0 && Milliseconde < 10) {
tft.setCursor(84, 72);
tft.println("00");
tft.setCursor(96, 72);
tft.println(Milliseconde);
}
else {
tft.setCursor(60, 72);
tft.println(":000");
}
tft.setCursor(24, 72);
tft.println(":");
if (Seconde < 10) {
tft.setCursor(36, 72);
tft.println("0");
tft.setCursor(48, 72);
tft.println(Seconde);
}
else {
tft.setCursor(36, 72);
tft.println(Seconde);
}
if (Minute < 10) {
tft.setCursor(0, 72);
tft.println("0");
tft.setCursor(12, 72);
tft.println(Minute);
}
else {
tft.setCursor(0, 72);
tft.println(Minute);
}
tft1.setCursor(0, 72);
tft1.println(millis());
}
Loading
ili9341-cap-touch
ili9341-cap-touch