3. APP - SPEED¶
In this project, you can view the speed and mileage of the car’s movement on the app.
Quick User Guide
Run the
app_3_speed.py
file under thepico_4wd_car\examples\app_control
path.Based on 2. APP - Car Move, add Gauge and Number widgets to the B and C areas as shown below.
After saving () and connecting () the controller, click to run it.
Now, tap on the D-Pad to control the movement and adjust the power via the Throttle widget. You can also see the speed and mileage from the B and C areas.
How it works?
This project is generally the same as 2. APP - Car Move, except that two lines have been added to the on_receive(data)
function to send the APP the speed and mileage data.
'''----------------- on_receive (ws.loop()) ---------------------'''
def on_receive(data):
global throttle_power, steer_power, move_status, dpad_touched
''' if not connected, skip & stop '''
if not ws.is_connected():
return
# Speed measurement
ws.send_dict['B'] = round(speed.get_speed(), 2) # uint: cm/s
# Speed mileage
ws.send_dict['C'] = speed.get_mileage() # unit: meter
# ..........