5 prev_flight_data =
None 8 def handler(event, sender, data, **args):
9 global prev_flight_data
11 if event
is drone.EVENT_CONNECTED:
15 drone.set_video_encoder_rate(4)
16 elif event
is drone.EVENT_FLIGHT_DATA:
17 if prev_flight_data != str(data):
19 prev_flight_data = str(data)
20 elif event
is drone.EVENT_TIME:
21 print(
'event="%s" data=%d' % (event.getname(), data[0] + data[1] << 8))
22 elif event
is drone.EVENT_VIDEO_FRAME:
25 print(
'event="%s" data=%s' % (event.getname(), str(data)))
32 drone.subscribe(drone.EVENT_CONNECTED, handler)
35 drone.subscribe(drone.EVENT_FLIGHT_DATA, handler)
37 drone.subscribe(drone.EVENT_TIME, handler)
38 drone.subscribe(drone.EVENT_VIDEO_FRAME, handler)
51 except Exception
as ex:
58 if __name__ ==
'__main__':
def handler(event, sender, data, args)