- Allow other scripts / inputs to control AP heading too
- Fix failure if rp2040_hid is connected above 32767 feet
This commit is contained in:
@@ -130,6 +130,8 @@ else
|
||||
send_app_report(device, math.floor(ap_hdg + 0.5), build_leds(), math.floor(ap_alt + 0.5), -2, -2, status_machmode == 1)
|
||||
local prev_status_altmode = 0
|
||||
local prev_status_machmode = status_machmode
|
||||
local prev_ap_hdg = ap_hdg
|
||||
local prev_report_ap_hdg = 0
|
||||
function usb_app()
|
||||
local send_hdg = -1
|
||||
local send_alt = -1
|
||||
@@ -157,9 +159,15 @@ else
|
||||
mag_hdg_int = math.floor(mag_hdg + 0.5)
|
||||
ap_hdg = mag_hdg_int
|
||||
send_hdg = mag_hdg_int
|
||||
elseif app_report_good and app_report[1] ~= 0xffff then
|
||||
elseif prev_ap_hdg ~= ap_hdg then
|
||||
send_hdg = ap_hdg
|
||||
elseif app_report_good and app_report[1] ~= 0xffff and prev_report_ap_hdg ~= app_report[1] then
|
||||
ap_hdg = app_report[1]
|
||||
end
|
||||
prev_ap_hdg = ap_hdg
|
||||
if app_report_good and app_report[1] ~= 0xffff then
|
||||
prev_report_ap_hdg = app_report[1]
|
||||
end
|
||||
-- autopilot altitude
|
||||
if button(button_offset + button_alt_sync) and not last_button(button_offset + button_alt_sync) then
|
||||
cur_alt_int = math.floor(cur_alt + 0.5)
|
||||
@@ -213,4 +221,10 @@ else
|
||||
end
|
||||
|
||||
do_every_frame("usb_app()")
|
||||
|
||||
function exit_handler()
|
||||
send_app_report(device, -2, 0, -2, -2, -2, 0)
|
||||
end
|
||||
|
||||
do_on_exit('exit_handler()')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user