#pragma once #include #include #include namespace microbu { // Calibrated divider voltage for the selected board. class BatteryMonitor { public: BatteryMonitor(); std::uint16_t sample_millivolts(); // 0 means unavailable, never an invented percentage /// MicrOBU: powers the board down for CONFIG_MICROBU_BATTERY_SLEEP_S seconds (timer wake-up). [[noreturn]] static void deep_sleep(); /// MicrOBU: true when this boot is the timer wake-up of deep_sleep(). static bool woke_from_battery_sleep(); private: adc_oneshot_unit_handle_t adc_ = nullptr; adc_cali_handle_t calibration_ = nullptr; adc_channel_t channel_ = ADC_CHANNEL_0; }; }