Skip to content

Commit

Permalink
add power setup example
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitshaoxiang committed Nov 6, 2024
1 parent 8c5dd9d commit cedc6d1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/Basic/power/power.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD
*
* SPDX-License-Identifier: MIT
*/

#include "M5CoreS3.h"

void setup()
{
auto cfg = M5.config();
// cfg.output_power = false; // if using ext power input(Grove Port or DC input power supply) needs to be set to
// false.
CoreS3.begin(cfg);
CoreS3.Display.setTextSize(2);
}

void loop()
{
CoreS3.Display.clear();
int bat_vol = CoreS3.Power.getBatteryVoltage();
CoreS3.Display.setCursor(10, 30);
CoreS3.Display.printf("BAT: %dmv", bat_vol);
int bat_level = CoreS3.Power.getBatteryLevel();
CoreS3.Display.setCursor(10, 50);
CoreS3.Display.printf("BAT Level: %d", bat_level);
delay(1000);
}

0 comments on commit cedc6d1

Please sign in to comment.