Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Brenton Poke <[email protected]>
  • Loading branch information
BrentonPoke committed Jul 29, 2024
1 parent 796a0bd commit 6fd55cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@

// AXP setup
#include <Wire.h>
#include <axp20x.h>
#define XPOWERS_CHIP_AXP192
#include <XPowersLib.h>

AXP20X_Class axp;
XPowersPMU axp;

bool runSensor(void *);
const uint8_t i2c_sda = 21;
const uint8_t i2c_scl = 22;

Expand All @@ -33,7 +35,6 @@ DuckDisplay* display = NULL;


// Set device ID between ""
String deviceId = "MAMA001";
MamaDuck duck;

auto timer = timer_create_default();
Expand All @@ -60,12 +61,9 @@ void setup() {

Wire.begin(i2c_sda, i2c_scl);

int ret = axp.begin(Wire, AXP192_SLAVE_ADDRESS);
int ret = axp.begin(Wire, AXP192_SLAVE_ADDRESS,i2c_sda,i2c_scl);

if (ret == AXP_FAIL) {
Serial.println("AXP Power begin failed");
while (1);
}
axp.enableIRQ(XPOWERS_AXP192_BAT_CHG_DONE_IRQ | XPOWERS_AXP192_BAT_CHG_START_IRQ);
}

void loop() {
Expand All @@ -81,12 +79,12 @@ void loop() {
bool runSensor(void *) {


float isCharging = axp.isChargeing();
boolean isFullyCharged = axp.isChargingDoneIRQ();
float isCharging = axp.isCharging();
boolean isFullyCharged = axp.isBatChagerDoneIrq();
float batteryVoltage = axp.getBattVoltage();
float batteryDischarge = axp.getAcinCurrent();
float getTemp = axp.getTemp();
int battPercentage = axp.getBattPercentage();
float getTemp = axp.getTemperature();
int battPercentage = axp.getBatteryPercent();

Serial.println("--- T-BEAM Power Information ---");
Serial.print("Duck charging (1 = Yes): ");
Expand All @@ -101,17 +99,17 @@ int battPercentage = axp.getBattPercentage();
Serial.println(getTemp);
Serial.print("battery Percentage: ");
Serial.println(battPercentage);


String sensorVal =
"Charging: " +
String(isCharging) ;
" BattFull: " +
String(isFullyCharged)+
" Voltage " +
String(batteryVoltage) ;
" Temp: " +
String(getTemp);

std::string sensorVal =
"Charging: ";
sensorVal.append(isCharging ? "Yes" : "No")
.append(" BattFull: ")
.append(isFullyCharged ? "Yes" : "No")
.append(" Voltage: ")
.append(std::to_string(batteryVoltage))
.append(" Temp: ")
.append(std::to_string(getTemp));


duck.sendData(topics::sensor, sensorVal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ monitor_speed = 115200
monitor_filters = time

lib_deps =
https://github.com/Call-for-Code/ClusterDuck-Protocol
lewisxhe/AXP202X_Library
ArduinoOTA

This comment has been minimized.

Copy link
@BrentonPoke

BrentonPoke Jul 29, 2024

Author Owner

This is here because I was still getting build issues regarding the ArduinoOTA.h header

clusterduck-protocol/ClusterDuck Protocol@^4.0.1
lewisxhe/XPowersLib@^0.2.5

; uncomment for OTA update
; upload_port = duck.local

0 comments on commit 6fd55cf

Please sign in to comment.