betaflight-tx-lua-scripts icon indicating copy to clipboard operation
betaflight-tx-lua-scripts copied to clipboard

X-Lite Lua : changes require single stick press for each individual value change

Open ghost opened this issue 8 years ago • 11 comments

I am using the most recent lua script with support for the xlite.

In the main otx menus of the tx the joystick long press on options ie model name will allow a fast scroll through all the values.

In lua long pressing up or down to change values results in no change except for one single digit value.

So if I needed to change a value from 10 down to 0 I would have to click the stick 10 times to get there rather than hold the stick. 10 is a small number but imagine changing other values (tpa throttle value or rates for example). It takes a while.

Also, stick up decreases values while stick down increases values.

Many thanks.

ghost avatar Jul 02 '18 14:07 ghost

I also noticed this in Crossfire and fixed it, will find for Betaflight tonight

DieHertz avatar Jul 02 '18 14:07 DieHertz

I was also wondering why up/down decrease/increase inverse to what I'd expect. As this is also mentioned in the release notes, is there any deeper reason behind it or can it just be flipped? I know X-lite was just newly added, thanks for that!

mheberlein avatar Jul 08 '18 14:07 mheberlein

Could you try the script from this branch? https://github.com/DieHertz/betaflight-tx-lua-scripts/tree/bfdev-diehertz-fix-xlite-key-directions My radio is currently disassemble for tests and I can't check :)

DieHertz avatar Jul 08 '18 15:07 DieHertz

@DieHertz

I just tested your changed file (Scripts > Bf > events.lua).

If this was the only change (that I can see from your repo) then here are the results.

Long press still results in single digit change. Up stick is now reversed for menu navigation but correct for value change. Down stick is now reversed for menu navigation but correct for value change.

So by flipping the stick directions for value changes it also flipped it for menu navigation. Seems to be tied together.

Many thank.s

ghost avatar Jul 08 '18 16:07 ghost

Based on what is in the OpenTX lua api, there aren't any repeat (REPT) events for XLite. Consequently, each event must be handled with single button presses.

https://github.com/opentx/opentx/blob/xlite-prod-batch2/radio/src/lua/api_general.cpp#L1409-L1424

codecae avatar Jul 13 '18 23:07 codecae

We could use the EVT_SHIFT_FIRST and UP/DOWN in order to increase/decrease by 10 instead of 1

hsuq510 avatar Jul 17 '18 11:07 hsuq510

Thank you very much for your Info! Hello frome North Germany Am 17.07.18, 13:25, madec [email protected] schrieb: We could use the EVT_SHIFT_FIRST and UP/DOWN in order to increase/decrease by 10 instead of 1

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or mute the thread. {"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/betaflight/betaflight-tx-lua-scripts","title":"betaflight/betaflight-tx-lua-scripts","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/betaflight/betaflight-tx-lua-scripts"}},"updates":{"snippets":[{"icon":"PERSON","message":"@hsuq510 in #145: We could use the EVT_SHIFT_FIRST and UP/DOWN in order to increase/decrease by 10 instead of 1\r\n"}],"action":{"name":"View Issue","url":"https://github.com/betaflight/betaflight-tx-lua-scripts/issues/145#issuecomment-405549082"}}} [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/betaflight/betaflight-tx-lua-scripts/issues/145#issuecomment-405549082", "url": "https://github.com/betaflight/betaflight-tx-lua-scripts/issues/145#issuecomment-405549082", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Re: [betaflight/betaflight-tx-lua-scripts] X-Lite Lua : changes require single stick press for each individual value change (#145)", "sections": [ { "text": "", "activityTitle": "madec", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@hsuq510", "facts": [

] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n"commandName": "IssueComment",\n"repositoryFullName": "betaflight/betaflight-tx-lua-scripts",\n"issueId": 145,\n"IssueComment": "{{IssueComment.value}}"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n"commandName": "IssueClose",\n"repositoryFullName": "betaflight/betaflight-tx-lua-scripts",\n"issueId": 145\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/betaflight/betaflight-tx-lua-scripts/issues/145#issuecomment-405549082" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n"commandName": "MuteNotification",\n"threadId": 352157384\n}" } ], "themeColor": "26292E" } ]

FlipFlopRacer avatar Jul 17 '18 19:07 FlipFlopRacer

@codecae have tried this but not seems to work.. but shift is working as event, and condition is not.

   elseif userEvent.press.plus and (event == userEvent.longPress.shift) then
          incValue(10)
   elseif userEvent.press.minus and (event == userEvent.longPress.shift) then
          incValue(-10)

hsuq510 avatar Jul 18 '18 08:07 hsuq510

I solved with this: pageDown = EVT_PAGEDN_FIRST or EVT_RIGHT_BREAK, pageUp = EVT_PAGEUP_FIRST or EVT_LEFT_BREAK to inc/dec 10 would be better.

hsuq510 avatar Jul 18 '18 13:07 hsuq510

This issue / pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within a week.

stale[bot] avatar Aug 18 '18 10:08 stale[bot]

@codecae

#147

I think I got this sorted out.

Here are the changes I made (after many attempts) to get it working on the xlite...at least.

events.txt ui.txt

Changes:

Menu save moved to shift long press instead of joystick right long press Joystick left/right navigates the pages accordingly Joystick up/down navigates the page lines accordingly Joystick up/down increments/decrements values accordingly Joystick long press up/down increments/decrements values accordingly as a scroll Joystick right long press for save menu removed Joystick menu long press for save menu removed since the xlite would also popup a telemetry reset window

In ui.lua (ui.txt) the changed lines are

   -- editing value
    elseif currentState == pageStatus.editing then
        if (event == userEvent.release.exit) or (event == userEvent.release.enter) then
            currentState = pageStatus.display
        elseif event == userEvent.press.minus or event == userEvent.longPress.minus or event == userEvent.dial.right then
            incValue(-1)
        elseif event == userEvent.press.plus or event == userEvent.longPress.plus or event == userEvent.dial.left then
            incValue(1)
        end
    end

events.lua (events.txt)


return 
{
    press = {
        minus = EVT_MINUS_FIRST,
        plus = EVT_PLUS_FIRST,
        pageDown = EVT_PAGEDN_FIRST or EVT_RIGHT_BREAK,
        pageUp = EVT_PAGEUP_FIRST or EVT_LEFT_BREAK
    },
    longPress = {
        menu = EVT_SHIFT_LONG,
	minus = EVT_DOWN_REPT,
	plus = EVT_UP_REPT
    },
    repeatPress = {
        minus = EVT_MINUS_REPT,
        plus = EVT_PLUS_REPT
    },
    release = {
        enter = EVT_ENTER_BREAK,
        exit = EVT_EXIT_BREAK,
        menu = EVT_RIGHT_BREAK,
        minus = EVT_DOWN_BREAK or EVT_MINUS_BREAK,
        plus = EVT_UP_BREAK or EVT_PLUS_BREAK
    },
    dial = {
        left = EVT_ROT_LEFT or EVT_UP_BREAK,
        right = EVT_ROT_RIGHT or EVT_DOWN_BREAK
    }
}

ghost avatar Aug 18 '18 22:08 ghost