mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
- 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)
47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
#include "SimulatorPower.h"
|
|
|
|
#define TAG "simulator_power"
|
|
|
|
bool SimulatorPower::supportsMetric(MetricType type) const {
|
|
switch (type) {
|
|
using enum MetricType;
|
|
case IsCharging:
|
|
case Current:
|
|
case BatteryVoltage:
|
|
case ChargeLevel:
|
|
return true;
|
|
}
|
|
|
|
return false; // Safety guard for when new enum values are introduced
|
|
}
|
|
|
|
bool SimulatorPower::getMetric(Power::MetricType type, Power::MetricData& data) {
|
|
switch (type) {
|
|
using enum MetricType;
|
|
case IsCharging:
|
|
data.valueAsBool = true;
|
|
return true;
|
|
case Current:
|
|
data.valueAsInt32 = 42;
|
|
return true;
|
|
case BatteryVoltage:
|
|
data.valueAsUint32 = 4032;
|
|
return true;
|
|
case ChargeLevel:
|
|
data.valueAsUint8 = 100;
|
|
return true;
|
|
}
|
|
|
|
return false; // Safety guard for when new enum values are introduced
|
|
}
|
|
|
|
static std::shared_ptr<Power> power;
|
|
|
|
std::shared_ptr<Power> simulatorPower() {
|
|
if (power == nullptr) {
|
|
power = std::make_shared<SimulatorPower>();
|
|
}
|
|
return power;
|
|
}
|
|
|