Drop gScreenToDisplay switch and use function table
Saves some bytes
This commit is contained in:
49
ui/ui.c
49
ui/ui.c
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "app/chFrScanner.h"
|
||||
@@ -34,6 +35,7 @@
|
||||
#include "ui/menu.h"
|
||||
#include "ui/scanner.h"
|
||||
#include "ui/ui.h"
|
||||
#include "../misc.h"
|
||||
|
||||
GUI_DisplayType_t gScreenToDisplay;
|
||||
GUI_DisplayType_t gRequestDisplayScreen = DISPLAY_INVALID;
|
||||
@@ -42,36 +44,27 @@ uint8_t gAskForConfirmation;
|
||||
bool gAskToSave;
|
||||
bool gAskToDelete;
|
||||
|
||||
|
||||
void (*UI_DisplayFunctions[])(void) = {
|
||||
[DISPLAY_MAIN] = &UI_DisplayMain,
|
||||
[DISPLAY_MENU] = &UI_DisplayMenu,
|
||||
[DISPLAY_SCANNER] = &UI_DisplayScanner,
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
[DISPLAY_FM] = &UI_DisplayFM,
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
[DISPLAY_AIRCOPY] = &UI_DisplayAircopy,
|
||||
#endif
|
||||
};
|
||||
|
||||
static_assert(ARRAY_SIZE(UI_DisplayFunctions) == DISPLAY_N_ELEM);
|
||||
|
||||
void GUI_DisplayScreen(void)
|
||||
{
|
||||
switch (gScreenToDisplay)
|
||||
{
|
||||
case DISPLAY_MAIN:
|
||||
UI_DisplayMain();
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_FMRADIO
|
||||
case DISPLAY_FM:
|
||||
UI_DisplayFM();
|
||||
break;
|
||||
#endif
|
||||
|
||||
case DISPLAY_MENU:
|
||||
UI_DisplayMenu();
|
||||
break;
|
||||
|
||||
case DISPLAY_SCANNER:
|
||||
UI_DisplayScanner();
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
case DISPLAY_AIRCOPY:
|
||||
UI_DisplayAircopy();
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
if (gScreenToDisplay != DISPLAY_INVALID) {
|
||||
UI_DisplayFunctions[gScreenToDisplay]();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user