Make function inputs const, and fix some compiler errors
This commit is contained in:
parent
a7a2655f02
commit
8faa9c58c7
12
menu.cpp
12
menu.cpp
|
@ -1,11 +1,11 @@
|
|||
#include "menu.h"
|
||||
|
||||
bool runSubmenu(Menu_t* current_menu,
|
||||
void(*redraw_callback)(),
|
||||
ButtonPress_e tuner_button,
|
||||
ButtonPress_e touch_button,
|
||||
Point touch_point,
|
||||
int16_t knob){
|
||||
bool runSubmenu(Menu_t* const current_menu,
|
||||
void(*const redraw_callback)(),
|
||||
const ButtonPress_e tuner_button,
|
||||
const ButtonPress_e touch_button,
|
||||
const Point touch_point,
|
||||
const int16_t knob){
|
||||
if(nullptr != current_menu->active_submenu){
|
||||
auto ret = current_menu->active_submenu->runMenu(tuner_button,touch_button,touch_point,knob);
|
||||
switch(ret){
|
||||
|
|
20
menu.h
20
menu.h
|
@ -13,13 +13,13 @@ enum ButtonPress_e : uint8_t {
|
|||
NotPressed,
|
||||
ShortPress,
|
||||
LongPress
|
||||
}
|
||||
};
|
||||
|
||||
struct Menu_t {
|
||||
MenuReturn_e (*runMenu)(ButtonPress_e tuner_button,
|
||||
ButtonPress_e touch_button,
|
||||
Point touch_point,
|
||||
int16_t knob);
|
||||
MenuReturn_e (*const runMenu)(const ButtonPress_e tuner_button,
|
||||
const ButtonPress_e touch_button,
|
||||
const Point touch_point,
|
||||
const int16_t knob);
|
||||
Menu_t* active_submenu;
|
||||
};
|
||||
|
||||
|
@ -27,8 +27,8 @@ static const uint8_t MENU_KNOB_COUNTS_PER_ITEM = 10;
|
|||
|
||||
//Returns true if submenu was run, false otherwise
|
||||
bool runSubmenu(Menu_t* current_menu,
|
||||
void(*redraw_callback)(),
|
||||
ButtonPress_e tuner_button,
|
||||
ButtonPress_e touch_button,
|
||||
Point touch_point,
|
||||
int16_t knob);
|
||||
void(*const redraw_callback)(),
|
||||
const ButtonPress_e tuner_button,
|
||||
const ButtonPress_e touch_button,
|
||||
const Point touch_point,
|
||||
const int16_t knob);
|
|
@ -1,20 +1,22 @@
|
|||
#include "menu_main.h"
|
||||
|
||||
#include "button.h"
|
||||
#include "morse.h"
|
||||
#include "settings.h"
|
||||
#include "ubitx.h"//THRESHOLD_USB_LSB
|
||||
#include "utils.h"
|
||||
|
||||
MenuReturn_e runMainMenu(ButtonPress_e tuner_button,
|
||||
ButtonPress_e touch_button,
|
||||
Point touch_point,
|
||||
int16_t knob);
|
||||
MenuReturn_e runMainMenu(const ButtonPress_e tuner_button,
|
||||
const ButtonPress_e touch_button,
|
||||
const Point touch_point,
|
||||
const int16_t knob);
|
||||
|
||||
Menu_t mainMenu = {
|
||||
runMainMenu
|
||||
runMainMenu,
|
||||
nullptr
|
||||
};
|
||||
|
||||
static Menu_t* const rootMenu = &mainMenu;
|
||||
Menu_t* const rootMenu = &mainMenu;
|
||||
|
||||
bool mainMenuSelecting = false;//Tracks if we're selecting buttons with knob, or adjusting frequency
|
||||
uint8_t mainMenuSelectedItemRaw = 0;
|
||||
|
@ -50,10 +52,10 @@ void mainMenuTune(int16_t knob)
|
|||
current_freq = new_freq;
|
||||
}
|
||||
|
||||
MenuReturn_e runMainMenu(ButtonPress_e tuner_button,
|
||||
ButtonPress_e touch_button,
|
||||
Point touch_point,
|
||||
int16_t knob)
|
||||
MenuReturn_e runMainMenu(const ButtonPress_e tuner_button,
|
||||
const ButtonPress_e touch_button,
|
||||
const Point touch_point,
|
||||
const int16_t knob)
|
||||
{
|
||||
if(runSubmenu(&mainMenu,
|
||||
drawMainMenu,
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
#include "menu.h"
|
||||
extern static Menu_t* const rootMenu;
|
||||
extern Menu_t* const rootMenu;
|
||||
|
|
Loading…
Reference in New Issue