示例#1
0
void doIRButtons(TouchButton * const aTheTouchedButton, int16_t aValue) {
    FeedbackToneOK();
    if (aTheTouchedButton == TouchButtonsIRSend[0]) {
        sIRSendData.protocol = IRMP_NEC_PROTOCOL; // use NEC protocol
        sIRSendData.address = 64260; // set address LG 0XFB04
        sIRSendData.command = 0x00FF; // set command to EZ Adjust
        sIRSendData.flags = 0; // don't repeat frame
        //irsnd_send_data(&sIRSendData, TRUE); // send frame, wait for completion
        irsnd_send_data(&sIRSendData, FALSE); // send frame, do not wait for completion
    } else if (aTheTouchedButton == TouchButtonsIRSend[1]) {
        sIRSendData.protocol = IRMP_NEC_PROTOCOL; // use NEC protocol
        sIRSendData.address = 64260; // set address
        sIRSendData.command = 251; // set command to In  Start
        sIRSendData.flags = 0;
        irsnd_send_data(&sIRSendData, TRUE); // send frame, wait for completion
    } else if (aTheTouchedButton == TouchButtonsIRSend[2]) {
        float tNumber = getNumberFromNumberPad(NUMBERPAD_DEFAULT_X, 0, COLOR_GREEN);
        if (!isnan(tNumber) && tNumber != IN_STOP_CODE) {
            sCode = tNumber;
        }
        displayIRPage();
        assertParamMessage((sCode != IN_STOP_CODE), sCode, "");
        if (sCode != IN_STOP_CODE) {
            sIRSendData.protocol = IRMP_NEC_PROTOCOL; // use NEC protocol
            sIRSendData.address = 64260; // set address
            sIRSendData.command = sCode; // set command to
            sIRSendData.flags = 1; //  repeat frame once
            irsnd_send_data(&sIRSendData, TRUE); // send frame, wait for completion
        }
    } else if (aTheTouchedButton == TouchButtonsIRSend[3]) {
        sIRSendData.protocol = IRMP_NEC_PROTOCOL; // use NEC protocol
        sIRSendData.address = 64260; // set address
        sIRSendData.command = sCode; // set command to Volume -
        sIRSendData.flags = 0x0F; // repeat frame forever
        irsnd_send_data(&sIRSendData, FALSE); // send frame, do not wait for completion
        delayMillis(2000);
        irsnd_stop();
    }

    snprintf(StringBuffer, sizeof StringBuffer, "Cmd=%4d|%3X", sCode, sCode);
    BlueDisplay1.drawText(BUTTON_WIDTH_3_POS_2, BUTTON_HEIGHT_5_LINE_2 + TEXT_SIZE_22_HEIGHT, StringBuffer, TEXT_SIZE_22,
            COLOR_PAGE_INFO, COLOR_WHITE);
}
/**
 * Deallocates / free a button and put it back to button bool
 * Do not need to remove from list since FLAG_IS_ALLOCATED ist set
 */
void TouchButton::setFree(void) {
    assertParamMessage((this != NULL), sButtonCombinedPoolSize, "Button handle is null");
    sButtonCombinedPoolSize++;
    mFlags &= ~FLAG_IS_ALLOCATED;
    mFlags &= ~FLAG_IS_ACTIVE;
}