[wip] controllers and display
This commit is contained in:
14
firmware/.vscode/c_cpp_properties.json
vendored
14
firmware/.vscode/c_cpp_properties.json
vendored
@@ -3,9 +3,17 @@
|
||||
{
|
||||
"name": "Win32",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/func_gen_stm32f303re_nucleo/Core/**",
|
||||
"${workspaceFolder}/func_gen_stm32f303re_nucleo/Drivers/**",
|
||||
"${workspaceFolder}/shared_libs/**"
|
||||
"${workspaceFolder}/func_gen_stm32f303re_nucleo/Core/Inc",
|
||||
"${workspaceFolder}/func_gen_stm32f303re_nucleo/Drivers/CMSIS/Core/Include",
|
||||
"${workspaceFolder}/func_gen_stm32f303re_nucleo/Drivers/CMSIS/Device/ST/STM32F3xx/Include",
|
||||
"${workspaceFolder}/func_gen_stm32f303re_nucleo/Drivers/STM32F3xx_HAL_Driver/Inc",
|
||||
"${workspaceFolder}/shared_libs",
|
||||
"${workspaceFolder}/shared_libs/bitmaps",
|
||||
"${workspaceFolder}/shared_libs/controllers",
|
||||
"${workspaceFolder}/shared_libs/disp_layout",
|
||||
"${workspaceFolder}/shared_libs/display",
|
||||
"${workspaceFolder}/shared_libs/drivers/**",
|
||||
"${workspaceFolder}/shared_libs/utils/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
|
||||
6
firmware/.vscode/settings.json
vendored
6
firmware/.vscode/settings.json
vendored
@@ -7,6 +7,10 @@
|
||||
"bitmap_fonts.h": "c",
|
||||
"font_gfx.h": "c",
|
||||
"display_gfx.h": "c",
|
||||
"main.h": "c"
|
||||
"main.h": "c",
|
||||
"ctrl_button.h": "c",
|
||||
"ctrl_bottom_button.h": "c",
|
||||
"printf.h": "c",
|
||||
"disp_layout_template.h": "c"
|
||||
}
|
||||
}
|
||||
@@ -83,6 +83,13 @@ C_SOURCES += ../shared_libs/display/font_gfx.c
|
||||
# bitmaps
|
||||
C_SOURCES += ../shared_libs/bitmaps/bitmap_disp_buttons.c
|
||||
C_SOURCES += ../shared_libs/bitmaps/bitmap_font_5x7.c
|
||||
# display_layout
|
||||
C_SOURCES += ../shared_libs/disp_layout/disp_layout.c
|
||||
C_SOURCES += ../shared_libs/disp_layout/disp_layout_defs.c
|
||||
# controllers
|
||||
C_SOURCES += ../shared_libs/controllers/ctrl_bottom_button.c
|
||||
C_SOURCES += ../shared_libs/controllers/ctrl_channel_button.c
|
||||
C_SOURCES += ../shared_libs/controllers/ctrl_app.c
|
||||
|
||||
# utils/printf
|
||||
C_SOURCES += ../shared_libs/utils/printf/printf.c
|
||||
@@ -165,11 +172,18 @@ C_INCLUDES += -I../shared_libs/drivers/hw_button
|
||||
C_INCLUDES += -I../shared_libs/display
|
||||
# bitmaps includes
|
||||
C_INCLUDES += -I../shared_libs/bitmaps
|
||||
# display layout includes
|
||||
C_INCLUDES += -I../shared_libs/disp_layout
|
||||
# controllers includes
|
||||
C_INCLUDES += -I../shared_libs/controllers
|
||||
|
||||
# utils/print includes
|
||||
# utils includes
|
||||
C_INCLUDES += -I../shared_libs/utils/printf
|
||||
C_INCLUDES += -I../shared_libs/utils/rtt
|
||||
|
||||
# config
|
||||
C_INCLUDES += -I../shared_libs
|
||||
|
||||
# compile gcc flags
|
||||
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "display_gfx.h"
|
||||
|
||||
#include "bitmap_disp_buttons.h"
|
||||
|
||||
// clang-format off
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "display_gfx.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DISP_BTN_FREQ,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "main.h"
|
||||
#include "font_gfx.h"
|
||||
|
||||
#include "bitmap_fonts.h"
|
||||
|
||||
// clang-format off
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "font_gfx.h"
|
||||
|
||||
/* Font data for standard 5x7t */
|
||||
extern const uint8_t font5x7[];
|
||||
extern const GFX_font_t font5x7Info;
|
||||
|
||||
13
firmware/shared_libs/config.h
Normal file
13
firmware/shared_libs/config.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#define BTN1_GPIO_Port GPIOA
|
||||
#define BTN2_GPIO_Port GPIOA
|
||||
#define BTN3_GPIO_Port GPIOA
|
||||
#define BTN4_GPIO_Port GPIOA
|
||||
#define BTN5_GPIO_Port GPIOA
|
||||
|
||||
#define BTN1_Pin 0
|
||||
#define BTN2_Pin 0
|
||||
#define BTN3_Pin 0
|
||||
#define BTN4_Pin 0
|
||||
#define BTN5_Pin 0
|
||||
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);
|
||||
@@ -1,214 +1,191 @@
|
||||
#include "main.h"
|
||||
#include "display_gfx.h"
|
||||
#include "font_gfx.h"
|
||||
#include "bitmap_fonts.h"
|
||||
#include "bitmap_disp_buttons.h"
|
||||
|
||||
// #include "wave_gfx.h"
|
||||
|
||||
#include "printf.h"
|
||||
#include "bitmap_fonts.h"
|
||||
#include "disp_layout_defs.h"
|
||||
|
||||
#include "disp_layout.h"
|
||||
|
||||
static uint8_t isChannelChange = 1;
|
||||
static uint8_t isGraphChange = 1;
|
||||
static uint8_t isValuesChange = 1;
|
||||
static uint8_t isButtonsChange = 1;
|
||||
static int8_t isButtonsBlink = 1;
|
||||
|
||||
static uint8_t timer_blink[LAY_BTN_MAX];
|
||||
|
||||
void LAY_blinkButton(LAY_dispBtnName_t disp_btn)
|
||||
static void _drawFreqValue(GFX_display_t *disp, uint32_t freq)
|
||||
{
|
||||
timer_blink[disp_btn] = 2;
|
||||
isButtonsBlink = 1;
|
||||
// uint32_t freq = 9999999;
|
||||
uint8_t data[8];
|
||||
snprintf((char *)data, 8, "%07u", freq);
|
||||
DISP_writeString(disp, &font5x7Info, data, 76, 13, BM_NORMAL);
|
||||
}
|
||||
|
||||
void LAY_updateChannels(void)
|
||||
static void _drawAmplValue(GFX_display_t *disp, uint16_t ampl)
|
||||
{
|
||||
isChannelChange = 1;
|
||||
// float ampl = getAmplValue();
|
||||
uint8_t data[8];
|
||||
// snprintf((char *)data, 8, "%05.2f V", ampl);
|
||||
snprintf((char *)data, 8, "%02d.%02d V", ampl / 100, ampl % 100);
|
||||
DISP_writeString(disp, &font5x7Info, data, 76, 23, BM_NORMAL);
|
||||
}
|
||||
|
||||
void LAY_updateGraph(void)
|
||||
static void _drawOffsValue(GFX_display_t *disp, uint16_t offs)
|
||||
{
|
||||
isGraphChange = 1;
|
||||
// float offs = getOffsetValue();
|
||||
uint8_t data[8];
|
||||
// snprintf((char *)data, 8, "%+4.2f V", offs);
|
||||
snprintf((char *)data, 8, "%+01d.%02d V", offs / 100, offs % 100);
|
||||
DISP_writeString(disp, &font5x7Info, data, 76, 33, BM_NORMAL);
|
||||
}
|
||||
|
||||
void LAY_updateValues(void)
|
||||
static void _drawPhasValue(GFX_display_t *disp, uint16_t phase)
|
||||
{
|
||||
isValuesChange = 1;
|
||||
// uint32_t phase = getPhaseValue();
|
||||
uint8_t data[8];
|
||||
snprintf((char *)data, 8, "%03u'", phase);
|
||||
DISP_writeString(disp, &font5x7Info, data, 76, 43, BM_NORMAL);
|
||||
}
|
||||
|
||||
void LAY_updateButtons(void)
|
||||
static void _drawDutyValue(GFX_display_t *disp, uint8_t duty)
|
||||
{
|
||||
isButtonsChange = 1;
|
||||
// uint32_t duty = getDutyValue();
|
||||
uint8_t data[8];
|
||||
snprintf((char *)data, 8, "%03u%%", duty);
|
||||
DISP_writeString(disp, &font5x7Info, data, 76, 43, BM_NORMAL); // zmien pozycje!!!!!!!!
|
||||
}
|
||||
|
||||
static void _drawFreqValue(GFX_display_t *disp)
|
||||
{
|
||||
uint32_t value = getFreqValue();
|
||||
uint8_t input[8];
|
||||
snprintf((char *)input, 8, "%07u", value);
|
||||
DISP_writeString(disp, &font5x7Info, input, 76, 13, BM_NORMAL);
|
||||
}
|
||||
|
||||
static void _drawAmplValue(GFX_display_t *disp)
|
||||
{
|
||||
float value = getAmplValue();
|
||||
uint8_t input[8];
|
||||
snprintf((char *)input, 8, "%05.2f V", value);
|
||||
DISP_writeString(disp, &font5x7Info, input, 76, 23, BM_NORMAL);
|
||||
}
|
||||
|
||||
static void _drawOffsValue(GFX_display_t *disp)
|
||||
{
|
||||
float value = getOffsetValue();
|
||||
uint8_t input[8];
|
||||
snprintf((char *)input, 8, "%+4.2f V", value);
|
||||
DISP_writeString(disp, &font5x7Info, input, 76, 33, BM_NORMAL);
|
||||
}
|
||||
|
||||
static void _drawPhasValue(GFX_display_t *disp)
|
||||
{
|
||||
uint32_t value = getPhaseValue();
|
||||
uint8_t input[8];
|
||||
snprintf((char *)input, 8, "%03u'", value);
|
||||
DISP_writeString(disp, &font5x7Info, input, 76, 43, BM_NORMAL);
|
||||
}
|
||||
|
||||
static void _drawDutyValue(GFX_display_t *disp)
|
||||
{
|
||||
uint32_t value = getDutyValue();
|
||||
uint8_t input[8];
|
||||
snprintf((char *)input, 8, "%03u%%", value);
|
||||
DISP_writeString(disp, &font5x7Info, input, 76, 43, BM_NORMAL); // zmien pozycje!!!!!!!!
|
||||
}
|
||||
|
||||
static void _blinkButtons(GFX_display_t *disp)
|
||||
static void _blinkButtons(GFX_display_t *disp, APP_data_t *app_data)
|
||||
{
|
||||
// input: display buttons, invert
|
||||
uint8_t done = 0;
|
||||
for (LAY_dispBtnName_t disp_btn = LAY_BTN_1; disp_btn < LAY_BTN_MAX; disp_btn++)
|
||||
BITMAP_buttonName_t bitmap_idx;
|
||||
for (LAY_dispBtnIdx_t btn_idx = LAY_BTN_1; btn_idx < LAY_BTN_MAX; btn_idx++)
|
||||
{
|
||||
if (timer_blink[disp_btn] > 0)
|
||||
if (!(app_data->isButtonBlink & (1 << btn_idx)))
|
||||
{
|
||||
DISP_drawBitmap(disp, &btn_bottom[disp_btns[curr_layout][disp_btn] + 1], btn_pos_x[disp_btn], 53, BM_NORMAL);
|
||||
timer_blink[disp_btn]--;
|
||||
continue;
|
||||
}
|
||||
else if (timer_blink[disp_btn] == 0)
|
||||
{
|
||||
DISP_drawBitmap(disp, &btn_bottom[disp_btns[curr_layout][disp_btn]], btn_pos_x[disp_btn], 53, BM_NORMAL);
|
||||
done++;
|
||||
timer_blink[disp_btn]--;
|
||||
}
|
||||
}
|
||||
|
||||
if (done == LAY_BTN_MAX)
|
||||
{
|
||||
isButtonsBlink = 0;
|
||||
bitmap_idx = btn_names[app_data->curr_layout][btn_idx];
|
||||
if (app_data->timer_blink[btn_idx] > 0)
|
||||
{
|
||||
DISP_drawBitmap(disp, &bitmap_btnBottom[bitmap_idx + 1], btn_pos_x[btn_idx], 53, BM_NORMAL);
|
||||
app_data->timer_blink[btn_idx]--;
|
||||
}
|
||||
else
|
||||
{
|
||||
DISP_drawBitmap(disp, &bitmap_btnBottom[bitmap_idx], btn_pos_x[btn_idx], 53, BM_NORMAL);
|
||||
app_data->isButtonBlink &= ~(1 << btn_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void _drawButtons(GFX_display_t *disp)
|
||||
static void _drawButtons(GFX_display_t *disp, APP_data_t *app_data)
|
||||
{
|
||||
// input: display buttons, invert
|
||||
BITMAP_buttonName_t bitmap_idx;
|
||||
DISP_clearRegion(disp, 0, 53, disp->width, 11);
|
||||
uint8_t pos_x = 0;
|
||||
|
||||
for (LAY_dispBtnName_t disp_btn = LAY_BTN_1; disp_btn < LAY_BTN_MAX; disp_btn++)
|
||||
for (LAY_dispBtnIdx_t btn_idx = LAY_BTN_1; btn_idx < LAY_BTN_MAX; btn_idx++)
|
||||
{
|
||||
BITMAP_buttonName_t btn_name = getBitmapName(disp_btn);
|
||||
|
||||
DISP_drawBitmap(disp, &bitmap_btnBottom[btn_name], pos_x, 53, BM_NORMAL);
|
||||
pos_x += bitmap_btnBottom[btn_name].width + 1;
|
||||
bitmap_idx = btn_names[app_data->curr_layout][btn_idx];
|
||||
DISP_drawBitmap(disp, &bitmap_btnBottom[bitmap_idx], btn_pos_x[btn_idx], 53, BM_NORMAL);
|
||||
}
|
||||
|
||||
isButtonsChange = 0;
|
||||
app_data->isButtonChange = 0;
|
||||
}
|
||||
|
||||
static void _drawFuncGenValues(GFX_display_t *disp)
|
||||
static void _drawFuncGenValues(GFX_display_t *disp, APP_data_t *app_data)
|
||||
{
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"F:", 64, 13, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"A:", 64, 23, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"O:", 64, 33, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"P:", 64, 43, BM_NORMAL);
|
||||
|
||||
_drawFreqValue(disp);
|
||||
_drawAmplValue(disp);
|
||||
_drawOffsValue(disp);
|
||||
_drawPhasValue(disp);
|
||||
GEN_fg_t *fun_gen = (GEN_fg_t *)app_data->generator;
|
||||
switch (app_data->curr_layout)
|
||||
{
|
||||
case LAY_FG_FREQ:
|
||||
_drawFreqValue(disp, fun_gen->frequency);
|
||||
break;
|
||||
case LAY_FG_AMPL:
|
||||
_drawAmplValue(disp, fun_gen->amplitude);
|
||||
break;
|
||||
case LAY_FG_OFFS:
|
||||
_drawOffsValue(disp, fun_gen->offset);
|
||||
break;
|
||||
case LAY_FG_PHAS:
|
||||
_drawPhasValue(disp, fun_gen->phase);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void _drawPwmGenValues(GFX_display_t *disp)
|
||||
static void _drawPwmGenValues(GFX_display_t *disp, APP_data_t *app_data)
|
||||
{
|
||||
GEN_pwm_t *pwm_gen = app_data->generator;
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"F:", 64, 13, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"A:", 64, 23, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"O:", 64, 33, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"P:", 64, 43, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"D:", 64, 43, BM_NORMAL);
|
||||
|
||||
_drawFreqValue(disp);
|
||||
_drawAmplValue(disp);
|
||||
_drawOffsValue(disp);
|
||||
_drawPhasValue(disp);
|
||||
_drawDutyValue(disp);
|
||||
_drawFreqValue(disp, pwm_gen->frequency);
|
||||
_drawAmplValue(disp, pwm_gen->amplitude / 100);
|
||||
_drawOffsValue(disp, pwm_gen->offset / 100);
|
||||
_drawPhasValue(disp, pwm_gen->phase);
|
||||
_drawDutyValue(disp, pwm_gen->duty);
|
||||
}
|
||||
|
||||
static void _drawValues(GFX_display_t *disp)
|
||||
static void _drawValues(GFX_display_t *disp, APP_data_t *app_data)
|
||||
{
|
||||
// input: frequency(value), amplitiude(value), offset(value), phase(value), duty(value), invert(info), position(value)
|
||||
switch (getLayoutType())
|
||||
switch (app_data->gen_type)
|
||||
{
|
||||
case LT_TYPE_FG:
|
||||
_drawFuncGenValues(disp);
|
||||
case GEN_FG_TYPE:
|
||||
_drawFuncGenValues(disp, app_data);
|
||||
break;
|
||||
case LT_TYPE_PWM:
|
||||
_drawPwmGenValues(disp);
|
||||
case GEN_PWM_TYPE:
|
||||
_drawPwmGenValues(disp, app_data);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
isValuesChange = 0;
|
||||
app_data->isValueChange = 0;
|
||||
}
|
||||
|
||||
static void _drawGraph(GFX_display_t *disp)
|
||||
static void _drawGraph(GFX_display_t *disp, APP_data_t *app_data)
|
||||
{
|
||||
// input: graph type(sin, triangle, squere, pwm), frequency(info), amplitiude(value), offset(value), phase(value), invert(pwm),
|
||||
DISP_drawSin(disp, 4, 32, 16, 0, 0);
|
||||
// DISP_drawSin(disp, 4, 32, 16, 0, 0);
|
||||
DISP_drawHorizontalLine(disp, 2, 32, 56, GFX_WHITE);
|
||||
|
||||
isGraphChange = 0;
|
||||
app_data->isGraphChange = 0;
|
||||
}
|
||||
|
||||
static void _drawChannels(GFX_display_t *disp)
|
||||
static void _drawChannels(GFX_display_t *disp, APP_data_t *app_data)
|
||||
{
|
||||
// input: active channel
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH1", 2, 2, BM_INVERSE);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH2", 23, 2, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH3", 44, 2, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH4", 65, 2, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH5", 86, 2, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH6", 107, 2, BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH1", 2, 2, CHANNEL1 == app_data->curr_channel ? BM_INVERSE : BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH2", 23, 2, CHANNEL2 == app_data->curr_channel ? BM_INVERSE : BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH3", 44, 2, CHANNEL3 == app_data->curr_channel ? BM_INVERSE : BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH4", 65, 2, CHANNEL4 == app_data->curr_channel ? BM_INVERSE : BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH5", 86, 2, CHANNEL5 == app_data->curr_channel ? BM_INVERSE : BM_NORMAL);
|
||||
DISP_writeString(disp, &font5x7Info, (uint8_t *)"CH6", 107, 2, CHANNEL6 == app_data->curr_channel ? BM_INVERSE : BM_NORMAL);
|
||||
DISP_drawHorizontalLine(disp, 0, 10, 127, GFX_WHITE);
|
||||
|
||||
isChannelChange = 0;
|
||||
app_data->isChannelChange = 0;
|
||||
}
|
||||
|
||||
void LAY_drawDisplayLayout(GFX_display_t *disp)
|
||||
void LAY_drawDisplayLayout(GFX_display_t *disp, APP_data_t *app_data)
|
||||
{
|
||||
if (isChannelChange)
|
||||
_drawChannels(disp);
|
||||
if (app_data->isChannelChange)
|
||||
_drawChannels(disp, app_data);
|
||||
|
||||
if (isGraphChange)
|
||||
_drawGraph(disp);
|
||||
if (app_data->isGraphChange)
|
||||
_drawGraph(disp, app_data);
|
||||
|
||||
if (isValuesChange)
|
||||
_drawValues(disp);
|
||||
if (app_data->isValueChange)
|
||||
_drawValues(disp, app_data);
|
||||
|
||||
if (isButtonsChange)
|
||||
_drawButtons(disp);
|
||||
if (app_data->isButtonChange)
|
||||
_drawButtons(disp, app_data);
|
||||
|
||||
if (isButtonsBlink)
|
||||
_blinkButtons(disp);
|
||||
if (app_data->isButtonBlink)
|
||||
_blinkButtons(disp, app_data);
|
||||
}
|
||||
|
||||
@@ -1,44 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LAY_BTN_1,
|
||||
LAY_BTN_2,
|
||||
LAY_BTN_3,
|
||||
LAY_BTN_4,
|
||||
LAY_BTN_5,
|
||||
LAY_BTN_MAX,
|
||||
} LAY_dispBtnName_t;
|
||||
#include "display_gfx.h"
|
||||
#include "ctrl_app.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LAY_CH_1,
|
||||
LAY_CH_2,
|
||||
LAY_CH_3,
|
||||
LAY_CH_4,
|
||||
LAY_CH_5,
|
||||
LAY_CH_6,
|
||||
LAY_CH_MAX,
|
||||
} LAY_chanName_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LAY_FG_MAIN,
|
||||
LAY_FG_FREQ,
|
||||
LAY_FG_AMPL,
|
||||
LAY_FG_OFFS,
|
||||
LAY_FG_PHAS,
|
||||
LAY_FG_WAVE,
|
||||
LAY_STATE_MAX,
|
||||
} LAY_state_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LT_TYPE_FG,
|
||||
LT_TYPE_PWM
|
||||
} LAY_type_t;
|
||||
|
||||
void LAY_drawDisplayLayout(GFX_display_t *disp);
|
||||
void LAY_setDisplayLayout(LAY_state_t layout);
|
||||
void LAY_blinkButton(LAY_dispBtnName_t disp_btn);
|
||||
void LAY_setFreqValue(uint32_t value);
|
||||
void LAY_drawDisplayLayout(GFX_display_t *disp, APP_data_t *app_data);
|
||||
|
||||
13
firmware/shared_libs/disp_layout/disp_layout_defs.c
Normal file
13
firmware/shared_libs/disp_layout/disp_layout_defs.c
Normal file
@@ -0,0 +1,13 @@
|
||||
#include "main.h"
|
||||
#include "disp_layout_defs.h"
|
||||
|
||||
const BITMAP_buttonName_t btn_names[LAY_STATE_MAX][LAY_BTN_MAX] = {
|
||||
{DISP_BTN_FREQ, DISP_BTN_AMPL, DISP_BTN_OFFS, DISP_BTN_PHAS, DISP_BTN_WAVE}, // Func Gen Main
|
||||
{DISP_BTN_LEFT, DISP_BTN_RIGHT, DISP_BTN_NONE, DISP_BTN_NONE, DISP_BTN_BACK}, // Func Gen Freq
|
||||
{DISP_BTN_X1, DISP_BTN_X0_1, DISP_BTN_X0_01, DISP_BTN_NONE, DISP_BTN_BACK}, // Func Gen Ampl
|
||||
{DISP_BTN_X1, DISP_BTN_X0_1, DISP_BTN_X0_01, DISP_BTN_NONE, DISP_BTN_BACK}, // Func Gen Offs
|
||||
{DISP_BTN_X10, DISP_BTN_X1, DISP_BTN_NONE, DISP_BTN_NONE, DISP_BTN_BACK}, // Func Gen Phas
|
||||
{DISP_BTN_NONE, DISP_BTN_NONE, DISP_BTN_NONE, DISP_BTN_NONE, DISP_BTN_BACK}, // Func Gen Wave
|
||||
};
|
||||
|
||||
const uint8_t btn_pos_x[LAY_BTN_MAX] = {0, 26, 52, 78, 104};
|
||||
7
firmware/shared_libs/disp_layout/disp_layout_defs.h
Normal file
7
firmware/shared_libs/disp_layout/disp_layout_defs.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "bitmap_disp_buttons.h"
|
||||
#include "disp_layout_types.h"
|
||||
|
||||
extern const BITMAP_buttonName_t btn_names[LAY_STATE_MAX][LAY_BTN_MAX];
|
||||
extern const uint8_t btn_pos_x[LAY_BTN_MAX];
|
||||
22
firmware/shared_libs/disp_layout/disp_layout_types.h
Normal file
22
firmware/shared_libs/disp_layout/disp_layout_types.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LAY_BTN_1,
|
||||
LAY_BTN_2,
|
||||
LAY_BTN_3,
|
||||
LAY_BTN_4,
|
||||
LAY_BTN_5,
|
||||
LAY_BTN_MAX,
|
||||
} LAY_dispBtnIdx_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LAY_FG_MAIN,
|
||||
LAY_FG_FREQ,
|
||||
LAY_FG_AMPL,
|
||||
LAY_FG_OFFS,
|
||||
LAY_FG_PHAS,
|
||||
LAY_FG_WAVE,
|
||||
LAY_STATE_MAX,
|
||||
} LAY_state_t;
|
||||
Reference in New Issue
Block a user