INNER CODE UNIT · Python
main
ryan4yin/knowledge · electrical-engineering/raspberrypi/robot_car_pi.py:63
def main():
x_value = 0
y_value = 0
while True or KeyboardInterrupt:
for e in pygame.event.get():
# <Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 1, 'value': 0.8169499801629688})>
# 左摇杆(平面直角坐标系)
# axis=0 左右
# axis=1 上下
# 右摇杆:2 3
if e.type == JOYAXISMOTION:
if e.axis == 0:
x_value = e.value
elif e.axis == 1:
y_value = e.value
run(x_value, y_value)