-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrone_controller.py
More file actions
executable file
·73 lines (51 loc) · 1.19 KB
/
Copy pathdrone_controller.py
File metadata and controls
executable file
·73 lines (51 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
import smbus
import RPi.GPIO as GPIO
import time
class Motor:
I2C_BUS_ID = 1
bus = None
def __init__(self):
self.bus = smbus.SMBus(I2C_BUS_ID)
pass
def start(self):
self.bus.write_byte_data(0x20, 0x06, 0x00)
return True
def set_target_speed(self, channel, speed):
pass
class RemoteControl:
def __init__(self):
pass
@staticmethod
def on_signal(self):
pass
def start(self):
GPIO.add_event_detect(25, GPIO.FALLING, callback=on_signal)
return True
def read_command(self):
pass
class MainLoop:
rc = None
motor = None
def __init__(self):
self.rc = RemoteControl()
self.motor = Motor()
pass
def start(self):
if not self.rc.start():
return False
if not self.motor.start():
return False
return True
def spin(self):
pass
class Main:
@staticmethod
def main():
controller = MainLoop()
if controller.start():
print("drone started.")
controller.spin()
else:
print("drone start failed.\n")
Main.main()