Tactility/Boards/Simulator/Source/hal/SimulatorPower.cpp
Ken Van Hoeylandt 2345ba6d13
HAL renaming & relocation (#215)
Implemented more consistent naming:
- Moved all HAL devices into their own namespace (and related folder)
- Post-fixed all HAL device names with "Device"
2025-02-09 16:48:23 +01:00

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(MetricType type, 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<PowerDevice> power;
std::shared_ptr<PowerDevice> simulatorPower() {
if (power == nullptr) {
power = std::make_shared<SimulatorPower>();
}
return power;
}