
Arduino Quick Start
API references and example programs related to the Paper rotary encoder button.
#include <M5Unified.h>
#include <M5GFX.h>
void setup() {
M5.begin();
M5.Display.setRotation(0);
M5.Display.setFont(&fonts::FreeMonoBold24pt7b);
M5.Display.setEpdMode(epd_fast); // epd_quality, epd_text, epd_fast, epd_fastest
Serial.begin(115200);
M5.Display.clear();
M5.Display.setCursor(20, 100);
M5.Display.print("Rotary Button Test");
Serial.println("Rotary Button Test");
M5.Display.setCursor(40, 300);
M5.Display.print("____ was pressed");
}
void loop() {
M5.update();
if (M5.BtnA.wasPressed()) {
M5.Display.setCursor(40, 300);
M5.Display.print("BtnA was pressed");
Serial.println("BtnA was pressed");
}
if (M5.BtnB.wasPressed()) {
M5.Display.setCursor(40, 300);
M5.Display.print("BtnB was pressed");
Serial.println("BtnB was pressed");
}
if (M5.BtnC.wasPressed()) {
M5.Display.setCursor(40, 300);
M5.Display.print("BtnC was pressed");
Serial.println("BtnC was pressed");
}
}This program will display the button states on the screen. BtnA corresponds to rotating the wheel upward (G37), BtnB corresponds to pressing the wheel (G38), and BtnC corresponds to rotating the wheel downward (G39).
The Paper button section uses the Button_Class from the M5Unified library. For more related APIs, refer to the documentation below: