add basic brightness control

This commit is contained in:
sigil-03 2025-11-05 10:24:19 -07:00
parent 95b55f88a8
commit 930d10218f
2 changed files with 43 additions and 14 deletions

View file

@ -329,8 +329,8 @@ fn app_main(mut p: hal::Peripherals) -> ! {
app.init();
loop {
// system servicing
//
// edge detector
// volume edge detector
if !volume_btn_input.active() {
let volume_btn_curr = volume_btn_input.is_high_immediate();
if volume_btn_prev != volume_btn_curr {
@ -349,6 +349,25 @@ fn app_main(mut p: hal::Peripherals) -> ! {
volume_btn_input.reset();
}
// brightness edge detector
if !light_ctrl_btn_input.active() {
let light_ctrl_btn_curr = light_ctrl_btn_input.is_high_immediate();
if light_ctrl_btn_prev != light_ctrl_btn_curr {
light_ctrl_btn_input.begin();
light_ctrl_btn_prev = light_ctrl_btn_curr;
}
}
light_ctrl_btn_input.service();
if light_ctrl_btn_input.ready() {
#[cfg(feature = "enable_print")]
println!("brightness btn value: {}", light_ctrl_btn_input.value());
if !light_ctrl_btn_input.value() {
app.brightness_button();
}
light_ctrl_btn_input.reset();
}
// systick tick
if unsafe {
#[allow(static_mut_refs)]