Skip to content

Commit

Permalink
update power example
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitshaoxiang committed Nov 7, 2024
1 parent cedc6d1 commit 1a36e00
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions examples/Basic/power/power.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,32 @@
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.
// if using ext power input(Grove Port or DC input power supply) needs to be set to false.
// cfg.output_power = false;
CoreS3.begin(cfg);
CoreS3.Display.setTextSize(2);

CoreS3.Power.setChargeCurrent(200);
}

void loop()
{
CoreS3.Display.clear();
int bat_vol = CoreS3.Power.getBatteryVoltage();

bool bat_ischarging = CoreS3.Power.isCharging();
CoreS3.Display.setCursor(10, 30);
CoreS3.Display.printf("BAT: %dmv", bat_vol);
int bat_level = CoreS3.Power.getBatteryLevel();
CoreS3.Display.printf("Bat Charging: %d", bat_ischarging);

int bat_vol = CoreS3.Power.getBatteryVoltage();
CoreS3.Display.setCursor(10, 50);
CoreS3.Display.printf("BAT Level: %d", bat_level);
CoreS3.Display.printf("Bat Voltage: %dmv", bat_vol);

int bat_level = CoreS3.Power.getBatteryLevel();
CoreS3.Display.setCursor(10, 70);
CoreS3.Display.printf("Bat Level: %d", bat_level);

int vbus_vol = CoreS3.Power.getVBUSVoltage();
CoreS3.Display.setCursor(10, 90);
CoreS3.Display.printf("VBus Voltage: %dmv", vbus_vol);
delay(1000);
}

0 comments on commit 1a36e00

Please sign in to comment.