Exemplo n.º 1
0
void PAGE_RemoveHeader()
{
    if(OBJ_IS_USED(&gui->exitico))
        GUI_RemoveObj((guiObject_t *)&gui->exitico);
    if(OBJ_IS_USED(&gui->title))
        GUI_RemoveObj((guiObject_t *)&gui->title);
    if(OBJ_IS_USED(&gui->previco))
        GUI_RemoveObj((guiObject_t *)&gui->previco);
    if(OBJ_IS_USED(&gui->nextico))
        GUI_RemoveObj((guiObject_t *)&gui->nextico);
}
Exemplo n.º 2
0
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));
}
Exemplo n.º 3
0
void PAGE_DrExpCurvesEvent()
{
    if (OBJ_IS_USED(&gui->graph)) {
        if(MIXER_GetCachedInputs(mp->raw, CHAN_MAX_VALUE / 100)) { // +/-1%
            GUI_Redraw(&gui->graph);
        }
    }
}
Exemplo n.º 4
0
static void add_dlgbut_cb(struct guiObject *obj, const void *data)
{
    (void)obj;
    if(!data) {
        if (OBJ_IS_USED(&gui->dialog))
            GUI_RemoveObj((guiObject_t *)&gui->dialog);
        PAGE_PushByID(PAGEID_LOADSAVE, LOAD_LAYOUT);
    }
}
Exemplo n.º 5
0
static void dialog_ok_cb(u8 state, void * data)
{
    (void)state;
    (void)data;
    guiObject_t *obj = (guiObject_t *)&gui->elem[lp->selected_for_move];
    draw_elements();
    if(obj && OBJ_IS_USED(obj))
        select_for_move((guiLabel_t *)obj);
}
Exemplo n.º 6
0
struct guiObject *GUI_IsModal(void)
{
    struct guiObject *obj = objHEAD;
    if (objDIALOG)
        return objDIALOG;
    while(obj) {
        if(OBJ_IS_MODAL(obj) && OBJ_IS_USED(obj) && ! OBJ_IS_HIDDEN(obj))
            return obj;
        obj = obj->next;
    }
    return NULL;
}
Exemplo n.º 7
0
void PAGE_LayoutEditInit(int page)
{
    (void)page;
    PAGE_SetActionCB(_layaction_cb);
    lp->selected_x = 0;
    lp->selected_y = 0;
    for (int i = 0 ; i < 5; i++)
        gui->desc[i] = (struct LabelDesc){
            .font = MICRO_FONT.font,
            .font_color = 0xffff,
            .fill_color = 0x0000,
            .outline_color = 0xffff,
            .style = LABEL_SQUAREBOX,
        };
    gui->desc[1].style = LABEL_BRACKET; //Special case for trims

    struct LabelDesc micro = MICRO_FONT;
    struct LabelDesc rect = MICRO_FONT;
    micro.style = LABEL_LEFT;
    rect.fill_color = 0x0000;
    rect.outline_color = 0x0000;
    GUI_CreateRect(&gui->editelem, 41, 1, 9, 5, &rect);
    gui->editelem.CallBack = move_cb;
    GUI_CreateLabel(&gui->xlbl, 0,  1, NULL, micro, "X:");
    GUI_CreateLabelBox(&gui->x, 8, 1, 13, 6, &micro, pos_cb, NULL, (void *) 0L);
    GUI_CreateLabel(&gui->ylbl, 22, 1, NULL, micro, "Y:");
    GUI_CreateLabelBox(&gui->y, 30, 1, 9, 6, &micro, pos_cb, NULL, (void *) 1L);
    //gui->y must be the last element!
    GUI_SelectionNotify(notify_cb);

    draw_elements();
    if(OBJ_IS_USED(&gui->elem[0]))
        GUI_SetSelected((guiObject_t *)&gui->elem[0]);
}

static void xpos_cb(guiObject_t *obj, int dir, void *data)
{
    (void)obj;
    (void)data;
    if (lp->selected_for_move >= 0) {
        int x = GUI_TextSelectHelper(lp->selected_x, 0, LCD_WIDTH-lp->selected_w, dir, 1, 10, NULL);
        if (x != lp->selected_x) {
            lp->selected_x = x;
            move_elem();
        }
    }
}
Exemplo n.º 8
0
static void select_cb(guiObject_t *obj, u16 sel, void *data)
{
    (void)obj;
    (void)data;
    const char *ico;
    mp->selected = sel + 1;
    if(! OBJ_IS_USED(&gui->image))
        return;
    if ((long)data == LOAD_ICON) {
        ico = CONFIG_GetIcon(mp->modeltype);
        if (sel > 0 && FS_OpenDir("modelico")) {
            char filename[13];
            int count = 0;
            int type;
            while((type = FS_ReadDir(filename)) != 0) {
                if (type == 1 && strncasecmp(filename + strlen(filename) - 4, ".bmp", 4) == 0) {
                    count++;
                    if (sel == count) {
                        CONFIG_ParseIconName(mp->iconstr, filename);
                        ico = mp->iconstr;
                        break;
                    }
                }
            }
            FS_CloseDir();
        }
    } else {
        sprintf(tempstring, "models/model%d.ini", mp->selected);
        mp->modeltype = 0;
        mp->iconstr[0] = 0;
        ini_parse(tempstring, ini_handle_icon, NULL);
        if (mp->selected == CONFIG_GetCurrentModel() && Model.icon[0])
            ico = Model.icon;
        else {
            if (mp->iconstr[0])
                ico = mp->iconstr;
            else
                ico = CONFIG_GetIcon(mp->modeltype);
        }
        if (! fexists(ico))
            ico = UNKNOWN_ICON;
    }
    GUI_ReplaceImage(&gui->image, ico, 0, 0);
}
Exemplo n.º 9
0
static void toggle_press_cb(guiObject_t *obj, const void *data)
{
    if (OBJ_IS_USED(&gui->dialog))
        GUI_RemoveObj((guiObject_t *)&gui->dialog);
    TGLICO_Select(obj, data);
}
Exemplo n.º 10
0
void PAGE_ShowHeader_SetLabel(const char *(*label_cb)(guiObject_t *obj, const void *data), void *data)
{
    if(OBJ_IS_USED(&gui->title))
        GUI_RemoveObj((guiObject_t *)&gui->title);
    GUI_CreateLabelBox(&gui->title, 40, 10, 0, 0, &TITLE_FONT, label_cb, NULL, data);
}
Exemplo n.º 11
0
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
}