cancel
Showing results for 
Search instead for 
Did you mean: 

Hardware integration for qwerty keypad

KM L.1
Associate II
 
17 REPLIES 17
KM L.1
Associate II

Actually Martin had told me to work on the physical button first then he is going to help me out , how to react to the custom keyboard

Alexandre RENOUX
Principal

Hello,

You will find enclosed a quick implementation of the keyboard using buttons.

I haven't tested it with the actual board but the simulator is working. To link each physical button to a certain value, you should create a ButtonController class as follows (also explained in the documentation) :

class CustomButtonController : public touchgfx::ButtonController
{
    virtual void init() { previousState = JOY_NONE; }
    virtual bool sample(uint8_t& key)
    {
        JOYState_TypeDef state = BSP_JOY_GetState();
        if (state == previousState)
        {
          return false;
        }
        previousState = state;
        switch(state)
        {
        case JOY_SEL:
            key = '5';
            return true;
        case JOY_DOWN:
            key = '2';
            return true;
        case JOY_UP:
            key = '8';
            return true;
        case JOY_LEFT:
            key = '4';
            return true;
        case JOY_RIGHT:
            key = '6';
            return true;
 
        }
        return false;
    }
private:
  JOYState_TypeDef previousState;
};

Here are the keys used for the keyboard (you can change the code as you like) :

  • '5' select the highlighted key and print the corresponding letter
  • '6' and '4' are used to navigate among the different keys
  • '8' allows you to select capslock, numbers/special characters and delete.

You will find the main function making what you want possible void KeyboardJoystick::externalKeyPressed(uint8_t c) in KeyboardJoystick.cpp (gui\src\common\KeyboardJoystick.cpp)

/Alexandre

KM L.1
Associate II

Thank you so much for the support.

I will check with the board and ill come back to you.

KM L.1
Associate II

where I have to create this Button controller class?

Hello,

As a dirty way, you can create it in TouchGFXHAL.cpp or if you want to be more clean, create your own files just like the STM32TouchController.cpp and .hpp.

/Alexandre

KM L.1
Associate II

Okay!! keyboardjoystick.cpp will be same but I have to create Buttoncontroller class for joystick buttons.

KM L.1
Associate II

Hi,

Can you please check whether I have linked physical buttons properly.

KM L.1
Associate II

Thank you so much for your quick support. Project is working fine with the joystick.