aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2017-09-22 07:20:54 -0600
committerSelene ToyKeeper2017-09-22 07:20:54 -0600
commit91fcc0b8ce25161692a7ef79cbc06d8c735a0318 (patch)
tree771f4570282c7f9fd1df9e3fcd43ceb50edc7360 /spaghetti-monster
parentFixed a bug in gradual_tick(), I think. (diff)
downloadanduril-91fcc0b8ce25161692a7ef79cbc06d8c735a0318.tar.gz
anduril-91fcc0b8ce25161692a7ef79cbc06d8c735a0318.tar.bz2
anduril-91fcc0b8ce25161692a7ef79cbc06d8c735a0318.zip
Added FW3A driver support to FSM and Anduril.
Made lightning storm mode look a bit more like real lightning. Minor refactoring on how single-option config modes save state.
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/anduril.c44
-rw-r--r--spaghetti-monster/fsm-ramping.h12
2 files changed, 36 insertions, 20 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 3d08b26..22f6eb9 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -19,9 +19,10 @@
*/
#define FSM_EMISAR_D4_DRIVER
+//#define FSM_FW3A_DRIVER
#define USE_LVP
#define USE_THERMAL_REGULATION
-#define DEFAULT_THERM_CEIL 45
+#define DEFAULT_THERM_CEIL 50
#define USE_DELAY_MS
#define USE_DELAY_4MS
#define USE_DELAY_ZERO
@@ -283,6 +284,9 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
// 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_max))) {
set_level(0);
delay_4ms(8/4);
@@ -304,6 +308,9 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
// 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))) {
set_level(0);
delay_4ms(8/4);
@@ -678,18 +685,17 @@ uint8_t thermal_config_state(EventPtr event, uint16_t arg) {
}
// advance forward through config steps
else if (event == EV_tick) {
- if (! done) push_state(number_entry_state, 1);
- else {
- save_config();
- // return to beacon mode
- set_state(tempcheck_state, 0);
- }
+ // ask the user for a number
+ if (! done) push_state(number_entry_state, 0);
+ // return to original mode
+ else set_state(tempcheck_state, 0);
return MISCHIEF_MANAGED;
}
// an option was set (return from number_entry_state)
else if (event == EV_reenter_state) {
if (number_entry_value) therm_ceil = 30 + number_entry_value;
if (therm_ceil > MAX_THERM_CEIL) therm_ceil = MAX_THERM_CEIL;
+ save_config();
done = 1;
return MISCHIEF_MANAGED;
}
@@ -706,17 +712,16 @@ uint8_t beacon_config_state(EventPtr event, uint16_t arg) {
}
// advance forward through config steps
else if (event == EV_tick) {
- if (! done) push_state(number_entry_state, 1);
- else {
- save_config();
- // return to beacon mode
- set_state(beacon_state, 0);
- }
+ // ask the user for a number
+ if (! done) push_state(number_entry_state, 0);
+ // return to original mode
+ else set_state(beacon_state, 0);
return MISCHIEF_MANAGED;
}
// an option was set (return from number_entry_state)
else if (event == EV_reenter_state) {
if (number_entry_value) beacon_seconds = number_entry_value;
+ save_config();
done = 1;
return MISCHIEF_MANAGED;
}
@@ -955,7 +960,8 @@ void loop() {
// turn the emitter on at a random level,
// for a random amount of time between 1ms and 32ms
- rand_time = 1 << (pseudo_rand() % 6);
+ //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)
@@ -971,6 +977,16 @@ void loop() {
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,
diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h
index ac4e58c..04beb31 100644
--- a/spaghetti-monster/fsm-ramping.h
+++ b/spaghetti-monster/fsm-ramping.h
@@ -89,12 +89,12 @@ void gradual_tick();
#define MAX_Nx7135 59
#elif RAMP_LENGTH == 150
// FIXME: These values aren't tweaked or tested at all
- // ../../bin/level_calc.py 3 150 7135 4 0.33 150 7135 4 1 840 FET 1 10 2000
- PROGMEM const uint8_t pwm1_levels[] = { 4,4,4,5,5,6,6,7,7,8,9,10,11,12,13,15,16,18,20,22,24,26,28,31,33,36,39,42,46,49,53,57,61,65,70,75,80,85,90,96,102,108,115,121,128,136,143,151,159,167,176,185,194,204,214,224,235,246,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,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,4,6,8,10,13,15,17,20,22,25,28,30,33,36,39,42,45,48,51,55,58,62,65,69,73,76,80,84,88,92,97,101,105,110,115,119,124,129,134,139,144,149,155,160,166,171,177,183,189,195,201,207,214,220,227,234,241,248,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 pwm3_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,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,4,10,17,23,30,36,43,50,57,64,71,78,85,93,100,108,115,123,131,139,148,156,164,173,182,190,199,208,217,227,236,245,255 };
- #define MAX_1x7135 59
- #define MAX_Nx7135 117
+ // ../../../bin/level_calc.py 3 150 7135 1 0.33 150 7135 1 1 850 FET 1 10 1500
+ PROGMEM const uint8_t pwm1_levels[] = { 1,1,1,2,2,2,3,3,4,5,5,6,7,8,9,10,11,12,14,15,17,19,21,23,25,27,29,32,34,37,40,43,46,50,53,57,61,65,69,74,78,83,88,93,99,104,110,116,122,129,135,142,149,157,164,172,180,189,197,206,215,225,235,244,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,2,4,6,8,10,13,15,17,19,22,24,26,29,31,34,37,39,42,45,48,51,54,57,60,64,67,70,74,77,81,85,88,92,96,100,104,108,112,116,121,125,130,134,139,143,148,153,158,163,168,173,179,184,189,195,201,206,212,218,224,230,236,243,249,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 pwm3_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,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,8,19,31,43,55,67,79,91,104,117,130,143,157,170,184,198,212,226,240,255 };
+ #define MAX_1x7135 65
+ #define MAX_Nx7135 130
#endif
#elif PWM_CHANNELS == 4
4-channel PWM not really supported yet, sorry.
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.