aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSelene ToyKeeper2019-10-15 02:34:47 -0600
committerSelene ToyKeeper2019-10-15 02:34:47 -0600
commitc2e7b42b14271acbae1b28ae2289005dcb92e420 (patch)
tree23a3aa19171fc461b25acad76afc94599c362cc7 /bin
parentslowed down rainbow RGB mode, added a ramp-down on stuck-button for safety pu... (diff)
parentmerged Emisar D4S V2 support branch (diff)
downloadanduril-c2e7b42b14271acbae1b28ae2289005dcb92e420.tar.gz
anduril-c2e7b42b14271acbae1b28ae2289005dcb92e420.tar.bz2
anduril-c2e7b42b14271acbae1b28ae2289005dcb92e420.zip
merged changes from fsm branch, including version check and stuck-button safety
Diffstat (limited to 'bin')
-rwxr-xr-xbin/build.sh4
-rwxr-xr-xbin/level_calc.py24
2 files changed, 23 insertions, 5 deletions
diff --git a/bin/build.sh b/bin/build.sh
index 192fa30..fbb24ea 100755
--- a/bin/build.sh
+++ b/bin/build.sh
@@ -14,9 +14,9 @@ export PROGRAM=$1 ; shift
export MCU=attiny$ATTINY
export CC=avr-gcc
export OBJCOPY=avr-objcopy
-export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -DATTINY=$ATTINY -I.. -I../.. -I../../.. -fshort-enums"
+export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -fgnu89-inline -DATTINY=$ATTINY -I.. -I../.. -I../../.. -fshort-enums"
export OFLAGS="-Wall -g -Os -mmcu=$MCU"
-export LDFLAGS=
+export LDFLAGS="-fgnu89-inline"
export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex'
export OBJS=$PROGRAM.o
diff --git a/bin/level_calc.py b/bin/level_calc.py
index f16f8ce..74385da 100755
--- a/bin/level_calc.py
+++ b/bin/level_calc.py
@@ -14,7 +14,7 @@ def main(args):
"""
# Get parameters from the user
questions_main = [
- (str, 'ramp_shape', 'cube', 'Ramp shape? [cube, square, fifth, seventh, ninth, log]'),
+ (str, 'ramp_shape', 'cube', 'Ramp shape? [cube, square, fifth, seventh, ninth, log, N.NN]'),
(int, 'num_channels', 1, 'How many power channels?'),
(int, 'num_levels', 4, 'How many total levels do you want?'),
]
@@ -152,6 +152,16 @@ def multi_pwm(answers, channels):
(cnum+1,
','.join([str(int(round(i))) for i in channel.modes])))
+ # Show highest level for each channel before next channel starts
+ for cnum, channel in enumerate(channels[:-1]):
+ prev = 0
+ i = 1
+ while (i < answers.num_levels) \
+ and (channel.modes[i] >= channel.modes[i-1]) \
+ and (channels[cnum+1].modes[i] == 0):
+ i += 1
+ print('Ch%i max: %i (%.2f/255)' % (cnum, i, channel.modes[i-1]))
+
def get_value(text, default, args):
"""Get input from the user, or from the command line args."""
@@ -179,11 +189,19 @@ shapes = dict(
)
def power(x):
- return shapes[ramp_shape][0](x)
+ try:
+ factor = float(ramp_shape)
+ return math.pow(x, factor)
+ except ValueError:
+ return shapes[ramp_shape][0](x)
def invpower(x):
- return shapes[ramp_shape][1](x)
+ try:
+ factor = float(ramp_shape)
+ return math.pow(x, 1.0 / factor)
+ except ValueError:
+ return shapes[ramp_shape][1](x)
def input_text():