add initial ADC shutdown code

This commit is contained in:
sigil-03 2025-11-13 20:12:38 -07:00
parent 43790abbc5
commit b0b77a1538
2 changed files with 35 additions and 8 deletions

View file

@ -183,7 +183,7 @@ use crate::synthesizer::SynthesizerService;
pub use settings::Settings;
#[cfg(feature = "enable_print")]
// #[cfg(feature = "enable_print")]
use ch32_hal::println;
pub struct TimerConfig {
@ -390,8 +390,15 @@ impl App {
if self.timers.batt_adc_timer.need_service() {
self.timers.batt_adc_timer.service();
let bv = self.interfaces.adc_core.get_battery_voltage();
#[cfg(feature = "enable_print")]
println!("batt adc service: {bv}");
let avg = self.interfaces.adc_core.get_average();
// #[cfg(feature = "enable_print")]
// println!("batt adc service: {bv}, {avg}");
if avg < 421 {
// self.services
// .sequencer
// .play_sequence(&crate::sequences::COIN_CHIRP, 0);
self.set_state(State::DeepSleep);
}
// TODO:
// do stuff if the battery voltage is below some threshold