2020-02-14 21:50:57 -05:00
|
|
|
#include "menu_numpad.h"
|
|
|
|
#include "menu_numpad_buttons.h"
|
|
|
|
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
|
|
|
|
#include "color_theme.h"
|
2020-02-14 22:05:12 -05:00
|
|
|
#include "menu_utils.h"
|
2020-02-14 21:50:57 -05:00
|
|
|
#include "nano_gui.h"
|
|
|
|
|
|
|
|
void initNumpad(void);
|
|
|
|
MenuReturn_e runNumpad(const ButtonPress_e tuner_button,
|
|
|
|
const ButtonPress_e touch_button,
|
|
|
|
const Point touch_point,
|
|
|
|
const int16_t knob);
|
|
|
|
Menu_t numpad_menu = {
|
|
|
|
initNumpad,
|
|
|
|
runNumpad,
|
|
|
|
nullptr
|
|
|
|
};
|
|
|
|
|
|
|
|
Menu_t *const numpadMenu = &numpad_menu;
|
|
|
|
|
2020-02-14 22:05:12 -05:00
|
|
|
int16_t numpadMenuSelectedItemRaw = 0;//Allow negative only for easier checks on wrap around
|
|
|
|
|
2020-02-14 21:50:57 -05:00
|
|
|
void drawNumpad(void)
|
|
|
|
{
|
|
|
|
displayFillrect(0,47,320,200,COLOR_BACKGROUND);
|
2020-04-25 22:46:36 -04:00
|
|
|
drawButtonGrid(&numpadMenuGrid);
|
2020-02-14 21:50:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void initNumpad(void)
|
|
|
|
{
|
|
|
|
numpadMenuFrequency = 0;
|
|
|
|
drawNumpad();
|
2020-02-14 22:05:12 -05:00
|
|
|
initSelector(&numpadMenuSelectedItemRaw,
|
2020-04-25 22:46:36 -04:00
|
|
|
&numpadMenuGrid,
|
2020-02-14 22:05:12 -05:00
|
|
|
MorsePlaybackType_e::PlayChar);
|
2020-02-14 21:50:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
MenuReturn_e runNumpad(const ButtonPress_e tuner_button,
|
|
|
|
const ButtonPress_e touch_button,
|
|
|
|
const Point touch_point,
|
|
|
|
const int16_t knob)
|
|
|
|
{
|
2020-02-14 22:05:12 -05:00
|
|
|
if(ButtonPress_e::NotPressed != tuner_button){
|
|
|
|
//We treat long and short presses the same, so no need to have a switch
|
2020-04-25 22:46:36 -04:00
|
|
|
|
|
|
|
ButtonGrid_t button_grid;
|
|
|
|
memcpy_P(&button_grid,&numpadMenuGrid,sizeof(button_grid));
|
|
|
|
|
2020-02-14 22:05:12 -05:00
|
|
|
uint8_t menu_index = numpadMenuSelectedItemRaw/MENU_KNOB_COUNTS_PER_ITEM;
|
|
|
|
Button* bp;
|
2020-04-25 22:46:36 -04:00
|
|
|
memcpy_P(&bp,&(button_grid.buttons_P[menu_index]),sizeof(bp));
|
|
|
|
|
|
|
|
if(nullptr != bp){
|
|
|
|
Button button;
|
|
|
|
memcpy_P(&button,bp,sizeof(button));
|
|
|
|
button.on_select();
|
|
|
|
}
|
2020-02-14 22:05:12 -05:00
|
|
|
}//tuner_button
|
|
|
|
|
|
|
|
else if(ButtonPress_e::NotPressed != touch_button){
|
|
|
|
//We treat long and short presses the same, so no need to have a switch
|
|
|
|
Button button;
|
2020-04-25 22:46:36 -04:00
|
|
|
if(findPressedButton(&numpadMenuGrid,&button,touch_point)){
|
2020-02-14 22:05:12 -05:00
|
|
|
button.on_select();
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
//Touch detected, but not on our buttons, so ignore
|
|
|
|
}
|
|
|
|
}//touch_button
|
|
|
|
|
|
|
|
else{//Neither button input type found, so handle the knob
|
|
|
|
adjustSelector(&numpadMenuSelectedItemRaw,
|
|
|
|
knob,
|
2020-04-25 22:46:36 -04:00
|
|
|
&numpadMenuGrid,
|
2020-02-14 22:05:12 -05:00
|
|
|
MorsePlaybackType_e::PlayChar);
|
|
|
|
}
|
2020-02-14 21:50:57 -05:00
|
|
|
|
|
|
|
if(NUMPAD_MENU_EXIT_FREQ == numpadMenuFrequency){
|
|
|
|
return MenuReturn_e::ExitedRedraw;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return MenuReturn_e::StillActive;
|
|
|
|
}
|
|
|
|
}
|