toughc5_ili9342c_touch_ui.ino
Simple UI showing color display and capacitive touch detection.
Uses the M5ToughC5 integrated graphics library for the ILI9342C panel. The screen is 320x240 pixels. The code displays X/Y coordinates of the touch press. Brightness is handled automatically by the library.
toughc5_ili9342c_touch_ui.ino
#include <M5ToughC5.h>
void setup() {
M5.begin();
M5.Display.init();
// Remplir l'écran de noir
M5.Display.fillScreen(BLACK);
// Afficher du texte
M5.Display.setTextColor(WHITE);
M5.Display.setTextSize(2);
M5.Display.setCursor(10, 10);
M5.Display.println("M5ToughC5 Touch");
M5.Display.setTextColor(CYAN);
M5.Display.setCursor(10, 40);
M5.Display.println("Tap the screen...");
}
void loop() {
M5.update();
if (M5.Touch.isPressed()) {
uint16_t x, y;
M5.Touch.getPoint(&x, &y);
// Effacer l'écran et afficher les coordonnées
M5.Display.fillScreen(BLACK);
M5.Display.setTextColor(YELLOW);
M5.Display.setTextSize(3);
M5.Display.setCursor(10, 100);
M5.Display.printf("X: %d\nY: %d", x, y);
// Petit bip pour feedback
M5.Speaker.tone(1000, 50);
delay(200); // Anti-rebond tactile
}
}