Make function inputs const, and fix some compiler errors

This commit is contained in:
Reed Nightingale 2020-02-09 15:30:37 -08:00
parent a7a2655f02
commit 8faa9c58c7
4 changed files with 29 additions and 27 deletions

View File

@ -1,11 +1,11 @@
#include "menu.h" #include "menu.h"
bool runSubmenu(Menu_t* current_menu, bool runSubmenu(Menu_t* const current_menu,
void(*redraw_callback)(), void(*const redraw_callback)(),
ButtonPress_e tuner_button, const ButtonPress_e tuner_button,
ButtonPress_e touch_button, const ButtonPress_e touch_button,
Point touch_point, const Point touch_point,
int16_t knob){ const int16_t knob){
if(nullptr != current_menu->active_submenu){ if(nullptr != current_menu->active_submenu){
auto ret = current_menu->active_submenu->runMenu(tuner_button,touch_button,touch_point,knob); auto ret = current_menu->active_submenu->runMenu(tuner_button,touch_button,touch_point,knob);
switch(ret){ switch(ret){

20
menu.h
View File

@ -13,13 +13,13 @@ enum ButtonPress_e : uint8_t {
NotPressed, NotPressed,
ShortPress, ShortPress,
LongPress LongPress
} };
struct Menu_t { struct Menu_t {
MenuReturn_e (*runMenu)(ButtonPress_e tuner_button, MenuReturn_e (*const runMenu)(const ButtonPress_e tuner_button,
ButtonPress_e touch_button, const ButtonPress_e touch_button,
Point touch_point, const Point touch_point,
int16_t knob); const int16_t knob);
Menu_t* active_submenu; 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 //Returns true if submenu was run, false otherwise
bool runSubmenu(Menu_t* current_menu, bool runSubmenu(Menu_t* current_menu,
void(*redraw_callback)(), void(*const redraw_callback)(),
ButtonPress_e tuner_button, const ButtonPress_e tuner_button,
ButtonPress_e touch_button, const ButtonPress_e touch_button,
Point touch_point, const Point touch_point,
int16_t knob); const int16_t knob);

View File

@ -1,20 +1,22 @@
#include "menu_main.h" #include "menu_main.h"
#include "button.h"
#include "morse.h" #include "morse.h"
#include "settings.h" #include "settings.h"
#include "ubitx.h"//THRESHOLD_USB_LSB
#include "utils.h" #include "utils.h"
MenuReturn_e runMainMenu(ButtonPress_e tuner_button, MenuReturn_e runMainMenu(const ButtonPress_e tuner_button,
ButtonPress_e touch_button, const ButtonPress_e touch_button,
Point touch_point, const Point touch_point,
int16_t knob); const int16_t knob);
Menu_t mainMenu = { Menu_t mainMenu = {
runMainMenu runMainMenu,
nullptr 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 bool mainMenuSelecting = false;//Tracks if we're selecting buttons with knob, or adjusting frequency
uint8_t mainMenuSelectedItemRaw = 0; uint8_t mainMenuSelectedItemRaw = 0;
@ -50,10 +52,10 @@ void mainMenuTune(int16_t knob)
current_freq = new_freq; current_freq = new_freq;
} }
MenuReturn_e runMainMenu(ButtonPress_e tuner_button, MenuReturn_e runMainMenu(const ButtonPress_e tuner_button,
ButtonPress_e touch_button, const ButtonPress_e touch_button,
Point touch_point, const Point touch_point,
int16_t knob) const int16_t knob)
{ {
if(runSubmenu(&mainMenu, if(runSubmenu(&mainMenu,
drawMainMenu, drawMainMenu,

View File

@ -1,2 +1,2 @@
#include "menu.h" #include "menu.h"
extern static Menu_t* const rootMenu; extern Menu_t* const rootMenu;