aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spaghetti-monster/anduril/anduril.c44
-rw-r--r--spaghetti-monster/fsm-ramping.h12
-rw-r--r--tk-attiny.h37
3 files changed, 73 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.
diff --git a/tk-attiny.h b/tk-attiny.h
index 887a151..e58c4bb 100644
--- a/tk-attiny.h
+++ b/tk-attiny.h
@@ -203,6 +203,43 @@
#endif // ifdef FSM_EMISAR_D4_DRIVER
+#ifdef FSM_FW3A_DRIVER
+#define DRIVER_TYPE_DEFINED
+/*
+ * ----
+ * Reset -|1 8|- VCC
+ * eswitch -|2 7|- optic nerve
+ * FET -|3 6|- 7x7135
+ * GND -|4 5|- 1x7135
+ * ----
+ */
+
+#define PWM_CHANNELS 3
+
+#define SWITCH_PIN PB3 // pin 2
+#define SWITCH_PCINT PCINT3 // pin 2 pin change interrupt
+
+#define PWM1_PIN PB0 // pin 5, 1x7135 PWM
+#define PWM1_LVL OCR0A // OCR0A is the output compare register for PB0
+#define PWM2_PIN PB1 // pin 6, FET PWM
+#define PWM2_LVL OCR0B // OCR0B is the output compare register for PB1
+#define PWM3_PIN PB4 // pin 3
+#define PWM3_LVL OCR1B
+
+#define VISION_PIN PB2 // pin 7, optic nerve
+#define ADC_CHANNEL 0x01 // MUX 01 corresponds with PB2
+#define ADC_DIDR ADC1D // Digital input disable bit corresponding with PB2
+#define ADC_PRSCL 0x06 // clk/64
+
+//#define TEMP_DIDR ADC4D
+#define TEMP_CHANNEL 0b00001111
+
+#define FAST 0xA3 // fast PWM both channels
+#define PHASE 0xA1 // phase-correct PWM both channels
+
+#endif // ifdef FSM_FW3A_DRIVER
+
+
#ifdef FSM_TKSABER_DRIVER
#define DRIVER_TYPE_DEFINED
/*
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.