mirror of
https://codeberg.org/mclemens/ubitxv6.git
synced 2024-11-18 23:56:06 -05:00
Add actual menu running functions
This commit is contained in:
parent
2f964b3ffb
commit
f47c45194e
@ -4,6 +4,7 @@
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
#include "color_theme.h"
|
||||
#include "menu_utils.h"
|
||||
#include "nano_gui.h"
|
||||
|
||||
void initNumpad(void);
|
||||
@ -19,6 +20,8 @@ Menu_t numpad_menu = {
|
||||
|
||||
Menu_t *const numpadMenu = &numpad_menu;
|
||||
|
||||
int16_t numpadMenuSelectedItemRaw = 0;//Allow negative only for easier checks on wrap around
|
||||
|
||||
void drawNumpad(void)
|
||||
{
|
||||
displayFillrect(0,47,320,200,COLOR_BACKGROUND);
|
||||
@ -35,6 +38,10 @@ void initNumpad(void)
|
||||
{
|
||||
numpadMenuFrequency = 0;
|
||||
drawNumpad();
|
||||
initSelector(&numpadMenuSelectedItemRaw,
|
||||
numpadMenuButtons,
|
||||
NUMPAD_MENU_NUM_BUTTONS,
|
||||
MorsePlaybackType_e::PlayChar);
|
||||
}
|
||||
|
||||
MenuReturn_e runNumpad(const ButtonPress_e tuner_button,
|
||||
@ -42,7 +49,34 @@ MenuReturn_e runNumpad(const ButtonPress_e tuner_button,
|
||||
const Point touch_point,
|
||||
const int16_t knob)
|
||||
{
|
||||
(void)tuner_button;(void)touch_button;(void)touch_point;(void)knob;//TODO
|
||||
if(ButtonPress_e::NotPressed != tuner_button){
|
||||
//We treat long and short presses the same, so no need to have a switch
|
||||
uint8_t menu_index = numpadMenuSelectedItemRaw/MENU_KNOB_COUNTS_PER_ITEM;
|
||||
Button button;
|
||||
Button* bp;
|
||||
memcpy_P(&bp,&(numpadMenuButtons[menu_index]),sizeof(bp));
|
||||
memcpy_P(&button,bp,sizeof(button));
|
||||
button.on_select();
|
||||
}//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;
|
||||
if(findPressedButton(numpadMenuButtons,NUMPAD_MENU_NUM_BUTTONS,&button,touch_point)){
|
||||
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,
|
||||
numpadMenuButtons,
|
||||
NUMPAD_MENU_NUM_BUTTONS,
|
||||
MorsePlaybackType_e::PlayChar);
|
||||
}
|
||||
|
||||
if(NUMPAD_MENU_EXIT_FREQ == numpadMenuFrequency){
|
||||
return MenuReturn_e::ExitedRedraw;
|
||||
|
Loading…
Reference in New Issue
Block a user