Skip to content

Latest commit

 

History

History
106 lines (79 loc) · 2.23 KB

README.md

File metadata and controls

106 lines (79 loc) · 2.23 KB

M5Battery


📝 Overview

An M5Stack library for displaying battery charge.

🚀 Features

  • Display battery charge
  • Customize size and rotation


📦 Installation



  1. Initialize your Platform IO project
  2. platformio init -d . -b m5stack-core-esp32
  3. Install the library and its dependency
  4. platformio lib install M5Battery
    platformio lib install M5Unified

🔧 Usage

Warning This library has been tested only with M5Stack and M5StickC-PLUS.


#include <M5Unified.h>
#include <M5Battery.h>

M5Battery bat;

void setup() {
  auto cfg = M5.config();
  M5.begin(cfg);

  bat.init(0, 0);
}

void loop() {
  M5.update();
  
  if (M5.BtnA.wasPressed()) {
    if (bat.isDrawing()) {
      bat.hide();
    }
    else {
      bat.show();
    }
  }

  if (M5.BtnB.wasPressed()) {
    bat.setPosition(random(0, M5.Display.width()), random(0, M5.Display.height()));
    bat.setRotation(random(0, 3));
    bat.setSize(random(1, 7));
  }

  delay(100);
}

You can also read the module doc for a list of supported calls.


👀 Author

Yushin Ito

📜 License

MIT License