File tree 1 file changed +22
-14
lines changed
1 file changed +22
-14
lines changed Original file line number Diff line number Diff line change 1
- import sys
2
1
import time
2
+ import os
3
3
4
- import navio .pwm
5
- import navio .util
4
+ import navio .Common .util
6
5
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
8
10
11
+ SERVO_MIN = 1.250 # ms
12
+ SERVO_MAX = 1.750 # ms
9
13
PWM_OUTPUT = 0
10
- SERVO_MIN = 1.250 #ms
11
- SERVO_MAX = 1.750 #ms
12
14
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 )
16
18
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