Exemple #1
0
static inline guiObject_t * _get_obj(int idx, int objid) {
    if (PAGE_GetModal()) {
        if(objid == TRIM_MINUS) {
            idx = ITEM_TRIMNEG; objid = -1;
        } else if(objid == TRIM_SWITCH) {
            idx = ITEM_TRIMSWITCH; objid = -1;
        }
        return (guiObject_t *)GUI_GetScrollableObj(&gui->scrollable, idx, objid);
    }
    return NULL;
}
Exemple #2
0
static inline guiObject_t * _get_obj(int idx, int objid) {
    if (PAGE_GetModal()) {
        if(objid == TRIM_MINUS) {
            return (guiObject_t *)&gui_ed->neg;
        } else if(objid == TRIM_SWITCH) {
            return (guiObject_t *)&gui_ed->sw;
        }
    } else {
        if(objid == TRIM_MINUS) {
            return (guiObject_t *)&gui->neg[idx - GUI_ScrollableCurrentRow(&gui->scrollable)];
        }
    }
    return NULL;

}
Exemple #3
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
}