Esempio n. 1
0
unsigned _action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if (CHAN_ButtonIsPressed(button, BUT_ENTER))
        return 0;
    if (! (flags & BUTTON_RELEASE))
        return 1;
    {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT))
            PAGE_Pop();
        else if (CHAN_ButtonIsPressed(button, BUT_UP))
            navigate_toggleicons(-1);
        else if (CHAN_ButtonIsPressed(button, BUT_DOWN))
            navigate_toggleicons(1);
        else if (CHAN_ButtonIsPressed(button, BUT_LEFT))
            navigate_symbolicons(-1);
        else if (CHAN_ButtonIsPressed(button, BUT_RIGHT))
            navigate_symbolicons(1);
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 2
0
void PAGE_CalibInit(int page)
{
    (void)page;
    PROTOCOL_DeInit();
    PAGE_SetActionCB(_action_cb_calibrate);
    snprintf(tempstring, sizeof(tempstring), "%s",  _tr("Center all \nsticks and knobs\nthen press ENT"));
    GUI_CreateLabelBox(&guic->msg, 1, CALIB_Y, 0, 0,
            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_Pop();
//    PAGE_SetActionCB(NULL);
//    PROTOCOL_Init(0);
//    PAGE_SetModal(0);
//    //cp->enable = CALIB_NONE;
//    PAGE_ChangeByID(PAGEID_TXCFG, 0);
}
Esempio n. 3
0
static unsigned action_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if ((flags & BUTTON_PRESS) || (flags & BUTTON_LONGPRESS)) {
        if (CHAN_ButtonIsPressed(button, BUT_EXIT)) {
            PAGE_Pop();
        } else if (CHAN_ButtonIsPressed(button, BUT_ENTER) && (flags & BUTTON_LONGPRESS)) {
            // long press enter = save without exiting
            if (edit->pointnum < 0)
                edit->curve.points[1] = edit->curve.points[0];
            *edit->curveptr = edit->curve;
            struct mixer_page * const mp = &pagemem.u.mixer_page;
            PAGE_SaveMixerSetup(mp);
        }
        else {
            // only one callback can handle a button press, so we don't handle BUT_ENTER here, let it handled by press cb
            return 0;
        }
    }
    return 1;
}
Esempio n. 4
0
static unsigned _layaction_cb(u32 button, unsigned flags, void *data)
{
    (void)data;
    if(CHAN_ButtonIsPressed(button, BUT_EXIT)) {
        if (flags & BUTTON_RELEASE) {
            if (lp->selected_for_move >= 0) {
                set_selected_for_move(-1);
            } else {
                PAGE_Pop();
            }
        }
        return 1;
    }
    if (! GUI_GetSelected() || flags & BUTTON_RELEASE)
        return 0;
    if (CHAN_ButtonIsPressed(button, BUT_ENTER) && lp->selected_for_move < 0) {
        select_for_move((guiLabel_t *)GUI_GetSelected());
        return 1;
    }
    if (lp->selected_for_move < 0)
        return 0;
    if(CHAN_ButtonIsPressed(button, BUT_LEFT)) {
        xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_RIGHT)) {
        xpos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_UP)) {
        ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? -2 : -1, NULL);
        return 1;
    }
    if(CHAN_ButtonIsPressed(button, BUT_DOWN)) {
        ypos_cb(NULL, (flags & BUTTON_LONGPRESS) ? 2 : 1, NULL);
        return 1;
    }
    return 0;
}
Esempio n. 5
0
void changepage_cb(guiObject_t *obj, const void *data)
{
    (void)obj;
    (void)data;
    if(GUI_IsButtonLongPress(obj)) {
        page_stack = _page_stack;
    } 
    PAGE_Pop();
#if 0
    if((long)data == 0) {
        PAGE_SetSection(SECTION_MAIN);
    } else if ((long)data == 1) {
        if (cur_section == 0)
            PAGE_ChangeQuick(1);
        else
            PAGE_Change(1);
    } else if ((long)data == -1) {
        if (cur_section == 0)
            PAGE_ChangeQuick(-1);
        else
            PAGE_Change(-1);
    }
#endif
}
Esempio n. 6
0
void PAGE_ShowTelemetryAlarm()
{
    int cur_page = PAGE_GetID();
    if (cur_page != PAGEID_TELEMMON && cur_page != PAGEID_TELEMCFG)
        PAGE_Pop();
}