const char *set_source_cb(guiObject_t *obj, int dir, void *data) { (void) obj; u8 *source = (u8 *)data; if (!GUI_IsTextSelectEnabled(obj) ) { strcpy(mp->tmpstr, _tr("None")); return mp->tmpstr; } u8 is_neg = MIXER_SRC_IS_INV(*source); u8 changed; *source = GUI_TextSelectHelper(MIXER_SRC(*source), 1, NUM_SOURCES, dir, 1, 1, &changed); MIXER_SET_SRC_INV(*source, is_neg); if (changed) { if(mp->cur_template == MIXERTEMPLATE_COMPLEX) { guiObject_t *trim = _get_obj(COMPLEX_TRIM, 0); if(trim) { if (MIXER_SourceHasTrim(MIXER_SRC(mp->mixer[0].src))) GUI_SetHidden(trim, 0); else GUI_SetHidden(trim, 1); } } sync_mixers(); MIXPAGE_RedrawGraphs(); } GUI_TextSelectEnablePress((guiTextSelect_t *)obj, MIXER_SRC(*source)); return INPUT_SourceName(mp->tmpstr, *source); }
static void _refresh_page() { int hide3 = (INPUT_NumSwitchPos(mapped_std_channels.switches[SWITCHFUNC_DREXP_AIL+drexp_type]) < 3) ? 1 : 0; GUI_SetHidden((guiObject_t *)&gui->mode[2], hide3); GUI_SetHidden((guiObject_t *)&gui->dr[2], hide3); GUI_SetHidden((guiObject_t *)&gui->exp[2], hide3); GUI_SetHidden((guiObject_t *)&gui->graph[2], hide3); GUI_RedrawAllObjects(); }
static int complex_row_cb(int absrow, int relrow, int y, void *data) { const char *label = NULL; void *tgl = NULL; void *value = NULL; data = NULL; int x = 0; int w = LEFT_VIEW_WIDTH; if (absrow + COMMON_LAST == COMPLEX_TRIM) { GUI_CreateButtonPlateText(&gui->value[relrow].but, x, y, w, ITEM_HEIGHT, &labelDesc, show_trim_cb, 0x0000, toggle_trim_cb, NULL); if (! MIXER_SourceHasTrim(MIXER_SRC(mp->mixer[0].src))) GUI_SetHidden((guiObject_t *)&gui->label[relrow], 1); return 1; } switch(absrow + COMMON_LAST) { case COMPLEX_MIXER: label = _tr_noop("Mixers"); value = set_nummixers_cb; break; case COMPLEX_PAGE: label = _tr_noop("Page"); tgl = reorder_cb; value = set_mixernum_cb; break; case COMPLEX_SWITCH: label = _tr_noop("Switch"); tgl = sourceselect_cb; value = set_drsource_cb; data = &mp->cur_mixer->sw; break; case COMPLEX_MUX: label = _tr_noop("Mux"); value = set_mux_cb; break; case COMPLEX_SRC: label = _tr_noop("Src"); tgl = sourceselect_cb; value = set_source_cb; data = &mp->cur_mixer->src; break; case COMPLEX_CURVE: label = _tr_noop("Curve"); tgl = curveselect_cb; value = set_curvename_cb; data = mp->cur_mixer; break; case COMPLEX_SCALE: label = _tr_noop("Scale"); value = set_number100_cb; data = &mp->cur_mixer->scalar; break; case COMPLEX_OFFSET: label = _tr_noop("Offset"); value = set_number100_cb; data = &mp->cur_mixer->offset; break; } labelDesc.style = LABEL_LEFTCENTER; GUI_CreateLabelBox(&gui->label[relrow], x, y, w, ITEM_HEIGHT, &labelDesc, NULL, NULL, _tr(label)); labelDesc.style = LABEL_CENTER; GUI_CreateTextSelectPlate(&gui->value[relrow].ts, x, y + ITEM_HEIGHT + 1, w, ITEM_HEIGHT, &labelDesc, tgl, value, data); if (absrow + COMMON_LAST == COMPLEX_SRC) set_src_enable(CURVE_TYPE(&mp->cur_mixer->curve)); return 1; }
void set_selected_for_move(int idx) { lp->selected_for_move = idx; int state = idx >= 0 ? 1 : 0; GUI_SetHidden((guiObject_t *)&gui->editelem, !state); GUI_TextSelectEnable(&gui->x, state); GUI_TextSelectEnable(&gui->y, state); }
static void update_countdown(u8 idx) { u8 hide = Model.timer[idx].type == TIMER_STOPWATCH || Model.timer[idx].type == TIMER_STOPWATCH_PROP || Model.timer[idx].type == TIMER_PERMANENT; GUI_SetHidden((guiObject_t *)&gui->start, hide); GUI_SetHidden((guiObject_t *)&gui->startlbl, hide); GUI_SetSelectable((guiObject_t *)&gui->start, !hide); // Permanent timer do not have reset command hide = Model.timer[idx].type == TIMER_PERMANENT || Model.mixer_mode == MIXER_STANDARD ; GUI_SetHidden((guiObject_t *)&gui->resetsrc, hide); GUI_SetSelectable((guiObject_t *)&gui->resetsrc, !hide); GUI_SetHidden((guiObject_t *)&gui->resetlbl, hide); hide = Model.timer[idx].type == TIMER_STOPWATCH || Model.timer[idx].type == TIMER_STOPWATCH_PROP || Model.timer[idx].type == TIMER_COUNTDOWN || Model.timer[idx].type == TIMER_COUNTDOWN_PROP; GUI_SetHidden((guiObject_t *)&gui->resetperm, hide); GUI_SetSelectable((guiObject_t *)&gui->resetperm, !hide); GUI_SetHidden((guiObject_t *)&gui->resetpermlbl, hide); // don't include this in Devo7e due to memory restrictions #if HAS_PERMANENT_TIMER GUI_SetHidden((guiObject_t *)&gui->setperm, hide); GUI_SetSelectable((guiObject_t *)&gui->setperm, !hide); #endif GUI_Redraw(&gui->switchlbl); }
static void update_countdown(u8 timernum) { int cur_row = GUI_ScrollableCurrentRow(&gui->scrollable); int idx = timernum - cur_row * TIMERCOLUMNS; if (idx < 0 || idx >= TIMERS_PER_PAGE) return; u8 hide = Model.timer[timernum].type == TIMER_STOPWATCH || Model.timer[timernum].type == TIMER_STOPWATCH_PROP || Model.timer[timernum].type == TIMER_PERMANENT; GUI_SetHidden((guiObject_t *)&gui->start[idx], hide); GUI_SetHidden((guiObject_t *)&gui->startlbl[idx], hide); GUI_SetSelectable((guiObject_t *)&gui->start[idx], !hide); // Permanent timer OR Standard Mixer do not have reset command hide = Model.timer[timernum].type == TIMER_PERMANENT || Model.mixer_mode == MIXER_STANDARD ; GUI_SetHidden((guiObject_t *)&gui->resetsrc[idx], hide); GUI_SetSelectable((guiObject_t *)&gui->resetsrc[idx], !hide); GUI_SetHidden((guiObject_t *)&gui->resetlbl[idx], hide); hide = Model.timer[timernum].type == TIMER_STOPWATCH || Model.timer[timernum].type == TIMER_COUNTDOWN || Model.timer[timernum].type == TIMER_STOPWATCH_PROP || Model.timer[timernum].type == TIMER_COUNTDOWN_PROP; GUI_SetHidden((guiObject_t *)&gui->resetperm[idx], hide); GUI_SetSelectable((guiObject_t *)&gui->resetperm[idx], !hide); GUI_SetHidden((guiObject_t *)&gui->setperm[idx], hide); GUI_SetSelectable((guiObject_t *)&gui->setperm[idx], !hide); GUI_SetHidden((guiObject_t *)&gui->resetpermlbl[idx], hide); GUI_Redraw(&gui->switchlbl[idx]); }
void PAGE_MainLayoutInit(int page) { (void)page; memset(lp, 0, sizeof(*lp)); BUTTON_RegisterCallback(&action, CHAN_ButtonMask(BUT_ENTER) | CHAN_ButtonMask(BUT_EXIT) | CHAN_ButtonMask(BUT_LEFT) | CHAN_ButtonMask(BUT_LEFT) | CHAN_ButtonMask(BUT_RIGHT) | CHAN_ButtonMask(BUT_UP) | CHAN_ButtonMask(BUT_DOWN), BUTTON_PRESS | BUTTON_LONGPRESS | BUTTON_PRIORITY, _action_cb, NULL); PAGE_ShowHeader(NULL); lp->long_press = 0; lp->newelem = 0; lp->selected_x = 0; const u16 color[5] = { RGB888_to_RGB565(0xaa, 0x44, 0x44), RGB888_to_RGB565(0x44, 0xaa, 0x44), RGB888_to_RGB565(0x44, 0x44, 0xaa), RGB888_to_RGB565(0x44, 0x44, 0x44), RGB888_to_RGB565(0x33, 0x33, 0x33), }; for (int i = 0 ; i < 5; i++) gui->desc[i] = (struct LabelDesc){ .font = 0, .font_color = 0xffff, .fill_color = color[i], .outline_color = 0, .style = LABEL_FILL}; gui->desc[1].font = TINY_FONT.font; //Special case for trims GUI_CreateIcon(&gui->newelem, 32, 0, &icons[ICON_LAYOUT_ADD], add_dlg_cb, NULL); GUI_CreateIcon(&gui->editelem, 64, 0, &icons[ICON_LAYOUT_CFG], cfg_cb, NULL); GUI_SetHidden((guiObject_t *)&gui->editelem, 1); //GUI_CreateTextSelect(&gui->newelem, 36, 12, TEXTSELECT_96, newelem_press_cb, newelem_cb, NULL); GUI_CreateLabel(&gui->xlbl, 80+18, 9, NULL, TITLE_FONT, "X"); GUI_CreateTextSelect(&gui->x, 88+18, 8, TEXTSELECT_64, NULL, xpos_cb, NULL); GUI_CreateLabel(&gui->ylbl, 164+16, 9, NULL, TITLE_FONT, "Y"); GUI_CreateTextSelect(&gui->y, 172+16, 8, TEXTSELECT_64, NULL, ypos_cb, NULL); GUI_SelectionNotify(notify_cb); draw_elements(); if (show_config_menu) { lp->selected_for_move = show_config_menu; show_config(); show_config_menu = 0; } } void PAGE_MainLayoutEvent() { } void PAGE_MainLayoutExit() { BUTTON_UnregisterCallback(&action); }
static const char *set_source_helper(guiObject_t *obj, void *data, int changed) { (void) obj; u8 *source = (u8 *)data; if (!GUI_IsTextSelectEnabled(obj) ) { tempstring_cpy(_tr("None")); return tempstring; } if (changed) { if(mp->cur_template == MIXERTEMPLATE_COMPLEX) { guiObject_t *trim = _get_obj(COMPLEX_TRIM, 0); if(trim) { if (MIXER_SourceHasTrim(MIXER_SRC(mp->mixer[0].src))) GUI_SetHidden(trim, 0); else GUI_SetHidden(trim, 1); } } sync_mixers(); MIXPAGE_RedrawGraphs(); } GUI_TextSelectEnablePress((guiTextSelect_t *)obj, MIXER_SRC(*source)); return INPUT_SourceName(tempstring, *source); }
static void create_scrollable_objs(guiScrollable_t *scrollable, int row) { if (row >= 0) { row = adjust_row(scrollable, row); } else { //Force row # row = - row; } int offset = row - scrollable->cur_row; if (scrollable->head && offset == 0) return; scrollable->cur_row = row; int rel_row = 0; int selectable_rows = 0; GUI_RemoveScrollableObjs((guiObject_t *)scrollable); guiObject_t *head = objHEAD; objHEAD = NULL; for(int y = scrollable->header.box.y, bottom = y + scrollable->header.box.height; y < bottom && row < scrollable->item_count && rel_row < scrollable->max_visible_rows; row++, rel_row++) { guiObject_t *row_start = get_last_object(); scrollable->row_cb(row, rel_row, y, scrollable->cb_data); OBJ_SET_ROWSTART(row_start ? row_start->next : objHEAD, 1); y += scrollable->row_height * (scrollable->size_cb ? scrollable->size_cb(row, scrollable->cb_data) : 1); if (y > bottom + scrollable->row_height - ROW_HEIGHT_OFFSET) break; //is not selectable because it's not completely visible selectable_rows++; } scrollable->visible_rows = rel_row; scrollable->selectable_rows = selectable_rows; scrollable->head = objHEAD; objHEAD = head; head = scrollable->head; while(head) { OBJ_SET_SCROLLABLE(head, 1); head = head->next; } int scroll_pos = (2 * scrollable->cur_row + rel_row) / 2; if (scrollable->cur_row == 0) scroll_pos = 0; else if(scrollable->cur_row + rel_row == scrollable->item_count) scroll_pos = scrollable->item_count - 1; int hidden = (rel_row >= scrollable->item_count) ? 1 : 0; GUI_SetHidden((guiObject_t *)&scrollable->scrollbar, hidden); if (! hidden) GUI_SetScrollbar(&scrollable->scrollbar, scroll_pos); }
void set_selected_for_move(int idx) { lp->selected_for_move = idx; GUI_SetHidden((guiObject_t *)&gui->editelem, idx >= 0 ? 0 : 1); }
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 }