From 9e1183779c8a265803b7b64f65ccf5d6363f98fc Mon Sep 17 00:00:00 2001 From: Howard Su Date: Wed, 20 Feb 2019 14:45:50 +0800 Subject: [PATCH] Move elem and quickpages into Model structure --- src/config/model.c | 20 +++++----- src/config/model.h | 3 +- src/config/pagecfg.h | 5 --- src/pages/128x64x1/main_config.c | 15 ++++---- src/pages/128x64x1/main_layout.c | 1 - src/pages/128x64x1/pages.c | 6 +-- src/pages/128x64x1/toggle_select.c | 10 ++--- src/pages/320x240x16/main_layout.c | 3 +- src/pages/320x240x16/pages.c | 8 ++-- src/pages/320x240x16/toggle_select.c | 14 +++---- src/pages/common/_main_config.c | 56 ++++++++++++++-------------- src/pages/common/_main_layout.c | 20 +++++----- src/pages/common/_main_page.c | 33 ++++++++-------- src/pages/common/_toggle_select.c | 8 ++-- src/pages/text/main_layout.c | 1 - src/remap_channels.c | 8 ++-- 16 files changed, 101 insertions(+), 110 deletions(-) diff --git a/src/config/model.c b/src/config/model.c index 77ca8f51e9..01e23c488b 100644 --- a/src/config/model.c +++ b/src/config/model.c @@ -408,7 +408,7 @@ static int layout_ini_handler(void* user, const char* section, const char* name, int max = PAGE_GetNumPages(); for(i = 0; i < max; i++) { if(mapstrcasecmp(PAGE_GetName(i), value) == 0) { - m->pagecfg2.quickpage[idx] = i; + m->quickpage[idx] = i; return 1; } } @@ -423,7 +423,7 @@ static int layout_ini_handler(void* user, const char* section, const char* name, }; if (! MATCH_SECTION(SECTION_GUI)) { if(MATCH_SECTION("gui-320x240") - && (! ELEM_USED(Model.pagecfg2.elem[0]) || seen_res != HIRES)) + && (! ELEM_USED(Model.elem[0]) || seen_res != HIRES)) { seen_res = LOWRES; offset_x = (LCD_WIDTH - 320) / 2; @@ -432,7 +432,7 @@ static int layout_ini_handler(void* user, const char* section, const char* name, return 1; } else { if (seen_res == LOWRES) { - memset(&Model.pagecfg2.elem, 0, sizeof(Model.pagecfg2.elem)); + memset(&Model.elem, 0, sizeof(Model.elem)); } seen_res = HIRES; } @@ -441,7 +441,7 @@ static int layout_ini_handler(void* user, const char* section, const char* name, return 1; #endif for (idx = 0; idx < NUM_ELEMS; idx++) { - if (Model.pagecfg2.elem[idx].type == ELEM_NONE) + if (Model.elem[idx].type == ELEM_NONE) break; } if (idx == NUM_ELEMS) { @@ -468,7 +468,7 @@ static int layout_ini_handler(void* user, const char* section, const char* name, } struct elem *cur_elem; - cur_elem = &Model.pagecfg2.elem[idx]; + cur_elem = &Model.elem[idx]; memset(cur_elem, 0, sizeof(struct elem)); cur_elem->x = data[0]; @@ -1384,7 +1384,7 @@ u8 CONFIG_WriteModel(u8 model_num) { } fprintf(fh, "[%s]\n", SECTION_GUI); for(idx = 0; idx < NUM_ELEMS; idx++) { - struct elem *cur_elem = &Model.pagecfg2.elem[idx]; + struct elem *cur_elem = &Model.elem[idx]; if (cur_elem->type == ELEM_NONE) break; int src = cur_elem->src; @@ -1418,8 +1418,8 @@ u8 CONFIG_WriteModel(u8 model_num) { } } for(idx = 0; idx < NUM_QUICKPAGES; idx++) { - if (WRITE_FULL_MODEL || m->pagecfg2.quickpage[idx]) { - u8 val = m->pagecfg2.quickpage[idx]; + if (WRITE_FULL_MODEL || m->quickpage[idx]) { + u8 val = m->quickpage[idx]; fprintf(fh, "%s%d=%s\n", GUI_QUICKPAGE, idx+1, PAGE_GetName(val)); } } @@ -1501,7 +1501,7 @@ u8 CONFIG_ReadModel(u8 model_num) { if (CONFIG_IniParse(file, ini_handler, &Model)) { printf("Failed to parse Model file: %s\n", file); } - if (Model.pagecfg2.elem[0].type == ELEM_NONE) + if (Model.elem[0].type == ELEM_NONE) CONFIG_ReadLayout("layout/default.ini"); if(! PROTOCOL_HasPowerAmp(Model.protocol)) Model.tx_power = TXPOWER_150mW; @@ -1628,7 +1628,7 @@ u8 CONFIG_ReadTemplate(const char *filename) { } u8 CONFIG_ReadLayout(const char *filename) { - memset(&Model.pagecfg2, 0, sizeof(Model.pagecfg2)); + memset(&Model.elem, 0, sizeof(Model.elem)); if (CONFIG_IniParse(filename, layout_ini_handler, &Model)) { printf("Failed to parse Layout file: %s\n", filename); return 0; diff --git a/src/config/model.h b/src/config/model.h index 3a2c28bf18..f170770faa 100644 --- a/src/config/model.h +++ b/src/config/model.h @@ -65,7 +65,8 @@ struct Model { struct Mixer mixers[NUM_MIXERS]; struct Limit limits[NUM_OUT_CHANNELS]; struct Timer timer[NUM_TIMERS]; - struct PageCfg2 pagecfg2; + struct elem elem[NUM_ELEMS]; + u8 quickpage[NUM_QUICKPAGES]; #if HAS_DATALOG struct datalog datalog; #endif diff --git a/src/config/pagecfg.h b/src/config/pagecfg.h index c01ca11664..0bd34e250d 100644 --- a/src/config/pagecfg.h +++ b/src/config/pagecfg.h @@ -41,11 +41,6 @@ struct elem { //#define NUM_BAR_ELEMS 8 //#define NUM_TOGGLE_ELEMS 4 -struct PageCfg2 { - struct elem elem[NUM_ELEMS]; - u8 quickpage[NUM_QUICKPAGES]; - u8 padding_1[3]; -}; enum { ELEM_NONE, diff --git a/src/pages/128x64x1/main_config.c b/src/pages/128x64x1/main_config.c index ab2d2d3ed6..19b97e2eec 100644 --- a/src/pages/128x64x1/main_config.c +++ b/src/pages/128x64x1/main_config.c @@ -41,7 +41,6 @@ enum { }; #endif //OVERRIDE_PLACEMENT static struct layout_page * const lp = &pagemem.u.layout_page; -static struct PageCfg2 * const pc = &Model.pagecfg2; static struct mainconfig_obj * const gui = &gui_objs.u.mainconfig; static u16 current_selected = 0; @@ -77,7 +76,7 @@ static const char *cfglabel_cb(guiObject_t *obj, const void *data) { (void)obj; int i = (long)data; - int type = pc->elem[i].type; + int type = Model.elem[i].type; int idx = elem_abs_to_rel(i); const char *str; switch(type) { @@ -122,13 +121,13 @@ void newelem_press_cb(guiObject_t *obj, const void *data) static const char *dlgts1_cb(guiObject_t *obj, int dir, void *data) { int idx = (long)data; - if (pc->elem[idx].src == 0 && dir < 0) - pc->elem[idx].src = -1; - if ((s8)pc->elem[idx].src == -1 && dir > 0) { - pc->elem[idx].src = 0; + if (Model.elem[idx].src == 0 && dir < 0) + Model.elem[idx].src = -1; + if ((s8)Model.elem[idx].src == -1 && dir > 0) { + Model.elem[idx].src = 0; dir = 0; } - if ((s8)pc->elem[idx].src < 0) { + if ((s8)Model.elem[idx].src < 0) { GUI_TextSelectEnablePress((guiTextSelect_t *)obj, 1); //PAGE_MainLayoutExit(); return _tr("Delete"); @@ -205,7 +204,7 @@ void show_config() { long count = 0; for (count = 0; count < NUM_ELEMS; count++) { - if (pc->elem[count].type == ELEM_NONE) + if (Model.elem[count].type == ELEM_NONE) break; } #if HAS_LAYOUT_EDITOR diff --git a/src/pages/128x64x1/main_layout.c b/src/pages/128x64x1/main_layout.c index 699eb053f9..6b811987d0 100644 --- a/src/pages/128x64x1/main_layout.c +++ b/src/pages/128x64x1/main_layout.c @@ -22,7 +22,6 @@ #if HAS_LAYOUT_EDITOR static struct layout_page * const lp = &pagemem.u.layout_page; -static struct PageCfg2 * const pc = &Model.pagecfg2; static struct mainlayout_obj * const gui = &gui_objs.u.mainlayout; #define NUMERIC_LABELS diff --git a/src/pages/128x64x1/pages.c b/src/pages/128x64x1/pages.c index a5b2881b49..b5ef354e56 100644 --- a/src/pages/128x64x1/pages.c +++ b/src/pages/128x64x1/pages.c @@ -115,7 +115,7 @@ void PAGE_ChangeQuick(int dir) { int quick = 0; for (int i = 0; i < NUM_QUICKPAGES; i++) { - if(Model.pagecfg2.quickpage[i] && Model.pagecfg2.quickpage[i] == cur_page) { + if(Model.quickpage[i] && Model.quickpage[i] == cur_page) { quick = i + 1; break; } @@ -123,13 +123,13 @@ void PAGE_ChangeQuick(int dir) int increment = dir > 0 ? 1 : NUM_QUICKPAGES; while(1) { quick = (quick + increment) % 5; - if (quick == 0 || (Model.pagecfg2.quickpage[quick-1] && PAGE_IsValidQuickPage(Model.pagecfg2.quickpage[quick-1]))) + if (quick == 0 || (Model.quickpage[quick-1] && PAGE_IsValidQuickPage(Model.quickpage[quick-1]))) break; } if (quick == 0) { PAGE_ChangeByID(PAGEID_MAIN, 0); } else { - PAGE_ChangeByID(Model.pagecfg2.quickpage[quick-1], 0); + PAGE_ChangeByID(Model.quickpage[quick-1], 0); } } int PAGE_QuickPage(u32 buttons, u8 flags, void *data) diff --git a/src/pages/128x64x1/toggle_select.c b/src/pages/128x64x1/toggle_select.c index 9d4d6c5b2a..bd072077a5 100644 --- a/src/pages/128x64x1/toggle_select.c +++ b/src/pages/128x64x1/toggle_select.c @@ -77,7 +77,7 @@ static void show_iconsel_page(int SelectedIcon) { GUI_RemoveAllObjects(); memset(gui, 0, sizeof(*gui)); current_toggleicon = SelectedIcon; - int toggleinput = MIXER_SRC(Model.pagecfg2.elem[tp->tglidx].src); + int toggleinput = MIXER_SRC(Model.elem[tp->tglidx].src); //Header PAGE_ShowHeader(INPUT_SourceNameAbbrevSwitch(tempstring, toggleinput)); @@ -100,9 +100,9 @@ static void show_iconsel_page(int SelectedIcon) { GUI_CreateLabelBox(&gui->togglelabel[i], LABEL_X, row, LABEL_W, LABEL_H, SelectedIcon == i ? &inverted : &DEFAULT_FONT, NULL, NULL, tglidx[i]); #ifdef HAS_CHAR_ICONS GUI_CreateLabelBox(&gui->toggleicon[i], ICON_X, row, ICON_W, LABEL_H, &DEFAULT_FONT, TGLICO_font_cb, - NULL, (void *)(long)Model.pagecfg2.elem[tp->tglidx].extra.ico[i]); + NULL, (void *)(long)Model.elem[tp->tglidx].extra.ico[i]); #else - struct ImageMap img = TGLICO_GetImage(Model.pagecfg2.elem[tp->tglidx].extra.ico[i]); + struct ImageMap img = TGLICO_GetImage(Model.elem[tp->tglidx].extra.ico[i]); GUI_CreateImageOffset(&gui->toggleicon[i], ICON_X, row, ICON_W, LABEL_H, img.x_off, img.y_off, img.file, NULL, //SelectedIcon == 0 ? tglico_reset_cb : tglico_setpos_cb, (void *)(long)i); @@ -121,13 +121,13 @@ static void show_iconsel_page(int SelectedIcon) { void PAGE_ToggleEditInit(int page) { tp->tglidx = page; - memcpy(tp->tglicons, Model.pagecfg2.elem[tp->tglidx].extra.ico, sizeof(tp->tglicons)); + memcpy(tp->tglicons, Model.elem[tp->tglidx].extra.ico, sizeof(tp->tglicons)); PAGE_SetActionCB(_action_cb); show_iconsel_page(0); } static void navigate_toggleicons(s8 direction) { - int toggleinput = MIXER_SRC(Model.pagecfg2.elem[tp->tglidx].src); + int toggleinput = MIXER_SRC(Model.elem[tp->tglidx].src); int num_positions = INPUT_NumSwitchPos(toggleinput); if(num_positions < 2) num_positions = 2; diff --git a/src/pages/320x240x16/main_layout.c b/src/pages/320x240x16/main_layout.c index 8505edd157..8994fffa22 100644 --- a/src/pages/320x240x16/main_layout.c +++ b/src/pages/320x240x16/main_layout.c @@ -22,7 +22,6 @@ static struct mainlayout_obj * const gui = &gui_objs.u.mainlayout; static struct layout_page * const lp = &pagemem.u.layout_page; -static struct PageCfg2 * const pc = &Model.pagecfg2; static void draw_elements(); static const char *newelem_cb(guiObject_t *obj, int dir, void *data); @@ -319,7 +318,7 @@ void show_config() FullRedraw = draw_mode; } if(lp->selected_for_move >= 0) { - type = pc->elem[lp->selected_for_move].type; + type = Model.elem[lp->selected_for_move].type; row_idx = elem_abs_to_rel(lp->selected_for_move); count = elem_get_count(type); } diff --git a/src/pages/320x240x16/pages.c b/src/pages/320x240x16/pages.c index 866c2c4e7f..4a4d1cda68 100644 --- a/src/pages/320x240x16/pages.c +++ b/src/pages/320x240x16/pages.c @@ -239,7 +239,7 @@ void PAGE_ChangeQuick(int dir) { int quick = 0; for (int i = 0; i < NUM_QUICKPAGES; i++) { - if(Model.pagecfg2.quickpage[i] && Model.pagecfg2.quickpage[i] == cur_page) { + if(Model.quickpage[i] && Model.quickpage[i] == cur_page) { quick = i+1; break; } @@ -248,7 +248,7 @@ void PAGE_ChangeQuick(int dir) while(1) { quick = (quick + increment) % 5; if (quick == 0 - || (Model.pagecfg2.quickpage[quick-1] && PAGE_IsValidQuickPage(Model.pagecfg2.quickpage[quick-1]))) + || (Model.quickpage[quick-1] && PAGE_IsValidQuickPage(Model.quickpage[quick-1]))) { break; } @@ -256,7 +256,7 @@ void PAGE_ChangeQuick(int dir) if (quick == 0) { PAGE_ChangeByID(PAGEID_MAIN, 0); } else { - PAGE_ChangeByID(Model.pagecfg2.quickpage[quick-1], 0); + PAGE_ChangeByID(Model.quickpage[quick-1], 0); } } @@ -266,7 +266,7 @@ int PAGE_QuickPage(u32 buttons, u8 flags, void *data) (void)flags; int i; for(i = 0; i < NUM_QUICKPAGES; i++) - if(Model.pagecfg2.quickpage[i]) + if(Model.quickpage[i]) break; if(i == NUM_QUICKPAGES) return 0; diff --git a/src/pages/320x240x16/toggle_select.c b/src/pages/320x240x16/toggle_select.c index e99c4acc75..d210fba853 100644 --- a/src/pages/320x240x16/toggle_select.c +++ b/src/pages/320x240x16/toggle_select.c @@ -34,7 +34,7 @@ static void show_icons(int SelectedIcon, int idx) { int x, y; struct ImageMap img; - u8 cursel = Model.pagecfg2.elem[tp->tglidx].extra.ico[SelectedIcon]; + u8 cursel = Model.elem[tp->tglidx].extra.ico[SelectedIcon]; for(int i = 0; i < NUM_SYMBOL_ELEMS; i++) { y = 80 + (i / NUM_SYMBOL_COLS) * 40; @@ -89,7 +89,7 @@ static const char * revert_str_cb(guiObject_t *obj, const void *data) static void show_iconsel_page(int SelectedIcon) { struct ImageMap img; - int toggleinput = MIXER_SRC(Model.pagecfg2.elem[tp->tglidx].src); + int toggleinput = MIXER_SRC(Model.elem[tp->tglidx].src); PAGE_RemoveAllObjects(); PAGE_ShowHeader(INPUT_SourceNameAbbrevSwitch(tempstring, toggleinput)); GUI_CreateButton(&gui->revert, LCD_WIDTH-96-8, 4, BUTTON_96, revert_str_cb, revert_cb, NULL); @@ -107,24 +107,24 @@ static void show_iconsel_page(int SelectedIcon) GUI_CreateRect(&gui->toggleframe, 80+80*SelectedIcon, 39, 77, 33, &outline); GUI_CreateLabelBox(&gui->switchbox, 4, 47, 70, 22, &NORMALBOX_FONT, NULL, NULL, - INPUT_SourceNameAbbrevSwitch(tempstring, Model.pagecfg2.elem[tp->tglidx].src)); + INPUT_SourceNameAbbrevSwitch(tempstring, Model.elem[tp->tglidx].src)); int num_positions = INPUT_NumSwitchPos(toggleinput); if(num_positions < 2) num_positions = 2; GUI_CreateLabelBox(&gui->togglelabel[0], 94, 50, 30, 14, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Pos 0")); - img = TGLICO_GetImage(Model.pagecfg2.elem[tp->tglidx].extra.ico[0]); + img = TGLICO_GetImage(Model.elem[tp->tglidx].extra.ico[0]); GUI_CreateImageOffset(&gui->toggleicon[0], 124, 40, TOGGLEICON_WIDTH, TOGGLEICON_HEIGHT, img.x_off, img.y_off, img.file, SelectedIcon == 0 ? tglico_reset_cb : tglico_setpos_cb, (void *)0L); GUI_CreateLabelBox(&gui->togglelabel[1], 174, 50, 30, 14, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Pos 1")); - img = TGLICO_GetImage(Model.pagecfg2.elem[tp->tglidx].extra.ico[1]); + img = TGLICO_GetImage(Model.elem[tp->tglidx].extra.ico[1]); GUI_CreateImageOffset(&gui->toggleicon[1], 204, 40, TOGGLEICON_WIDTH, TOGGLEICON_HEIGHT, img.x_off, img.y_off, img.file, SelectedIcon == 1 ? tglico_reset_cb : tglico_setpos_cb, (void *)1L); if (num_positions == 3) { GUI_CreateLabelBox(&gui->togglelabel[2], 254, 50, 30, 14, &LABEL_FONT, GUI_Localize, NULL, _tr_noop("Pos 2")); - img = TGLICO_GetImage(Model.pagecfg2.elem[tp->tglidx].extra.ico[2]); + img = TGLICO_GetImage(Model.elem[tp->tglidx].extra.ico[2]); GUI_CreateImageOffset(&gui->toggleicon[2], 284, 40, TOGGLEICON_WIDTH, TOGGLEICON_HEIGHT, img.x_off, img.y_off, img.file, SelectedIcon == 2 ? tglico_reset_cb : tglico_setpos_cb, (void *)2L); } @@ -137,7 +137,7 @@ static void show_iconsel_page(int SelectedIcon) void PAGE_ToggleEditInit(int page) { tp->tglidx = page; - memcpy(tp->tglicons, Model.pagecfg2.elem[tp->tglidx].extra.ico, sizeof(tp->tglicons)); + memcpy(tp->tglicons, Model.elem[tp->tglidx].extra.ico, sizeof(tp->tglicons)); show_iconsel_page(0); } diff --git a/src/pages/common/_main_config.c b/src/pages/common/_main_config.c index ecf215ab8b..7a6b98c45e 100644 --- a/src/pages/common/_main_config.c +++ b/src/pages/common/_main_config.c @@ -17,7 +17,7 @@ int elem_abs_to_rel(int idx) { - unsigned type = pc->elem[idx].type; + unsigned type = Model.elem[idx].type; int nxt = -1; for (int i = 0; i < NUM_ELEMS-1; i++) { nxt = MAINPAGE_FindNextElem(type, nxt+1); @@ -109,7 +109,7 @@ int create_element() int i; u16 x,y,w,h; for (i = 0; i < NUM_ELEMS; i++) - if (pc->elem[i].type == ELEM_NONE) + if (Model.elem[i].type == ELEM_NONE) break; if (i == NUM_ELEMS) return -1; @@ -117,10 +117,10 @@ int create_element() GetElementSize(lp->newelem, &w, &h); x = (LCD_WIDTH - w) / 2; y = (((LCD_HEIGHT - HEADER_Y) - h) / 2) + HEADER_Y; - memset(&pc->elem[i], 0, sizeof(struct elem)); - pc->elem[i].x = x; - pc->elem[i].y = y; - pc->elem[i].type = lp->newelem; + memset(&Model.elem[i], 0, sizeof(struct elem)); + Model.elem[i].x = x; + Model.elem[i].y = y; + Model.elem[i].type = lp->newelem; return i; } @@ -150,32 +150,32 @@ static const char *dlgts_cb(guiObject_t *obj, int dir, void *data) { (void)obj; int idx = (long)data; - int type = pc->elem[idx].type; + int type = Model.elem[idx].type; switch (type) { case ELEM_SMALLBOX: case ELEM_BIGBOX: { u8 changed = 0; - pc->elem[idx].src = GUI_TextSelectHelper(pc->elem[idx].src, 0, NUM_RTC + NUM_TELEM + NUM_TIMERS + NUM_CHANNELS, dir, 1, 1, &changed); + Model.elem[idx].src = GUI_TextSelectHelper(Model.elem[idx].src, 0, NUM_RTC + NUM_TELEM + NUM_TIMERS + NUM_CHANNELS, dir, 1, 1, &changed); if(changed && dir) { - pc->elem[idx].src = _adjust_src_for_telemetry(pc->elem[idx].src, dir); + Model.elem[idx].src = _adjust_src_for_telemetry(Model.elem[idx].src, dir); } - return GetBoxSource(tempstring, pc->elem[idx].src); + return GetBoxSource(tempstring, Model.elem[idx].src); } case ELEM_BAR: - pc->elem[idx].src = GUI_TextSelectHelper(pc->elem[idx].src, 0, NUM_CHANNELS, dir, 1, 1, NULL); - return INPUT_SourceName(tempstring, pc->elem[idx].src ? pc->elem[idx].src + NUM_INPUTS : 0); + Model.elem[idx].src = GUI_TextSelectHelper(Model.elem[idx].src, 0, NUM_CHANNELS, dir, 1, 1, NULL); + return INPUT_SourceName(tempstring, Model.elem[idx].src ? Model.elem[idx].src + NUM_INPUTS : 0); case ELEM_TOGGLE: { - pc->elem[idx].src = INPUT_SelectAbbrevSource(pc->elem[idx].src, dir); - return INPUT_SourceNameAbbrevSwitch(tempstring, pc->elem[idx].src); + Model.elem[idx].src = INPUT_SelectAbbrevSource(Model.elem[idx].src, dir); + return INPUT_SourceNameAbbrevSwitch(tempstring, Model.elem[idx].src); } case ELEM_HTRIM: case ELEM_VTRIM: - pc->elem[idx].src = GUI_TextSelectHelper(pc->elem[idx].src, 0, NUM_TRIMS, dir, 1, 1, NULL); - if (pc->elem[idx].src == 0) + Model.elem[idx].src = GUI_TextSelectHelper(Model.elem[idx].src, 0, NUM_TRIMS, dir, 1, 1, NULL); + if (Model.elem[idx].src == 0) return _tr("None"); - snprintf(tempstring, sizeof(tempstring), "%s%d", _tr("Trim"),pc->elem[idx].src); + snprintf(tempstring, sizeof(tempstring), "%s%d", _tr("Trim"),Model.elem[idx].src); return tempstring; } return _tr("None"); @@ -195,7 +195,7 @@ static void dlgbut_cb(struct guiObject *obj, const void *data) FullRedraw = draw_mode; } //Erase object - GetWidgetLoc(&pc->elem[idx], &x, &y, &w, &h); + GetWidgetLoc(&Model.elem[idx], &x, &y, &w, &h); if (x > 0) { x -= 1; w += 2; @@ -213,14 +213,14 @@ static void dlgbut_cb(struct guiObject *obj, const void *data) GUI_DrawBackground(x, y, w, h); #endif //Remove object - int type = pc->elem[idx].type; + int type = Model.elem[idx].type; for(i = idx+1; i < NUM_ELEMS; i++) { - if (pc->elem[i].type == ELEM_NONE) + if (Model.elem[i].type == ELEM_NONE) break; - pc->elem[i-1] = pc->elem[i]; + Model.elem[i-1] = Model.elem[i]; } - pc->elem[i-1].x = 0; - pc->elem[i-1].y = 0; + Model.elem[i-1].x = 0; + Model.elem[i-1].y = 0; idx = MAINPAGE_FindNextElem(type, 0); set_selected_for_move(idx); //close the dialog and reopen with new elements @@ -242,14 +242,14 @@ const char *menusel_cb(guiObject_t *obj, int dir, void *data) int i = (long)data; int max_pages = PAGE_GetNumPages(); int start_page = PAGE_GetStartPage(); - int page = GUI_TextSelectHelper(pc->quickpage[i], start_page, max_pages -1, dir, 1, 1, NULL); - if (page != pc->quickpage[i]) { - int increment = (page > pc->quickpage[i]) ? 1 : -1; + int page = GUI_TextSelectHelper(Model.quickpage[i], start_page, max_pages -1, dir, 1, 1, NULL); + if (page != Model.quickpage[i]) { + int increment = (page > Model.quickpage[i]) ? 1 : -1; while (page >= start_page && page != max_pages && ! PAGE_IsValidQuickPage(page)) { page = (page + increment); } if (page >= start_page && page != max_pages) - pc->quickpage[i] = page; + Model.quickpage[i] = page; } - return PAGE_GetName(pc->quickpage[i]); + return PAGE_GetName(Model.quickpage[i]); } diff --git a/src/pages/common/_main_layout.c b/src/pages/common/_main_layout.c index 5844b7cbe7..0b91c46459 100644 --- a/src/pages/common/_main_layout.c +++ b/src/pages/common/_main_layout.c @@ -38,9 +38,9 @@ void draw_elements() FullRedraw = redraw_mode; } for (i = 0; i < NUM_ELEMS; i++) { - if (! GetWidgetLoc(&pc->elem[i], &x, &y, &w, &h)) + if (! GetWidgetLoc(&Model.elem[i], &x, &y, &w, &h)) break; - int type = pc->elem[i].type; + int type = Model.elem[i].type; const char *(*strCallback)(guiObject_t *, const void *) = label_cb; void *data = (void *)(long)elem_abs_to_rel(i); int desc = 0; @@ -83,7 +83,7 @@ const char *boxlabel_cb(guiObject_t *obj, const void *data) { (void)obj; int i = (long)data; - return GetBoxSource(tempstring, pc->elem[i].src); + return GetBoxSource(tempstring, Model.elem[i].src); } const char *label_cb(guiObject_t *obj, const void *data) @@ -142,7 +142,7 @@ void move_elem() if ((guiLabel_t *)obj < gui->elem) return; int idx = guielem_idx(obj); - GetWidgetLoc(&pc->elem[idx], &x, &y, &w, &h); + GetWidgetLoc(&Model.elem[idx], &x, &y, &w, &h); if (x > 0) { x -= 1; w += 2; @@ -158,8 +158,8 @@ void move_elem() h = LCD_HEIGHT - y; } GUI_DrawBackground(x, y, w, h); - pc->elem[idx].x = lp->selected_x; - pc->elem[idx].y = lp->selected_y; + Model.elem[idx].x = lp->selected_x; + Model.elem[idx].y = lp->selected_y; draw_elements(); select_for_move((guiLabel_t *)obj); } @@ -169,10 +169,10 @@ void notify_cb(guiObject_t *obj) if ((guiLabel_t *)obj < gui->elem) return; int idx = guielem_idx(obj); - lp->selected_x = pc->elem[idx].x; - lp->selected_y = pc->elem[idx].y; - GetElementSize(pc->elem[idx].type, &lp->selected_w, &lp->selected_h); - if (pc->elem[idx].type == ELEM_MODELICO) + lp->selected_x = Model.elem[idx].x; + lp->selected_y = Model.elem[idx].y; + GetElementSize(Model.elem[idx].type, &lp->selected_w, &lp->selected_h); + if (Model.elem[idx].type == ELEM_MODELICO) AdjustIconSize(&lp->selected_x, &lp->selected_y, &lp->selected_h, &lp->selected_w); GUI_Redraw((guiObject_t *)&gui->xlbl); GUI_Redraw((guiObject_t *)&gui->x); diff --git a/src/pages/common/_main_page.c b/src/pages/common/_main_page.c index d1d5966de9..241dad6737 100644 --- a/src/pages/common/_main_page.c +++ b/src/pages/common/_main_page.c @@ -15,7 +15,6 @@ static struct main_page * const mp = &pagemem.u.main_page; static struct mainpage_obj * const gui = &gui_objs.u.mainpage; -static struct PageCfg2 * const pc = &Model.pagecfg2; const char *show_box_cb(guiObject_t *obj, const void *data); const char *voltage_cb(guiObject_t *obj, const void *data); static s32 trim_cb(void * data); @@ -151,12 +150,12 @@ void PAGE_MainEvent() } volatile s32 *raw = MIXER_GetInputs(); for(i = 0; i < NUM_ELEMS; i++) { - if (pc->elem[i].type == ELEM_NONE) + if (Model.elem[i].type == ELEM_NONE) break; if (! OBJ_IS_USED(&gui->elem[i])) continue; - int src = pc->elem[i].src; - int type = pc->elem[i].type; + int src = Model.elem[i].src; + int type = Model.elem[i].type; switch(type) { case ELEM_VTRIM: case ELEM_HTRIM: @@ -225,16 +224,16 @@ void PAGE_MainEvent() //switch for (int j = 0; j < 3; j++) { // Assume switch 0/1/2 are in order - if(pc->elem[i].extra.ico[j] && raw[src+j] > 0) { - idx = pc->elem[i].extra.ico[j]; + if(Model.elem[i].extra.ico[j] && raw[src+j] > 0) { + idx = Model.elem[i].extra.ico[j]; break; } } } else { //Non switch int sw = raw[src] > 0 ? 1 : 0; - if (pc->elem[i].extra.ico[sw]) { - idx = pc->elem[i].extra.ico[sw]; + if (Model.elem[i].extra.ico[sw]) { + idx = Model.elem[i].extra.ico[sw]; } } } @@ -339,9 +338,9 @@ int MAINPAGE_FindNextElem(unsigned type, int idx) { type = map_type(type); for(int i = idx; i < NUM_ELEMS; i++) { - if (pc->elem[i].type == ELEM_NONE) + if (Model.elem[i].type == ELEM_NONE) break; - if (map_type(pc->elem[i].type) == type) + if (map_type(Model.elem[i].type) == type) return i; } return -1; @@ -351,9 +350,9 @@ void show_elements() { u16 x, y, w, h; for (int i = 0; i < NUM_ELEMS; i++) { - if (! GetWidgetLoc(&pc->elem[i], &x, &y, &w, &h)) + if (! GetWidgetLoc(&Model.elem[i], &x, &y, &w, &h)) break; - int type = pc->elem[i].type; + int type = Model.elem[i].type; switch(type) { case ELEM_MODELICO: GUI_CreateImageOffset(&gui->elem[i].img, x, y, w, h, 0, 0, CONFIG_GetCurrentIcon(), press_icon_cb, (void *)1); @@ -361,7 +360,7 @@ void show_elements() case ELEM_VTRIM: case ELEM_HTRIM: { - int src = pc->elem[i].src; + int src = Model.elem[i].src; if (src == 0) continue; mp->elem[i] = *(MIXER_GetTrim(src-1)); @@ -372,7 +371,7 @@ void show_elements() case ELEM_SMALLBOX: case ELEM_BIGBOX: { - int src = pc->elem[i].src; + int src = Model.elem[i].src; if (src == 0) continue; mp->elem[i] = get_boxval(src); @@ -395,7 +394,7 @@ void show_elements() } case ELEM_BAR: { - int src = pc->elem[i].src; + int src = Model.elem[i].src; if (src == 0) continue; mp->elem[i] = MIXER_GetChannel(src-1, APPLY_SAFETY); @@ -407,9 +406,9 @@ void show_elements() { #ifdef HAS_CHAR_ICONS GUI_CreateLabelBox(&gui->elem[i].box, x, y, 2, 2, &DEFAULT_FONT, TGLICO_font_cb, NULL, - (void *)(uintptr_t)pc->elem[i].extra.ico[0]); + (void *)(uintptr_t)Model.elem[i].extra.ico[0]); #else - struct ImageMap img = TGLICO_GetImage(pc->elem[i].extra.ico[0]); //We'll set this properly down below + struct ImageMap img = TGLICO_GetImage(Model.elem[i].extra.ico[0]); //We'll set this properly down below GUI_CreateImageOffset(&gui->elem[i].img, x, y, w, h, img.x_off, img.y_off, img.file, NULL, NULL); #endif diff --git a/src/pages/common/_toggle_select.c b/src/pages/common/_toggle_select.c index c01011f824..0eae598c91 100644 --- a/src/pages/common/_toggle_select.c +++ b/src/pages/common/_toggle_select.c @@ -35,7 +35,7 @@ void tglico_select_cb(guiObject_t *obj, s8 press_type, const void *data) // --> data = (ToggleNumber << 12) | (IconNumber << 8) | IconPosition u8 IconPosition = ((long)data ) & 0xff; u8 IconNumber = ((long)data >> 8 ) & 0x0f; - Model.pagecfg2.elem[tp->tglidx].extra.ico[IconNumber] = IconPosition; + Model.elem[tp->tglidx].extra.ico[IconNumber] = IconPosition; show_iconsel_page(IconNumber); } } @@ -87,7 +87,7 @@ struct ImageMap TGLICO_GetImage(int idx) void TGLICO_Select(guiObject_t *obj, const void *data) { (void)obj; - if(Model.pagecfg2.elem[(long)data].src) + if(Model.elem[(long)data].src) { PAGE_PushByID(PAGEID_TGLEDIT, (long)data); } @@ -107,7 +107,7 @@ void tglico_reset_cb(guiObject_t *obj, s8 press_type, const void *data) (void)obj; if (press_type == -1) { u32 pos = (long)data; - Model.pagecfg2.elem[tp->tglidx].extra.ico[pos] = 0; + Model.elem[tp->tglidx].extra.ico[pos] = 0; show_iconsel_page(pos); } } @@ -140,7 +140,7 @@ static void revert_cb(guiObject_t *obj, const void *data) { (void)data; (void)obj; - memcpy(Model.pagecfg2.elem[tp->tglidx].extra.ico, tp->tglicons, sizeof(tp->tglicons)); + memcpy(Model.elem[tp->tglidx].extra.ico, tp->tglicons, sizeof(tp->tglicons)); PAGE_ChangeByID(PAGEID_TGLEDIT, tp->tglidx); } diff --git a/src/pages/text/main_layout.c b/src/pages/text/main_layout.c index 383a957324..ffe1c04b61 100644 --- a/src/pages/text/main_layout.c +++ b/src/pages/text/main_layout.c @@ -22,7 +22,6 @@ #if HAS_LAYOUT_EDITOR static struct layout_page * const lp = &pagemem.u.layout_page; -static struct PageCfg2 * const pc = &Model.pagecfg2; static struct mainlayout_obj * const gui = &gui_objs.u.mainlayout; #define NUMERIC_LABELS diff --git a/src/remap_channels.c b/src/remap_channels.c index de145d0c21..4fbdf0e487 100644 --- a/src/remap_channels.c +++ b/src/remap_channels.c @@ -106,16 +106,16 @@ void RemapChannelsForProtocol(const u8 *oldmap) } //Map display for(i = 0; i < NUM_ELEMS; i++) { - switch(Model.pagecfg2.elem[i].type) { + switch(Model.elem[i].type) { case ELEM_SMALLBOX: case ELEM_BIGBOX: - _map_inp(chmap, &Model.pagecfg2.elem[i].src, NUM_TELEM + NUM_TIMERS + NUM_RTC+1); + _map_inp(chmap, &Model.elem[i].src, NUM_TELEM + NUM_TIMERS + NUM_RTC+1); break; case ELEM_BAR: - _map_inp(chmap, &Model.pagecfg2.elem[i].src, 1); + _map_inp(chmap, &Model.elem[i].src, 1); break; case ELEM_TOGGLE: - map_inp(chmap, &Model.pagecfg2.elem[i].src); + map_inp(chmap, &Model.elem[i].src); break; } }