1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
53
54
58
59
60
61
62
63
64
65
68
71
74
77
80
82
84
85
86
87
96
97
98
/* ... */
#include <gui/main_menu_screen/MainMenuView.hpp>
#include <BitmapDatabase.hpp>
#ifndef SIMULATOR
#define GFX_DEMO_SIGNATURE_B 0x5AA55BBB
extern "C"
{
#include "stm32f4xx.h"
}extern "C" { ... }
/* ... */#endif
MainMenuView::MainMenuView() :
selectedDemoScreenIndex(0),
onToggleButtonPressed(this, &MainMenuView::toggleButtonPressedHandler),
onStMenuButtonPressed(this, &MainMenuView::stMenuButtonPressedHandler)
{
toggleMenuButton.setBitmaps(Bitmap(BITMAP_MENU_TOGGLE_BUTTON_ID), Bitmap(BITMAP_MENU_TOGGLE_BUTTON_PRESSED_ID));
toggleMenuButton.setXY(35, 26);
toggleMenuButton.setAction(onToggleButtonPressed);
stMenuButton.setBitmaps(Bitmap(BITMAP_ST_MENU_BUTTON_ID), Bitmap(BITMAP_ST_MENU_BUTTON_PRESSED_ID));
stMenuButton.setXY(HAL::DISPLAY_WIDTH - stMenuButton.getWidth()-35, 26);
stMenuButton.setAction(onStMenuButtonPressed);
mcuLoadTxt.setXY(35, 82);
mcuLoadTxt.setColor(Color::getColorFrom24BitRGB(0xFF, 0xFF, 0xFF));
mcuLoadValueTxt.setPosition(mcuLoadTxt.getRect().right()-4, mcuLoadTxt.getY(), 50, 30);
mcuLoadValueTxt.setColor(mcuLoadTxt.getColor());
}{ ... }
MainMenuView::~MainMenuView()
{
}{ ... }
void MainMenuView::setSelectedDemoScreen(int demoIndex)
{
selectedDemoScreenIndex = demoIndex;
}{ ... }
void MainMenuView::gotoSelectedDemoScreen()
{
presenter->setSelectedDemoScreenIndex(selectedDemoScreenIndex);
switch (demoIDs[selectedDemoScreenIndex])
{
case MainMenuView::PRODUCT_PRESENTER:
static_cast<FrontendApplication*>(Application::getInstance())->gotoProductPresenterScreen();
break;case MainMenuView::PRODUCT_PRESENTER:
case MainMenuView::GAME2048:
static_cast<FrontendApplication*>(Application::getInstance())->gotoGame2048Screen();
break;case MainMenuView::GAME2048:
case MainMenuView::GAME2D:
static_cast<FrontendApplication*>(Application::getInstance())->gotoGame2DScreen();
break;case MainMenuView::GAME2D:
case MainMenuView::CUSTOM_CONTROLS:
static_cast<FrontendApplication*>(Application::getInstance())->gotoCustomControlsScreen();
break;case MainMenuView::CUSTOM_CONTROLS:
case MainMenuView::GRAPH:
static_cast<FrontendApplication*>(Application::getInstance())->gotoGraphScreen();
break;case MainMenuView::GRAPH:
case MainMenuView::NO_DEMO_SCREEN:
break;case MainMenuView::NO_DEMO_SCREEN:
default:
break;default
}switch (demoIDs[selectedDemoScreenIndex]) { ... }
}{ ... }
void MainMenuView::toggleButtonPressedHandler(const AbstractButton& button)
{
presenter->setPreviousSelectedMenuType(MainMenuPresenter::NO_MENU);
presenter->setSelectedDemoScreenIndex(0);
toggleMenu();
}{ ... }
void MainMenuView::stMenuButtonPressedHandler(const AbstractButton& button)
{
#ifndef SIMULATOR
*(uint32_t *)(0x40024000) = GFX_DEMO_SIGNATURE_B;
NVIC_SystemReset(); /* ... */
#endif
}{ ... }