aboutsummaryrefslogtreecommitdiff
path: root/spaghetti-monster
diff options
context:
space:
mode:
Diffstat (limited to 'spaghetti-monster')
-rw-r--r--spaghetti-monster/anduril/MODELS111
-rw-r--r--spaghetti-monster/anduril/Makefile8
-rw-r--r--spaghetti-monster/anduril/anduril-manual.txt8
-rw-r--r--spaghetti-monster/anduril/aux-leds.c2
-rw-r--r--spaghetti-monster/anduril/cfg-blf-lantern.h4
-rw-r--r--spaghetti-monster/anduril/cfg-blf-q8-t1616.h4
-rw-r--r--spaghetti-monster/anduril/cfg-blf-q8.h4
-rw-r--r--spaghetti-monster/anduril/cfg-thefreeman-lin16dac.h45
-rwxr-xr-xspaghetti-monster/anduril/models.py71
-rw-r--r--spaghetti-monster/anduril/tint-ramping.c2
-rw-r--r--spaghetti-monster/fsm-ramping.c2
11 files changed, 188 insertions, 73 deletions
diff --git a/spaghetti-monster/anduril/MODELS b/spaghetti-monster/anduril/MODELS
index 7a2c438..317bb6a 100644
--- a/spaghetti-monster/anduril/MODELS
+++ b/spaghetti-monster/anduril/MODELS
@@ -1,55 +1,58 @@
-Model numbers:
-0111 emisar-d4
-0112 emisar-d4-219c
-0113 emisar-d4v2
-0114 emisar-d4v2-219
-0115 emisar-d4v2-nofet
-0121 emisar-d1
-0122 emisar-d1s
-0123 emisar-d1v2
-0131 emisar-d4s
-0132 emisar-d4s-219c
-0133 emisar-d4sv2
-0134 emisar-d4sv2-219
-0135 emisar-d4sv2-tintramp
-0136 emisar-d4sv2-tintramp-fet
-0141 emisar-d18
-0142 emisar-d18-219
-0211 noctigon-kr4
-0212 noctigon-kr4-nofet
-0213 noctigon-kr4-219
-0214 noctigon-kr4-219b
-0251 noctigon-k1
-0252 noctigon-k1-sbt90
-0253 noctigon-k1-12v
-0261 noctigon-k9.3
-0262 noctigon-k9.3-nofet
-0263 noctigon-k9.3-219
-0265 noctigon-k9.3-tintramp-nofet
-0266 noctigon-k9.3-tintramp-fet
-0267 noctigon-k9.3-tintramp-219
-0311 fw3a
-0312 fw3a-219
-0313 fw3a-nofet
-0314 fw3x-lume1
-0321 blf-gt
-0322 blf-gt-mini
-0411 ff-rot66
-0412 ff-rot66-219
-0413 ff-rot66g2
-0421 ff-pl47
-0422 ff-pl47-219
-0423 ff-pl47g2
-0441 ff-e01
-0511 mateminco-mf01s
-0521 mateminco-mf01-mini
-0611 blf-q8
-0612 sofirn-sp36
-0613 blf-q8-t1616
-0614 sofirn-sp36-t1616
-0621 blf-lantern
-0622 blf-lantern-t1616
-0631 sofirn-sp10-pro
-1618 gchart-fet1-t1616
+Model Name MCU
+----- ---- ---
+0111 emisar-d4 attiny85
+0112 emisar-d4-219c attiny85
+0113 emisar-d4v2 attiny1634
+0114 emisar-d4v2-219 attiny1634
+0115 emisar-d4v2-nofet attiny1634
+0121 emisar-d1 attiny85
+0122 emisar-d1s attiny85
+0123 emisar-d1v2 attiny1634
+0131 emisar-d4s attiny85
+0132 emisar-d4s-219c attiny85
+0133 emisar-d4sv2 attiny1634
+0134 emisar-d4sv2-219 attiny1634
+0135 emisar-d4sv2-tintramp attiny1634
+0136 emisar-d4sv2-tintramp-fet attiny1634
+0141 emisar-d18 attiny85
+0142 emisar-d18-219 attiny85
+0211 noctigon-kr4 attiny1634
+0212 noctigon-kr4-nofet attiny1634
+0213 noctigon-kr4-219 attiny1634
+0214 noctigon-kr4-219b attiny1634
+0251 noctigon-k1 attiny1634
+0252 noctigon-k1-sbt90 attiny1634
+0253 noctigon-k1-12v attiny1634
+0261 noctigon-k9.3 attiny1634
+0262 noctigon-k9.3-nofet attiny1634
+0263 noctigon-k9.3-219 attiny1634
+0265 noctigon-k9.3-tintramp-nofet attiny1634
+0266 noctigon-k9.3-tintramp-fet attiny1634
+0267 noctigon-k9.3-tintramp-219 attiny1634
+0311 fw3a attiny85
+0312 fw3a-219 attiny85
+0313 fw3a-nofet attiny85
+0314 fw3x-lume1 attiny1634
+0321 blf-gt attiny85
+0322 blf-gt-mini attiny85
+0411 ff-rot66 attiny85
+0412 ff-rot66-219 attiny85
+0413 ff-rot66g2 attiny85
+0421 ff-pl47 attiny85
+0422 ff-pl47-219 attiny85
+0423 ff-pl47g2 attiny85
+0441 ff-e01 attiny85
+0511 mateminco-mf01s attiny85
+0521 mateminco-mf01-mini attiny85
+0611 blf-q8 attiny85
+0612 sofirn-sp36 attiny85
+0613 blf-q8-t1616 attiny1616
+0614 sofirn-sp36-t1616 attiny1616
+0621 blf-lantern attiny85
+0622 blf-lantern-t1616 attiny1616
+0631 sofirn-sp10s attiny1616
+1618 gchart-fet1-t1616 attiny1616
+
Duplicates:
-Missing:
+
+Missing: \ No newline at end of file
diff --git a/spaghetti-monster/anduril/Makefile b/spaghetti-monster/anduril/Makefile
index d1e6b46..332f0f3 100644
--- a/spaghetti-monster/anduril/Makefile
+++ b/spaghetti-monster/anduril/Makefile
@@ -8,13 +8,7 @@ todo:
@egrep 'TODO:|FIXME:' *.[ch]
models:
- @echo -n > MODELS
- @echo 'Model numbers:' >> MODELS
- @grep '^#define MODEL_NUMBER' cfg-*.h | perl -ne '/cfg-(.*)\.h:#define MODEL_NUMBER "(.*)"/ && print "$$2\t$$1\n";' | sort -n >> MODELS
- @echo 'Duplicates:' >> MODELS
- @cat cfg-*.h | grep '^#define MODEL_NUMBER' | sort | uniq -c | grep -v ' 1 ' || true >> MODELS
- @echo 'Missing:' >> MODELS
- @for f in cfg-*.h ; do grep --silent '^#define MODEL_NUMBER' $$f ; if [ "$$?" = "1" ] ; then echo " $$f" ; fi ; done >> MODELS
+ @./models.py > MODELS
@cat MODELS
.phony: clean todo
diff --git a/spaghetti-monster/anduril/anduril-manual.txt b/spaghetti-monster/anduril/anduril-manual.txt
index a8f3730..009e95e 100644
--- a/spaghetti-monster/anduril/anduril-manual.txt
+++ b/spaghetti-monster/anduril/anduril-manual.txt
@@ -173,8 +173,9 @@ There are four ways to access ramping mode when the light is off:
While the light is on, a few actions are available:
- 1C: Turn off.
- - 2C: Go to or from the ceiling level.
- (or if already at ceiling, and not in Simple UI, go to/from turbo)
+ - 2C: Go to or from the turbo level.
+ (or if it has regulated down, "bump" back up to turbo)
+ (turbo level / behavior is configurable)
- 1H: Change brightness (up). If the button was released less than a
second ago, or if it's already at the ceiling, it goes down instead.
- 2H: Change brightness (down).
@@ -760,8 +761,7 @@ Off Any 15+C Version check
Ramp Any 1C Off
Ramp Any 1H Ramp (up, with reversing)
Ramp Any 2H Ramp (down)
-Ramp Simple 2C Go to/from ceiling
-Ramp Full 2C Go to/from ceiling (or turbo if at ceil already)
+Ramp Any 2C Go to/from ceiling or turbo (configurable)
Ramp Full 3C Change ramp style (smooth / stepped)
Ramp Any 3H Tint ramping (on some lights)
Ramp Full 3H Momentary turbo (on lights without tint ramping)
diff --git a/spaghetti-monster/anduril/aux-leds.c b/spaghetti-monster/anduril/aux-leds.c
index 3195fdc..a0a6d7a 100644
--- a/spaghetti-monster/anduril/aux-leds.c
+++ b/spaghetti-monster/anduril/aux-leds.c
@@ -64,7 +64,7 @@ uint8_t voltage_to_rgb() {
255, 6, // 7, R+G+B
};
uint8_t volts = voltage;
- if (volts < 29) return 0;
+ if (volts < VOLTAGE_LOW) return 0;
uint8_t i;
for (i = 0; volts >= levels[i]; i += 2) {}
diff --git a/spaghetti-monster/anduril/cfg-blf-lantern.h b/spaghetti-monster/anduril/cfg-blf-lantern.h
index ff28a98..a989ca4 100644
--- a/spaghetti-monster/anduril/cfg-blf-lantern.h
+++ b/spaghetti-monster/anduril/cfg-blf-lantern.h
@@ -53,8 +53,8 @@
#define SIMPLE_UI_CEIL RAMP_DISCRETE_CEIL
#define SIMPLE_UI_STEPS RAMP_DISCRETE_STEPS
-// also at Sofirn's request, enable 2 click turbo
-#define USE_2C_MAX_TURBO
+// also at Sofirn's request, enable 2 click turbo (Anduril 1 style)
+#define DEFAULT_2C_STYLE 1
#define USE_SOS_MODE
#define USE_SOS_MODE_IN_BLINKY_GROUP
diff --git a/spaghetti-monster/anduril/cfg-blf-q8-t1616.h b/spaghetti-monster/anduril/cfg-blf-q8-t1616.h
index 340faa1..30a3368 100644
--- a/spaghetti-monster/anduril/cfg-blf-q8-t1616.h
+++ b/spaghetti-monster/anduril/cfg-blf-q8-t1616.h
@@ -34,8 +34,8 @@
#define SIMPLE_UI_CEIL 150
#define SIMPLE_UI_STEPS 5
-// also at Sofirn's request, enable 2 click turbo
-#define USE_2C_MAX_TURBO
+// also at Sofirn's request, enable 2 click turbo (Anduril 1 style)
+#define DEFAULT_2C_STYLE 1
// enable SOS in the blinkies group
#define USE_SOS_MODE
diff --git a/spaghetti-monster/anduril/cfg-blf-q8.h b/spaghetti-monster/anduril/cfg-blf-q8.h
index 00bdd8a..6a5055c 100644
--- a/spaghetti-monster/anduril/cfg-blf-q8.h
+++ b/spaghetti-monster/anduril/cfg-blf-q8.h
@@ -33,8 +33,8 @@
#define SIMPLE_UI_CEIL 150
#define SIMPLE_UI_STEPS 5
-// also at Sofirn's request, enable 2 click turbo
-#define USE_2C_MAX_TURBO
+// also at Sofirn's request, enable 2 click turbo (Anduril 1 style)
+#define DEFAULT_2C_STYLE 1
// enable SOS in the blinkies group
#define USE_SOS_MODE
diff --git a/spaghetti-monster/anduril/cfg-thefreeman-lin16dac.h b/spaghetti-monster/anduril/cfg-thefreeman-lin16dac.h
new file mode 100644
index 0000000..64dcd8c
--- /dev/null
+++ b/spaghetti-monster/anduril/cfg-thefreeman-lin16dac.h
@@ -0,0 +1,45 @@
+// thefreeman's Linear 16 driver using DAC control
+#define MODEL_NUMBER "0000" // TBD
+#include "hwdef-thefreeman-lin16dac.h"
+// ATTINY: 1616
+
+// the button lights up
+#define USE_INDICATOR_LED
+// the button is visible while main LEDs are on
+#define USE_INDICATOR_LED_WHILE_RAMPING
+// off mode: low (1)
+// lockout: blinking (3)
+#define INDICATOR_LED_DEFAULT_MODE ((3<<2) + 1)
+
+#undef BLINK_AT_RAMP_MIDDLE
+
+// We're abusing the Dynamic PWM functionality to set the VREF instead of PWM TOP.
+// We don't want the Gradual functionality to mess with the PWM_TOP value.
+#ifdef USE_SET_LEVEL_GRADUALLY
+#undef USE_SET_LEVEL_GRADUALLY
+#endif
+
+// level_calc.py ninth 2 150 7135 1 0.03 6.4 7135 1 6.3 1600
+#define RAMP_LENGTH 150
+#define USE_DYN_PWM
+
+// PWM1: DAC Data, PWM Tops: VREF selector
+#define PWM1_LEVELS 25,25,33,41,41,50,58,66,75,83,92,108,117,133,150,167,192,209,234,58,64,71,80,90,99,110,121,134,149,163,180,198,218,241,1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,5,5,6,6,7,7,8,8,9,10,11,11,12,13,14,15,16,18,19,20,22,23,25,26,28,30,32,34,36,39,41,44,47,50,53,56,59,63,67,71,75,79,84,89,94,100,105,112,118,124,131,139,146,154,163,172,181,191,201,212,223,234,246,57,60,63,66,69,73,76,80,84,88,93,97,102,107,112,117,123,129,135,141,147,154,161,169,176,184,193,201,210,220,229,239,250,255
+#define PWM_TOPS 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18
+
+#define MAX_1x7135 34
+#define HALFSPEED_LEVEL 14
+#define QUARTERSPEED_LEVEL 6
+
+#define RAMP_SMOOTH_FLOOR 1
+#define RAMP_SMOOTH_CEIL 120
+// 10, 28, 46, [65], 83, 101, 120
+#define RAMP_DISCRETE_FLOOR 10
+#define RAMP_DISCRETE_CEIL RAMP_SMOOTH_CEIL
+#define RAMP_DISCRETE_STEPS 7
+
+// stop panicking at ~30% power
+#define THERM_FASTER_LEVEL 123
+
+// enable 2 click turbo
+#define DEFAULT_2C_STYLE 1
diff --git a/spaghetti-monster/anduril/models.py b/spaghetti-monster/anduril/models.py
new file mode 100755
index 0000000..1985352
--- /dev/null
+++ b/spaghetti-monster/anduril/models.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+
+import os
+import re
+
+def main(args):
+ """models.py: scan build targets to generate the MODELS file
+ """
+
+ models = []
+
+ # load all cfg-*.h files
+ paths = os.listdir('.')
+ for p in paths:
+ if p.startswith('cfg-') and p.endswith('.h'):
+ m = load_cfg(p)
+ models.append(m)
+
+ # sort by model number
+ foo = [(m.num, m.name, m) for m in models]
+ foo.sort()
+ models = [x[-1] for x in foo]
+
+ fmt = '%s\t%-30s\t%s'
+ print(fmt % ('Model', 'Name', 'MCU'))
+ print(fmt % ('-----', '----', '---'))
+ for m in models:
+ print(fmt % (m.num, m.name, m.attiny))
+
+ print('\nDuplicates:')
+ for i, m in enumerate(models):
+ for m2 in models[i+1:]:
+ #if (m.num == m2.num) and (m is not m2):
+ if m.num == m2.num:
+ print('%s\t%s, %s' % (m.num, m.name, m2.name))
+
+ print('\nMissing:')
+ for m in models:
+ if not m.num:
+ print(m.name)
+
+
+class Empty:
+ pass
+
+
+def load_cfg(path):
+ m = Empty()
+ m.name, m.num, m.attiny = '', '', 'attiny85'
+
+ m.name = path.replace('cfg-', '').replace('.h', '')
+
+ num_pat = re.compile(r'#define\s+MODEL_NUMBER\s+"(\d+)"')
+ mcu_pat = re.compile(r'ATTINY:\s+(\d+)')
+ # TODO? use C preprocessor to generate more complete file to scan
+ with open(path) as fp:
+ for line in fp:
+ found = num_pat.search(line)
+ if found:
+ m.num = found.group(1)
+ found = mcu_pat.search(line)
+ if found:
+ m.attiny = 'attiny' + found.group(1)
+
+ return m
+
+
+if __name__ == "__main__":
+ import sys
+ main(sys.argv[1:])
+
diff --git a/spaghetti-monster/anduril/tint-ramping.c b/spaghetti-monster/anduril/tint-ramping.c
index 0b077ef..aa9b1f6 100644
--- a/spaghetti-monster/anduril/tint-ramping.c
+++ b/spaghetti-monster/anduril/tint-ramping.c
@@ -31,7 +31,7 @@ uint8_t tint_ramping_state(Event event, uint16_t arg) {
if (! arg) {
tint = !tint;
set_level(actual_level);
- blink_once();
+ //blink_once(); // unnecessary, and kind of annoying on moon
}
return EVENT_HANDLED;
}
diff --git a/spaghetti-monster/fsm-ramping.c b/spaghetti-monster/fsm-ramping.c
index e8fcde7..05c2e0e 100644
--- a/spaghetti-monster/fsm-ramping.c
+++ b/spaghetti-monster/fsm-ramping.c
@@ -267,7 +267,9 @@ void gradual_tick() {
)
{
//actual_level = gt + 1;
+ uint8_t orig = gradual_target;
set_level(gt + 1);
+ gradual_target = orig;
}
// is handled in set_level()
//#ifdef USE_TINT_RAMPING