diff options
Diffstat (limited to '')
| -rw-r--r-- | spaghetti-monster/fsm-ramping.c | 4 | ||||
| -rw-r--r-- | spaghetti-monster/fsm-ramping.h | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c index 52a7246..7bee07e 100644 --- a/spaghetti-monster/fsm-ramping.c +++ b/spaghetti-monster/fsm-ramping.c @@ -146,13 +146,13 @@ void gradual_tick() { gt --; // convert 1-based number to 0-based - uint8_t target; + PWM_DATATYPE target; #if PWM_CHANNELS >= 1 target = PWM_GET(pwm1_levels, gt); if ((gt < actual_level) // special case for FET-only turbo && (PWM1_LVL == 0) // (bypass adjustment period for first step) - && (target == 255)) PWM1_LVL = 255; + && (target == PWM_TOP)) PWM1_LVL = PWM_TOP; else if (PWM1_LVL < target) PWM1_LVL ++; else if (PWM1_LVL > target) PWM1_LVL --; #endif 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 |
