Skip to content

Commit

Permalink
python: Servo: add Navio+ support
Browse files Browse the repository at this point in the history
Add root check
Add Navio+ entry and add shield auto choice
  • Loading branch information
Igor Anokhin committed Jan 9, 2018
1 parent 4f1e4b1 commit b3779ae
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions Python/Servo.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import sys
import time
import os

import navio.pwm
import navio.util
import navio.Common.util

navio.util.check_apm()
if navio.Common.util.get_navio_version() == "NAVIO2":
import navio.Navio2.RCOutput as RCOutput
else:
import navio.Navio.RCOutput as RCOutput

SERVO_MIN = 1.250 # ms
SERVO_MAX = 1.750 # ms
PWM_OUTPUT = 0
SERVO_MIN = 1.250 #ms
SERVO_MAX = 1.750 #ms

with navio.pwm.PWM(PWM_OUTPUT) as pwm:
pwm.set_period(50)
pwm.enable()
if (os.getuid() != 0):
print "Not root. Please, launch like this: sudo python Servo.py"
exit(-1)

while (True):
pwm.set_duty_cycle(SERVO_MIN)
time.sleep(1)
pwm.set_duty_cycle(SERVO_MAX)
time.sleep(1)
navio.Common.util.check_apm()

with RCOutput(PWM_OUTPUT) as pwm:
pwm.set_period(50)
pwm.enable()

while (True):
pwm.set_duty_cycle(SERVO_MIN)
time.sleep(1)
pwm.set_duty_cycle(SERVO_MAX)
time.sleep(1)

0 comments on commit b3779ae

Please sign in to comment.