MCPcopy Create free account
hub / github.com/Arduino-IRremote/Arduino-IRremote / printIRResultAsCArray

Method printIRResultAsCArray

src/IRReceive.hpp:2311–2355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2309 printIRResultAsCArray(aSerial, aOutputMicrosecondsInsteadOfTicks, true);
2310}
2311void IRrecv::printIRResultAsCArray(Print *aSerial, bool aOutputMicrosecondsInsteadOfTicks, bool aDoCompensate) {
2312// Start declaration
2313 if (aOutputMicrosecondsInsteadOfTicks) {
2314 aSerial->print(F("uint16_t rawIRTimings[")); // variable type, array name
2315 } else {
2316 aSerial->print(F("uint8_t rawTicks[")); // variable type, array name
2317 }
2318
2319 aSerial->print(decodedIRData.rawlen - 1); // array size
2320 aSerial->print(F("] = {")); // Start declaration
2321
2322// Dump data
2323 for (IRRawlenType i = 1; i < decodedIRData.rawlen; i++) {
2324 uint32_t tDuration = irparams.rawbuf[i] * MICROS_PER_TICK; // no problem to use 50 instead of 50L here!
2325
2326 if (aDoCompensate) {
2327 if (i & 1) {
2328 // Mark
2329 tDuration -= MARK_EXCESS_MICROS;
2330 } else {
2331 tDuration += MARK_EXCESS_MICROS;
2332 }
2333 }
2334
2335 if (aOutputMicrosecondsInsteadOfTicks) {
2336 aSerial->print(tDuration);
2337 } else {
2338 unsigned int tTicks = (tDuration + (MICROS_PER_TICK / 2)) / MICROS_PER_TICK;
2339 /*
2340 * Clip to 8 bit value
2341 */
2342 tTicks = (tTicks > UINT8_MAX) ? UINT8_MAX : tTicks;
2343 aSerial->print(tTicks);
2344 }
2345 if (i + 1 < decodedIRData.rawlen) aSerial->print(','); // ',' not required on last one
2346 if (!(i & 1)) aSerial->print(' ');
2347 }
2348
2349// End declaration
2350 aSerial->print(F("};")); //
2351
2352// Comment
2353 aSerial->print(F(" // "));
2354 printIRResultShort(aSerial);
2355}
2356
2357/**
2358 * Store the decodedIRData to be used for sendRaw().

Callers

nothing calls this directly

Calls 1

printIRResultShortFunction · 0.85

Tested by

no test coverage detected