m5paper_touch_canvas.ino
Allows drawing shapes on the e-Ink screen by reacting to capacitive touches.
Uses the integrated GT911 driver. The touchGetRaw() function checks for touch activity. Coordinates are read via touchGetXY(). Due to the nature of e-Ink, full refresh is slow, so updateFrame() is called after each action for immediate visual feedback.
m5paper_touch_canvas.ino
#include <M5EPD.h>
M5EPD m5;
void setup() {
m5.begin();
m5.clear();
m5.updateFrame();
Serial.begin(115200);
}
void loop() {
// Vérifier si un touch a été détecté
if (m5.touchGetRaw()) {
uint16_t x, y;
uint8_t id;
// Lire les coordonnées du touch
m5.touchGetXY(&x, &y, &id);
// Dessiner un pixel ou une forme à la position touchée
// Note: L'e-Ink a un temps de rafraîchissement, dessiner des lignes continues est lent
m5.drawCircle(x, y, 5, 0); // Dessine un cercle noir
// Rafraîchir partiellement pour une meilleure réactivité
m5.updateFrame();
delay(50); // Petit délai pour éviter le surchargement
}
}