aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-05-10 02:13:13 -0600
committerSelene ToyKeeper2019-05-10 02:13:13 -0600
commit680c2b723f5ebe259741bf34f25a09957ddc8a0b (patch)
treef5e73ce9ca74e838b3c1b136f44d0d5dbe4dbf94 /spaghetti-monster
parentmerged fsm branch, resolved conflicts in anduril.c, did some quick testing (diff)
downloadanduril-680c2b723f5ebe259741bf34f25a09957ddc8a0b.tar.gz
anduril-680c2b723f5ebe259741bf34f25a09957ddc8a0b.tar.bz2
anduril-680c2b723f5ebe259741bf34f25a09957ddc8a0b.zip
made candle mode amplitude configurable at compile time,
and increased the magnitude for the lantern build
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/anduril.c27
-rw-r--r--spaghetti-monster/anduril/cfg-blf-lantern.h3
2 files changed, 19 insertions, 11 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index ea3c06a..675062f 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -383,6 +383,9 @@ volatile uint8_t bike_flasher_brightness = MAX_1x7135;
#ifdef USE_CANDLE_MODE
uint8_t candle_mode_state(Event event, uint16_t arg);
uint8_t triangle_wave(uint8_t phase);
+#ifndef CANDLE_AMPLITUDE
+#define CANDLE_AMPLITUDE 20
+#endif
#endif
#ifdef USE_BEACON_MODE
@@ -1100,17 +1103,14 @@ inline void bike_flasher_iter() {
#ifdef USE_CANDLE_MODE
uint8_t candle_mode_state(Event event, uint16_t arg) {
- // FIXME: make candle variance magnitude a compile-time option,
- // since 20 is sometimes too much or too little,
- // depending on the driver type and ramp shape
- //#define MAX_CANDLE_LEVEL (RAMP_SIZE-8-6-4)
- #define MAX_CANDLE_LEVEL (RAMP_SIZE/2)
+ #define MAX_CANDLE_LEVEL (RAMP_LENGTH-CANDLE_AMPLITUDE-20)
static uint8_t candle_wave1 = 0;
static uint8_t candle_wave2 = 0;
static uint8_t candle_wave3 = 0;
static uint8_t candle_wave2_speed = 0;
- static uint8_t candle_wave2_depth = 7;
- static uint8_t candle_wave3_depth = 4;
+ static const uint8_t candle_wave1_depth = 8 * CANDLE_AMPLITUDE / 20;
+ static uint8_t candle_wave2_depth = 7 * CANDLE_AMPLITUDE / 20;
+ static uint8_t candle_wave3_depth = 5 * CANDLE_AMPLITUDE / 20;
static uint8_t candle_mode_brightness = 24;
static uint8_t candle_mode_timer = 0;
#define TICKS_PER_CANDLE_MINUTE 4096 // about 65 seconds
@@ -1155,7 +1155,7 @@ uint8_t candle_mode_state(Event event, uint16_t arg) {
// self-timer dims the light during the final minute
uint8_t subtract = 0;
if (candle_mode_timer == 1) {
- subtract = ((candle_mode_brightness+20)
+ subtract = ((candle_mode_brightness+CANDLE_AMPLITUDE)
* ((arg & (TICKS_PER_CANDLE_MINUTE-1)) >> 4))
>> 8;
}
@@ -1172,7 +1172,7 @@ uint8_t candle_mode_state(Event event, uint16_t arg) {
}
// 3-oscillator synth for a relatively organic pattern
uint8_t add;
- add = ((triangle_wave(candle_wave1) * 8) >> 8)
+ 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;
@@ -1180,6 +1180,7 @@ uint8_t candle_mode_state(Event event, uint16_t arg) {
set_level(brightness);
// wave1: slow random LFO
+ // TODO: make wave slower and more erratic?
if ((arg & 1) == 0) candle_wave1 += pseudo_rand() & 1;
// wave2: medium-speed erratic LFO
candle_wave2 += candle_wave2_speed;
@@ -1192,16 +1193,20 @@ uint8_t candle_mode_state(Event event, uint16_t arg) {
if ((candle_wave2_depth > 0) && ((pseudo_rand() & 0b00111111) == 0))
candle_wave2_depth --;
// random sawtooth retrigger
+ // TODO: trigger less often?
if ((pseudo_rand()) == 0) {
- candle_wave2_depth = 7;
+ // TODO: random amplitude with higher maximum?
+ candle_wave2_depth = 7 * CANDLE_AMPLITUDE / 20;
//candle_wave3_depth = 5;
candle_wave2 = 0;
}
// downward sawtooth on wave3 depth to simulate stabilizing
if ((candle_wave3_depth > 2) && ((pseudo_rand() & 0b00011111) == 0))
candle_wave3_depth --;
+ // TODO: trigger less often?
if ((pseudo_rand() & 0b01111111) == 0)
- candle_wave3_depth = 5;
+ // TODO: random amplitude with higher maximum?
+ candle_wave3_depth = 5 * CANDLE_AMPLITUDE / 20;
return MISCHIEF_MANAGED;
}
return EVENT_NOT_HANDLED;
diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h
index 71e7021..f4c2d1c 100644
--- a/spaghetti-monster/anduril/cfg-blf-lantern.h
+++ b/spaghetti-monster/anduril/cfg-blf-lantern.h
@@ -39,6 +39,9 @@
#define HALFSPEED_LEVEL 14
#define QUARTERSPEED_LEVEL 5
+// the default of 20 looks a bit flat, so increase it
+#define CANDLE_AMPLITUDE 33
+
// set floor and ceiling as far apart as possible
// because this lantern isn't overpowered
#define RAMP_SMOOTH_FLOOR 1
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.