aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSelene ToyKeeper2018-08-22 22:59:48 -0600
committerSelene ToyKeeper2018-08-22 22:59:48 -0600
commite2a07531ebe03e65f1c546b1d3dccde66d387c75 (patch)
tree8b7199baed09fd6c1c0672178488be42aa933d27
parentReplaced hardcoded eeprom index values with auto-calculated enums. (diff)
downloadanduril-e2a07531ebe03e65f1c546b1d3dccde66d387c75.tar.gz
anduril-e2a07531ebe03e65f1c546b1d3dccde66d387c75.tar.bz2
anduril-e2a07531ebe03e65f1c546b1d3dccde66d387c75.zip
Rearranged strobe group mode order, fixed party strobe.
Was broken due to some remaining hardcoded stuff about the mode numbers. Lost the 20 bytes saved earlier, but that was only reduced due to accidentally compiling out the party strobe code.
-rwxr-xr-xspaghetti-monster/anduril/anduril.c111
1 files changed, 58 insertions, 53 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index ccb42ab..3637c3d 100755
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -295,12 +295,6 @@ uint8_t target_level = 0;
// internal numbering for strobe modes
#ifdef USE_STROBE_STATE
typedef enum {
- #ifdef USE_CANDLE_MODE
- candle_mode_e,
- #endif
- #ifdef USE_BIKE_FLASHER_MODE
- bike_flasher_e,
- #endif
#ifdef USE_PARTY_STROBE_MODE
party_strobe_e,
#endif
@@ -310,14 +304,24 @@ typedef enum {
#ifdef USE_LIGHTNING_MODE
lightning_storm_e,
#endif
+ #ifdef USE_CANDLE_MODE
+ candle_mode_e,
+ #endif
+ #ifdef USE_BIKE_FLASHER_MODE
+ bike_flasher_e,
+ #endif
strobe_mode_END
} strobe_mode_te;
const int NUM_STROBES = strobe_mode_END;
// which strobe mode is active?
+#ifdef USE_CANDLE_MODE
+volatile strobe_mode_te strobe_type = candle_mode_e;
+#else
volatile strobe_mode_te strobe_type = 0;
#endif
+#endif
#if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
// party / tactical strobe timing
@@ -814,6 +818,22 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) {
else if (event == EV_click1_hold) {
if (0) {} // placeholder
+ // party / tactical strobe faster
+ #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
+ #ifdef USE_TACTICAL_STROBE_MODE
+ else if (st <= tactical_strobe_e) {
+ #else
+ else if (st == party_strobe_e) {
+ #endif
+ if ((arg & 1) == 0) {
+ if (strobe_delays[st] > 8) strobe_delays[st] --;
+ }
+ }
+ #endif
+
+ // lightning has no adjustments
+ //else if (st == lightning_storm_e) {}
+
// candle mode brighter
#ifdef USE_CANDLE_MODE
else if (st == candle_mode_e) {
@@ -831,7 +851,14 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) {
}
#endif
- // party / tactical strobe faster
+ return MISCHIEF_MANAGED;
+ }
+ // click, hold: change speed (go slower)
+ // or change brightness (dimmer)
+ else if (event == EV_click2_hold) {
+ if (0) {} // placeholder
+
+ // party / tactical strobe slower
#if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
#ifdef USE_TACTICAL_STROBE_MODE
else if (st <= tactical_strobe_e) {
@@ -839,7 +866,7 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) {
else if (st == party_strobe_e) {
#endif
if ((arg & 1) == 0) {
- if (strobe_delays[st-1] > 8) strobe_delays[st-1] --;
+ if (strobe_delays[st] < 255) strobe_delays[st] ++;
}
}
#endif
@@ -847,13 +874,6 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) {
// lightning has no adjustments
//else if (st == lightning_storm_e) {}
- return MISCHIEF_MANAGED;
- }
- // click, hold: change speed (go slower)
- // or change brightness (dimmer)
- else if (event == EV_click2_hold) {
- if (0) {} // placeholder
-
// candle mode dimmer
#ifdef USE_CANDLE_MODE
else if (st == candle_mode_e) {
@@ -871,22 +891,6 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) {
}
#endif
- // party / tactical strobe slower
- #if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
- #ifdef USE_TACTICAL_STROBE_MODE
- else if (st <= tactical_strobe_e) {
- #else
- else if (st == party_strobe_e) {
- #endif
- if ((arg & 1) == 0) {
- if (strobe_delays[st-1] < 255) strobe_delays[st-1] ++;
- }
- }
- #endif
-
- // lightning has no adjustments
- //else if (st == lightning_storm_e) {}
-
return MISCHIEF_MANAGED;
}
// release hold: save new strobe settings
@@ -1791,26 +1795,6 @@ void loop() {
if (0) {} // placeholder
- // candle mode
- #ifdef USE_CANDLE_MODE
- //else if (st == candle_mode_e) {}
- #endif
-
- // bike flasher
- #ifdef USE_BIKE_FLASHER_MODE
- else if (st == 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
- }
- #endif
-
// party / tactial strobe
#if defined(USE_PARTY_STROBE_MODE) || defined(USE_TACTICAL_STROBE_MODE)
#ifdef USE_TACTICAL_STROBE_MODE
@@ -1818,11 +1802,11 @@ void loop() {
#else
else if (st == party_strobe_e) {
#endif
- uint8_t del = strobe_delays[st-1];
+ uint8_t del = strobe_delays[st];
// 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 (st == party_strobe_e) { // party strobe
if (del < 42) delay_zero();
else nice_delay_ms(1);
} else { //tactical strobe
@@ -1880,6 +1864,27 @@ void loop() {
}
#endif
+ // candle mode
+ #ifdef USE_CANDLE_MODE
+ // this NOP should get compiled out
+ else if (st == candle_mode_e) {}
+ #endif
+
+ // bike flasher
+ #ifdef USE_BIKE_FLASHER_MODE
+ else if (st == 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
+ }
+ #endif
+
}
#endif // #ifdef USE_STROBE_STATE
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.