1.Open Arduino IDE,Select File
->preference
->Setting
2.Copy the M5Stack board management URL below into Additional Development Board Manager:
https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/arduino/package_m5stack_index.json
3.Select Tools
->Development Board:
->Development Board Manager...
4.In the new dialog box that pops up, type and search for M5Stack
and click Install
(if the search fails, you can try restarting the Arduino program)
Note: STAMP-S3 requires at least 2.0.6-1.0 or later to compile
5.Select Tools
->Development Board:
->M5Stack Arduino
, the master used by Cardputer is M5StampS3, so select (STAMP-S3
) in this option.
Different hardware devices have different case libraries, please choose to download according to the device you use. Open the Arduino IDE and select Project
-> Load Library
-> Library Management...
Cardputer relies on the M5Unified and M5GFX libraries. When using Arduino libraries to manage downloads, follow the prompts to download the dependent libraries or manually pull them to the local via the Github link below.
Keyboard class calls the interface in M5GFX and displays the status of the keys on the screen. Please refer to more API
Keyboard_Class
.Note: You need to add M5Cardputer.update() to the main loop;
Used to refresh key status.
#include "M5Cardputer.h"
void setup() {
auto cfg = M5.config();
M5Cardputer.begin(cfg);
}
void loop() {
M5Cardputer.update();
if (M5Cardputer.Keyboard.isChange()) {
if (M5Cardputer.Keyboard.isKeyPressed(KB_KEY_L_M)) {
}
}
}
The Cardputer library invokes the M5Unified
API on the drivers of some built-in peripherals, so the operation and use are similar.
#include "M5Cardputer.h"
void setup() {
//Most of the built-in peripherals are initialized with M5Dial.begin().
M5Cardputer.begin();
//Set font color
M5Cardputer.Display.setTextColor(GREEN);
//Set the font to its mode
M5Cardputer.Display.setTextDatum(middle_center);
//set font
M5Cardputer.Display.setTextFont(&fonts::Orbitron_Light_32);
//font-size
M5Cardputer.Display.setTextSize(1);
//Print Text File
M5Cardputer.Display.drawString("Hello World", M5Cardputer.Display.width() / 2,
M5Cardputer.Display.height() / 2);
}
void loop() {
}
The Button class invokes the interface in M5Unified and can obtain the state of button press, release, and long press. Please refer to more API Button_Class .The Button class invokes the interface in M5Unified and can obtain the state of button press, release, and long press. Please refer to more API
#include "M5Cardputer.h"
void setup() {
auto cfg = M5.config();
M5Cardputer.begin(cfg);
}
void loop() {
M5Cardputer.update();
if (M5Cardputer.BtnA.wasPressed()) {
}
if (M5Cardputer.BtnA.wasReleased()) {
}
}