pdf-icon

Arduino Quick Start

Cardputer Button

M5Cardputer keystroke input related APIs and case programs.

Note:
Include M5Cardputer.update() function in the main loop to read status update and minimize blocking, otherwise you may not be able to retrieve the status of key changes in time.

Example

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include "M5Cardputer.h"
void setup() {
auto cfg = M5.config();
M5Cardputer.begin(cfg);
}
void loop() {
M5Cardputer.update();
if (M5Cardputer.BtnA.wasPressed()) {
Serial.println("Pressed");
}
if (M5Cardputer.BtnA.wasReleased()) {
Serial.println("Released");
}
}

API

M5Cardputer library is based on the M5Unified library, the key part uses the Button_Class in the M5Unified library, for more key related APIs you can refer to the following document:

On This Page