Mercurial > code > home > repos > light9
annotate light8/util.py @ 271:97c08a1c4351
gyrocontroller: remap buttons, fix keep mode
Also, solo mode is now default, colors are brighter, numeric names for subs
are converted to subs with only that channel up, send zeroes when exiting
author | David McClosky <dmcc@bigasterisk.com> |
---|---|
date | Fri, 17 Jun 2005 04:23:07 +0000 |
parents | 71489bb71528 |
children |
rev | line source |
---|---|
0 | 1 def maxes(dicts): |
2 ''' | |
3 ({'a' : 5, 'b' : 9}, {'a' : 10, 'b' : 943}) | |
4 ''' | |
5 newdict = {} | |
6 for d in dicts: | |
7 for k,v in d.items(): | |
8 newdict[k] = max(v, newdict.get(k, 0)) | |
9 return newdict | |
10 | |
11 def scaledict(d,scl): | |
12 # scales all values in dict and returns a new dict | |
13 return dict([(k,v*scl) for k,v in d.items()]) | |
14 | |
15 # class Setting that scales, maxes | |
45 | 16 |
17 def subsetdict(d, dkeys, default=0): | |
51
71489bb71528
- Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents:
45
diff
changeset
|
18 """Subset of dictionary d: only the keys in dkeys. If you plan on omitting |
71489bb71528
- Meet Fader. He is going to grow up and be a crossfader some day
dmcc
parents:
45
diff
changeset
|
19 keys, make sure you like the default.""" |
45 | 20 newd = {} # dirty variables! |
21 for k in dkeys: | |
22 newd[k] = d.get(k, default) | |
23 return newd |