Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with the syntax
#1
Bug 
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=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 0
part.
Reply
#2
This isn't python code, it's bash. Are you trying to run it as python?
Reply
#3
(Oct-23-2020, 12:17 AM)bowlofred Wrote: This isn't python code, it's bash. Are you trying to run it as python?
that explains a lot, thanks and sorry
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020