MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / getMetric

Method getMetric

Devices/m5stack-papers3/Source/devices/Power.cpp:139–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139bool 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
167void PaperS3Power::toneOn(int frequency, int duration) {
168 if (!buzzerInitialized) {

Callers

nothing calls this directly

Tested by

no test coverage detected