aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
authorSelene ToyKeeper2017-12-11 15:03:17 -0700
committerSelene ToyKeeper2017-12-11 15:03:17 -0700
commite52df9c3ac606b24bda70287bc62323b46b7b4c4 (patch)
treed8964447c4e790f1d86c1c7cfff8267b1e1e228b /spaghetti-monster
parentMade it possible to override address of eeprom array in RAM. (diff)
downloadanduril-e52df9c3ac606b24bda70287bc62323b46b7b4c4.tar.gz
anduril-e52df9c3ac606b24bda70287bc62323b46b7b4c4.tar.bz2
anduril-e52df9c3ac606b24bda70287bc62323b46b7b4c4.zip
Working toward a FW3A release now. Made strobes use Nx7135 (when available) instead of FET.
Added some ideas. Simplified some syntax.
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/anduril.c52
-rw-r--r--spaghetti-monster/fsm-ramping.h6
2 files changed, 38 insertions, 20 deletions
diff --git a/spaghetti-monster/anduril/anduril.c b/spaghetti-monster/anduril/anduril.c
index 85fe493..4915b39 100644
--- a/spaghetti-monster/anduril/anduril.c
+++ b/spaghetti-monster/anduril/anduril.c
@@ -21,14 +21,14 @@
/********* User-configurable options *********/
// Physical driver type
//#define FSM_EMISAR_D4_DRIVER
-#define FSM_BLF_Q8_DRIVER
-//#define FSM_FW3A_DRIVER
+//#define FSM_BLF_Q8_DRIVER
+#define FSM_FW3A_DRIVER
#define USE_LVP
#define USE_THERMAL_REGULATION
#define DEFAULT_THERM_CEIL 50
#define USE_SET_LEVEL_GRADUALLY
-//#define BLINK_AT_CHANNEL_BOUNDARIES
+#define BLINK_AT_CHANNEL_BOUNDARIES
//#define BLINK_AT_RAMP_FLOOR
#define BLINK_AT_RAMP_CEILING
#define BATTCHECK_VpT
@@ -60,6 +60,8 @@
#define VOLTAGE_FUDGE_FACTOR 7 // add 0.35V
#elif defined(FSM_EMISAR_D4_DRIVER)
#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V
+#elif defined(FSM_FW3A_DRIVER)
+#define VOLTAGE_FUDGE_FACTOR 5 // add 0.25V
#endif
// try to auto-detect how many eeprom bytes
@@ -94,6 +96,14 @@
#endif
#define NUM_STROBES (NUM_STROBES_BASE+ADD_LIGHTNING_STROBE+ADD_CANDLE_MODE)
+// full FET strobe can be a bit much... use max regulated level instead,
+// if there's a bright enough regulated level
+#ifdef MAX_Nx7135
+#define STROBE_BRIGHTNESS MAX_Nx7135
+#else
+#define STROBE_BRIGHTNESS MAX_LEVEL
+#endif
+
#include "spaghetti-monster.h"
@@ -385,17 +395,15 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
#if defined(BLINK_AT_RAMP_CEILING) || defined(BLINK_AT_CHANNEL_BOUNDARIES)
// only blink once for each threshold
if ((memorized_level != actual_level) && (
+ 0 // for easier syntax below
#ifdef BLINK_AT_CHANNEL_BOUNDARIES
- (memorized_level == MAX_1x7135)
+ || (memorized_level == MAX_1x7135)
#if PWM_CHANNELS >= 3
|| (memorized_level == MAX_Nx7135)
#endif
- #ifdef BLINK_AT_RAMP_CEILING
- ||
- #endif
#endif
#ifdef BLINK_AT_RAMP_CEILING
- (memorized_level == mode_max)
+ || (memorized_level == mode_max)
#endif
#if defined(USE_REVERSING) && defined(BLINK_AT_RAMP_FLOOR)
|| (memorized_level == mode_min)
@@ -437,17 +445,15 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
#if defined(BLINK_AT_RAMP_FLOOR) || defined(BLINK_AT_CHANNEL_BOUNDARIES)
// only blink once for each threshold
if ((memorized_level != actual_level) && (
+ 0 // for easier syntax below
#ifdef BLINK_AT_CHANNEL_BOUNDARIES
- (memorized_level == MAX_1x7135)
+ || (memorized_level == MAX_1x7135)
#if PWM_CHANNELS >= 3
|| (memorized_level == MAX_Nx7135)
#endif
- #ifdef BLINK_AT_RAMP_FLOOR
- ||
- #endif
#endif
#ifdef BLINK_AT_RAMP_FLOOR
- (memorized_level == mode_min)
+ || (memorized_level == mode_min)
#endif
)) {
set_level(0);
@@ -467,6 +473,15 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
#if defined(USE_SET_LEVEL_GRADUALLY) || defined(USE_REVERSING)
else if (event == EV_tick) {
#ifdef USE_SET_LEVEL_GRADUALLY
+ /* TODO: make thermal adjustment speed scale with magnitude
+ if (ticks_since_adjust > ticks_per_adjust) {
+ gradual_tick();
+ ticks_since_adjust = 0;
+ ticks_per_adjust = (TICKS_PER_SECOND*2) \
+ / (diff(actual_level, target_level)) \
+ + 8 - log2(actual_level);
+ }
+ */
if (!(arg & 7)) gradual_tick();
//if (!(arg & 3)) gradual_tick();
//gradual_tick();
@@ -527,6 +542,7 @@ uint8_t steady_state(EventPtr event, uint16_t arg) {
uint8_t strobe_state(EventPtr event, uint16_t arg) {
+ // FIXME: re-order the strobes so candle and lightning are adjacent
#ifdef USE_CANDLE_MODE
//#define MAX_CANDLE_LEVEL (RAMP_SIZE-8-6-4)
#define MAX_CANDLE_LEVEL (RAMP_SIZE/2)
@@ -534,7 +550,7 @@ uint8_t strobe_state(EventPtr event, uint16_t arg) {
static uint8_t candle_wave2 = 0;
static uint8_t candle_wave3 = 0;
static uint8_t candle_wave2_speed = 0;
- static uint8_t candle_mode_brightness = 12;
+ static uint8_t candle_mode_brightness = 20;
#endif
if (event == EV_enter_state) {
@@ -813,6 +829,7 @@ uint8_t lockout_state(EventPtr event, uint16_t arg) {
uint8_t momentary_state(EventPtr event, uint16_t arg) {
+ // TODO: momentary strobe here? (for light painting)
if (event == EV_click1_press) {
set_level(memorized_level);
empty_event_sequence(); // don't attempt to parse multiple clicks
@@ -1014,7 +1031,6 @@ uint8_t number_entry_state(EventPtr event, uint16_t arg) {
blinks_left = arg;
entry_step = 0;
wait_ticks = 0;
- // TODO: blink out the 'arg' to show which option this is
return MISCHIEF_MANAGED;
}
// advance through the process:
@@ -1279,10 +1295,8 @@ void loop() {
if (state == strobe_state) {
// party / tactical strobe
if (strobe_type < 2) {
- // FIXME: for tactical strobe, use max Nx7135 level?
- // (perhaps a compile option)
- // (is relevant for FW3A)
- set_level(MAX_LEVEL);
+ // TODO: make tac strobe brightness configurable?
+ set_level(STROBE_BRIGHTNESS);
CLKPR = 1<<CLKPCE; CLKPR = 0; // run at full speed
if (strobe_type == 0) { // party strobe
if (strobe_delays[strobe_type] < 42) delay_zero();
diff --git a/spaghetti-monster/fsm-ramping.h b/spaghetti-monster/fsm-ramping.h
index 900630c..1657e4a 100644
--- a/spaghetti-monster/fsm-ramping.h
+++ b/spaghetti-monster/fsm-ramping.h
@@ -91,12 +91,16 @@ 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 1 65 7135 1 0.8 150
+ // ... mixed with this:
// ../../../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 pwm1_levels[] = { 1,1,2,2,3,3,4,4,5,6,7,8,9,10,12,13,14,15,17,19,20,22,24,26,29,31,34,36,39,42,45,48,51,55,59,62,66,70,75,79,84,89,93,99,104,110,115,121,127,134,140,147,154,161,168,176,184,192,200,209,217,226,236,245,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,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
+ #define HALFSPEED_LEVEL 14
+ #define QUARTERSPEED_LEVEL 5
#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.