File tree 1 file changed +24
-13
lines changed
1 file changed +24
-13
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
6
-
7
- navio .util .check_apm ()
4
+ import navio .Common .util
5
+ import navio .Navio2 .RCOutput
6
+ import navio .Navio .RCOutput
8
7
9
8
PWM_OUTPUT = 0
10
9
SERVO_MIN = 1.250 #ms
11
10
SERVO_MAX = 1.750 #ms
12
11
13
- with navio .pwm .PWM (PWM_OUTPUT ) as pwm :
14
- pwm .set_period (50 )
15
- pwm .enable ()
12
+ def get_pwm ():
13
+ if (navio .Common .util .get_navio_version () == "NAVIO2" ):
14
+ return navio .Navio2 .RCOutput (PWM_OUTPUT )
15
+ else :
16
+ return navio .Navio .RCOutput (PWM_OUTPUT )
17
+
18
+ if (os .getuid () != 0 ):
19
+ print "Not root. Please, launch like this: sudo python Servo.py"
20
+ exit (- 1 )
21
+
22
+ navio .Common .util .check_apm ()
23
+
24
+ with get_pwm () as pwm :
25
+ pwm .set_period (50 )
26
+ pwm .enable ()
16
27
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 )
28
+ while (True ):
29
+ pwm .set_duty_cycle (SERVO_MIN )
30
+ time .sleep (1 )
31
+ pwm .set_duty_cycle (SERVO_MAX )
32
+ time .sleep (1 )
You can’t perform that action at this time.
0 commit comments