diff options
| author | Selene ToyKeeper | 2021-09-22 01:54:19 -0600 |
|---|---|---|
| committer | Selene ToyKeeper | 2021-09-22 01:54:19 -0600 |
| commit | 892c6985b8e64997ff61c0510d087364c80e72d4 (patch) | |
| tree | 579f0c9f171a73c07e5062aea1d07ca1424a82fb /spaghetti-monster | |
| parent | clarified where brightness level comes from in beacon/sos/momentary modes (diff) | |
| download | anduril-892c6985b8e64997ff61c0510d087364c80e72d4.tar.gz anduril-892c6985b8e64997ff61c0510d087364c80e72d4.tar.bz2 anduril-892c6985b8e64997ff61c0510d087364c80e72d4.zip | |
added attiny type to the MODELS file, rewrote how MODELS file gets generated
(because it's kind of important to know which MCU each light uses,
and because this will be helpful later when the build system is rewritten)
Diffstat (limited to 'spaghetti-monster')
| -rw-r--r-- | spaghetti-monster/anduril/MODELS | 109 | ||||
| -rw-r--r-- | spaghetti-monster/anduril/Makefile | 8 | ||||
| -rwxr-xr-x | spaghetti-monster/anduril/models.py | 71 |
3 files changed, 128 insertions, 60 deletions
diff --git a/spaghetti-monster/anduril/MODELS b/spaghetti-monster/anduril/MODELS index 11f7dfa..ca9da30 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-sp10s -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: 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/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:]) + |
