aboutsummaryrefslogtreecommitdiff
path: root/hwdef-blf-lt1.c
diff options
context:
space:
mode:
authorSelene ToyKeeper2023-10-26 06:58:23 -0600
committerSelene ToyKeeper2023-10-26 06:58:23 -0600
commit5e86193dce022967cbe41288d30cb4b21500f5e6 (patch)
tree69215ca189e9e33010ae0e3bcf63bb8a7e2b7c27 /hwdef-blf-lt1.c
parentrewrote blf-lantern (blf-lt1) code to use multi-channel and PWM+DSM, (diff)
downloadanduril-5e86193dce022967cbe41288d30cb4b21500f5e6.tar.gz
anduril-5e86193dce022967cbe41288d30cb4b21500f5e6.tar.bz2
anduril-5e86193dce022967cbe41288d30cb4b21500f5e6.zip
improved blf-lt1 ramp and fixed issue with missed button presses
(it seems t85 doesn't like having timer overflow interrupts enabled in standby?)
Diffstat (limited to 'hwdef-blf-lt1.c')
-rw-r--r--hwdef-blf-lt1.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hwdef-blf-lt1.c b/hwdef-blf-lt1.c
index df17612..8a8af52 100644
--- a/hwdef-blf-lt1.c
+++ b/hwdef-blf-lt1.c
@@ -50,6 +50,10 @@ Channel channels[] = {
};
void set_level_zero() {
+ // disable timer 0 overflow interrupt
+ // (helps improve button press handling from Off state)
+ TIMSK &= ~(1 << TOIE0);
+
// turn off all LEDs
ch1_dsm_lvl = 0;
ch2_dsm_lvl = 0;
@@ -67,6 +71,9 @@ void set_hw_levels(PWM_DATATYPE ch1, PWM_DATATYPE ch2) {
// set hardware PWM levels and init dsm loop
CH1_PWM = ch1_pwm = ch1 >> 7;
CH2_PWM = ch2_pwm = ch2 >> 7;
+
+ // enable timer 0 overflow interrupt so DSM can work
+ TIMSK |= (1 << TOIE0);
}
// delta-sigma modulation of PWM outputs