aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hwdef-Emisar_D1Sv2.h1
-rw-r--r--spaghetti-monster/fsm-ramping.c4
-rw-r--r--spaghetti-monster/fsm-ramping.h3
3 files changed, 6 insertions, 2 deletions
diff --git a/hwdef-Emisar_D1Sv2.h b/hwdef-Emisar_D1Sv2.h
index e1f8029..5912ea8 100644
--- a/hwdef-Emisar_D1Sv2.h
+++ b/hwdef-Emisar_D1Sv2.h
@@ -41,6 +41,7 @@
#define PWM_CHANNELS 1
#define PWM_BITS 10 // 0 to 1023 at 4 kHz, not 0 to 255 at 16 kHz
+#define PWM_TOP 1023
#define SWITCH_PIN PA7 // pin 20
#define SWITCH_PCINT PCINT7 // pin 20 pin change interrupt
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
If you find this content useful please consider a small donation via bitcoin: bitcoin:1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2?amount=0.001&message=Donation Scraping git contents via cgit is very resource intensive. The continued hosting of these git repositories is entirely financed by your bitcoin contributions. For donations of a least 1 mBTC you include your IP address in the message of your bitcoin donation. This will remove this message in the future for requests from your IP, which will significantly reduce token usage. In any case, any contributions to bitcoin address 1mxKyQsHHugqRxPKgwaA7wUwJEGCNthn2 are very welcome. Thanks in advance for you contribution to a self-sustaining ecosystem.