hello-stick.ino
Primeros píxeles en la miniestación: M5Unified gestiona la rotación y el framebuffer del ST7789 de 1,14". En horizontal 240x135, printf se vuelve una consola de depuración de bolsillo.
Hardware necesario
Un M5StickC Plus2 (ESP32-PICO-V3-02, pantalla de 135×240, botones A/B/C, zumbador pasivo en G2, IR + LED rojo en G19, IMU MPU6886, micrófono, batería de 200 mAh). Ninguno.
Cableado
Sin cableado. En la v2 sin PMIC: mantenga el botón C más de 2 s para encender; HOLD (G4) mantiene la alimentación a batería.
Funcionamiento
M5.begin detecta el panel y aplica la rotación; setTextColor/fillRect dibujan directamente. M5.update refresca los botones A (38), B (37) y C (35). En el Arduino IDE (paquete esp32), placa « M5StickCPlus2 »; biblioteca « M5StickCPlus2 » o M5Unified. En la v2 sin PMIC, mantenga el botón C más de 2 s para encender; HOLD (G4) mantiene la alimentación.
Para ir más lejos
Apague la pantalla con M5.Display.setBrightness(0) para ahorrar, o muestre la hora del sketch NTP.
hello-stick.ino
// Hello ST7789 — bibliotheque M5Unified (Gestionnaire de bibliotheques).
#include <M5Unified.h>
void setup() {
auto cfg = M5.config();
M5.begin(cfg);
M5.Display.setRotation(1); // paysage : 240 x 135
M5.Display.fillScreen(TFT_BLACK);
M5.Display.setTextColor(TFT_YELLOW);
M5.Display.setTextSize(2);
M5.Display.setCursor(4, 4);
M5.Display.println("StickC Plus2");
}
void loop() {
M5.update();
M5.Display.fillRect(0, 40, 240, 60, TFT_BLACK);
M5.Display.setCursor(4, 44);
M5.Display.setTextSize(1);
M5.Display.printf("millis : %lu\n", millis());
M5.Display.printf("heap : %u o\n", ESP.getFreeHeap());
M5.Display.printf("btn A : %d\n", M5.BtnA.isPressed());
delay(200);
}