MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / __init__

Method __init__

Projects/ServoControl/keyboarded_robot.py:41–67  ·  view source on GitHub ↗

Instantiates the key-bindings between the GoPiGo3 and the keyboard's keys. Sets the order of the keys in the menu.

(self)

Source from the content-addressed store, hash-verified

39
40
41 def __init__(self):
42 """
43 Instantiates the key-bindings between the GoPiGo3 and the keyboard's keys.
44 Sets the order of the keys in the menu.
45 """
46 self.gopigo3 = easy.EasyGoPiGo3()
47 self.servo1 = self.gopigo3.init_servo("SERVO1")
48 self.servo2 = self.gopigo3.init_servo("SERVO2")
49
50 self.keybindings = {
51 "<F1>" : ["Turn SERVO1 completely to 0 degrees", "leftservo1_immediately"],
52 "<F2>" : ["Turn SERVO1 completely to 180 degrees", "rightservo1_immediately"],
53
54 "<F5>" : ["Turn SERVO2 completely to 0 degrees", "leftservo2_immediately"],
55 "<F6>" : ["Turn SERVO2 completely to 180 degrees", "rightservo2_immediately"],
56
57 "a" : ["Turn SERVO1 towards 0 degrees incrementely", "leftservo1_incrementally"],
58 "d" : ["Turn SERVO1 towords 180 degrees incrementely", "rightservo1_incrementally"],
59
60 "<LEFT>" : ["Turn SERVO2 towards 0 degrees incrementely", "leftservo2_incrementally"],
61 "<RIGHT>" : ["Turn SERVO2 towards 180 degrees incrementely", "rightservo2_incrementally"],
62
63 "<SPACE>" : ["Turn off power supply to both servos", "kill"],
64
65 "<ESC>" : ["Exit", "exit"],
66 }
67 self.order_of_keys = ["<F1>", "<F2>", "<F5>", "<F6>", "a", "d", "<LEFT>", "<RIGHT>", "<SPACE>", "<ESC>"]
68
69 def executeKeyboardJob(self, argument):
70 """

Callers

nothing calls this directly

Calls 1

init_servoMethod · 0.80

Tested by

no test coverage detected