File tree Expand file tree Collapse file tree 1 file changed +22
-14
lines changed Expand file tree Collapse file tree 1 file changed +22
-14
lines changed Original file line number Diff line number Diff line change 1- import sys
21import time
2+ import os
33
4- import navio .pwm
5- import navio .util
4+ import navio .Common .util
65
7- navio .util .check_apm ()
6+ if navio .Common .util .get_navio_version () == "NAVIO2" :
7+ import navio .Navio2 .RCOutput as RCOutput
8+ else :
9+ import navio .Navio .RCOutput as RCOutput
810
11+ SERVO_MIN = 1.250 # ms
12+ SERVO_MAX = 1.750 # ms
913PWM_OUTPUT = 0
10- SERVO_MIN = 1.250 #ms
11- SERVO_MAX = 1.750 #ms
1214
13- with navio . pwm . PWM ( PWM_OUTPUT ) as pwm :
14- pwm . set_period ( 50 )
15- pwm . enable ( )
15+ if ( os . getuid () != 0 ) :
16+ print "Not root. Please, launch like this: sudo python Servo.py"
17+ exit ( - 1 )
1618
17- while (True ):
18- pwm .set_duty_cycle (SERVO_MIN )
19- time .sleep (1 )
20- pwm .set_duty_cycle (SERVO_MAX )
21- time .sleep (1 )
19+ navio .Common .util .check_apm ()
20+
21+ with RCOutput (PWM_OUTPUT ) as pwm :
22+ pwm .set_period (50 )
23+ pwm .enable ()
24+
25+ while (True ):
26+ pwm .set_duty_cycle (SERVO_MIN )
27+ time .sleep (1 )
28+ pwm .set_duty_cycle (SERVO_MAX )
29+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments