static const char *cfglabel_cb(guiObject_t *obj, const void *data) { (void)obj; int i = (long)data; int type = ELEM_TYPE(pc->elem[i]); int idx = elem_abs_to_rel(i); const char *str; switch(type) { case ELEM_VTRIM: case ELEM_HTRIM: str = _tr("Trimbar"); break; case ELEM_BIGBOX: case ELEM_SMALLBOX: str = _tr("Box"); break; case ELEM_BAR: str = _tr("Bar"); break; case ELEM_TOGGLE: str = _tr("Toggle"); break; default: str = GetElemName(type); break; } sprintf(tempstring,"%s%d", str, idx+1); return tempstring; }
void show_config() { int count = 0; int row_idx = 0; long type; if (OBJ_IS_USED(&gui->dialog)) { u8 draw_mode = FullRedraw; GUI_RemoveObj((guiObject_t *)&gui->dialog); FullRedraw = draw_mode; } if(lp->selected_for_move >= 0) { type = ELEM_TYPE(pc->elem[lp->selected_for_move]); row_idx = elem_abs_to_rel(lp->selected_for_move); count = elem_get_count(type); } if (! count) { dialog_ok_cb(1, NULL); return; } int x = LAYDLG_X - (type == ELEM_TOGGLE ? 68/2 : 0); int width = LAYDLG_MIN_WIDTH + (type == ELEM_TOGGLE ? 64 : 0); GUI_CreateDialog(&gui->dialog, x, LAYDLG_Y, width, LAYDLG_HEIGHT, _tr("Page Config"), NULL, dialog_ok_cb, dtOk, ""); GUI_CreateScrollable(&gui->scrollable, x + LAYDLG_SCROLLABLE_X, LAYDLG_Y + LAYDLG_SCROLLABLE_Y, width - 2 * LAYDLG_SCROLLABLE_X + 1, LAYDLG_SCROLLABLE_HEIGHT, LAYDLG_TEXT_HEIGHT, count, row_cb, NULL, NULL, (void *)type); GUI_SetSelected(GUI_ShowScrollableRowCol(&gui->scrollable, row_idx, 0)); }
static const char *dlgts_cb(guiObject_t *obj, int dir, void *data) { (void)obj; int idx = (long)data; int type = ELEM_TYPE(pc->elem[idx]); 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); if(changed && dir) { pc->elem[idx].src = _adjust_src_for_telemetry(pc->elem[idx].src, dir); } return GetBoxSource(tempstring, pc->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); case ELEM_TOGGLE: { pc->elem[idx].src = INPUT_SelectAbbrevSource(pc->elem[idx].src, dir); return INPUT_SourceNameAbbrevSwitch(tempstring, pc->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) return _tr("None"); snprintf(tempstring, sizeof(tempstring), "%s%d", _tr("Trim"),pc->elem[idx].src); return tempstring; } return _tr("None"); }
int elem_abs_to_rel(int idx) { unsigned type = ELEM_TYPE(pc.elem[idx]); int nxt = -1; for (int i = 0; i < NUM_ELEMS-1; i++) { nxt = MAINPAGE_FindNextElem(type, nxt+1); if (nxt == idx) return i; } return 0; }
static void dlgbut_cb(struct guiObject *obj, const void *data) { (void)obj; int idx = (long)data; int i; //Remove object int type = ELEM_TYPE(pc.elem[idx]); for(i = idx+1; i < NUM_ELEMS; i++) { if (! ELEM_USED(pc.elem[i])) break; pc.elem[i-1] = pc.elem[i]; } ELEM_SET_Y(pc.elem[i-1], 0); idx = MAINPAGE_FindNextElem(type, 0); set_selected_for_move(idx); //close the dialog and reopen with new elements show_config(); }
static const char *dlgts_cb(guiObject_t *obj, int dir, void *data) { (void)obj; int idx = (long)data; int type = ELEM_TYPE(pc.elem[idx]); switch (type) { case ELEM_SMALLBOX: case ELEM_BIGBOX: { pc.elem[idx].src = GUI_TextSelectHelper(pc.elem[idx].src, 0, NUM_RTC + NUM_TELEM + NUM_TIMERS + NUM_CHANNELS, dir, 1, 1, NULL); return GetBoxSource(lp.tmp, pc.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(lp.tmp, pc.elem[idx].src ? pc.elem[idx].src + NUM_INPUTS : 0); case ELEM_TOGGLE: { int val = MIXER_SRC(pc.elem[idx].src); int newval = GUI_TextSelectHelper(val, 0, NUM_SOURCES, dir, 1, 1, NULL); newval = INPUT_GetAbbrevSource(val, newval, dir); if (val != newval) { val = newval; pc.elem[idx].src = val; } return INPUT_SourceNameAbbrevSwitch(lp.tmp, pc.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) return _tr("None"); sprintf(lp.tmp, "%s%d", _tr("Trim"),pc.elem[idx].src); return lp.tmp; } return ""; }
void PAGE_MainEvent() { int i; if (PAGE_GetModal()) { #if HAS_TELEMETRY if(pagemem.modal_page == 2) { PAGE_TelemtestEvent(); } #endif return; } volatile s32 *raw = MIXER_GetInputs(); for(i = 0; i < NUM_ELEMS; i++) { if (! ELEM_USED(pc->elem[i])) break; if (! OBJ_IS_USED(&gui->elem[i])) continue; int src = pc->elem[i].src; int type = ELEM_TYPE(pc->elem[i]); switch(type) { case ELEM_VTRIM: case ELEM_HTRIM: { int value = *(MIXER_GetTrim(src-1)); if (mp->elem[i] != value) { mp->elem[i] = value; GUI_Redraw(&gui->elem[i].bar); } break; } case ELEM_SMALLBOX: case ELEM_BIGBOX: { s32 val = get_boxval(src); #if HAS_RTC if (src <= NUM_RTC) { if (mp->elem[i] != val) { mp->elem[i] = val; GUI_Redraw(&gui->elem[i].box); } } else #endif if (src - NUM_RTC <= NUM_TIMERS) { //Timer if ((val >= 0 && mp->elem[i] < 0) || (val < 0 && mp->elem[i] >= 0)) { GUI_SetLabelDesc(&gui->elem[i].box, get_box_font(type == ELEM_BIGBOX ? 0 : 2, val < 0)); mp->elem[i] = val; GUI_Redraw(&gui->elem[i].box); } else if (mp->elem[i] / 1000 != val /1000) { mp->elem[i] = val; GUI_Redraw(&gui->elem[i].box); } } else if (src - NUM_RTC - NUM_TIMERS <= NUM_TELEM) { //Telem int alarm = TELEMETRY_HasAlarm(src - NUM_RTC - NUM_TIMERS); if (alarm || ! TELEMETRY_IsUpdated(0xff)) { GUI_SetLabelDesc(&gui->elem[i].box, get_box_font(type == ELEM_BIGBOX ? 0 : 2, 1)); } else if(mp->elem[i] != val) { GUI_SetLabelDesc(&gui->elem[i].box, get_box_font(type == ELEM_BIGBOX ? 0 : 2, 0)); mp->elem[i] = val; GUI_Redraw(&gui->elem[i].box); } } else if (mp->elem[i] != val) { //Source mp->elem[i] = val; GUI_Redraw(&gui->elem[i].box); } break; } case ELEM_BAR: { s32 chan = MIXER_GetChannel(src-1, APPLY_SAFETY); if (mp->elem[i] != chan) { mp->elem[i] = chan; GUI_Redraw(&gui->elem[i].bar); } break; } case ELEM_TOGGLE: { src = MIXER_SRC(src); int idx = -1; if(src) { if (src > INP_HAS_CALIBRATION && src < INP_LAST) { //switch for (int j = 0; j < 3; j++) { // Assume switch 0/1/2 are in order if(ELEM_ICO(pc->elem[i], j) && raw[src+j] > 0) { idx = ELEM_ICO(pc->elem[i], j); break; } } } else { //Non switch int sw = raw[src] > 0 ? 1 : 0; if (ELEM_ICO(pc->elem[i], sw)) { idx = ELEM_ICO(pc->elem[i], sw); } } } if (idx != -1) { #ifdef HAS_CHAR_ICONS gui->elem[i].box.cb_data = (void *)(long)idx; #else struct ImageMap img; img = TGLICO_GetImage(idx); GUI_ChangeImage(&gui->elem[i].img, img.file, img.x_off, img.y_off); #endif GUI_SetHidden((guiObject_t *)&gui->elem[i], 0); } else { GUI_SetHidden((guiObject_t *)&gui->elem[i], 1); } } break; case ELEM_BATTERY: _check_voltage(&gui->elem[i].box); break; } } if(HAS_TOUCH) //FIXME: Hack to let 320x240 GUI continue to work _check_voltage(NULL); #if HAS_RTC if(Display.flags & SHOW_TIME) { u32 time = RTC_GetValue() / 60; if(mp->time != time) { mp->time = time; GUI_Redraw(&gui->time); } } #endif }