2020-07-20 01:01 AM
2020-07-20 04:43 AM
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
2020-07-21 12:59 AM
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) :
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
2020-07-21 03:17 AM
Thank you so much for the support.
I will check with the board and ill come back to you.
2020-07-21 04:42 AM
where I have to create this Button controller class?
2020-07-21 06:53 AM
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
2020-07-21 07:03 AM
Okay!! keyboardjoystick.cpp will be same but I have to create Buttoncontroller class for joystick buttons.
2020-07-22 12:15 AM
2020-07-23 08:31 PM
Thank you so much for your quick support. Project is working fine with the joystick.