m5paper_touch_read.ino
Demonstrates capacitive touch interaction on the e-Ink screen by drawing a dot where the user touches.
Uses the M5EPD library. The screen is set to 90-degree rotation. The loop checks touch state via M5.TP. Refresh uses UPDATE_MODE_DU4 for fast partial updates.
m5paper_touch_read.ino
#include <M5EPD.h>
M5EPD_Canvas canvas(&M5.EPD);
void setup() {
M5.begin();
M5.EPD.SetRotation(90);
M5.EPD.Clear(true);
canvas.createCanvas(480, 800); // Rotation 90 deg
canvas.setTextSize(3);
canvas.drawCentreString("Touch Screen", 240, 400, 4);
canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
}
void loop() {
M5.update();
if (M5.TP.Touched()) {
int x = M5.TP.readX();
int y = M5.TP.readY();
// Effacer l'ancienne position (simple exemple)
canvas.drawCircle(240, 400, 20, G16_BLACK);
canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
// Dessiner un nouveau point
canvas.drawCircle(x, y, 10, G16_BLACK);
canvas.pushCanvas(0, 0, UPDATE_MODE_DU4);
delay(200);
}
}