-
-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lua function for trainer status #2483
Conversation
Testing trainer input fairly often, I like the idea of having the extra voice for trainer connected 👍 It not obvious it's working the first time you connect a device. When you consider some of the previous issues with the trainer jack on TX16s or trying to find the proper PPM input levels, did you pick the right bluetooth address, not having a notification the first time it's working can be highly confusing. (Also need to bring the B&W trainer connected icon on the main title bar (in color).. but that's another issue) @CamGenius What is the purpose of having disconnected and not_connected? Are these not the same thing? |
I figured a widget could have use to differentiate between not connected and disconnected. For instance not connected could be gray while disconnected could be red. |
Have tested this with the following dumb widget, and a newly generated local options = {
}
local function create(zone, options)
local widget = { zone=zone, options=options }
return widget
end
local function update(widget, options)
widget.options = options
end
local function background(widget)
end
local function refresh(widget)
local trainerStatus = getTrainerStatus()
if trainerStatus == 0 then
lcd.drawText(widget.zone.x, widget.zone.y, "Not Connected", LEFT);
elseif trainerStatus == 1 then
lcd.drawText(widget.zone.x, widget.zone.y, "Connected", LEFT);
elseif trainerStatus == 2 then
lcd.drawText(widget.zone.x, widget.zone.y, "Disconnected", LEFT);
elseif trainerStatus == 3 then
lcd.drawText(widget.zone.x, widget.zone.y, "Reconnected", LEFT);
else
lcd.drawText(widget.zone.x, widget.zone.y, "Unknown state", LEFT);
end
end
return { name="Trainer Status", options=options, create=create, update=update, refresh=refresh, background=background }
|
Hi @CamGenius and @pfeerick One request..... Could you please add one extra line to the script to insert the numerical value of 'trainerstatus' into a telemetry or global variable on the radio that logical switches could reference? |
I'm not sure that is the best way to do it... probably better to have a lua widget or some other script do that sort of conversion - it's not telemetry as such, and sending it to a GV then begs the question "which GV" and "who else is going to complain we've just clobbered GV# that they use for XYZ" e.g. The flight modes widget uses GV9 IIRC (to store the persistent flight counter). I suggest instead that perhaps a "trainer" widget needs to be developed, and as part of that an option to push the trainer state to a (configurable) GV. |
Yes, I totally agree that the best approach would be a widget that you can configure to put the 'trainerstatus' into the GV of your choice. By default, it wouldn't push the value to any GV so other scripts aren't clobbered. The user would need to make a config selection to choose the GV to use. |
* Initial Commit * Finished Trainer Status * fix: Bump version number Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
Summary of changes:
Adds a lua function for getting the status of the trainer input. #627
Also adds a sound function for trainer initial connection.