How to Develop/define GPIO for keyboard?

Hi team,

I'm developing BLE keyboard and i'm interfacing keyboard with nRF52832 using Zephyr RTOS.

I have example code in SDK, I'll share the path "manthan@man:~/ncs/nrf/samples/bluetooth/peripheral_hids_keyboard " in this example code i got output according to README file but now i going to do interfacing 4x4 matrix keypad with nRF52DK DV using zephyr rtos. I want to know how i'll declare gpio and how to use both key at a time it's means 1. shift key  2. ctrl key like this other key also.  And one more thing is i'm changing the example code it's on my use, if i'll change than it'll keep advertising & giving output what i mention?

But i'm not getting how i'll make it ble keyboard and now i just want to make it on keypad only not a full keyboard.

If anyone knows about this query please help me to clear this query.

Thank you,

Parents Reply Children
  • Hi Simon,

    i have checked above link, but i not getting properly what it's saying. As i mention in my query i have example code and i just wanna declare my function and some more gpio.

    I wrote one function using "switch case" for the taking data from the keypad/keyboard and in example code they give a string "hello" and this string operating development kit's button.

    And i'm trying to give any external button and when i press that button that time i get output in any text editor or word file like that.

    I got stuck how to do that things,

    Thank you,

  • I'm not sure if I understand what your goal is. If you could provide a visual illustration (using for example https://app.diagrams.net/)

    I want to know how i'll declare gpio and how to use both key at a time it's means 1. shift key  2. ctrl key like this other key also.

    So do you want to be able to press two buttons simultaneously? For example a shift key that changes the text output UPPER CASE? Let me know if this is the case, and I will look into it.

    If you're just wondering how to set up a new GPIO/Button and use that as input, you could check out <ncs location>\zephyr\samples\basic\button. It uses the API zephyr/include/zephyr/drivers/gpio.h

    I can see that the peripheral_hids_keyboard sample uses \nrf\include\dk_buttons_and_leds.h to set up button interrupts. However, if you're using that API, then you're limited to using the Buttons on the nRF52 DK only.

    And one more thing is i'm changing the example code it's on my use, if i'll change than it'll keep advertising & giving output what i mention?

    I don't understand what you're trying to say here, could you try to explain int more clearly?

    Manthan Khunt said:
    As i mention in my query i have example code and i just wanna declare my function and some more gpio.

    Check out <ncs location>\zephyr\samples\basic\button

    Best regards,

    Simon

  • Hi Simon,

    I'm not sure if I understand what your goal is. If you could provide a visual illustration (using for example https://app.diagrams.net/)

    I'll share this tomorrow or later and 

    So do you want to be able to press two buttons simultaneously?

    Yes, I want to do simultaneously two keys. And you mention "button" path that i already check.

    It's possible to first we write normal gpio button program, means now i'll write normal gpio and after getting proper gpio output then i'll add BLE for advertising and print keypad data on notepad.

    And one more thing is i'm changing the example code it's on my use, if i'll change than it'll keep advertising & giving output what i mention?

    Now i'm not doing this task. Simon can you share one simple code(your own code)? Means how to write interrupt gpio and declare,calling like that. I'll be wait for your ans. 

    And you know how to make keycode for keypad/keyboard? in that what things i have to add or declaration. Can you explain me or any refer links?

    Thank you simon, 

  • Manthan Khunt said:
    Yes, I want to do simultaneously two keys. And you mention "button" path that i already check.

    You can achieve this by simply adding another gpio input to the button sample. I did this for you in the sample below. Test it with NCS v2.0.0

    two_buttons.zip

    Manthan Khunt said:
    It's possible to first we write normal gpio button program, means now i'll write normal gpio and after getting proper gpio output then i'll add BLE for advertising and print keypad data on notepad.

    Are you asking how to merge the button/gpio sample with a BLE sample. I would recommend you to start with the BLE sample, and then merge the gpio sample into that. 

    It is actually quite straightforward in NCS. Just merge the main.c files, the prj.conf files, the overlay files and so on..

    Manthan Khunt said:
    Now i'm not doing this task. Simon can you share one simple code(your own code)? Means how to write interrupt gpio and declare,calling like that. I'll be wait for your ans.

    Why can't you just use the button sample I referred to earlier? It should be located here: 

    The sample I uploaded above (two_buttons) is this sample modified.

    Manthan Khunt said:

    And you know how to make keycode for keypad/keyboard? in that what things i have to add or declaration. Can you explain me or any refer links?

    I don't have too much experience with this. Could you try to study the nrf_desktop example and see how it's done there?

    Best regards,

    Simon

Related