Skip to content

Instantly share code, notes, and snippets.

@paulstary
Created November 1, 2023 16:03
Show Gist options
  • Save paulstary/780e02f011fcb941c70f6563fd58aa45 to your computer and use it in GitHub Desktop.
Save paulstary/780e02f011fcb941c70f6563fd58aa45 to your computer and use it in GitHub Desktop.
Arduino Raw export file created by IRS from Global Cache Control Tower data for TCL Roku TV Power ON
// This Arduino sketch was automatically generated by IrScrutinizer.
// It supports:
//
// * IRremote https://github.com/Arduino-IRremote/Arduino-IRremote
// * IRLib https://github.com/cyborg5/IRLib
// * Infrared4Arduino https://github.com/bengtmartensson/Infrared4Arduino,
// http://www.harctoolbox.org/Infrared4Arduino.html
// For problems, bugs, and suggestions, please open an issue at
// https://github.com/bengtmartensson/IrScrutinizer/issues
// This file contains C identifiers which have been translated from command names.
// Under some circumstances, these may clash with predefined variables.
// Define exactly one of these
// #define IRREMOTE
// #define IRLIB
#define INFRARED4ARDUINO
/////////////////////////////////////////////////////
// Sanity check
#if defined(IRREMOTE) + defined(IRLIB) + defined(INFRARED4ARDUINO) != 1
#error Must define exactly only one of IRREMOTE, IRLIB, or INFRARED4ARDUINO
#endif
#ifdef IRREMOTE
#include <IRremote.h>
#elif defined(IRLIB)
#include <IRLib.h>
#define sendRaw send
#elif defined(INFRARED4ARDUINO)
#include <IrSenderPwm.h>
#else
#error Must defined one of IRREMOTE, IRLIB, or INFRARED4ARDUINO
#endif
#if defined(IRREMOTE) | defined(IRLIB)
typedef uint16_t microseconds_t; // Change if desired
typedef uint16_t frequency_t; // Change if desired
static inline unsigned hz2khz(frequency_t f) { return f/1000U; }
// IRremote and IRLib does not have HAS_FLASH_READ or similar.
// As a first guess, use defined(ARDUINO_ARCH_AVR).
// Change if desired.
#define HAS_FLASH_READ defined(ARDUINO_ARCH_AVR)
#endif
// Infrared4Arduino already defines HAS_FLASH_READ, architecture dependant.
// Feel free to override if you think that is a good idea.
#if ! HAS_FLASH_READ
#define PROGMEM /* nothing */
#endif
// Constants
static const long BAUD = 115200UL; // Change if desired
// Global variables
#ifdef IRREMOTE
IRsend irsend;
#elif defined(IRLIB)
IRsendRaw irsend;
#else
IrSender *irsend = IrSenderPwm::getInstance(true);
#endif
// Command #1: nec1_D0F0
// Protocol: nec1, Parameters: F=0 D=0
const microseconds_t intro_nec1_D0F0[] PROGMEM = { 9024U, 4512U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 1692U, 564U, 39756 };
const microseconds_t repeat_nec1_D0F0[] PROGMEM = { 9024U, 2256U, 564U, 65535U };
static void sendRaw
#if HAS_FLASH_READ
(const microseconds_t intro_P[], size_t lengthIntro, const microseconds_t repeat_P[],
size_t lengthRepeat, frequency_t frequency, unsigned times) {
microseconds_t intro[lengthIntro];
microseconds_t repeat[lengthRepeat];
memcpy_PF(intro, (uint_farptr_t) intro_P, sizeof(microseconds_t) * lengthIntro);
memcpy_PF(repeat, (uint_farptr_t) repeat_P, sizeof(microseconds_t) * lengthRepeat);
#else // ! HAS_FLASH_READ
(const microseconds_t intro[], size_t lengthIntro, const microseconds_t repeat[],
size_t lengthRepeat, frequency_t frequency, unsigned times) {
#endif // ! HAS_FLASH_READ
#if defined(IRREMOTE) | defined(IRLIB)
if (lengthIntro > 0U)
irsend.sendRaw(intro, lengthIntro, hz2khz(frequency));
if (lengthRepeat > 0U)
for (unsigned i = 0U; i < times - (lengthIntro > 0U); i++)
irsend.sendRaw(repeat, lengthRepeat, hz2khz(frequency));
#else // INFRARED4ARDUINO
IrSignal irSignal(intro, lengthIntro, repeat, lengthRepeat, NULL, 0U, frequency);
irsend->sendIrSignal(irSignal, times);
#endif
}
void setup() {
Serial.begin(BAUD);
Serial.setTimeout(60000UL);
}
// A pretty silly main loop; just intended as an example.
void loop() {
Serial.println(F("Enter number of signal to send (1 .. 1)"));
long commandno = Serial.parseInt();
Serial.println(F("Enter number of times to send it"));
long times = Serial.parseInt();
switch (commandno) {
case 1U:
sendRaw(intro_nec1_D0F0, 68U, repeat_nec1_D0F0, 4U, 38400U, times);
break;
default:
Serial.println(F("Invalid number entered, try again"));
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment