aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/candle-mode.c23
-rw-r--r--spaghetti-monster/anduril/sunset-timer.c30
2 files changed, 28 insertions, 25 deletions
diff --git a/spaghetti-monster/anduril/candle-mode.c b/spaghetti-monster/anduril/candle-mode.c
index 70f5e0e..3704ee6 100644
--- a/spaghetti-monster/anduril/candle-mode.c
+++ b/spaghetti-monster/anduril/candle-mode.c
@@ -21,6 +21,7 @@
#define CANDLE_MODE_C
#include "candle-mode.h"
+
#ifdef USE_SUNSET_TIMER
#include "sunset-timer.h"
#endif
@@ -99,22 +100,22 @@ uint8_t candle_mode_state(Event event, uint16_t arg) {
// un-reverse after 1 second
if (arg == TICKS_PER_SECOND) ramp_direction = 1;
- // self-timer dims the light during the final minute
- uint8_t subtract = 0;
- #ifdef USE_SUNSET_TIMER
- if (sunset_timer == 1) {
- subtract = (candle_mode_brightness+CANDLE_AMPLITUDE)
- * sunset_ticks / TICKS_PER_MINUTE;
- }
- #endif // ifdef USE_SUNSET_TIMER
-
// 3-oscillator synth for a relatively organic pattern
uint8_t add;
add = ((triangle_wave(candle_wave1) * candle_wave1_depth) >> 8)
+ ((triangle_wave(candle_wave2) * candle_wave2_depth) >> 8)
+ ((triangle_wave(candle_wave3) * candle_wave3_depth) >> 8);
- int8_t brightness = candle_mode_brightness + add - subtract;
- if (brightness < 0) { brightness = 0; }
+ uint16_t brightness = candle_mode_brightness + add;
+
+ // self-timer dims the light during the final minute
+ #ifdef USE_SUNSET_TIMER
+ if (1 == sunset_timer) {
+ brightness = brightness
+ * ((TICKS_PER_MINUTE>>5) - (sunset_ticks>>5))
+ / (TICKS_PER_MINUTE>>5);
+ }
+ #endif // ifdef USE_SUNSET_TIMER
+
set_level(brightness);
// wave1: slow random LFO
diff --git a/spaghetti-monster/anduril/sunset-timer.c b/spaghetti-monster/anduril/sunset-timer.c
index 0687993..4c91723 100644
--- a/spaghetti-monster/anduril/sunset-timer.c
+++ b/spaghetti-monster/anduril/sunset-timer.c
@@ -30,20 +30,22 @@ uint8_t sunset_timer_state(Event event, uint16_t arg) {
sunset_ticks = 0;
return MISCHIEF_MANAGED;
}
- // 3 clicks: add 30m to timer
- else if (event == EV_3clicks) {
- if (sunset_timer < (255 - SUNSET_TIMER_UNIT)) {
- // add 30m to the timer
- sunset_timer += SUNSET_TIMER_UNIT;
- sunset_timer_peak = sunset_timer; // reset ceiling
- sunset_ticks = 0; // reset phase
- // blink to confirm
- uint8_t brightness = actual_level;
- uint8_t bump = actual_level + 32;
- if (bump > MAX_LEVEL) bump = 0;
- set_level(bump);
- delay_4ms(2);
- set_level(brightness);
+ // 4H: add 10m to timer, per second, until released
+ else if (event == EV_click4_hold) {
+ if (0 == (arg % TICKS_PER_SECOND)) {
+ if (sunset_timer < (255 - SUNSET_TIMER_UNIT)) {
+ // add 30m to the timer
+ sunset_timer += SUNSET_TIMER_UNIT;
+ sunset_timer_peak = sunset_timer; // reset ceiling
+ sunset_ticks = 0; // reset phase
+ // blink to confirm
+ uint8_t brightness = actual_level;
+ uint8_t bump = actual_level + 32;
+ if (bump > MAX_LEVEL) bump = 0;
+ set_level(bump);
+ delay_4ms(2);
+ set_level(brightness);
+ }
}
return MISCHIEF_MANAGED;
}
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.