Cleanup and improvements (#194)
- Lots of changes for migrating C code to C++ - Improved `Lockable` in several ways like adding `withLock()` (+ tests) - Improved `Semaphore` a bit for improved readability, and also added some tests - Upgrade Linux machine in GitHub Actions so that we can compile with a newer GCC - Simplification of WiFi connection - Updated funding options - (and more)
This commit is contained in:
committed by
GitHub
parent
1bb1260ea0
commit
6c67845645
@@ -5,11 +5,12 @@
|
||||
|
||||
bool CoreS3Power::supportsMetric(MetricType type) const {
|
||||
switch (type) {
|
||||
case MetricType::BatteryVoltage:
|
||||
case MetricType::IsCharging:
|
||||
case MetricType::ChargeLevel:
|
||||
using enum MetricType;
|
||||
case BatteryVoltage:
|
||||
case IsCharging:
|
||||
case ChargeLevel:
|
||||
return true;
|
||||
case MetricType::Current:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,7 +19,8 @@ bool CoreS3Power::supportsMetric(MetricType type) const {
|
||||
|
||||
bool CoreS3Power::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
switch (type) {
|
||||
case MetricType::BatteryVoltage: {
|
||||
using enum MetricType;
|
||||
case BatteryVoltage: {
|
||||
float milliVolt;
|
||||
if (axpDevice.getBatteryVoltage(milliVolt)) {
|
||||
data.valueAsUint32 = (uint32_t)milliVolt;
|
||||
@@ -27,7 +29,7 @@ bool CoreS3Power::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case MetricType::ChargeLevel: {
|
||||
case ChargeLevel: {
|
||||
float vbatMillis;
|
||||
if (axpDevice.getBatteryVoltage(vbatMillis)) {
|
||||
float vbat = vbatMillis / 1000.f;
|
||||
@@ -44,7 +46,7 @@ bool CoreS3Power::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case MetricType::IsCharging: {
|
||||
case IsCharging: {
|
||||
Axp2101::ChargeStatus status;
|
||||
if (axpDevice.getChargeStatus(status)) {
|
||||
data.valueAsBool = (status == Axp2101::CHARGE_STATUS_CHARGING);
|
||||
@@ -53,11 +55,9 @@ bool CoreS3Power::getMetric(Power::MetricType type, Power::MetricData& data) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
case MetricType::Current:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return false; // Safety guard for when new enum values are introduced
|
||||
}
|
||||
|
||||
bool CoreS3Power::isAllowedToCharge() const {
|
||||
|
||||
Reference in New Issue
Block a user