Beispiel #1
0
/**
 * use TIM15 as timer and TIM17 as PWM generator
 */
void startIRPage(void) {

    setZeroAcceleratorGyroValue();
    TouchButton::setDefaultButtonColor(COLOR_GREEN);
    int tXPos = 0;
    for (unsigned int i = 0; i < NUMBER_OF_IR_BUTTONS; ++i) {
        TouchButtonsIRSend[i] = TouchButton::allocAndInitSimpleButton(tXPos, 0, BUTTON_WIDTH_4, BUTTON_HEIGHT_5, 0,
                IRButtonStrings[i], TEXT_SIZE_11, BUTTON_FLAG_DO_BEEP_ON_TOUCH, i, &doIRButtons);
        tXPos += BUTTON_WIDTH_4 + BUTTON_DEFAULT_SPACING;
    }

    TouchButtonToggleSendReceive = TouchButton::allocAndInitSimpleButton(BUTTON_WIDTH_3_POS_3, BUTTON_HEIGHT_4_LINE_4,
            BUTTON_WIDTH_3, BUTTON_HEIGHT_4, COLOR_RED, StringReceive, TEXT_SIZE_22, BUTTON_FLAG_DO_BEEP_ON_TOUCH, 0,
            &doToggleSendReceive);

    TouchButtonToggleLights = TouchButton::allocAndInitSimpleButton(BUTTON_WIDTH_3_POS_2, BUTTON_HEIGHT_4_LINE_4, BUTTON_WIDTH_3,
            BUTTON_HEIGHT_4, COLOR_BLACK, StringLights, TEXT_SIZE_22, BUTTON_FLAG_DO_BEEP_ON_TOUCH, sLightValue,
            &doToggleRedGreenButton);
    TouchButtonToggleLights->setRedGreenButtonColorAndDraw();

    // Velocity
    TouchSliderVertical.initSlider(TEXT_SIZE_11_WIDTH, BUTTON_HEIGHT_5_LINE_2 + 10, TOUCHSLIDER_DEFAULT_SIZE * 2,
            VELOCITY_SLIDER_SIZE, VELOCITY_SLIDER_SIZE - 10, 0, StringVelocity, TOUCHSLIDER_DEFAULT_TOUCH_BORDER,
            TOUCHSLIDER_SHOW_BORDER | TOUCHSLIDER_SHOW_VALUE, &doVelocitySlider, &mapVelocityValue);

    TouchSliderVertical2.initSlider(70, BUTTON_HEIGHT_5_LINE_3, TOUCHSLIDER_DEFAULT_SIZE, NICK_MAX_VALUE, NICK_ZERO_VALUE,
            NICK_ZERO_VALUE, StringNick, TOUCHSLIDER_DEFAULT_TOUCH_BORDER, TOUCHSLIDER_SHOW_VALUE, NULL, NULL);

    TouchSliderHorizontal.initSlider(BUTTON_WIDTH_3_POS_2, BUTTON_HEIGHT_5_LINE_3, TOUCHSLIDER_DEFAULT_SIZE,
            YAW_MAX_VALUE - YAW_MIN_VALUE, YAW_ZERO_VALUE, YAW_ZERO_VALUE, StringYaw, TOUCHSLIDER_DEFAULT_TOUCH_BORDER,
            TOUCHSLIDER_SHOW_VALUE | TOUCHSLIDER_IS_HORIZONTAL, NULL, NULL);

    TouchButtonYaw_Minus = TouchButton::allocAndInitSimpleButton(BUTTON_WIDTH_3_POS_2,
            BUTTON_HEIGHT_4_LINE_3 + BUTTON_HEIGHT_4 - BUTTON_HEIGHT_6, BUTTON_WIDTH_10, BUTTON_HEIGHT_6, COLOR_RED, StringMinus,
            TEXT_SIZE_22, BUTTON_FLAG_DO_BEEP_ON_TOUCH, -3, &doSetYawTrim);

    TouchButtonYaw_Plus = TouchButton::allocAndInitSimpleButton(BUTTON_WIDTH_3_POS_2 + BUTTON_WIDTH_8 + 2 * BUTTON_DEFAULT_SPACING,
            BUTTON_HEIGHT_4_LINE_3 + BUTTON_HEIGHT_4 - BUTTON_HEIGHT_6, BUTTON_WIDTH_8, BUTTON_HEIGHT_6, COLOR_RED, StringPlus,
            TEXT_SIZE_22, BUTTON_FLAG_DO_BEEP_ON_TOUCH, 3, &doSetYawTrim);

// enable high sink capability
//	SYSCFG_I2CFastModePlusConfig(SYSCFG_I2CFastModePlus_PB9, ENABLE);
    irsnd_init();
    irmp_init();
    sSend = false;
    sIRSendData.protocol = IRMP_IHELICOPTER_PROTOCOL;

//compute autoreload value for 16 bit timer without prescaler
    RCC_GetClocksFreq(&RCC_Clocks);
    IR_Timer_initialize((RCC_Clocks.PCLK2_Frequency / F_INTERRUPTS) - 1);
    IR_Timer_Start();
    displayIRPage();
    registerSimpleResizeAndReconnectCallback(&displayIRPage);
}
/**
 * use TIM15 as timer and TIM17 as PWM generator
 */
void startIRPage(void) {

    setZeroAccelerometerGyroValue();
    int tXPos = 0;
    for (unsigned int i = 0; i < NUMBER_OF_IR_BUTTONS; ++i) {
        TouchButtonsIRSend[i].init(tXPos, 0, BUTTON_WIDTH_4, BUTTON_HEIGHT_5, COLOR_GREEN, IRButtonStrings[i],
        TEXT_SIZE_11, BUTTON_FLAG_DO_BEEP_ON_TOUCH, i, &doIRButtons);
        tXPos += BUTTON_WIDTH_4 + BUTTON_DEFAULT_SPACING;
    }

    TouchButtonToggleSendReceive.init(BUTTON_WIDTH_3_POS_3, BUTTON_HEIGHT_4_LINE_4, BUTTON_WIDTH_3, BUTTON_HEIGHT_4,
    COLOR_RED, StringReceive, TEXT_SIZE_22, BUTTON_FLAG_DO_BEEP_ON_TOUCH, 0, &doToggleSendReceive);

    TouchButtonToggleLights.init(BUTTON_WIDTH_3_POS_2, BUTTON_HEIGHT_4_LINE_4, BUTTON_WIDTH_3, BUTTON_HEIGHT_4,
    COLOR_GREEN, StringLights, TEXT_SIZE_22, BUTTON_FLAG_DO_BEEP_ON_TOUCH | BUTTON_FLAG_TYPE_TOGGLE_RED_GREEN,
            sLightValue, NULL);

    // Velocity
    TouchSliderVelocity.init(TEXT_SIZE_11_WIDTH, BUTTON_HEIGHT_5_LINE_2 + 12, SLIDER_DEFAULT_BAR_WIDTH * 2,
    VELOCITY_SLIDER_SIZE, VELOCITY_SLIDER_SIZE - 10, 0, COLOR_BLUE, COLOR_GREEN, FLAG_SLIDER_SHOW_BORDER,
            &doVelocitySlider);
    TouchSliderVelocity.setCaptionProperties(TEXT_SIZE_11, FLAG_SLIDER_CAPTION_ALIGN_LEFT, 4, COLOR_RED,
    COLOR_BACKGROUND_DEFAULT);
    TouchSliderVelocity.setCaption(StringVelocity);
    TouchSliderVelocity.setPrintValueProperties(TEXT_SIZE_11, FLAG_SLIDER_CAPTION_ALIGN_LEFT, 4 + TEXT_SIZE_11,
    COLOR_BLUE, COLOR_BACKGROUND_DEFAULT);

    // PITCH - vertical
    TouchSliderPitch.init(70, BUTTON_HEIGHT_5_LINE_3, SLIDER_DEFAULT_BAR_WIDTH, PITCH_MAX_VALUE,
    PITCH_ZERO_VALUE, PITCH_ZERO_VALUE, COLOR_BLACK, COLOR_GREEN, FLAG_SLIDER_VALUE_BY_CALLBACK, NULL);
    TouchSliderPitch.setBarBackgroundColor(COLOR_YELLOW);
    TouchSliderPitch.setCaptionProperties(TEXT_SIZE_11, FLAG_SLIDER_CAPTION_ALIGN_LEFT, 4, COLOR_RED,
    COLOR_BACKGROUND_DEFAULT);
    TouchSliderPitch.setCaption(StringPitch);
    TouchSliderPitch.setPrintValueProperties(TEXT_SIZE_11, FLAG_SLIDER_CAPTION_ALIGN_LEFT, 4 + TEXT_SIZE_11,
    COLOR_BLUE, COLOR_BACKGROUND_DEFAULT);

    // YAW - horizontal
    TouchSliderYaw.init(BUTTON_WIDTH_3_POS_2, BUTTON_HEIGHT_5_LINE_3, SLIDER_DEFAULT_BAR_WIDTH,
    YAW_MAX_VALUE - YAW_MIN_VALUE, YAW_ZERO_VALUE, YAW_ZERO_VALUE, COLOR_BLACK, COLOR_GREEN,
            FLAG_SLIDER_IS_HORIZONTAL | FLAG_SLIDER_VALUE_BY_CALLBACK, NULL);
    TouchSliderYaw.setBarBackgroundColor(COLOR_YELLOW);
    TouchSliderYaw.setCaptionProperties(TEXT_SIZE_11, FLAG_SLIDER_CAPTION_ALIGN_MIDDLE, 4, COLOR_RED,
    COLOR_BACKGROUND_DEFAULT);
    TouchSliderYaw.setCaption(StringYaw);
    TouchSliderYaw.setPrintValueProperties(TEXT_SIZE_11, FLAG_SLIDER_CAPTION_ALIGN_LEFT, 4, COLOR_BLUE,
    COLOR_BACKGROUND_DEFAULT);

    TouchButtonYaw_Minus.init(BUTTON_WIDTH_3_POS_2,
    BUTTON_HEIGHT_4_LINE_3 + BUTTON_HEIGHT_4 - BUTTON_HEIGHT_6, BUTTON_WIDTH_10, BUTTON_HEIGHT_6, COLOR_RED, "-",
    TEXT_SIZE_22, BUTTON_FLAG_DO_BEEP_ON_TOUCH, -3, &doSetYawTrim);

    TouchButtonYaw_Plus.init( BUTTON_WIDTH_3_POS_2 + BUTTON_WIDTH_8 + 2 * BUTTON_DEFAULT_SPACING,
    BUTTON_HEIGHT_4_LINE_3 + BUTTON_HEIGHT_4 - BUTTON_HEIGHT_6, BUTTON_WIDTH_8, BUTTON_HEIGHT_6, COLOR_RED, "+",
    TEXT_SIZE_22, BUTTON_FLAG_DO_BEEP_ON_TOUCH, 3, &doSetYawTrim);

    /* Enable fast mode plus driving capability for selected I2C pin */
//    SYSCFG->CFGR1 |= HAL_SYSCFG_FASTMODEPLUS_I2C1;
    irsnd_init();
    irmp_init();
    sSend = false;
    sIRSendData.protocol = IRMP_IHELICOPTER_PROTOCOL;

//compute autoreload value for 16 bit timer without prescaler
    IR_Timer_initialize((HAL_RCC_GetPCLK2Freq() / F_INTERRUPTS) - 1);
    IR_Timer_Start();
    drawIRPage();
    registerRedrawCallback(&drawIRPage);
}