* Interprets and sends a IRData structure. * @param aIRSendData The values of protocol, address, command and repeat flag are taken for sending. * @param aNumberOfRepeats Number of repeats to send after the initial data if data is no repeat. * @return 1 if data sent, 0 if no data sent (i.e. for BANG_OLUFSEN, which is currently not supported here) */ * Interprets and sends a IRData structure. *
| 144 | * @return 1 if data sent, 0 if no data sent (i.e. for BANG_OLUFSEN, which is currently not supported here) |
| 145 | */ |
| 146 | size_t IRsend::write(IRData *aIRSendData, int_fast8_t aNumberOfRepeats) { |
| 147 | |
| 148 | auto tProtocol = aIRSendData->protocol; |
| 149 | auto tAddress = aIRSendData->address; |
| 150 | auto tCommand = aIRSendData->command; |
| 151 | bool tIsRepeat = (aIRSendData->flags & IRDATA_FLAGS_IS_REPEAT); |
| 152 | if (tIsRepeat) { |
| 153 | aNumberOfRepeats = -1; // if aNumberOfRepeats < 0 then only a special repeat frame will be sent |
| 154 | } |
| 155 | // switch (tProtocol) { // 26 bytes bigger than if, else if, else |
| 156 | // case NEC: |
| 157 | // sendNEC(tAddress, tCommand, aNumberOfRepeats, tSendRepeat); |
| 158 | // break; |
| 159 | // case SAMSUNG: |
| 160 | // sendSamsung(tAddress, tCommand, aNumberOfRepeats); |
| 161 | // break; |
| 162 | // case SONY: |
| 163 | // sendSony(tAddress, tCommand, aNumberOfRepeats, aIRSendData->numberOfBits); |
| 164 | // break; |
| 165 | // case PANASONIC: |
| 166 | // sendPanasonic(tAddress, tCommand, aNumberOfRepeats); |
| 167 | // break; |
| 168 | // case DENON: |
| 169 | // sendDenon(tAddress, tCommand, aNumberOfRepeats); |
| 170 | // break; |
| 171 | // case SHARP: |
| 172 | // sendSharp(tAddress, tCommand, aNumberOfRepeats); |
| 173 | // break; |
| 174 | // case JVC: |
| 175 | // sendJVC((uint8_t) tAddress, (uint8_t) tCommand, aNumberOfRepeats); // casts are required to specify the right function |
| 176 | // break; |
| 177 | // case RC5: |
| 178 | // sendRC5(tAddress, tCommand, aNumberOfRepeats, !tSendRepeat); // No toggle for repeats |
| 179 | // break; |
| 180 | // case RC6: |
| 181 | // // No toggle for repeats// sendRC6(tAddress, tCommand, aNumberOfRepeats, !tSendRepeat); // No toggle for repeats |
| 182 | // break; |
| 183 | // default: |
| 184 | // break; |
| 185 | // } |
| 186 | |
| 187 | /* |
| 188 | * Order of protocols is in guessed relevance :-) |
| 189 | */ |
| 190 | if (tProtocol == NEC) { |
| 191 | sendNEC(tAddress, tCommand, aNumberOfRepeats); |
| 192 | |
| 193 | } else if (tProtocol == SAMSUNG) { |
| 194 | sendSamsung(tAddress, tCommand, aNumberOfRepeats); |
| 195 | |
| 196 | } else if (tProtocol == SAMSUNG48) { |
| 197 | sendSamsung48(tAddress, tCommand, aNumberOfRepeats); |
| 198 | |
| 199 | } else if (tProtocol == SAMSUNGLG) { |
| 200 | sendSamsungLG(tAddress, tCommand, aNumberOfRepeats); |
| 201 | |
| 202 | } else if (tProtocol == SONY) { |
| 203 | sendSony(tAddress, tCommand, aNumberOfRepeats, aIRSendData->numberOfBits); |