Guido Posted August 15, 2016 Report Share Posted August 15, 2016 Hallo, right now i'm evaluating if µGfx fit our needs for our new product. We using linux as OS and have 6 buttons attached via gpio-keys driver. This driver creates the same key-events like a normal keyboard does. Is there a way in µGfx, to use buttons, which are attached via gpio-keys driver? Thanks in advanced for your support Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted August 15, 2016 Report Share Posted August 15, 2016 Hello and welcome to the community! The GINPUT module is able to directly handle digital inputs (eg. buttons attached to GPIOs) through the toggle driver. Most widgets define one or more toggle roles. You can use gwinAttachToggle() to assign any of your buttons to any of the widgets toggle roles. This allows having physical buttons to press virtual buttons, scrolling through lists and so on. Our recommendation is to use this solution if that's possible for your system. It would allow bypassing (and therefore deprecating) the additional Linux driver that makes your buttons look like a keyboard and you would be able to dynamically change the roles of the buttons inside of your µGFX application. However, as per your description it sounds like the keyboard driver of the GINPUT module might be more suited for you. Just as with the toggles roles, most widgets implement keyboard handles. For example, you can use the space or enter keys to push a virtual button, check/uncheck a checkbox or use the arrow keys to scroll through a list. To use this feature you have to implement a GINPUT keyboard driver to interface your current gpio-keys-keyboard solution. You can find the GINPUT driver interface under /src/ginput/ginput_keyboard_driver.h. You can have a look at the keyboard driver implemented in the SDL driver to learn how to interface a keyboard on a Linux system. On a side note: Right at this moment we are writing the documentation for the new SDL driver that vastly increases the rendering speed of a µGFX application running on a Linux system when not using the framebuffer driver. We strongly recommend you changing from the X driver to the new SDL driver. Documentation: https://wiki.ugfx.io/index.php/Linux I hope that helps. Update: The new SDL driver has officially been added: Link to comment Share on other sites More sharing options...
Guido Posted August 16, 2016 Author Report Share Posted August 16, 2016 Hello Joel and thank you for your extensive reply. I think i'll give the toggle-drive and the keyboard-driver a try. But i can't find any documentation on how to use the toggle-driver with gpio-inputs. Is there any sample code or something else helpful? by the way, you did a great job with µGfx. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted August 16, 2016 Report Share Posted August 16, 2016 Hello Guido, I'm afraid that honestly there is currently no other documentation besides the API reference and the existing board files for the toggle, dial and keyboard drivers of the GINPUT module available. The toggle and dial drivers appears to be straight forward to use so that nobody complained so far that there's no extra documentation and as far as we know nobody ever wrote a keyboard driver. As our ToDo list is rather large we just never got to it. So you might want to re-evaluate your last statement (although very much appreciated, thanks!). There's quite a lot on the schedule for this week so I can't promise that we get to writing up some documentation for those GINPUT drivers this week, but I put it on the ToDo list now. However, I am pretty confident that you should be able to get it working anyway. The API reference is there (all functions, variables & types are documented). Also, you are more than welcome to ask for help whenever you have any questions. We are happy to help wherever we can. Link to comment Share on other sites More sharing options...
charliefjohnson Posted November 3, 2016 Report Share Posted November 3, 2016 OK, I am also trying to use gwinAttachToggle() to have a hardware button control the selection on a list widget. A few questions which are not that obvious from the examples. WIth GFX_USE_INPUT and GINPUT_TOGGLE set, my button driver needs to provide a ginput_lld_toggle_getbits() function. My understanding is that this just returns the state of the switches/buttons ?? If there is are two buttons and the first button is pressed, it would return 1 as its function result ?? My GToggleConfig configuration is: #define GINPUT_TOGGLE_NUM_PORTS 2 // The total number of toggle inputs #define GINPUT_TOGGLE_CONFIG_ENTRIES 1 // The total number of GToggleConfig entries #define CLI_SW1_MASK 1 #define CLI_SW2_MASK 2 #define GINPUT_TOGGLE_DECLARE_STRUCTURE() \ const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES] = { \ {0, \ CLI_SW1_MASK|CLI_SW2_MASK, \ 0, \ 0}, \ } So my issue here is that I never see an event from the list widget. The TogglePoll() function is getting called on a regular basis and ginput_lld_toggle_getbits() returns the state of SW1, but geventSendEvent() never is called. (For switch on or off). My setup when I populate the widget just does: gwinAttachToggle(setup_list, 0, 0); gwinAttachToggle(setup_list, 1, 1); geventListenerInit(&setup_listener); gwinAttachListener(&setup_listener); I see my list on my LCD screen, so I know it is displaying properly. My code is just calling: pe = geventEventWait(&setup_listener, TIME_INFINITE); And it never comes back. So what am I not understanding?? Thanks. Link to comment Share on other sites More sharing options...
Joel Bodenmann Posted November 5, 2016 Report Share Posted November 5, 2016 Hello and welcome to the community! The way you are using the TOGGLE support of the GINPUT module appears to be correct. The problem you are facing is that the list widget currently simply doesn't support a toggle role to select an entry. Looking at the list widget code we see that right now only two roles to move the selection up and down are defined. To implement the behavior you're looking for, you have to add a 3rd role to the switch() that processes the toggle roles. In that role, you have to programatically select the current list item. I hope that helps. Please don't hesitate to ask if you have any further questions. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now