Calculator: move 160 bytes from RAM to flash
Making the 'button matrix' arrays 'const' saves 160 bytes of non-stack RAM, which in this context is a lot, and makes it fit (for me) in a real-device build along with my choice of other apps.
This commit is contained in:
parent
68384fc34e
commit
0745ebd82c
1 changed files with 5 additions and 5 deletions
|
@ -122,14 +122,14 @@ Calculator::~Calculator() {
|
|||
lv_obj_clean(lv_scr_act());
|
||||
}
|
||||
|
||||
static const char* buttonMap1[] = {
|
||||
static const char* const buttonMap1[] = {
|
||||
"7", "8", "9", "/", "\n",
|
||||
"4", "5", "6", "x", "\n",
|
||||
"1", "2", "3", "-", "\n",
|
||||
".", "0", "=", "+", "",
|
||||
};
|
||||
|
||||
static const char* buttonMap2[] = {
|
||||
static const char* const buttonMap2[] = {
|
||||
"7", "8", "9", "(", "\n",
|
||||
"4", "5", "6", ")", "\n",
|
||||
"1", "2", "3", "^", "\n",
|
||||
|
@ -154,7 +154,7 @@ Calculator::Calculator(Controllers::MotorController& motorController) : motorCon
|
|||
lv_obj_set_event_cb(returnButton, eventHandler);
|
||||
|
||||
buttonMatrix = lv_btnmatrix_create(lv_scr_act(), nullptr);
|
||||
lv_btnmatrix_set_map(buttonMatrix, buttonMap1);
|
||||
lv_btnmatrix_set_map(buttonMatrix, const_cast<const char **>(buttonMap1));
|
||||
lv_obj_set_size(buttonMatrix, 240, 180);
|
||||
lv_obj_set_pos(buttonMatrix, 0, 60);
|
||||
lv_obj_set_style_local_pad_all(buttonMatrix, LV_BTNMATRIX_PART_BG, LV_STATE_DEFAULT, 0);
|
||||
|
@ -383,11 +383,11 @@ bool Calculator::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
|||
return true;
|
||||
}
|
||||
if (event == Pinetime::Applications::TouchEvents::SwipeLeft) {
|
||||
lv_btnmatrix_set_map(buttonMatrix, buttonMap2);
|
||||
lv_btnmatrix_set_map(buttonMatrix, const_cast<const char **>(buttonMap2));
|
||||
return true;
|
||||
}
|
||||
if (event == Pinetime::Applications::TouchEvents::SwipeRight) {
|
||||
lv_btnmatrix_set_map(buttonMatrix, buttonMap1);
|
||||
lv_btnmatrix_set_map(buttonMatrix, const_cast<const char **>(buttonMap1));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue