Oct-23-2020, 12:06 AM
Hi :) im new to python and tried to modifie someone elses code. When i run the debugger syntax error occured and i don't know how to handle that. (im running the code on raspberry pi 4)
[python=the code]
#!/bin/bash
if [[ "$1" == "on" ]] ; then
pigs pwm 14 0 pwm 16 0 pwm 18 0 pmw 20 0
else
if [[ "$1" == "off" ]] ; then
pigs pwm 14 0 pwm 16 0 pwm 18 0 pmw 20 0
else
# trying to compensate for eye's log response to brightness
# tmpR=
# tmpG=
# tmpB=
# but simple linear seems to work better :-(
tmpR=
tmpG=
tmpB=
tmpW=
# convert to integer
tmpR=
tmpG=
tmpB=
tmpW=
# echo "RGB: "$tmpR $tmpG $tmpB
pigs pwm 18 $tmpR pwm 14 $tmpG pwm 16 $tmpB 20 $tmpW
fi
fi
[/python]
The problem is with the
[python=the code]
#!/bin/bash
if [[ "$1" == "on" ]] ; then
pigs pwm 14 0 pwm 16 0 pwm 18 0 pmw 20 0
else
if [[ "$1" == "off" ]] ; then
pigs pwm 14 0 pwm 16 0 pwm 18 0 pmw 20 0
else
# trying to compensate for eye's log response to brightness
# tmpR=
echo 'scale=4; (e(l(2) * (((100 - '$1') * 8) / 100))-0.01)' | bc -l
# tmpG=
echo 'scale=4; (e(l(2) * (((100 - '$2') * 8) / 100))-0.01)' | bc -l
# tmpB=
echo 'scale=4; (e(l(2) * (((100 - '$3') * 8) / 100))-0.01)' | bc -l
# but simple linear seems to work better :-(
tmpR=
echo 'scale=4; ((100-'$1')*255/100)' | bc -l
tmpG=
echo 'scale=4; ((100-'$2')*255/100)' | bc -l
tmpB=
echo 'scale=4; ((100-'$3')*255/100)' | bc -l
tmpW=
echo 'scale=4; ((100-'$4')*255/100)' | bc -l
# convert to integer
tmpR=
echo 'scale=0; ('$tmpR'/1)' | bc -l
tmpG=
echo 'scale=0; ('$tmpG'/1)' | bc -l
tmpB=
echo 'scale=0; ('$tmpB'/1)' | bc -l
tmpW=
echo 'scale=0; ('$tmpW'/1)' | bc -l
# echo "RGB: "$tmpR $tmpG $tmpB
pigs pwm 18 $tmpR pwm 14 $tmpG pwm 16 $tmpB 20 $tmpW
fi
fi
[/python]
The problem is with the
if [[ "$1" == "on" ]] ; then pigs pwm 14 0 pwm 16 0 pwm 18 0 pmw 20 0 else if [[ "$1" == "off" ]] ; then pigs pwm 14 0 pwm 16 0 pwm 18 0 pmw 20 0part.