Skip to content

Commit

Permalink
Increase number of possible elements on a page, minor safety checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
qvasic committed Jun 30, 2024
1 parent 455bf19 commit 9de91a1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "HDZGOGGLE emulator",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build_emu/HDZGOGGLE",
"cwd": "${workspaceFolder}"
}
]
}
2 changes: 1 addition & 1 deletion src/ui/page_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extern "C" {
#define RIGHT_BUTTON_IMG "right_button.png"
#define ALERT_IMG "alert.png"

#define MAX_PANELS 9
#define MAX_PANELS 10

#define FLAG_SELECTABLE LV_OBJ_FLAG_USER_1
#define STATE_DISABLED LV_STATE_USER_1
Expand Down
11 changes: 8 additions & 3 deletions src/ui/ui_main_menu.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "ui/ui_main_menu.h"

#include <assert.h>
#include <stdio.h>

#include <log/log.h>
Expand Down Expand Up @@ -100,8 +101,12 @@ void submenu_enter(void) {

if (pp->p_arr.max) {
// if we have selectable entries, select the first selectable one
for (pp->p_arr.cur = 0; !lv_obj_has_flag(pp->p_arr.panel[pp->p_arr.cur], FLAG_SELECTABLE); ++pp->p_arr.cur);
set_select_item(&pp->p_arr, pp->p_arr.cur);
for (pp->p_arr.cur = 0; pp->p_arr.cur < pp->p_arr.max && !lv_obj_has_flag(pp->p_arr.panel[pp->p_arr.cur], FLAG_SELECTABLE); ++pp->p_arr.cur);
if (pp->p_arr.cur == pp->p_arr.max) {
pp->p_arr.cur = 0;
} else {
set_select_item(&pp->p_arr, pp->p_arr.cur);
}
}

if (pp->enter) {
Expand Down Expand Up @@ -264,7 +269,7 @@ void main_menu_show(bool is_show) {

static void main_menu_create_entry(lv_obj_t *menu, lv_obj_t *section, page_pack_t *pp) {
LOGD("creating main menu entry %s", pp->name);

assert(pp->p_arr.max <= MAX_PANELS);
pp->page = pp->create(menu, &pp->p_arr);

lv_obj_t *cont = lv_menu_cont_create(section);
Expand Down

0 comments on commit 9de91a1

Please sign in to comment.