Files
PortableFuncGen/firmware/shared_libs/controllers/ctrl_channel_button.c
2023-04-01 23:23:14 +02:00

68 lines
2.6 KiB
C

#include "main.h"
#include "hw_button.h"
#include "ctrl_channel_button.h"
#define DUMMY_GPIO_Port GPIOA
#define DUMMY_GPIO_Pin GPIO_PIN_0
static ButtonKey_t channel_buttons[BTN_CH_MAX];
void CTRL_channelButtonInit(void)
{
channel_buttons[BTN_CH_1].instance = BTN_CH_1;
channel_buttons[BTN_CH_1].buttonPressed = CTRL_pushedChanBtnEvent;
channel_buttons[BTN_CH_1].gpio_port = DUMMY_GPIO_Port;
channel_buttons[BTN_CH_1].gpio_pin = DUMMY_GPIO_Pin;
channel_buttons[BTN_CH_1].pushed_state = GPIO_PIN_SET;
channel_buttons[BTN_CH_2].instance = BTN_CH_2;
channel_buttons[BTN_CH_2].buttonPressed = CTRL_pushedChanBtnEvent;
channel_buttons[BTN_CH_2].gpio_port = DUMMY_GPIO_Port;
channel_buttons[BTN_CH_2].gpio_pin = DUMMY_GPIO_Pin;
channel_buttons[BTN_CH_2].pushed_state = GPIO_PIN_SET;
channel_buttons[BTN_CH_3].instance = BTN_CH_3;
channel_buttons[BTN_CH_3].buttonPressed = CTRL_pushedChanBtnEvent;
channel_buttons[BTN_CH_3].gpio_port = DUMMY_GPIO_Port;
channel_buttons[BTN_CH_3].gpio_pin = DUMMY_GPIO_Pin;
channel_buttons[BTN_CH_3].pushed_state = GPIO_PIN_SET;
channel_buttons[BTN_CH_4].instance = BTN_CH_4;
channel_buttons[BTN_CH_4].buttonPressed = CTRL_pushedChanBtnEvent;
channel_buttons[BTN_CH_4].gpio_port = DUMMY_GPIO_Port;
channel_buttons[BTN_CH_4].gpio_pin = DUMMY_GPIO_Pin;
channel_buttons[BTN_CH_4].pushed_state = GPIO_PIN_SET;
channel_buttons[BTN_CH_5].instance = BTN_CH_5;
channel_buttons[BTN_CH_5].buttonPressed = CTRL_pushedChanBtnEvent;
channel_buttons[BTN_CH_5].gpio_port = DUMMY_GPIO_Port;
channel_buttons[BTN_CH_5].gpio_pin = DUMMY_GPIO_Pin;
channel_buttons[BTN_CH_5].pushed_state = GPIO_PIN_SET;
channel_buttons[BTN_CH_6].instance = BTN_CH_6;
channel_buttons[BTN_CH_6].buttonPressed = CTRL_pushedChanBtnEvent;
channel_buttons[BTN_CH_6].gpio_port = DUMMY_GPIO_Port;
channel_buttons[BTN_CH_6].gpio_pin = DUMMY_GPIO_Pin;
channel_buttons[BTN_CH_6].pushed_state = GPIO_PIN_SET;
for (HW_chanBtnName_t btn_key = BTN_CH_1; btn_key < BTN_CH_MAX; btn_key++)
{
channel_buttons[btn_key].state = IDLE;
channel_buttons[btn_key].timer_debounce = BTN_DEFAULT_DEBOUNCE_MS;
channel_buttons[btn_key].timer_long_pressed = BTN_DEFAULT_LONGPRESSED_MS;
channel_buttons[btn_key].timer_repeat_delay = BTN_DEFAULT_REPEAT_MS;
}
}
void CTRL_channelButtonsHandler(void)
{
for (HW_chanBtnName_t btn_key = BTN_CH_1; btn_key < BTN_CH_MAX; btn_key++)
{
buttonHandler(&channel_buttons[btn_key]);
}
}
__weak void CTRL_pushedChanBtnEvent(ButtonKey_t *key)
{
UNUSED(key);
}