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

Function createPower

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

Source from the content-addressed store, hash-verified

257}
258
259std::shared_ptr<PowerDevice> createPower() {
260 ChargeFromAdcVoltage::Configuration config = {
261 .adcMultiplier = VOLTAGE_DIVIDER_MULTIPLIER,
262 .adcRefVoltage = 3.3f,
263 .adcChannel = VBAT_ADC_CHANNEL,
264 .adcConfig = {
265 .unit_id = ADC_UNIT_1,
266 .clk_src = ADC_RTC_CLK_SRC_DEFAULT,
267 .ulp_mode = ADC_ULP_MODE_DISABLE,
268 },
269 .adcChannelConfig = {
270 .atten = ADC_ATTEN_DB_12,
271 .bitwidth = ADC_BITWIDTH_DEFAULT,
272 },
273 };
274
275 auto adc = std::make_unique<ChargeFromAdcVoltage>(config, MIN_BATTERY_VOLTAGE, MAX_BATTERY_VOLTAGE);
276 if (!adc->isInitialized()) {
277 LOG_E(TAG, "ADC initialization failed; power monitoring unavailable");
278 return nullptr;
279 }
280
281 return std::make_shared<PaperS3Power>(std::move(adc), POWER_OFF_PIN);
282}

Callers 1

createDevicesFunction · 0.50

Calls 1

isInitializedMethod · 0.80

Tested by

no test coverage detected