MCPcopy Create free account
hub / github.com/BruceDevices/firmware / sendRawCommand

Function sendRawCommand

src/modules/ir/custom_ir.cpp:602–649  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

600}
601
602void sendRawCommand(uint16_t frequency, String rawData, bool hideDefaultUI) {
603#ifdef USE_BOOST /// ENABLE 5V OUTPUT
604 PPM.enableOTG();
605#endif
606
607 IRsend irsend(bruceConfigPins.irTx); // Set the GPIO to be used to sending the message.
608 irsend.begin();
609 if (!hideDefaultUI) { displayTextLine("Sending.."); }
610
611 uint16_t dataBufferSize = 1;
612 for (int i = 0; i < rawData.length(); i++) {
613 if (rawData[i] == ' ') dataBufferSize += 1;
614 }
615 uint16_t *dataBuffer = (uint16_t *)malloc((dataBufferSize) * sizeof(uint16_t));
616
617 uint16_t count = 0;
618 // Parse raw data string
619 while (rawData.length() > 0 && count < dataBufferSize) {
620 int delimiterIndex = rawData.indexOf(' ');
621 if (delimiterIndex == -1) { delimiterIndex = rawData.length(); }
622 String dataChunk = rawData.substring(0, delimiterIndex);
623 rawData.remove(0, delimiterIndex + 1);
624 dataBuffer[count++] = (dataChunk.toInt());
625 }
626
627 Serial.println("Parsing raw data complete.");
628 // Serial.println(count);
629 // Serial.println(dataBuffer[count-1]);
630 // Serial.println(dataBuffer[0]);
631
632 // Send raw command
633 irsend.sendRaw(dataBuffer, count, frequency);
634
635 if (bruceConfigPins.irTxRepeats > 0) {
636 for (uint8_t i = 1; i <= bruceConfigPins.irTxRepeats; i++) {
637 irsend.sendRaw(dataBuffer, count, frequency);
638 }
639 }
640
641 free(dataBuffer);
642
643 Serial.println(
644 "Sent Raw Command" + (bruceConfigPins.irTxRepeats > 0
645 ? " (1 initial + " + String(bruceConfigPins.irTxRepeats) + " repeats)"
646 : "")
647 );
648 digitalWrite(bruceConfigPins.irTx, LED_OFF);
649}
650
651bool chooseCmdIrFile(FS *fs, String filepath) {
652 checkIrTxPin();

Callers 1

sendIRCommandFunction · 0.85

Calls 3

displayTextLineFunction · 0.85
beginMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected