| 137 | } |
| 138 | |
| 139 | bool PaperS3Power::getMetric(MetricType type, MetricData& data) { |
| 140 | switch (type) { |
| 141 | using enum MetricType; |
| 142 | |
| 143 | case BatteryVoltage: |
| 144 | return chargeFromAdcVoltage->readBatteryVoltageSampled(data.valueAsUint32); |
| 145 | |
| 146 | case ChargeLevel: { |
| 147 | uint32_t voltage = 0; |
| 148 | if (chargeFromAdcVoltage->readBatteryVoltageSampled(voltage)) { |
| 149 | data.valueAsUint8 = chargeFromAdcVoltage->estimateChargeLevelFromVoltage(voltage); |
| 150 | return true; |
| 151 | } |
| 152 | return false; |
| 153 | } |
| 154 | |
| 155 | case IsCharging: |
| 156 | // isUsbConnected() is tracked separately but not used as a gate here: |
| 157 | // when USB is absent the charge IC's CHG pin is inactive (high), so |
| 158 | // isCharging() already returns false correctly. |
| 159 | data.valueAsBool = isCharging(); |
| 160 | return true; |
| 161 | |
| 162 | default: |
| 163 | return false; |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | void PaperS3Power::toneOn(int frequency, int duration) { |
| 168 | if (!buzzerInitialized) { |
nothing calls this directly
no test coverage detected