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:
Ken Van Hoeylandt
2025-01-28 17:39:58 +01:00
committed by GitHub
parent 1bb1260ea0
commit 6c67845645
54 changed files with 518 additions and 531 deletions
+10 -10
View File
@@ -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 {