36 lines
838 B
C++
36 lines
838 B
C++
#include <MyButtonController.hpp>
|
|
#include <main.h>
|
|
#include <touchgfx/hal/HAL.hpp>
|
|
|
|
extern "C"{
|
|
extern uint8_t User_ButtonState;
|
|
}
|
|
void MyButtonController::init()
|
|
{
|
|
// previousState = 0xFF;
|
|
}
|
|
|
|
bool MyButtonController::sample(uint8_t& key)
|
|
{
|
|
//// if(HAL_GPIO_ReadPin(BTN_GPIO_Port, BTN_Pin) == GPIO_PIN_SET)
|
|
// if(User_ButtonState)
|
|
// {
|
|
//// if(previousState == 0xFF)
|
|
//// {
|
|
//// previousState = 0x00;
|
|
// User_ButtonState = 0x00;
|
|
// key = 0;
|
|
// return true;
|
|
//// }
|
|
//// return false;
|
|
// }
|
|
//// previousState = 0xFF;
|
|
switch(User_ButtonState){
|
|
case 1: key = 0; User_ButtonState = 0x00; return true;
|
|
case 2: key = 1; User_ButtonState = 0x00; return true;
|
|
case 3: key = 2; User_ButtonState = 0x00; return true;
|
|
case 4: key = 0; User_ButtonState = 0x00; return true;
|
|
default: User_ButtonState = 0x00; return false;
|
|
}
|
|
}
|