aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spaghetti-monster/anduril/anduril.c33
-rw-r--r--spaghetti-monster/fsm-main.c6
-rw-r--r--spaghetti-monster/fsm-ramping.h2
3 files changed, 37 insertions, 4 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 8784bc5..a1c9f5b 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -29,12 +29,16 @@
#define USE_RAMPING
#define USE_SET_LEVEL_GRADUALLY
#define RAMP_LENGTH 150
+#define BLINK_AT_RAMP_BOUNDARIES
+//#define BLINK_AT_RAMP_FLOOR
#define USE_BATTCHECK
#define BATTCHECK_VpT
#define MAX_CLICKS 5
#define USE_EEPROM
#define EEPROM_BYTES 12
#define USE_IDLE_MODE
+//#define HALFSPEED_LEVEL 30 // looks good, but sounds bad
+#define HALFSPEED_LEVEL 14
#include "spaghetti-monster.h"
// Options specific to this UI (not inherited from SpaghettiMonster)
@@ -86,7 +90,7 @@ void save_config();
uint8_t memorized_level = MAX_1x7135;
// smooth vs discrete ramping
volatile uint8_t ramp_style = 0; // 0 = smooth, 1 = discrete
-volatile uint8_t ramp_smooth_floor = 5;
+volatile uint8_t ramp_smooth_floor = 1;
#if PWM_CHANNELS == 3
volatile uint8_t ramp_smooth_ceil = MAX_Nx7135;
volatile uint8_t ramp_discrete_ceil = MAX_Nx7135;
@@ -226,6 +230,16 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
ramp_step_size = ramp_discrete_step_size;
}
+ if (actual_level < HALFSPEED_LEVEL) {
+ // run at half speed
+ CLKPR = 1<<CLKPCE;
+ CLKPR = 1;
+ } else {
+ // run at full speed
+ CLKPR = 1<<CLKPCE;
+ CLKPR = 0;
+ }
+
// turn LED on when we first enter the mode
if (event == EV_enter_state) {
// remember this level, unless it's moon or turbo
@@ -287,6 +301,7 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
#ifdef USE_THERMAL_REGULATION
target_level = memorized_level;
#endif
+ #ifdef BLINK_AT_RAMP_BOUNDARIES
// only blink once for each threshold
if ((memorized_level != actual_level)
&& ((memorized_level == MAX_1x7135)
@@ -297,6 +312,7 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
set_level(0);
delay_4ms(8/4);
}
+ #endif
set_level(memorized_level);
return MISCHIEF_MANAGED;
}
@@ -311,16 +327,21 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
#ifdef USE_THERMAL_REGULATION
target_level = memorized_level;
#endif
+ #ifdef BLINK_AT_RAMP_BOUNDARIES
// only blink once for each threshold
if ((memorized_level != actual_level)
&& ((memorized_level == MAX_1x7135)
#if PWM_CHANNELS >= 3
|| (memorized_level == MAX_Nx7135)
#endif
- || (memorized_level == mode_min))) {
+ #ifdef BLINK_AT_RAMP_FLOOR
+ || (memorized_level == mode_min)
+ #endif
+ )) {
set_level(0);
delay_4ms(8/4);
}
+ #endif
set_level(memorized_level);
return MISCHIEF_MANAGED;
}
@@ -952,11 +973,17 @@ void loop() {
#ifdef USE_IDLE_MODE
else if ((state == steady_state)
|| (state == goodnight_state)) {
+ // doze until next clock tick
idle_mode();
}
+ else {
+ // run at full speed
+ CLKPR = 1<<CLKPCE;
+ CLKPR = 0;
+ }
#endif
- else if (state == strobe_state) {
+ if (state == strobe_state) {
// party / tactical strobe
if (strobe_type < 2) {
set_level(MAX_LEVEL);
diff --git a/spaghetti-monster/fsm-main.c b/spaghetti-monster/fsm-main.c
index bc41cd6..5efcd4c 100644
--- a/spaghetti-monster/fsm-main.c
+++ b/spaghetti-monster/fsm-main.c
@@ -40,6 +40,12 @@ int main() {
// Don't allow interrupts while booting
cli();
+ #ifdef HALFSPEED
+ // run at half speed
+ CLKPR = 1<<CLKPCE;
+ CLKPR = 1;
+ #endif
+
// configure PWM channels
#if PWM_CHANNELS >= 1
DDRB |= (1 << PWM1_PIN);
diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h
index 04beb31..0914186 100644
--- a/spaghetti-monster/fsm-ramping.h
+++ b/spaghetti-monster/fsm-ramping.h
@@ -66,7 +66,7 @@ void gradual_tick();
// ../../bin/level_calc.py 1 65 7135 1 0.8 150
// ... mixed with this:
// ../../bin/level_calc.py 2 150 7135 4 0.33 150 FET 1 10 1500
- PROGMEM const uint8_t pwm1_levels[] = { 1,1,2,2,3,3,4,4,5,6,7,8,9,10,11,12,14,15,17,19,20,22,24,26,29,31,34,36,39,42,45,48,51,55,59,62,66,70,75,79,84,89,93,99,104,110,115,121,127,134,140,147,154,161,168,176,184,192,200,209,217,226,236,245,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0 };
+ PROGMEM const uint8_t pwm1_levels[] = { 1,1,2,2,3,3,4,4,5,6,7,8,9,10,12,13,14,15,17,19,20,22,24,26,29,31,34,36,39,42,45,48,51,55,59,62,66,70,75,79,84,89,93,99,104,110,115,121,127,134,140,147,154,161,168,176,184,192,200,209,217,226,236,245,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0 };
PROGMEM const uint8_t pwm2_levels[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,4,5,7,8,9,11,12,14,15,17,19,20,22,24,25,27,29,31,33,35,37,39,41,43,45,48,50,52,55,57,59,62,64,67,70,72,75,78,81,84,87,90,93,96,99,102,105,109,112,115,119,122,126,129,133,137,141,144,148,152,156,160,165,169,173,177,182,186,191,195,200,205,209,214,219,224,229,234,239,244,250,255 };
#define MAX_1x7135 65
#endif
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.