mirror of
https://gitlab.dit.htwk-leipzig.de/phillip.kuehne/dezibot.git
synced 2025-05-19 11:01:46 +02:00
Add power test cases
This commit is contained in:
parent
2b57f300f2
commit
ef8a757772
@ -0,0 +1,29 @@
|
|||||||
|
#include "Dezibot.h"
|
||||||
|
// Output CSV-Data about the power state on secondary UART mapped to bottom
|
||||||
|
// header
|
||||||
|
|
||||||
|
// Using alternate Serial pins to not be powered by the USB port
|
||||||
|
#define RXD_HEADER 16
|
||||||
|
#define TXD_HEADER 17
|
||||||
|
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
dezibot.begin();
|
||||||
|
Serial1.begin(9600, SERIAL_8N1, RXD_HEADER, TXD_HEADER);
|
||||||
|
Serial1.printf("Timestamp (ms),Current (mA),charge (%%),charge (C),voltage (V),isUSBPowered,isBatteryPowered,isBatteryCharging,isBatteryDischarging,isBatteryFullyCharged\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Serial1.printf("%d,%f,%f,%f,%f,%d,%d,%d,%d,%d\r\n",
|
||||||
|
millis(),
|
||||||
|
dezibot.power.getCurrentCurrent(),
|
||||||
|
dezibot.power.getBatteryChargePercent(),
|
||||||
|
dezibot.power.getBatteryChargeCoulombs(),
|
||||||
|
dezibot.power.getBatteryVoltage(),
|
||||||
|
dezibot.power.isUSBPowered(), dezibot.power.isBatteryPowered(),
|
||||||
|
dezibot.power.isBatteryCharging(),
|
||||||
|
dezibot.power.isBatteryDischarging(),
|
||||||
|
dezibot.power.isBatteryFullyCharged());
|
||||||
|
sleep(1);
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
#include "Dezibot.h"
|
||||||
|
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
dezibot.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
float i_3v3;
|
||||||
|
float i_bat;
|
||||||
|
float bat_chargePercent;
|
||||||
|
float bat_coloumbs;
|
||||||
|
float bat_voltage;
|
||||||
|
bool isUSBPowered;
|
||||||
|
bool isCharging;
|
||||||
|
bool isFullyCharged;
|
||||||
|
|
||||||
|
char i3v3_line[26];
|
||||||
|
char ibat_line[26];
|
||||||
|
char bat_chargePercent_line[26];
|
||||||
|
char bat_coloumbs_line[26];
|
||||||
|
char bat_voltage_line[26];
|
||||||
|
char isUSBPowered_line[26];
|
||||||
|
char isCharging_line[26];
|
||||||
|
char isFullyCharged_line[26];
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
i_3v3 = dezibot.power.getCurrentCurrent();
|
||||||
|
i_bat = dezibot.power.getBatteryCurrent();
|
||||||
|
bat_chargePercent = dezibot.power.getBatteryChargePercent();
|
||||||
|
bat_coloumbs = dezibot.power.getBatteryChargeCoulombs();
|
||||||
|
bat_voltage = dezibot.power.getBatteryVoltage();
|
||||||
|
isUSBPowered = dezibot.power.isUSBPowered();
|
||||||
|
isCharging = dezibot.power.isBatteryCharging();
|
||||||
|
isFullyCharged = dezibot.power.isBatteryFullyCharged();
|
||||||
|
|
||||||
|
sprintf(i3v3_line, "i_3v3: %.1f mA", i_3v3);
|
||||||
|
sprintf(ibat_line, "i_bat: %.1f mA", i_bat);
|
||||||
|
sprintf(bat_chargePercent_line, "CHG: %.2f %%", bat_chargePercent);
|
||||||
|
sprintf(bat_coloumbs_line, "CHG: %.2f C", bat_coloumbs);
|
||||||
|
sprintf(bat_voltage_line, "U: %.2f3V", bat_voltage);
|
||||||
|
sprintf(isUSBPowered_line, "USBPower: %d", isUSBPowered);
|
||||||
|
sprintf(isCharging_line, "Charging: %d", isCharging);
|
||||||
|
sprintf(isFullyCharged_line, "Full: %d", isFullyCharged);
|
||||||
|
|
||||||
|
dezibot.display.clear();
|
||||||
|
dezibot.display.println(i3v3_line);
|
||||||
|
dezibot.display.println(ibat_line);
|
||||||
|
dezibot.display.println(bat_chargePercent_line);
|
||||||
|
dezibot.display.println(bat_coloumbs_line);
|
||||||
|
dezibot.display.println(bat_voltage_line);
|
||||||
|
dezibot.display.println(isUSBPowered_line);
|
||||||
|
dezibot.display.println(isCharging_line);
|
||||||
|
dezibot.display.println(isFullyCharged_line);
|
||||||
|
delay(1000);
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
#include "Dezibot.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This serves as an example of how to use the power management system deals with gradual changes.
|
||||||
|
* The ColorCycle example is a good one, because it contains gradual overstepping of the power budget,
|
||||||
|
* with the effect being easily visible.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Dezibot dezibot = Dezibot();
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
dezibot.begin();
|
||||||
|
Serial.begin(115200);
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
for (int d = 0; d < 255; d++) {
|
||||||
|
dezibot.multiColorLight.setLed(
|
||||||
|
ALL, dezibot.multiColorLight.color(d, 0, 255 - d));
|
||||||
|
delay(2);
|
||||||
|
Serial.printf("current: %f, battery: %f\r\n",
|
||||||
|
dezibot.power.getCurrentCurrent(),
|
||||||
|
dezibot.power.getBatteryChargePercent());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int d = 0; d < 255; d++) {
|
||||||
|
dezibot.multiColorLight.setLed(
|
||||||
|
ALL, dezibot.multiColorLight.color(255 - d, d, 0));
|
||||||
|
delay(2);
|
||||||
|
Serial.printf("current: %f, battery: %f\r\n",
|
||||||
|
dezibot.power.getCurrentCurrent(),
|
||||||
|
dezibot.power.getBatteryChargePercent());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int d = 0; d < 255; d++) {
|
||||||
|
dezibot.multiColorLight.setLed(
|
||||||
|
ALL, dezibot.multiColorLight.color(0, 255 - d, d));
|
||||||
|
delay(2);
|
||||||
|
Serial.printf("current: %f, battery: %f\r\n",
|
||||||
|
dezibot.power.getCurrentCurrent(),
|
||||||
|
dezibot.power.getBatteryChargePercent());
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,11 @@
|
|||||||
#include "Dezibot.h"
|
#include "Dezibot.h"
|
||||||
|
|
||||||
std::Dezibot dezibot;
|
/*
|
||||||
|
* This serves as an example of how to use the power management system deals with huge requests
|
||||||
|
* for power on an already heavily loaded system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Dezibot dezibot;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
dezibot.begin();
|
dezibot.begin();
|
||||||
@ -12,7 +17,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
Serial.println("Starting Power Management Test");
|
Serial.println("Starting Power Management Test");
|
||||||
Serial.println("Status on end of setup:");
|
Serial.println("Status on end of setup:");
|
||||||
|
|
||||||
dezibot.power.dumpPowerStatistics();
|
dezibot.power.dumpPowerStatistics();
|
||||||
dezibot.power.dumpConsumerStatistics();
|
dezibot.power.dumpConsumerStatistics();
|
||||||
}
|
}
|
||||||
@ -28,15 +33,15 @@ void loop() {
|
|||||||
dezibot.multiColorLight.setLed(ALL, 0x00FFFFFF);
|
dezibot.multiColorLight.setLed(ALL, 0x00FFFFFF);
|
||||||
Serial.println("Turned on all RGB LEDs");
|
Serial.println("Turned on all RGB LEDs");
|
||||||
dumpInfoAndWait();
|
dumpInfoAndWait();
|
||||||
|
|
||||||
dezibot.motion.move();
|
dezibot.motion.move();
|
||||||
Serial.println("Turned on all motors");
|
Serial.println("Turned on all motors");
|
||||||
dumpInfoAndWait();
|
dumpInfoAndWait();
|
||||||
|
|
||||||
dezibot.infraredLight.bottom.turnOn();
|
dezibot.infraredLight.bottom.turnOn();
|
||||||
Serial.println("Turned on bottom IR LEDs");
|
Serial.println("Turned on bottom IR LEDs");
|
||||||
dumpInfoAndWait();
|
dumpInfoAndWait();
|
||||||
|
|
||||||
dezibot.multiColorLight.turnOffLed(ALL);
|
dezibot.multiColorLight.turnOffLed(ALL);
|
||||||
dezibot.motion.stop();
|
dezibot.motion.stop();
|
||||||
dezibot.infraredLight.bottom.turnOff();
|
dezibot.infraredLight.bottom.turnOff();
|
Loading…
x
Reference in New Issue
Block a user