aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster/fsm-ramping.h
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-08-06 20:17:09 -0600
committerSelene ToyKeeper2019-08-06 20:17:09 -0600
commit7d09466da0552c17b9968fa92d8ede534abfbbb6 (patch)
treec490fd9de5f3704df54d368715b1c5284f58f638 /spaghetti-monster/fsm-ramping.h
parentmeasured and adjusted D1S v2 ramp parameters (diff)
downloadanduril-7d09466da0552c17b9968fa92d8ede534abfbbb6.tar.gz
anduril-7d09466da0552c17b9968fa92d8ede534abfbbb6.tar.bz2
anduril-7d09466da0552c17b9968fa92d8ede534abfbbb6.zip
un-hardcoded 255 as the highest PWM level, and used a "PWM_TOP" value instead
(should make gradual adjustments work better on devices with more than 8 bits of PWM resolution)
Diffstat (limited to 'spaghetti-monster/fsm-ramping.h')
-rw-r--r--spaghetti-monster/fsm-ramping.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h
index 24c19c0..c650e21 100644
--- a/spaghetti-monster/fsm-ramping.h
+++ b/spaghetti-monster/fsm-ramping.h
@@ -41,12 +41,15 @@ void gradual_tick();
// auto-detect the data type for PWM tables
#ifndef PWM_BITS
#define PWM_BITS 8
+#define PWM_TOP 255
#endif
#if PWM_BITS <= 8
#define PWM_DATATYPE uint8_t
+#define PWM_TOP 255
#define PWM_GET(x,y) pgm_read_byte(x+y)
#else
#define PWM_DATATYPE uint16_t
+#define PWM_TOP 1023 // 10 bits by default
// pointer plus 2*y bytes
//#define PWM_GET(x,y) pgm_read_word(x+(2*y))
// nope, the compiler was already doing the math correctly