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

Function Main

Projects/PIDLineFollower/pid_tuner.py:129–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

127 gpg.stop()
128
129def Main():
130
131 drawLogo()
132 drawDescription()
133 drawMenu()
134
135 refresh_rate = 20.0
136 period = 1.0 / refresh_rate
137
138 controlThread = Thread(target = controller)
139 controlThread.start()
140
141 global stopper, gpg, lf, stepSize, loopFreq, motorSpeed, leftMotorSpeed, rightMotorSpeed, stopMotors, Kp, Ki, Kd
142 global integralArea
143 with Input(keynames = "curtsies", sigint_event = True) as input_generator:
144 while True:
145 # if nothing is captured in [period] seconds
146 # then send() function returns None
147 key = input_generator.send(period)
148
149 if key is None:
150 continue
151
152 if stopper.is_set():
153 # exit
154 gpg.stop()
155 break
156 if key == "<ESC>":
157 # exit
158 stopper.set()
159 break
160 if key == "x":
161 stopMotors = False
162 if key == "<SPACE>":
163 stopMotors = True
164 sleep(0.1)
165 gpg.stop()
166 if key == "1":
167 loopFreq += 1.0
168 if key == "2":
169 loopFreq -= 1.0
170 if key == "3":
171 motorSpeed += 1
172 if key == "4":
173 motorSpeed -= 1
174 if key == "u":
175 Kp += 5.0
176 if key == "j":
177 Ki += 0.001
178 if key == "n":
179 Kd += 100.0
180 if key == "i":
181 Kp -= 5.0
182 if key == "k":
183 Ki -= 0.001
184 if key == "m":
185 Kd -= 100.0
186 if key == "r":

Callers 1

pid_tuner.pyFile · 0.70

Calls 4

drawLogoFunction · 0.85
drawDescriptionFunction · 0.85
drawMenuFunction · 0.85
stopMethod · 0.45

Tested by

no test coverage detected