[wip] controllers and display
This commit is contained in:
19
firmware/shared_libs/controllers/ctrl_app.c
Normal file
19
firmware/shared_libs/controllers/ctrl_app.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "main.h"
|
||||
|
||||
#include "ctrl_app.h"
|
||||
|
||||
static GEN_fg_t func_gen[3];
|
||||
static GEN_pwm_t pwm_gen[3];
|
||||
|
||||
const static GENERATOR_t generators[CHANNEL_MAX] = {
|
||||
{.gen_type = GEN_FG_TYPE, .gen = &func_gen[0]},
|
||||
{.gen_type = GEN_FG_TYPE, .gen = &func_gen[1]},
|
||||
{.gen_type = GEN_FG_TYPE, .gen = &func_gen[2]},
|
||||
{.gen_type = GEN_PWM_TYPE, .gen = &pwm_gen[0]},
|
||||
{.gen_type = GEN_PWM_TYPE, .gen = &pwm_gen[1]},
|
||||
{.gen_type = GEN_PWM_TYPE, .gen = &pwm_gen[2]},
|
||||
};
|
||||
|
||||
void APP_init(APP_data_t *app_data)
|
||||
{
|
||||
}
|
||||
70
firmware/shared_libs/controllers/ctrl_app.h
Normal file
70
firmware/shared_libs/controllers/ctrl_app.h
Normal file
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
|
||||
#include "disp_layout_types.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t frequency;
|
||||
uint16_t amplitude;
|
||||
uint16_t offset;
|
||||
uint16_t phase;
|
||||
uint8_t duty;
|
||||
uint8_t enabled;
|
||||
} GEN_pwm_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t frequency;
|
||||
uint16_t amplitude;
|
||||
uint16_t offset;
|
||||
uint16_t phase;
|
||||
uint8_t wave;
|
||||
uint8_t enabled;
|
||||
uint8_t connected;
|
||||
} GEN_fg_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GEN_FG_TYPE,
|
||||
GEN_PWM_TYPE,
|
||||
GEN_TYPE_MAX
|
||||
} GEN_type_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GEN_type_t gen_type;
|
||||
void *gen;
|
||||
} GENERATOR_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CHANNEL1,
|
||||
CHANNEL2,
|
||||
CHANNEL3,
|
||||
CHANNEL4,
|
||||
CHANNEL5,
|
||||
CHANNEL6,
|
||||
CHANNEL_MAX
|
||||
} GEN_channel_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t freq_focus_digit;
|
||||
uint8_t ampl_focus_digit;
|
||||
uint8_t offs_focus_digit;
|
||||
uint8_t phas_focus_digit;
|
||||
uint8_t duty_focus_digit;
|
||||
|
||||
GEN_type_t gen_type;
|
||||
void *generator;
|
||||
|
||||
GEN_channel_t curr_channel;
|
||||
LAY_state_t curr_layout;
|
||||
uint8_t isChannelChange;
|
||||
uint8_t isGraphChange;
|
||||
uint8_t isValueChange;
|
||||
uint8_t isButtonChange;
|
||||
uint8_t isButtonBlink;
|
||||
uint8_t timer_blink[LAY_BTN_MAX];
|
||||
|
||||
} APP_data_t;
|
||||
56
firmware/shared_libs/controllers/ctrl_bottom_button.c
Normal file
56
firmware/shared_libs/controllers/ctrl_bottom_button.c
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "main.h"
|
||||
#include "config.h"
|
||||
#include "hw_button.h"
|
||||
#include "ctrl_button.h"
|
||||
#include "ctrl_bottom_button.h"
|
||||
|
||||
static ButtonKey_t bottom_buttons[BTN_BOT_MAX];
|
||||
|
||||
void CTRL_bottomButtonInit(void)
|
||||
{
|
||||
bottom_buttons[BTN_BOT_1].instance = BTN_BOT_1;
|
||||
bottom_buttons[BTN_BOT_1].buttonPressed = CTRL_pushedDispBtnEvent;
|
||||
bottom_buttons[BTN_BOT_1].gpio_port = BTN1_GPIO_Port;
|
||||
bottom_buttons[BTN_BOT_1].gpio_pin = BTN1_Pin;
|
||||
bottom_buttons[BTN_BOT_1].pushed_state = GPIO_PIN_SET;
|
||||
|
||||
bottom_buttons[BTN_BOT_2].instance = BTN_BOT_2;
|
||||
bottom_buttons[BTN_BOT_2].buttonPressed = CTRL_pushedDispBtnEvent;
|
||||
bottom_buttons[BTN_BOT_2].gpio_port = BTN2_GPIO_Port;
|
||||
bottom_buttons[BTN_BOT_2].gpio_pin = BTN2_Pin;
|
||||
bottom_buttons[BTN_BOT_2].pushed_state = GPIO_PIN_SET;
|
||||
|
||||
bottom_buttons[BTN_BOT_3].instance = BTN_BOT_3;
|
||||
bottom_buttons[BTN_BOT_3].buttonPressed = CTRL_pushedDispBtnEvent;
|
||||
bottom_buttons[BTN_BOT_3].gpio_port = BTN3_GPIO_Port;
|
||||
bottom_buttons[BTN_BOT_3].gpio_pin = BTN3_Pin;
|
||||
bottom_buttons[BTN_BOT_3].pushed_state = GPIO_PIN_SET;
|
||||
|
||||
bottom_buttons[BTN_BOT_4].instance = BTN_BOT_4;
|
||||
bottom_buttons[BTN_BOT_4].buttonPressed = CTRL_pushedDispBtnEvent;
|
||||
bottom_buttons[BTN_BOT_4].gpio_port = BTN4_GPIO_Port;
|
||||
bottom_buttons[BTN_BOT_4].gpio_pin = BTN4_Pin;
|
||||
bottom_buttons[BTN_BOT_4].pushed_state = GPIO_PIN_SET;
|
||||
|
||||
bottom_buttons[BTN_BOT_5].instance = BTN_BOT_5;
|
||||
bottom_buttons[BTN_BOT_5].buttonPressed = CTRL_pushedDispBtnEvent;
|
||||
bottom_buttons[BTN_BOT_5].gpio_port = BTN5_GPIO_Port;
|
||||
bottom_buttons[BTN_BOT_5].gpio_pin = BTN5_Pin;
|
||||
bottom_buttons[BTN_BOT_5].pushed_state = GPIO_PIN_SET;
|
||||
|
||||
for (HW_BotBtnName_t btn_key = BTN_BOT_1; btn_key < BTN_BOT_MAX; btn_key++)
|
||||
{
|
||||
bottom_buttons[btn_key].state = IDLE;
|
||||
bottom_buttons[btn_key].timer_debounce = BTN_DEFAULT_DEBOUNCE_MS;
|
||||
bottom_buttons[btn_key].timer_long_pressed = BTN_DEFAULT_LONGPRESSED_MS;
|
||||
bottom_buttons[btn_key].timer_repeat_delay = BTN_DEFAULT_REPEAT_MS;
|
||||
}
|
||||
}
|
||||
|
||||
void CTRL_bottomButtonsHandler(void)
|
||||
{
|
||||
for (HW_BotBtnName_t btn_key = BTN_BOT_1; btn_key < BTN_BOT_MAX; btn_key++)
|
||||
{
|
||||
buttonHandler(&bottom_buttons[btn_key]);
|
||||
}
|
||||
}
|
||||
14
firmware/shared_libs/controllers/ctrl_bottom_button.h
Normal file
14
firmware/shared_libs/controllers/ctrl_bottom_button.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BTN_BOT_1,
|
||||
BTN_BOT_2,
|
||||
BTN_BOT_3,
|
||||
BTN_BOT_4,
|
||||
BTN_BOT_5,
|
||||
BTN_BOT_MAX,
|
||||
} HW_BotBtnName_t;
|
||||
|
||||
void CTRL_bottomButtonInit(void);
|
||||
void CTRL_bottomButtonsHandler(void);
|
||||
62
firmware/shared_libs/controllers/ctrl_channel_button.c
Normal file
62
firmware/shared_libs/controllers/ctrl_channel_button.c
Normal file
@@ -0,0 +1,62 @@
|
||||
#include "main.h"
|
||||
#include "config.h"
|
||||
#include "hw_button.h"
|
||||
#include "ctrl_button.h"
|
||||
#include "ctrl_channel_button.h"
|
||||
|
||||
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 = BTN1_GPIO_Port;
|
||||
channel_buttons[BTN_CH_1].gpio_pin = BTN1_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 = BTN2_GPIO_Port;
|
||||
channel_buttons[BTN_CH_2].gpio_pin = BTN2_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 = BTN3_GPIO_Port;
|
||||
channel_buttons[BTN_CH_3].gpio_pin = BTN3_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 = BTN4_GPIO_Port;
|
||||
channel_buttons[BTN_CH_4].gpio_pin = BTN4_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 = BTN5_GPIO_Port;
|
||||
channel_buttons[BTN_CH_5].gpio_pin = BTN5_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 = BTN5_GPIO_Port;
|
||||
channel_buttons[BTN_CH_6].gpio_pin = BTN5_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]);
|
||||
}
|
||||
}
|
||||
15
firmware/shared_libs/controllers/ctrl_channel_button.h
Normal file
15
firmware/shared_libs/controllers/ctrl_channel_button.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum
|
||||
{
|
||||
BTN_CH_1,
|
||||
BTN_CH_2,
|
||||
BTN_CH_3,
|
||||
BTN_CH_4,
|
||||
BTN_CH_5,
|
||||
BTN_CH_6,
|
||||
BTN_CH_MAX,
|
||||
} HW_chanBtnName_t;
|
||||
|
||||
void CTRL_channelButtonInit(void);
|
||||
void CTRL_channelButtonsHandler(void);
|
||||
Reference in New Issue
Block a user