예제 #1
0
/* loadsave values:
 * 0 : Load Model
 * 1 : Save Model
 * 2 : Load Template
 * 3 : Load Icon
 * 4 : Load Layout
 */
void MODELPage_ShowLoadSave(int loadsave, void(*return_page)(int page))
{
    u8 num_models = 0;
    PAGE_RemoveAllObjects();
    PAGE_SetModal(1);
    mp->return_page = return_page;
    _show_buttons(loadsave);
    if (loadsave == LOAD_TEMPLATE) { //Template
        num_models = count_files("template", ".ini", NULL);
        mp->selected = 1;
    } else if (loadsave == LOAD_ICON) { //Icon
        mp->selected = 0;
        num_models = 1 + count_files("modelico", ".bmp", Model.icon[0] ? Model.icon+9 : NULL);
        const char *ico = mp->selected == 0 ? CONFIG_GetIcon(Model.type) : CONFIG_GetCurrentIcon();
        strlcpy(mp->iconstr, ico, sizeof(mp->iconstr));
        mp->selected++;
    } else if (loadsave == LOAD_LAYOUT) { //Layout
        mp->selected = 1;
        num_models = count_files("layout", ".ini", "default.ini");
        mp->file_state = num_models;
        num_models += model_count();
    } else {
        num_models = model_count();
        strlcpy(mp->iconstr, CONFIG_GetCurrentIcon(), sizeof(mp->iconstr));
        if (loadsave == SAVE_MODEL)
            mp->selected = 0;
        else
            mp->selected = CONFIG_GetCurrentModel();
    }
    _show_list(loadsave, num_models);
}
예제 #2
0
void PAGE_TelemconfigInit(int page)
{
    (void)page;
    enum {
        COL1 = (10 + ((LCD_WIDTH - 320) / 2)),
        COL2 = (COL1 + 55),
        COL3 = (COL1 + 156),
        COL4 = (COL1 + 225),
        ROW1 = (70 + ((LCD_HEIGHT - 240) / 2)),
    };
    const u8 row_height = 25;
    PAGE_SetModal(0);
#if HAS_STANDARD_GUI
    if (Model.mixer_mode == MIXER_STANDARD)
        PAGE_ShowHeader_ExitOnly(PAGE_GetName(PAGEID_TELEMCFG), MODELMENU_Show);
    else
#endif
        PAGE_ShowHeader(PAGE_GetName(PAGEID_TELEMCFG));

    if (telem_state_check() == 0) {
        GUI_CreateLabelBox(&gui->msg, 20, 80, 280, 100, &NARROW_FONT, NULL, NULL, tempstring);
        return;
    }

    for (long i = 0; i < TELEM_NUM_ALARMS; i++) {
        GUI_CreateLabelBox(&gui->name[i], COL1, ROW1 + row_height * i, 55, 16, &DEFAULT_FONT,
           label_cb, NULL, (void *)i);
        GUI_CreateTextSelect(&gui->type[i], COL2, ROW1 + row_height * i, TEXTSELECT_96, NULL, telem_name_cb, (void *)i);
        GUI_CreateTextSelect(&gui->gtlt[i], COL3, ROW1 + row_height * i, TEXTSELECT_64, NULL, gtlt_cb, (void *)i);
        GUI_CreateTextSelect(&gui->value[i], COL4, ROW1 + row_height * i, TEXTSELECT_64, NULL, limit_cb, (void *)i);
    }
}
예제 #3
0
void MODELPAGE_Config()
{
    PAGE_SetModal(1);
    show_titlerow(Model.type == 0 ? _tr("Helicopter") : _tr("Airplane"));
    if (Model.type == 0) {
        u8 i = ROW1;
        GUI_CreateLabel(&gui->swashlbl, COL1, i, NULL, DEFAULT_FONT, _tr("SwashType"));
        GUI_CreateTextSelect(&gui->swash, COL2, i - 1, TEXTSELECT_96, NULL, swash_val_cb, NULL);
        i+=28;
        GUI_CreateLabel(&gui->invlbl[0], COL1, i, NULL, DEFAULT_FONT, _tr("ELE Inv"));
        GUI_CreateTextSelect(&gui->inv[0], COL2, i - 1, TEXTSELECT_96, swashinv_press_cb, swashinv_val_cb, (void *)1);
        i+=22;
        GUI_CreateLabel(&gui->invlbl[1], COL1, i, NULL, DEFAULT_FONT, _tr("AIL Inv"));
        GUI_CreateTextSelect(&gui->inv[1], COL2, i - 1, TEXTSELECT_96, swashinv_press_cb, swashinv_val_cb, (void *)2);
        i+=22;
        GUI_CreateLabel(&gui->invlbl[2], COL1, i, NULL, DEFAULT_FONT, _tr("COL Inv"));
        GUI_CreateTextSelect(&gui->inv[2], COL2, i - 1, TEXTSELECT_96, swashinv_press_cb, swashinv_val_cb, (void *)4);
        i+=28;
        GUI_CreateLabel(&gui->mixlbl[0], COL1, i, NULL, DEFAULT_FONT, _tr("ELE Mix"));
        GUI_CreateTextSelect(&gui->mix[0], COL2, i - 1, TEXTSELECT_96, NULL, swashmix_val_cb, (void *)1);
        i+=22;
        GUI_CreateLabel(&gui->mixlbl[1], COL1, i, NULL, DEFAULT_FONT, _tr("AIL Mix"));
        GUI_CreateTextSelect(&gui->mix[1], COL2, i - 1, TEXTSELECT_96, NULL, swashmix_val_cb, (void *)0);
        i+=22;
        GUI_CreateLabel(&gui->mixlbl[2], COL1, i, NULL, DEFAULT_FONT, _tr("COL Mix"));
        GUI_CreateTextSelect(&gui->mix[2], COL2, i - 1, TEXTSELECT_96, NULL, swashmix_val_cb, (void *)2);
    }
}
예제 #4
0
void PAGE_RTCInit(int page)
{
    (void)page;
    PAGE_SetModal(1);
    PAGE_RemoveAllObjects();
    PAGE_ShowHeader_ExitOnly(PAGE_GetName(PAGEID_RTC), okcancel_cb);
    u32 time = RTC_GetValue();
    u32 timevalue = RTC_GetTimeValue(time);
    Rtc.value[HOUR] = (u16)(timevalue / 3600);
    Rtc.value[MINUTE] = (u16)(timevalue % 3600) / 60;
    Rtc.value[SECOND] = (u16)(timevalue % 60);
    RTC_GetDateStringLong(tempstring,time);
    int idx = (tempstring[1] == '.' ? 1 : 2);
    tempstring[idx] = 0;
    tempstring[idx+3] = 0;
    Rtc.value[DAY] = atoi(tempstring);
    Rtc.value[MONTH] = atoi(tempstring + idx + 1);
    Rtc.value[YEAR] = atoi(tempstring + idx + 4);
    min[SECOND] = 0;             max[SECOND] = 59;
    min[MINUTE] = 0;             max[MINUTE] = 59;
    min[HOUR]   = 0;             max[HOUR]   = 23;
    min[DAY]    = 1;             max[DAY]    = daysInMonth[Rtc.value[MONTH] - 1] + (((Rtc.value[YEAR] % 4) == 0) && (Rtc.value[MONTH] == 2) ? 1 : 0);
    min[MONTH]  = 1;             max[MONTH]  = 12;
    min[YEAR]   = RTC_STARTYEAR; max[YEAR]   = RTC_STARTYEAR + 67;
    _show_page();
}
예제 #5
0
void PAGE_SwashInit(int page)
{
    (void)page;
    PAGE_SetActionCB(_action_cb);
    PAGE_SetModal(0);
    PAGE_RemoveAllObjects();
    get_swash();

    u8 w = 60;
    u8 x = 63;
    PAGE_ShowHeader(_tr("SwashType"));
    GUI_CreateTextSelectPlate(&gui->type, x-3, 0, w + 8, LINE_HEIGHT - 1, &DEFAULT_FONT, NULL, swash_val_cb, NULL); // FIXME: need a special value for header button/textsels

    u8 row = LINE_SPACE;
    GUI_CreateLabelBox(&gui->lbl[0], 0, row, 0, LINE_HEIGHT, &DEFAULT_FONT, NULL, NULL, _tr("ELE Mix"));
    GUI_CreateTextSelectPlate(&gui->mix[0], x, row, w, LINE_HEIGHT, &DEFAULT_FONT, NULL, swashmix_val_cb, (void *)1);

    row += LINE_SPACE;
    GUI_CreateLabelBox(&gui->lbl[1], 0, row, 0, LINE_HEIGHT, &DEFAULT_FONT, NULL, NULL, _tr("AIL Mix"));
    GUI_CreateTextSelectPlate(&gui->mix[1], x, row, w, LINE_HEIGHT, &DEFAULT_FONT, NULL, swashmix_val_cb, (void *)0);

    row += LINE_SPACE;
    GUI_CreateLabelBox(&gui->lbl[2], 0, row, 0, LINE_HEIGHT, &DEFAULT_FONT, NULL, NULL, _tr("PIT Mix"));
    GUI_CreateTextSelectPlate(&gui->mix[2], x, row, w, LINE_HEIGHT, &DEFAULT_FONT, NULL, swashmix_val_cb, (void *)2);

    update_swashmixes();
    GUI_Select1stSelectableObj();
}
예제 #6
0
static void lang_select_cb(guiObject_t *obj, const void *data)
{
    (void)data;
    (void)obj;
    PAGE_SetModal(1);
    LANGPage_Select(PAGE_TxConfigureInit);
}
예제 #7
0
void PAGE_DrExpInit(int page)
{
    (void)page;
    PAGE_SetActionCB(_action_cb);
    PAGE_SetModal(0);
    PAGE_RemoveAllObjects();
    memset(mp, 0, sizeof(*mp));
    int count = get_mixers();
    int expected = INPUT_NumSwitchPos(mapped_std_channels.switches[SWITCHFUNC_DREXP_AIL+drexp_type]);
    if (count != expected) {
        GUI_CreateLabelBox(&gui->u.msg, 0, 10, 0, ITEM_HEIGHT, &DEFAULT_FONT, NULL, NULL, "Invalid model ini!");// must be invalid model ini
        return;
    }
    GUI_CreateTextSelectPlate(&gui->u.type, 0, 0,
        60, ITEM_HEIGHT, &DEFAULT_FONT, NULL, set_type_cb, (void *)NULL);
    GUI_CreateScrollable(&gui->scrollable, 0, ITEM_SPACE, 76, LCD_HEIGHT - ITEM_SPACE,
                     2 *ITEM_SPACE, count, row_cb, NULL, NULL, NULL);

    u16 ymax = CHAN_MAX_VALUE/100 * MAX_SCALAR;
    s16 ymin = -ymax;
    GUI_CreateXYGraph(&gui->graph, 77, 2, 50, RIGHT_VIEW_HEIGHT,
            CHAN_MIN_VALUE, ymin, CHAN_MAX_VALUE, ymax,
            0, 0, show_curve_cb, curpos_cb, NULL, NULL);

    GUI_Select1stSelectableObj();
}
예제 #8
0
void PAGE_DrExpInit(int page)
{
    (void)page;
    PAGE_SetModal(0);
    // draw a underline only:
    GUI_CreateRect(&gui->rect, 0, HEADER_WIDGET_HEIGHT, LCD_WIDTH, 1, &DEFAULT_FONT);
    memset(mp, 0, sizeof(*mp));
    int count = get_mixers();
    int expected = INPUT_NumSwitchPos(mapped_std_channels.switches[SWITCHFUNC_DREXP_AIL + drexp_type]);
    if (count != expected) {
        GUI_CreateLabelBox(&gui->u.msg, 0, MESSAGE_Y, 0, LINE_HEIGHT, &DEFAULT_FONT, NULL, NULL, "Invalid model ini!"); // must be invalid model ini
        return;
    }
    GUI_CreateTextSelectPlate(&gui->u.type, HEADER_X, 0, HEADER_W, HEADER_WIDGET_HEIGHT,
                     &TEXTSEL_FONT, NULL, set_type_cb, (void *)NULL);
    GUI_CreateScrollable(&gui->scrollable, 0, HEADER_HEIGHT + SCROLL_Y, SCROLL_W, LCD_HEIGHT - HEADER_HEIGHT - SCROLL_Y,
                     2 * LINE_SPACE, count, row_cb, NULL, NULL, NULL);

    GUI_CreateXYGraph(&gui->graph, GRAPH_X, GRAPH_Y, GRAPH_W, GRAPH_H,
                      CHAN_MIN_VALUE, CHAN_MIN_VALUE * 1251 / 1000,
                      CHAN_MAX_VALUE, CHAN_MAX_VALUE * 1251 / 1000,
                      0, 0, show_curve_cb, curpos_cb, NULL, NULL);

    GUI_Select1stSelectableObj();
}
예제 #9
0
void PAGE_USBInit(int page)
{
    (void)page;
    PAGE_SetModal(0);
    _draw_page(0);
    BUTTON_RegisterCallback(&up->action, CHAN_ButtonMask(BUT_ENTER), BUTTON_PRESS | BUTTON_RELEASE | BUTTON_PRIORITY, usb_cb, NULL);
}
예제 #10
0
void PAGE_TrimInit(int page)
{
    (void)page;
    PAGE_SetModal(0);
    PAGE_RemoveAllObjects();

    _show_page();
}
예제 #11
0
static void okcancel_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    PAGE_SetModal(0);
    PAGE_RemoveAllObjects();
    PAGE_ChangeByID(PAGEID_TXCFG);
}
예제 #12
0
static void okcancel_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    RTC_SetValue(RTC_GetSerial(Rtc.value[3], Rtc.value[4], Rtc.value[5]-RTC_STARTYEAR, Rtc.value[2], Rtc.value[1], Rtc.value[0]));
    PAGE_SetModal(0);
    PAGE_RemoveAllObjects();
    PAGE_ChangeByID(PAGEID_TXCFG);
}
예제 #13
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);
            }
        }
    }
}
예제 #14
0
void PAGE_TxConfigureInit(int page)
{
    (void)page;
    cp->enable = CALIB_NONE;
    PAGE_SetModal(0);
    PAGE_ShowHeader(PAGE_GetName(PAGEID_TXCFG));
    GUI_CreateScrollable(&gui->scrollable, 0, 32, LCD_WIDTH, LCD_HEIGHT-32,
                     LCD_HEIGHT-32, MAX_PAGE+1, row_cb, NULL, NULL, NULL);
}
예제 #15
0
static void okcancel_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    if(cp->return_page) {
        PAGE_SetModal(0);
        PAGE_RemoveAllObjects();
        cp->return_page(cp->return_val);
    }
}
예제 #16
0
void PAGE_DebuglogInit(int page)
{
    (void)page;
    PAGE_ShowHeader(PAGE_GetName(PAGEID_DEBUGLOG));
    PAGE_SetModal(0);

    find_line_ends();
    GUI_CreateScrollable(&gui->scrollable,
         0, HEADER_HEIGHT, LCD_WIDTH, LCD_HEIGHT - HEADER_HEIGHT, LINE_SPACE, NUM_ROWS, row_cb, NULL, NULL, NULL);
}
예제 #17
0
static void _changename_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    PAGE_SetModal(1);
    PAGE_RemoveAllObjects();
    tempstring_cpy((const char *)Model.name); // Don't change model name directly
    GUI_CreateKeyboard(&gui->keyboard, KEYBOARD_ALPHA, tempstring, 20, // no more than 20 chars is allowed for model name
                       _changename_done_cb, (void *)&callback_result);
}
예제 #18
0
static void _changename_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    PAGE_SetModal(1);
    PAGE_RemoveAllObjects();
    tempstring_cpy(Model.name);
    callback_result = 1;
    GUI_CreateKeyboard(&gui->keyboard, KEYBOARD_ALPHA, tempstring, sizeof(Model.name)-1, _changename_done_cb, &callback_result);
}
예제 #19
0
static void init_touch_calib()
{
    PAGE_RemoveAllObjects();
    PAGE_SetModal(1);
    //PAGE_ShowHeader_ExitOnly("Touch Calibrate", okcancel_cb); //Can't do this while calibrating
    GUI_CreateLabel(&guic->title, 40, 10, NULL, TITLE_FONT, _tr("Touch Calibrate"));
    GUI_CreateLabelBox(&guic->msg, XCOORD - 5, YCOORD + 32 - 5, 11, 11, &SMALLBOX_FONT, NULL, NULL, "");
    GUI_CreateLabelBox(&guic->msg1, (LCD_WIDTH - 100) /2, (LCD_HEIGHT - 20)/2, 100, 20, &NARROW_FONT, show_msg_cb, NULL, NULL);
    memset(&cp->coords, 0, sizeof(cp->coords));
    SPITouch_Calibrate(0x10000, 0x10000, 0, 0);
    cp->state = 0;
}
예제 #20
0
void PAGE_TxConfigureInit(int page)
{
    (void)page;
    cp->enable = CALIB_NONE;
    PAGE_SetModal(0);
    PAGE_RemoveAllObjects();
    PAGE_ShowHeader(PAGE_GetName(PAGEID_TXCFG));
    GUI_CreateScrollbar(&gui->scrollbar, LCD_WIDTH-16, 32, LCD_HEIGHT-32, MAX_PAGE+1, NULL, scroll_cb, NULL);
    firstObj = NULL;
    page_num = 0;
    _show_page();
}
예제 #21
0
void PAGE_SwitchAssignInit(int page)
{
    (void)page;
    PAGE_SetActionCB(_action_cb);
    PAGE_SetModal(0);
    PAGE_RemoveAllObjects();
    refresh_switches();

    PAGE_ShowHeader(_tr("Press ENT to change"));
    GUI_CreateScrollable(&gui->scrollable, 0, ITEM_HEIGHT + 1, LCD_WIDTH, LCD_HEIGHT - ITEM_HEIGHT -1,
                     ITEM_SPACE, SWITCHFUNC_LAST, row_cb, getobj_cb, NULL, NULL);
    GUI_SetSelected(GUI_ShowScrollableRowOffset(&gui->scrollable, 0));
}
예제 #22
0
void PAGE_TelemtestInit(int page)
{
    (void)okcancel_cb;
    (void)page;
    PAGE_SetModal(0);
    PAGE_SetActionCB(_action_cb);
    if (telem_state_check() == 0) {
        current_page = telemetry_off;
        GUI_CreateLabelBox(&gui->msg, 20, 10, 0, 0, &DEFAULT_FONT, NULL, NULL, tempstring);
        return;
    }

    _show_page(TELEMETRY_Type() == TELEM_DEVO ? &devo_page[current_page] : &dsm_page[current_page]);
}
예제 #23
0
void PAGE_TxConfigureInit(int page)
{
    (void)page;
    cp->enable = CALIB_NONE;
    PAGE_SetActionCB(_action_cb);
    PAGE_SetModal(0);
    PAGE_RemoveAllObjects();
    PAGE_ShowHeader(_tr("Configure"));
    cp->total_items = 0;

    GUI_CreateScrollable(&gui->scrollable, 0, HEADER_HEIGHT, LCD_WIDTH, LCD_HEIGHT - HEADER_HEIGHT,
                     LINE_SPACE, ITEM_LAST, row_cb, getobj_cb, size_cb, NULL);
    GUI_SetSelected(GUI_ShowScrollableRowOffset(&gui->scrollable, current_selected));
}
예제 #24
0
void PAGE_TelemtestInit(int page)
{
    (void)page;
    PAGE_SetModal(0);
    PAGE_SetActionCB(_action_cb);
    if (telem_state_check() == 0) {
        current_page = telemetry_off;
        GUI_CreateLabelBox(&gui->msg, 20, 10, 0, 0, &DEFAULT_FONT, NULL, NULL, tempstring);
        return;
    }
    if (current_page > telemetry_gps)
        current_page = telemetry_basic;

    _show_page();
}
예제 #25
0
static void fixedid_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    PAGE_SetModal(1);
    if(Model.fixed_id == 0) {
        u32 id = PROTOCOL_CurrentID();
        if (id)
            sprintf(mp->fixed_id, "%d", (int)id);
        else
            mp->fixed_id[0] = 0;
    }
    PAGE_RemoveAllObjects();
    callback_result = 1;
    GUI_CreateKeyboard(&gui->keyboard, KEYBOARD_NUM, mp->fixed_id, 999999, fixedid_done_cb, &callback_result);
}
예제 #26
0
void PAGE_ChantestInit(int page)
{
    (void)channum_cb; // remove compile warning as this method is not used here
    (void)okcancel_cb;
    PAGE_SetModal(0);
    PAGE_SetActionCB(_action_cb);
    PAGE_RemoveAllObjects();
    cp->return_page = NULL;
    if (page > 0)
        cp->return_val = page;
    if(cp->type == MONITOR_RAWINPUT )
        _show_bar_page(NUM_INPUTS);
    else {
        cp->type =  MONITOR_CHANNELOUTPUT;// cp->type may not be initialized yet, so do it here
        _show_bar_page(Model.num_channels);
    }
}
예제 #27
0
void PAGE_ModelMenuInit(int page)
{
    (void) page;
    long pos = 0;
    PAGE_SetModal(0);
    PAGE_ShowHeader_ExitOnly(PAGE_GetName(PAGEID_MODELMENU), goto_mainpage);
    u8 count = sizeof(menus) / sizeof(struct menu_s);
    for(int j = 0; j < 4; j++) {
        int y = 40 + j * (LCD_HEIGHT == 240 ? 50 : 59);
        for(int i = 0; i < 5; i++,pos++) {
            if (pos >= count)
                break;
            int x = (LCD_WIDTH == 320 ? 12 : 92) + i*60;
            GUI_CreateIcon(&gui->icon[pos], x, y, &menus[pos].icon, ico_select_cb, (void *)pos);
        }
    }
}
예제 #28
0
/*
 * Main page
 * KEY_UP: Press once to start timers, press again to stop timers
 * KEY_DOWN: Press to rest timers
 * KEY_ENT: enter the main menu page
 */
void PAGE_MainInit(int page)
{
    (void)page;
    (void)bar_cb;
    TGLICO_LoadFonts();
    memset(mp, 0, sizeof(struct main_page));// Bug fix: must initialize this structure to avoid unpredictable issues in the PAGE_MainEvent
    memset(gui, 0, sizeof(struct mainpage_obj));
    PAGE_SetModal(0);
    PAGE_SetActionCB(_action_cb);
    next_scan = CLOCK_getms()+BATTERY_SCAN_MSEC;

    GUI_CreateLabelBox(&gui->name, MODEL_NAME_X, MODEL_NAME_Y, //64, 12,
            LCD_WIDTH, LINE_HEIGHT, &MODELNAME_FONT, NULL, NULL, Model.name);

    show_elements();
    //Battery
    mp->battery = PWR_ReadVoltage();
}
예제 #29
0
static void _edit_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    PAGE_SetActionCB(_sub_action_cb);
    struct Trim *trim = MIXER_GetAllTrims();
    PAGE_SetModal(1);
    tp->index = (long)data;
    tp->trim = trim[tp->index];
    PAGE_RemoveAllObjects();
    PAGE_ShowHeader(""); // to draw a line only

    u8 w = 50;
    GUI_CreateButtonPlateText(&guit->save, LCD_WIDTH - w -1, 0, w, ITEM_HEIGHT,
            &DEFAULT_FONT, NULL, 0x0000, okcancel_cb, (void *)_tr("Save"));
    GUI_CreateScrollable(&gui->scrollable, 0, ITEM_HEIGHT + 1, LCD_WIDTH, LCD_HEIGHT - ITEM_HEIGHT -1,
                         ITEM_SPACE, ITEM_LAST, row2_cb, getobj2_cb, NULL, NULL);
    GUI_SetSelected(GUI_ShowScrollableRowOffset(&gui->scrollable, 0));
}
예제 #30
0
static void calibrate_sticks(void)
{
    // bug fix: should turn of safety dialog during calibrating, or it might fail when stick is not calibrated and safety setting is on
    PAGE_DisableSafetyDialog(1);
    PROTOCOL_DeInit();
    PAGE_SetModal(1);
    PAGE_RemoveAllObjects();
    PAGE_SetActionCB(_action_cb_calibrate);
    snprintf(tempstring, sizeof(tempstring), "%s",  _tr("Center all \nsticks and knobs\nthen press ENT"));
    GUI_CreateLabelBox(&guic->msg, 1, 10, LCD_WIDTH -1, LCD_HEIGHT - 10,
            LCD_HEIGHT > 70? &NARROW_FONT:&DEFAULT_FONT, NULL, NULL, tempstring);
    memcpy(cp->calibration, Transmitter.calibration, sizeof(cp->calibration));

    while(1) {
        CLOCK_ResetWatchdog();
        if(PWR_CheckPowerSwitch())
            PWR_Shutdown();
        if(priority_ready & (1 << MEDIUM_PRIORITY)) {
            BUTTON_Handler();
            priority_ready &= ~(1 << MEDIUM_PRIORITY);
        }
        if(priority_ready & (1 << LOW_PRIORITY)) {
            //Only sample every 100msec
            GUI_RefreshScreen();
            priority_ready = 0;
        }
        for (u8 i = 0; i < INP_HAS_CALIBRATION; i++) {
            s32 value = CHAN_ReadRawInput(i + 1);
            if (value > Transmitter.calibration[i].max)
                Transmitter.calibration[i].max = value;
            else if (value < Transmitter.calibration[i].min)
                Transmitter.calibration[i].min = value;
        }
        if (calibrate_state == CALI_SUCCESSEXIT || calibrate_state == CALI_EXIT)
            break;
    }
    if (calibrate_state == CALI_EXIT)
        memcpy(Transmitter.calibration, cp->calibration, sizeof(cp->calibration));

    PAGE_SetActionCB(NULL);
    PROTOCOL_Init(0);
    PAGE_TxConfigureInit(-1);   // should be -1 so that devo10 can get back to previous item selection
    PAGE_DisableSafetyDialog(0);
}