Problem with interface with physical buttons
Hello!
I try to create intefrace with physical buttons, following this instruction https://touchgfx.zendesk.com/hc/en-us/articles/205074551-Interfacing-with-physical-buttons
- I Added ../Middlewares/ST/touchgfx/framework/include/platform/driver/button to include path
- I created file Keysamper.cpp and added to it
#include "KeySampler.hpp"
#include "touchgfx/HAL/Buttons.hpp"
using namespace touchgfx;
void KeySampler::init()
{
//Initialise gpio for buttons here
}
bool KeySampler::sample(uint8_t &key)
{
// unsigned int buttons = ...; //sample GPIO
//Return true if button 1 was pressed, save 1 to key argument
//Return true if button 2 was pressed, save 2 to key argument
// ...
return false;
}3. I created file Keysampler.hpp and added to it
class KeySampler : public touchgfx::ButtonController
{
public:
KeySampler() {
init();
}
virtual ~KeySampler() {}
virtual void init();
virtual bool sample(uint8_t& key);
};4. I modified file TouchGFXConfiguration.hpp
KeySampler btnCtrl;
void touchgfx_init()
{
Bitmap::registerBitmapDatabase(BitmapDatabase::getInstance(), BitmapDatabase::getInstanceSize());
TypedText::registerTexts(&texts);
Texts::setLanguage(0);
FontManager::setFontProvider(&fontProvider);
FrontendHeap& heap = FrontendHeap::getInstance();
(void)heap; // we need to obtain the reference above to initialize the frontend heap.
hal.initialize();
hal.enableLCDControllerInterrupt();
hal.enableInterrupts();
hal.setButtonController(&btnCtrl); //Enable button controller
}6. try to complie, got errors
..\Drivers\KeySampler.hpp(1): error: #276: name followed by "::" must be a class or namespace name
class KeySampler : public touchgfx::ButtonController
..\Drivers\KeySampler.hpp(1): error: #262: not a class or struct name
class KeySampler : public touchgfx::ButtonController
..\Drivers\KeySampler.hpp(9): error: #20: identifier "uint8_t" is undefined
virtual bool sample(uint8_t& key);
../TouchGFX/target/generated/TouchGFXConfiguration.cpp(38): error: #20: identifier "KeySampler" is undefined
KeySampler btnCtrl;
What's wrong?
