aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
Diffstat (limited to 'spaghetti-monster')
-rwxr-xr-xspaghetti-monster/anduril/anduril.c472
1 files changed, 236 insertions, 236 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index c2a598e..fe5f268 100755
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -52,7 +52,7 @@
#define USE_BIKE_FLASHER_MODE
#define USE_PARTY_STROBE_MODE
#define USE_TACTICAL_STROBE_MODE
-#define USE_LIGHTNING_MODE
+//#define USE_LIGHTNING_MODE
#define USE_CANDLE_MODE
//Muggle mode for easy UI
@@ -263,22 +263,22 @@ uint8_t target_level = 0;
#endif
typedef enum {
- #ifdef USE_BIKE_FLASHER_MODE
- bike_flasher_e,
- #endif
- #ifdef USE_PARTY_STROBE_MODE
- party_strobe_e,
- #endif
- #ifdef USE_TACTICAL_STROBE_MODE
- tactial_strobe_e,
- #endif
- #ifdef USE_LIGHTNING_MODE
- lightening_storm_e,
- #endif
- #ifdef USE_CANDLE_MODE
- candle_mode_e,
- #endif
- strobe_mode_END
+ #ifdef USE_BIKE_FLASHER_MODE
+ bike_flasher_e,
+ #endif
+ #ifdef USE_PARTY_STROBE_MODE
+ party_strobe_e,
+ #endif
+ #ifdef USE_TACTICAL_STROBE_MODE
+ tactial_strobe_e,
+ #endif
+ #ifdef USE_LIGHTNING_MODE
+ lightening_storm_e,
+ #endif
+ #ifdef USE_CANDLE_MODE
+ candle_mode_e,
+ #endif
+ strobe_mode_END
} strobe_mode_te ;
const int NUM_STROBES = strobe_mode_END;
@@ -462,7 +462,7 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
return MISCHIEF_MANAGED;
}
// 3 clicks: toggle smooth vs discrete ramping
- else if (event == EV_3clicks) {
+ /*else if (event == EV_3clicks) {
ramp_style = !ramp_style;
memorized_level = nearest_level(memorized_level);
#ifdef USE_THERMAL_REGULATION
@@ -479,7 +479,7 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
delay_4ms(20/4);
set_level(memorized_level);
return MISCHIEF_MANAGED;
- }
+ }*/
// 4 clicks: configure this ramp mode
else if (event == EV_4clicks) {
push_state(ramp_config_state, 0);
@@ -769,121 +769,121 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) {
// hold: change speed (go faster)
// or change brightness (brighter)
else if (event == EV_click1_hold) {
- switch(st) {
- /* biking mode brighter */
- #ifdef USE_BIKE_FLASHER_MODE
- case bike_flasher_e:
- {
- if (bike_flasher_brightness < MAX_BIKING_LEVEL)
- {
- bike_flasher_brightness ++;
- }
- set_level(bike_flasher_brightness);
- break;
- }
- #endif
-
- /* party / tactial mode faster */
- #ifdef USE_PARTY_STROBE_MODE
- case party_strobe_e:
- #endif
- #ifdef USE_TACTICAL_STROBE_MODE
- case tactial_strobe_e:
- #endif
- #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
- {
- if ((arg & 0x01u) == 0u)
- {
- if (strobe_delays[st-1] > 8)
- {
- strobe_delays[st-1] --;
- }
- }
- break;
- }
- #endif
-
- /* lightening mode has no settings */
-
- /* candle mode brighter */
- #ifdef USE_CANDLE_MODE
- case candle_mode_e:
- {
- if (candle_mode_brightness < MAX_CANDLE_LEVEL)
- {
- candle_mode_brightness ++;
- }
+ switch(st) {
+ /* biking mode brighter */
+ #ifdef USE_BIKE_FLASHER_MODE
+ case bike_flasher_e:
+ {
+ if (bike_flasher_brightness < MAX_BIKING_LEVEL)
+ {
+ bike_flasher_brightness ++;
+ }
+ set_level(bike_flasher_brightness);
break;
- }
- #endif
-
- case strobe_mode_END:
- default:
- {
- /* Nothing */
- break;
- }
- }
+ }
+ #endif
+
+ /* party / tactial mode faster */
+ #ifdef USE_PARTY_STROBE_MODE
+ case party_strobe_e:
+ #endif
+ #ifdef USE_TACTICAL_STROBE_MODE
+ case tactial_strobe_e:
+ #endif
+ #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
+ {
+ if ((arg & 0x01u) == 0u)
+ {
+ if (strobe_delays[st-1] > 8)
+ {
+ strobe_delays[st-1] --;
+ }
+ }
+ break;
+ }
+ #endif
+
+ /* lightening mode has no settings */
+
+ /* candle mode brighter */
+ #ifdef USE_CANDLE_MODE
+ case candle_mode_e:
+ {
+ if (candle_mode_brightness < MAX_CANDLE_LEVEL)
+ {
+ candle_mode_brightness ++;
+ }
+ break;
+ }
+ #endif
+
+ case strobe_mode_END:
+ default:
+ {
+ /* Nothing */
+ break;
+ }
+ }
return MISCHIEF_MANAGED;
}
// click, hold: change speed (go slower)
// or change brightness (dimmer)
else if (event == EV_click2_hold) {
- switch(st) {
- /* biking mode dimmer */
- #ifdef USE_BIKE_FLASHER_MODE
- case bike_flasher_e:
- {
- if (bike_flasher_brightness > 2)
- {
- bike_flasher_brightness--;
- }
- set_level(bike_flasher_brightness);
- break;
- }
- #endif
-
- /* party / tactial mode slower */
- #ifdef USE_PARTY_STROBE_MODE
- case party_strobe_e:
- #endif
- #ifdef USE_TACTICAL_STROBE_MODE
- case tactial_strobe_e:
- #endif
- #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
- {
- if ((arg & 0x01u) == 0u)
- {
- if (strobe_delays[st-1] < 255)
- {
- strobe_delays[st-1] ++;
- }
- }
- break;
- }
- #endif
-
- /* lightening mode has no settings */
-
- /* candle mode brighter */
- #ifdef USE_CANDLE_MODE
- case candle_mode_e:
- {
- if (candle_mode_brightness > 1)
- {
- candle_mode_brightness --;
- }
+ switch(st) {
+ /* biking mode dimmer */
+ #ifdef USE_BIKE_FLASHER_MODE
+ case bike_flasher_e:
+ {
+ if (bike_flasher_brightness > 2)
+ {
+ bike_flasher_brightness--;
+ }
+ set_level(bike_flasher_brightness);
+ break;
+ }
+ #endif
+
+ /* party / tactial mode slower */
+ #ifdef USE_PARTY_STROBE_MODE
+ case party_strobe_e:
+ #endif
+ #ifdef USE_TACTICAL_STROBE_MODE
+ case tactial_strobe_e:
+ #endif
+ #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
+ {
+ if ((arg & 0x01u) == 0u)
+ {
+ if (strobe_delays[st-1] < 255)
+ {
+ strobe_delays[st-1] ++;
+ }
+ }
break;
- }
- #endif
-
- case strobe_mode_END:
- default:
- {
- /* Nothing */
- break;
- }
- }
+ }
+ #endif
+
+ /* lightening mode has no settings */
+
+ /* candle mode brighter */
+ #ifdef USE_CANDLE_MODE
+ case candle_mode_e:
+ {
+ if (candle_mode_brightness > 1)
+ {
+ candle_mode_brightness --;
+ }
+ break;
+ }
+ #endif
+
+ case strobe_mode_END:
+ default:
+ {
+ /* Nothing */
+ break;
+ }
+ }
return MISCHIEF_MANAGED;
}
// release hold: save new strobe settings
@@ -1769,115 +1769,115 @@ void loop() {
if (state == strobe_state) {
uint8_t st = strobe_type;
-
- switch(st) {
- /* bike flasher */
- #ifdef USE_BIKE_FLASHER_MODE
- case bike_flasher_e:
- {
- uint8_t burst = bike_flasher_brightness << 1;
- if (burst > MAX_LEVEL) burst = MAX_LEVEL;
- for(uint8_t i=0; i<4; i++) {
- set_level(burst);
- if (! nice_delay_ms(5)) return;
- set_level(bike_flasher_brightness);
- if (! nice_delay_ms(65)) return;
- }
- nice_delay_ms(720); // no return check necessary on final delay
- break;
- }
- #endif
-
- /* party / tactial strobe */
- #ifdef USE_PARTY_STROBE_MODE
- case party_strobe_e:
- #endif
- #ifdef USE_TACTICAL_STROBE_MODE
- case tactial_strobe_e:
- #endif
- #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
- {
- uint8_t del = strobe_delays[st-1];
- // TODO: make tac strobe brightness configurable?
- set_level(STROBE_BRIGHTNESS);
- CLKPR = 1<<CLKPCE; CLKPR = 0; // run at full speed
- if (st == 1) { // party strobe
- if (del < 42) delay_zero();
- else nice_delay_ms(1);
- } else { //tactical strobe
- nice_delay_ms(del >> 1);
- }
- set_level(0);
- nice_delay_ms(del); // no return check necessary on final delay
- break;
- }
- #endif
-
- /* lightening mode has no settings */
- #ifdef USE_LIGHTNING_MODE
- case lightening_storm_e:
- {
- int16_t brightness;
- uint16_t rand_time;
-
- // turn the emitter on at a random level,
- // for a random amount of time between 1ms and 32ms
- //rand_time = 1 << (pseudo_rand() % 7);
- rand_time = pseudo_rand() & 63;
- brightness = 1 << (pseudo_rand() % 7); // 1, 2, 4, 8, 16, 32, 64
- brightness += 1 << (pseudo_rand() & 0x03); // 2 to 80 now
- brightness += pseudo_rand() % brightness; // 2 to 159 now (w/ low bias)
- if (brightness > MAX_LEVEL) brightness = MAX_LEVEL;
- set_level(brightness);
- if (! nice_delay_ms(rand_time)) return;
-
- // decrease the brightness somewhat more gradually, like lightning
- uint8_t stepdown = brightness >> 3;
- if (stepdown < 1) stepdown = 1;
- while(brightness > 1) {
- if (! nice_delay_ms(rand_time)) return;
- brightness -= stepdown;
- if (brightness < 0) brightness = 0;
- set_level(brightness);
- /*
- if ((brightness < MAX_LEVEL/2) && (! (pseudo_rand() & 15))) {
- brightness <<= 1;
- set_level(brightness);
- }
- */
- if (! (pseudo_rand() & 3)) {
- if (! nice_delay_ms(rand_time)) return;
- set_level(brightness>>1);
- }
- }
-
- // turn the emitter off,
- // for a random amount of time between 1ms and 8192ms
- // (with a low bias)
- rand_time = 1 << (pseudo_rand() % 13);
- rand_time += pseudo_rand() % rand_time;
- set_level(0);
- nice_delay_ms(rand_time); // no return check necessary on final delay
- break;
- }
- #endif
-
- /* candle mode brighter */
- #ifdef USE_CANDLE_MODE
- case candle_mode_e:
- {
- /* Nothing */
- break;
- }
- #endif
-
- case strobe_mode_END:
- default:
- {
- /* Nothing */
- break;
- }
- }
+
+ switch(st) {
+ /* bike flasher */
+ #ifdef USE_BIKE_FLASHER_MODE
+ case bike_flasher_e:
+ {
+ uint8_t burst = bike_flasher_brightness << 1;
+ if (burst > MAX_LEVEL) burst = MAX_LEVEL;
+ for(uint8_t i=0; i<4; i++) {
+ set_level(burst);
+ if (! nice_delay_ms(5)) return;
+ set_level(bike_flasher_brightness);
+ if (! nice_delay_ms(65)) return;
+ }
+ nice_delay_ms(720); // no return check necessary on final delay
+ break;
+ }
+ #endif
+
+ /* party / tactial strobe */
+ #ifdef USE_PARTY_STROBE_MODE
+ case party_strobe_e:
+ #endif
+ #ifdef USE_TACTICAL_STROBE_MODE
+ case tactial_strobe_e:
+ #endif
+ #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
+ {
+ uint8_t del = strobe_delays[st-1];
+ // TODO: make tac strobe brightness configurable?
+ set_level(STROBE_BRIGHTNESS);
+ CLKPR = 1<<CLKPCE; CLKPR = 0; // run at full speed
+ if (st == 1) { // party strobe
+ if (del < 42) delay_zero();
+ else nice_delay_ms(1);
+ } else { //tactical strobe
+ nice_delay_ms(del >> 1);
+ }
+ set_level(0);
+ nice_delay_ms(del); // no return check necessary on final delay
+ break;
+ }
+ #endif
+
+ /* lightening mode has no settings */
+ #ifdef USE_LIGHTNING_MODE
+ case lightening_storm_e:
+ {
+ int16_t brightness;
+ uint16_t rand_time;
+
+ // turn the emitter on at a random level,
+ // for a random amount of time between 1ms and 32ms
+ //rand_time = 1 << (pseudo_rand() % 7);
+ rand_time = pseudo_rand() & 63;
+ brightness = 1 << (pseudo_rand() % 7); // 1, 2, 4, 8, 16, 32, 64
+ brightness += 1 << (pseudo_rand() & 0x03); // 2 to 80 now
+ brightness += pseudo_rand() % brightness; // 2 to 159 now (w/ low bias)
+ if (brightness > MAX_LEVEL) brightness = MAX_LEVEL;
+ set_level(brightness);
+ if (! nice_delay_ms(rand_time)) return;
+
+ // decrease the brightness somewhat more gradually, like lightning
+ uint8_t stepdown = brightness >> 3;
+ if (stepdown < 1) stepdown = 1;
+ while(brightness > 1) {
+ if (! nice_delay_ms(rand_time)) return;
+ brightness -= stepdown;
+ if (brightness < 0) brightness = 0;
+ set_level(brightness);
+ /*
+ if ((brightness < MAX_LEVEL/2) && (! (pseudo_rand() & 15))) {
+ brightness <<= 1;
+ set_level(brightness);
+ }
+ */
+ if (! (pseudo_rand() & 3)) {
+ if (! nice_delay_ms(rand_time)) return;
+ set_level(brightness>>1);
+ }
+ }
+
+ // turn the emitter off,
+ // for a random amount of time between 1ms and 8192ms
+ // (with a low bias)
+ rand_time = 1 << (pseudo_rand() % 13);
+ rand_time += pseudo_rand() % rand_time;
+ set_level(0);
+ nice_delay_ms(rand_time); // no return check necessary on final delay
+ break;
+ }
+ #endif
+
+ /* candle mode brighter */
+ #ifdef USE_CANDLE_MODE
+ case candle_mode_e:
+ {
+ /* Nothing */
+ break;
+ }
+ #endif
+
+ case strobe_mode_END:
+ default:
+ {
+ /* Nothing */
+ break;
+ }
+ }
}
#ifdef USE_BATTCHECK
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.