Skip to content

Commit

Permalink
Clean up SEND_XYZ/DECODE_XYZ protocol disables.
Browse files Browse the repository at this point in the history
- Add the ability to disable sendRaw() for consistency.

Testing compiling most of the examples with:
* All SEND_XYZs set to false
* All DECODE_XYZs set to false
* All SEND_XYZs & DECODE_XYZs set to false

Note: Does not include SEND_FUJITSU_AC changes as they are in
      PR #375

Fixes issue #376
  • Loading branch information
crankyoldgit committed Dec 18, 2017
1 parent 30a1f42 commit 614c372
Show file tree
Hide file tree
Showing 32 changed files with 167 additions and 34 deletions.
4 changes: 4 additions & 0 deletions examples/IRGCSendDemo/IRGCSendDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ void setup() {

void loop() {
Serial.println("Toggling power");
#if SEND_GLOBALCACHE
irsend.sendGC(Samsung_power_toggle, 71);
#else // SEND_GLOBALCACHE
Serial.println("Can't send because SEND_GLOBALCACHE has been disabled.");
#endif // SEND_GLOBALCACHE
delay(10000);
}
2 changes: 2 additions & 0 deletions examples/IRGCTCPServer/IRGCTCPServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ void sendGCString(String str) {
count++;
} while (index != -1);

#if SEND_GLOBALCACHE
irsend.sendGC(code_array, count); // All done. Send it.
#endif // SEND_GLOBALCACHE
free(code_array); // Free up the memory allocated.
}

Expand Down
75 changes: 75 additions & 0 deletions examples/IRMQTTServer/IRMQTTServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -453,30 +453,46 @@ void parseStringAndSendAirCon(const uint16_t irType, const String str) {

// Make the appropriate call for the protocol type.
switch (irType) {
#if SEND_KELVINATOR
case KELVINATOR:
irsend.sendKelvinator(reinterpret_cast<uint8_t *>(state));
break;
#endif
#if SEND_TOSHIBA_AC
case TOSHIBA_AC:
irsend.sendToshibaAC(reinterpret_cast<uint8_t *>(state));
break;
#endif
#if SEND_DAIKIN
case DAIKIN:
irsend.sendDaikin(reinterpret_cast<uint8_t *>(state));
break;
#endif
#if MITSUBISHI_AC
case MITSUBISHI_AC:
irsend.sendMitsubishiAC(reinterpret_cast<uint8_t *>(state));
break;
#endif
#if SEND_TROTEC
case TROTEC:
irsend.sendTrotec(reinterpret_cast<uint8_t *>(state));
break;
#endif
#if SEND_ARGO
case ARGO:
irsend.sendArgo(reinterpret_cast<uint8_t *>(state));
break;
#endif
#if SEND_GREE
case GREE:
irsend.sendGree(reinterpret_cast<uint8_t *>(state));
break;
#endif
#if SEND_FUJITSU_AC
case FUJITSU_AC:
irsend.sendFujitsuAC(reinterpret_cast<uint8_t *>(state), stateSize);
break;
#endif
}
}

Expand Down Expand Up @@ -517,6 +533,7 @@ uint16_t * newCodeArray(const uint16_t size) {
return result;
}

#if SEND_GLOBALCACHE
// Parse a GlobalCache String/code and send it.
// Args:
// str: A GlobalCache formatted String of comma separated numbers.
Expand Down Expand Up @@ -556,7 +573,9 @@ void parseStringAndSendGC(const String str) {
irsend.sendGC(code_array, count); // All done. Send it.
free(code_array); // Free up the memory allocated.
}
#endif // SEND_GLOBALCACHE

#if SEND_PRONTO
// Parse a Pronto Hex String/code and send it.
// Args:
// str: A comma-separated String of nr. of repeats, then hexadecimal numbers.
Expand Down Expand Up @@ -609,7 +628,9 @@ void parseStringAndSendPronto(const String str, uint16_t repeats) {
irsend.sendPronto(code_array, count, repeats); // All done. Send it.
free(code_array); // Free up the memory allocated.
}
#endif // SEND_PRONTO

#if SEND_RAW
// Parse an IRremote Raw Hex String/code and send it.
// Args:
// str: A comma-separated String containing the freq and raw IR data.
Expand Down Expand Up @@ -649,6 +670,7 @@ void parseStringAndSendRaw(const String str) {
irsend.sendRaw(raw_array, count, freq); // All done. Send it.
free(raw_array); // Free up the memory allocated.
}
#endif // SEND_RAW

// Parse the URL args to find the IR code.
void handleIr() {
Expand Down Expand Up @@ -876,80 +898,108 @@ void sendIRCode(int const ir_type, uint64_t const code, char const * code_str,

// send the IR message.
switch (ir_type) {
#if SEND_RC5
case RC5: // 1
if (bits == 0)
bits = RC5_BITS;
irsend.sendRC5(code, bits, repeat);
break;
#endif
#if SEND_RC6
case RC6: // 2
if (bits == 0)
bits = RC6_MODE0_BITS;
irsend.sendRC6(code, bits, repeat);
break;
#endif
#if SEND_NEC
case NEC: // 3
if (bits == 0)
bits = NEC_BITS;
irsend.sendNEC(code, bits, repeat);
break;
#endif
#if SEND_SONY
case SONY: // 4
if (bits == 0)
bits = SONY_12_BITS;
repeat = std::max(repeat, (uint16_t) SONY_MIN_REPEAT);
irsend.sendSony(code, bits, repeat);
break;
#endif
#if SEND_PANASONIC
case PANASONIC: // 5
if (bits == 0)
bits = PANASONIC_BITS;
irsend.sendPanasonic64(code, bits, repeat);
break;
#endif
#if SEND_JVC
case JVC: // 6
if (bits == 0)
bits = JVC_BITS;
irsend.sendJVC(code, bits, repeat);
break;
#endif
#if SEND_SAMSUNG
case SAMSUNG: // 7
if (bits == 0)
bits = SAMSUNG_BITS;
irsend.sendSAMSUNG(code, bits, repeat);
break;
#endif
#if SEND_WHYNTER
case WHYNTER: // 8
if (bits == 0)
bits = WHYNTER_BITS;
irsend.sendWhynter(code, bits, repeat);
break;
#endif
#if SEND_AIWA_RC_T501
case AIWA_RC_T501: // 9
if (bits == 0)
bits = AIWA_RC_T501_BITS;
repeat = std::max(repeat, (uint16_t) AIWA_RC_T501_MIN_REPEAT);
irsend.sendAiwaRCT501(code, bits, repeat);
break;
#endif
#if SEND_LG
case LG: // 10
if (bits == 0)
bits = LG_BITS;
irsend.sendLG(code, bits, repeat);
break;
#endif
#if SEND_MITSUBISHI
case MITSUBISHI: // 12
if (bits == 0)
bits = MITSUBISHI_BITS;
repeat = std::max(repeat, (uint16_t) MITSUBISHI_MIN_REPEAT);
irsend.sendMitsubishi(code, bits, repeat);
break;
#endif
#if SEND_DISH
case DISH: // 13
if (bits == 0)
bits = DISH_BITS;
repeat = std::max(repeat, (uint16_t) DISH_MIN_REPEAT);
irsend.sendDISH(code, bits, repeat);
break;
#endif
#if SEND_SHARP
case SHARP: // 14
if (bits == 0)
bits = SHARP_BITS;
irsend.sendSharpRaw(code, bits, repeat);
break;
#endif
#if SEND_COOLIX
case COOLIX: // 15
if (bits == 0)
bits = COOLIX_BITS;
irsend.sendCOOLIX(code, bits, repeat);
break;
#endif
case DAIKIN: // 16
case KELVINATOR: // 18
case MITSUBISHI_AC: // 20
Expand All @@ -960,60 +1010,85 @@ void sendIRCode(int const ir_type, uint64_t const code, char const * code_str,
case FUJITSU_AC: // 33
parseStringAndSendAirCon(ir_type, code_str);
break;
#if SEND_DENON
case DENON: // 17
if (bits == 0)
bits = DENON_BITS;
irsend.sendDenon(code, bits, repeat);
break;
#endif
#if SEND_SHERWOOD
case SHERWOOD: // 19
if (bits == 0)
bits = SHERWOOD_BITS;
repeat = std::max(repeat, (uint16_t) SHERWOOD_MIN_REPEAT);
irsend.sendSherwood(code, bits, repeat);
break;
#endif
#if SEND_RCMM
case RCMM: // 21
if (bits == 0)
bits == RCMM_BITS;
irsend.sendRCMM(code, bits, repeat);
break;
#endif
#if SEND_SANYO
case SANYO_LC7461: // 22
if (bits == 0)
bits = SANYO_LC7461_BITS;
irsend.sendSanyoLC7461(code, bits, repeat);
break;
#endif
#if SEND_RC5
case RC5X: // 23
if (bits == 0)
bits = RC5X_BITS;
irsend.sendRC5(code, bits, repeat);
break;
#endif
#if SEND_PRONTO
case PRONTO: // 25
parseStringAndSendPronto(code_str, repeat);
break;
#endif
#if SEND_NIKAI
case NIKAI: // 29
if (bits == 0)
bits = NIKAI_BITS;
irsend.sendNikai(code, bits, repeat);
break;
#endif
#if SEND_RAW
case RAW: // 30
parseStringAndSendRaw(code_str);
break;
#endif
#if SEND_GLOBALCACHE
case GLOBALCACHE: // 31
parseStringAndSendGC(code_str);
break;
#endif
#if SEND_MIDEA
case MIDEA: // 34
if (bits == 0)
bits = MIDEA_BITS;
irsend.sendMidea(code, bits, repeat);
break;
#endif
#if SEND_MAGIQUEST
case MAGIQUEST: // 35
if (bits == 0)
bits = MAGIQUEST_BITS;
irsend.sendMagiQuest(code, bits, repeat);
break;
#endif
#if SEND_LASERTAG
case LASERTAG: // 36
if (bits == 0)
bits = LASERTAG_BITS;
irsend.sendLasertag(code, bits, repeat);
break;
#endif
}

// Release the lock.
Expand Down
2 changes: 2 additions & 0 deletions examples/IRServer/IRServer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ void handleIr() {
for (uint8_t i = 0; i < server.args(); i++) {
if (server.argName(i) == "code") {
uint32_t code = strtoul(server.arg(i).c_str(), NULL, 10);
#if SEND_NEC
irsend.sendNEC(code, 32);
#endif // SEND_NEC
}
}
handleRoot();
Expand Down
2 changes: 2 additions & 0 deletions examples/IRrecvDumpV2/IRrecvDumpV2.ino
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,10 @@ void setup() {
Serial.begin(BAUD_RATE, SERIAL_8N1, SERIAL_TX_ONLY);
delay(500); // Wait a bit for the serial connection to be establised.

#if DECODE_HASH
// Ignore messages with less than minimum on or off pulses.
irrecv.setUnknownThreshold(MIN_UNKNOWN_SIZE);
#endif // DECODE_HASH
irrecv.enableIRIn(); // Start the receiver
}

Expand Down
6 changes: 6 additions & 0 deletions examples/IRsendDemo/IRsendDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ void setup() {
}

void loop() {
#if SEND_NEC
Serial.println("NEC");
irsend.sendNEC(0x00FFE01FUL, 32);
#endif // SEND_NEC
delay(2000);
#if SEND_SONY
Serial.println("Sony");
irsend.sendSony(0xa90, 12, 2);
#endif // SEND_SONY
delay(2000);
#if SEND_RAW
Serial.println("a rawData capture from IRrecvDumpV2");
irsend.sendRaw(rawData, 67, 38); // Send a raw data capture at 38kHz.
#endif // SEND_RAW
delay(2000);
}
5 changes: 5 additions & 0 deletions examples/IRsendProntoDemo/IRsendProntoDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ void setup() {
}

void loop() {
#if SEND_PRONTO
Serial.println("Sending a Samsung TV 'on' command.");
irsend.sendPronto(samsungProntoCode, 72);
delay(2000);
Serial.println("Sending a Panasonic Plasma TV 'on' command.");
irsend.sendPronto(panasonicProntoCode, 104);
delay(2000);
#else // SEND_PRONTO
Serial.println("Can't send because SEND_PRONTO has been disabled.");
delay(10000);
#endif // SEND_PRONTO
}
8 changes: 8 additions & 0 deletions examples/JVCPanasonicSendDemo/JVCPanasonicSendDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,19 @@ void setup() {

void loop() {
// This should turn your TV on and off
#if SEND_PANASONIC
irsend.sendPanasonic(PanasonicAddress, PanasonicPower);
#else // SEND_PANASONIC
Serial.println("Can't send because SEND_PANASONIC has been disabled.");
#endif // SEND_PANASONIC

#if SEND_JVC
irsend.sendJVC(JVCPower, 16, 0); // hex value, 16 bits, no repeat
// see http://www.sbprojects.com/knowledge/ir/jvc.php for information
delayMicroseconds(50);
irsend.sendJVC(JVCPower, 16, 1); // hex value, 16 bits, repeat
delayMicroseconds(50);
#else // SEND_JVC
Serial.println("Can't send because SEND_JVC has been disabled.");
#endif // SEND_JVC
}
8 changes: 6 additions & 2 deletions examples/LGACSend/LGACSend.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ void Ac_Send_Code(uint32_t code) {
Serial.print(" : ");
Serial.println(code, HEX);

#if SEND_LG
irsend.sendLG(code, 28);
#else // SEND_LG
Serial.println("Can't send because SEND_LG has been disabled.");
#endif // SEND_LG
}

void Ac_Activate(unsigned int temperature, unsigned int air_flow,
Expand Down Expand Up @@ -171,8 +175,8 @@ void loop() {
# 4 : air_flow 0 ~ 3 : flow
# + : temp + 1
# - : temp - 1
# c : cooling
# h : heating
# c : cooling
# h : heating
# m : change cooling to air clean, air clean to cooling
*/
Serial.print("a : ");
Expand Down
Loading

0 comments on commit 614c372

Please sign in to comment.