Ejemplo 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);
}
Ejemplo 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));
}
Ejemplo n.º 3
0
void PAGE_ShowSafetyDialog()
{
    if (disable_safety) {
        return; // don't show safety dialog when calibrating
    }
    if (dialog) {
        u64 unsafe = PROTOCOL_CheckSafe();
        if (! unsafe) {
            GUI_RemoveObj(dialog);
            dialog = NULL;
            PROTOCOL_Init(0);
        } else {
            safety_string_cb(NULL, NULL);
            u32 crc = Crc(tempstring, strlen(tempstring));
            if (crc != dialogcrc) {
                GUI_Redraw(dialog);
                dialogcrc = crc;
            }
        }
    } else {
        tempstring[0] = 0;
        dialogcrc = 0;
        dialog = GUI_CreateDialog(&gui->dialog, 10 + DLG_XOFFSET, 42 + DLG_YOFFSET, 300, 188, _tr("Safety"), safety_string_cb, safety_ok_cb, dtOk, NULL);
    }
}
Ejemplo n.º 4
0
void PAGE_CloseBindingDialog()
{
    if (dialog) {
        GUI_RemoveObj(dialog);
        dialog = 0;
    }
}
Ejemplo n.º 5
0
void DialogClose(struct guiObject *obj, u8 state)
{
    struct guiDialog *dialog = (struct guiDialog *)obj;
    void *data = dialog->string_cb ? dialog->cbData : NULL;
    void (*func)(u8, void*) = dialog->CallBack;
    GUI_RemoveObj(obj);
    func(state, data);
}
Ejemplo n.º 6
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);
    }
}
Ejemplo n.º 7
0
static void fixedid_done_cb(guiObject_t *obj, void *data)
{
    (void)data;
    if (callback_result == 1) {
        Model.fixed_id = atoi(mp->fixed_id);
    }
    GUI_RemoveObj(obj);
    PAGE_ModelInit(-1); // must be -1 for devo10 to get back to correct page
}
Ejemplo n.º 8
0
static void calibrate_touch(void)
{
    if (cp->state == 0 || cp->state == 3) {
        if (GUI_ObjectNeedsRedraw((guiObject_t *)&guic->msg))
            return;
        draw_target(cp->state ? LCD_WIDTH - XCOORD : XCOORD , cp->state ? LCD_HEIGHT - YCOORD : YCOORD + 32);
        cp->state++;
    } else if (cp->state == 1 || cp->state == 4) {
        if (SPITouch_IRQ()) {
            cp->coords = SPITouch_GetCoords();
            cp->state++;
        }
    } else if (cp->state == 2) {
        if (! SPITouch_IRQ()) {
            cp->coords1 = cp->coords;
            GUI_RemoveObj((guiObject_t *)&guic->msg);
            GUI_CreateLabelBox(&guic->msg, LCD_WIDTH - XCOORD - 5, LCD_HEIGHT - YCOORD - 5,
                                            11, 11, &SMALLBOX_FONT, NULL, NULL, "");
            GUI_Redraw(&guic->msg1);
            cp->state = 3;
        } else {
            cp->coords = SPITouch_GetCoords();
        }
    } else if (cp->state == 5) {
        if (! SPITouch_IRQ()) {
            s32 xscale, yscale;
            s32 xoff, yoff;
            printf("T1:(%d, %d)\n", cp->coords1.x, cp->coords1.y);
            printf("T2:(%d, %d)\n", cp->coords.x, cp->coords.y);
            xscale = cp->coords.x - cp->coords1.x;
            xscale = (LCD_WIDTH - 2 * XCOORD) * 0x10000 / xscale;
            yscale = cp->coords.y - cp->coords1.y;
            yscale = (LCD_HEIGHT - 32 - 2 * YCOORD) * 0x10000 / yscale;
            xoff = XCOORD - cp->coords1.x * xscale / 0x10000;
            yoff = YCOORD + 32 - cp->coords1.y * yscale / 0x10000;
            printf("Debug: scale(%d, %d) offset(%d, %d)\n", (int)xscale, (int)yscale, (int)xoff, (int)yoff);
            SPITouch_Calibrate(xscale, yscale, xoff, yoff);
            PAGE_RemoveAllObjects();
            PAGE_SetModal(1);
            PAGE_ShowHeader_ExitOnly(_tr("Touch Test"), okcancel_cb);
            GUI_CreateLabelBox(&guic->msg, (LCD_WIDTH - 150) / 2, (LCD_HEIGHT - 25) / 2, 150, 25, &SMALLBOX_FONT, coords_cb, NULL, NULL);
            memset(&cp->coords, 0, sizeof(cp->coords));
            cp->state = 6;
        } else {
            cp->coords = SPITouch_GetCoords();
        }
    } else if(cp->state == 6) {
        struct touch t;
        if (SPITouch_IRQ()) {
            t = SPITouch_GetCoords();
            if (memcmp(&t, &cp->coords, sizeof(t)) != 0) {
                cp->coords = t;
                GUI_Redraw(&guic->msg);
            }
        }
    }
}
Ejemplo n.º 9
0
/* Button callbacks */
static void _changename_done_cb(guiObject_t *obj, void *data)
{
    (void)data;
    GUI_RemoveObj(obj);
    if (callback_result == 1) {
        strlcpy(Model.name, tempstring, sizeof(Model.name));
        //Save model info here so it shows up on the model page
        CONFIG_SaveModelIfNeeded();
    }
    PAGE_ModelInit(0);
}
Ejemplo n.º 10
0
static void _changename_done_cb(guiObject_t *obj, void *data)  // devo8 doesn't handle cancel/discard properly,
{
    (void)obj;
    (void)data;
    GUI_RemoveObj(obj);
    if (callback_result == 1) {  // only change name when DONE is hit, otherwise, discard the change
        strlcpy(Model.name, (const char *)tempstring, sizeof(Model.name));
        //Save model info here so it shows up on the model page
        CONFIG_SaveModelIfNeeded();
    }
    PAGE_ModelInit(-1);
}
Ejemplo n.º 11
0
void GUI_RemoveHierObjects(struct guiObject *obj)
{
    if(obj == objHEAD) {
        GUI_RemoveAllObjects();
        return;
    }
    struct guiObject *parent = objHEAD;
    while(parent && parent->next != obj)
        parent = parent->next;
    if(! parent)
        return;
    while(parent->next)
        GUI_RemoveObj(parent->next);
    FullRedraw = REDRAW_IF_NOT_MODAL;
}
Ejemplo n.º 12
0
void GUI_RemoveObj(struct guiObject *obj)
{
    switch(obj->Type) {
    case Dialog: {
        GUI_HandleModalButtons(0);
        GUI_RemoveHierObjects(obj->next);
        objDIALOG = NULL;
        break;
    }
    case Scrollbar:
        BUTTON_UnregisterCallback(&((guiScrollbar_t *)obj)->action);
        break;
    case Scrollable:
        GUI_RemoveScrollableObjs(obj);
        GUI_RemoveObj((guiObject_t *)&((guiScrollable_t *)obj)->scrollbar);
        break;
    case Keyboard:
        BUTTON_UnregisterCallback(&((guiKeyboard_t *)obj)->action);
        break;
    case Image:
    case XYGraph:
        _GUI_UnmapWindow(1);
        break;
    default: break;
    }
    
    if (objTOUCHED == obj)
        objTOUCHED = NULL;
    if (objSELECTED == obj)
        objSELECTED = NULL;
    OBJ_SET_USED(obj, 0);
    // Reattach linked list
    struct guiObject *prev = objHEAD;
    if (prev == obj) {
        objHEAD = obj->next;
    } else {
        while(prev) {
            if(prev->next == obj) {
                prev->next = obj->next;
                break;
            }
            prev = prev->next;
        }
    }
    FullRedraw = objHEAD ? REDRAW_IF_NOT_MODAL : REDRAW_EVERYTHING;
}
Ejemplo n.º 13
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);
}
Ejemplo n.º 14
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);
}
Ejemplo n.º 15
0
void GUI_RemoveAllObjects()
{
    while(objHEAD)
        GUI_RemoveObj(objHEAD);
    FullRedraw = REDRAW_EVERYTHING;
}