Skip to content

Commit cae4f4e

Browse files
committed
organized carrier frequencies
1 parent e6b39b7 commit cae4f4e

File tree

12 files changed

+45
-32
lines changed

12 files changed

+45
-32
lines changed

examples/SendLGAirConditionerDemo/SendLGAirConditionerDemo.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333
#include <Arduino.h>
3434

35+
// LG2 has different header timing and a shorter bit time
3536
//#define USE_LG2_PROTOCOL // Try it if you do not have success with the default LG protocol
3637

3738
/*

src/IRProtocol.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,18 @@ const __FlashStringHelper* getProtocolString(decode_type_t aProtocol);
7070
#define PROTOCOL_IS_LSB_FIRST false
7171
#define PROTOCOL_IS_MSB_FIRST true
7272

73-
#define NEC_KHZ 38 // 38kHz carrier frequency for the NEC protocol
73+
/*
74+
* Carrier frequencies for various protocols
75+
*/
76+
#define SONY_KHZ 40
77+
#define BOSEWAVE_KHZ 38
78+
#define DENON_KHZ 38
79+
#define JVC_KHZ 38
80+
#define LG_KHZ 38
81+
#define NEC_KHZ 38
82+
#define SAMSUNG_KHZ 38
83+
#define KASEIKYO_KHZ 37
84+
#define RC5_RC6_KHZ 36
7485

7586
/*
7687
* Constants for some protocols

src/ir_BoseWave.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
void IRsend::sendBoseWave(uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
4646
// Set IR carrier frequency
47-
enableIROut(38);
47+
enableIROut(BOSEWAVE_KHZ); // 38 kHz
4848

4949
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
5050
while (tNumberOfCommands > 0) {

src/ir_Denon.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void IRsend::sendDenonRaw(uint16_t aRawData, uint_fast8_t aNumberOfRepeats) {
9393
//+=============================================================================
9494
void IRsend::sendDenon(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aSendSharp) {
9595
// Set IR carrier frequency
96-
enableIROut(38);
96+
enableIROut(DENON_KHZ); // 38 kHz
9797

9898
// Shift command and add frame marker
9999
uint16_t tCommand = aCommand << DENON_FRAME_BITS; // the lowest bits are 00 for Denon and 10 for Sharp
@@ -227,7 +227,7 @@ bool IRrecv::decodeDenonOld(decode_results *aResults) {
227227

228228
void IRsend::sendDenon(unsigned long data, int nbits) {
229229
// Set IR carrier frequency
230-
enableIROut(38);
230+
enableIROut(DENON_KHZ);
231231
Serial.println(
232232
"The function sendDenon(data, nbits) is deprecated and may not work as expected! Use sendDenonRaw(data, NumberOfRepeats) or better sendDenon(Address, Command, NumberOfRepeats).");
233233

src/ir_JVC.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#define JVC_COMMAND_BITS 8 // Command
5454

5555
#define JVC_BITS (JVC_ADDRESS_BITS + JVC_COMMAND_BITS) // 16 - The number of bits in the protocol
56-
#define JVC_UNIT 526
56+
#define JVC_UNIT 526 // 20 periods of 38 kHz (526.315789)
5757

5858
#define JVC_HEADER_MARK (16 * JVC_UNIT) // 8400
5959
#define JVC_HEADER_SPACE (8 * JVC_UNIT) // 4200
@@ -71,7 +71,7 @@
7171

7272
void IRsend::sendJVC(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats) {
7373
// Set IR carrier frequency
74-
enableIROut(38);
74+
enableIROut(JVC_KHZ); // 38 kHz
7575

7676
// Header
7777
mark(JVC_HEADER_MARK);
@@ -223,7 +223,7 @@ bool IRrecv::decodeJVCMSB(decode_results *aResults) {
223223
*/
224224
void IRsend::sendJVCMSB(unsigned long data, int nbits, bool repeat) {
225225
// Set IR carrier frequency
226-
enableIROut(38);
226+
enableIROut(JVC_KHZ);
227227

228228
// Only send the Header if this is NOT a repeat command
229229
if (!repeat) {

src/ir_Kaseikyo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
// P A A N NN A A S O O N NN I C
4646
// P A A N N A A SSSS OOO N N IIIII CCCC
4747
//==============================================================================
48-
// see: http://www.hifi-remote.com/johnsfine/DecodeIR.html#Panasonic
48+
// see: http://www.hifi-remote.com/johnsfine/DecodeIR.html#Panasonic and http://www.hifi-remote.com/johnsfine/DecodeIR.html#Kaseikyo
4949
// IRP notation: {37k,432}<1,-1|1,-3>(8,-4,M:8,N:8,X:4,D:4,S:8,F:8,G:8,1,-173)+ {X=M:4:0^M:4:4^N:4:0^N:4:4}
5050
// see: http://www.remotecentral.com/cgi-bin/mboard/rc-pronto/thread.cgi?26152
5151
// The first two (8-bit) bytes are always 2 and 32 (These identify Panasonic within the Kaseikyo standard)
@@ -63,7 +63,7 @@
6363
#define KASEIKYO_COMMAND_BITS 8
6464
#define KASEIKYO_PARITY_BITS 8
6565
#define KASEIKYO_BITS (KASEIKYO_VENDOR_ID_BITS + KASEIKYO_VENDOR_ID_PARITY_BITS + KASEIKYO_ADDRESS_BITS + KASEIKYO_COMMAND_BITS + KASEIKYO_PARITY_BITS)
66-
#define KASEIKYO_UNIT 432 // Pronto 0x70 / 0x10 - I measured 17 pulses
66+
#define KASEIKYO_UNIT 432 // 16 pulses of 37 kHz (432,432432) - Pronto 0x70 / 0x10
6767

6868
#define KASEIKYO_HEADER_MARK (8 * KASEIKYO_UNIT) // 3456
6969
#define KASEIKYO_HEADER_SPACE (4 * KASEIKYO_UNIT) // 1728
@@ -86,7 +86,7 @@
8686
*/
8787
void IRsend::sendKaseikyo(uint16_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, uint16_t aVendorCode) {
8888
// Set IR carrier frequency
89-
enableIROut(37); // 36.7kHz is the correct frequency
89+
enableIROut(KASEIKYO_KHZ); // 37 kHz
9090

9191
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
9292
while (tNumberOfCommands > 0) {
@@ -284,7 +284,7 @@ bool IRrecv::decodePanasonicMSB(decode_results *aResults) {
284284
*/
285285
void IRsend::sendPanasonic(uint16_t aAddress, uint32_t aData) {
286286
// Set IR carrier frequency
287-
enableIROut(37); // 36.7kHz is the correct frequency
287+
enableIROut(KASEIKYO_KHZ); // 36.7kHz is the correct frequency
288288

289289
// Header
290290
mark(KASEIKYO_HEADER_MARK);

src/ir_LG.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
#define LG_HEADER_SPACE (8 * LG_UNIT) // 4500
6262

6363
// used for some LG air conditioners e.g. AKB75215403
64-
#define LG2_UNIT 500
64+
#define LG2_UNIT 500 // 19 periods of 38 kHz
65+
6566
#define LG2_HEADER_MARK (6 * LG2_UNIT) // 3000
6667
#define LG2_HEADER_SPACE (19 * LG2_UNIT) // 9500
6768

@@ -85,7 +86,7 @@
8586
* Repeat commands should be sent in a 110 ms raster.
8687
*/
8788
void IRsend::sendLGRepeat(bool aUseLG2Protocol) {
88-
enableIROut(38);
89+
enableIROut(LG_KHZ); // 38 kHz
8990
if (aUseLG2Protocol) {
9091
mark(LG2_HEADER_MARK);
9192
} else {
@@ -125,7 +126,7 @@ void IRsend::sendLGRaw(uint32_t aRawData, uint_fast8_t aNumberOfRepeats, bool aI
125126
return;
126127
}
127128
// Set IR carrier frequency
128-
enableIROut(38);
129+
enableIROut(LG_KHZ);
129130

130131
// Header
131132
if (aUseLG2Protocol) {
@@ -300,7 +301,7 @@ bool IRrecv::decodeLGMSB(decode_results *aResults) {
300301
//+=============================================================================
301302
void IRsend::sendLG(unsigned long data, int nbits) {
302303
// Set IR carrier frequency
303-
enableIROut(38);
304+
enableIROut(LG_KHZ);
304305
Serial.println(
305306
"The function sendLG(data, nbits) is deprecated and may not work as expected! Use sendLGRaw(data, NumberOfRepeats) or better sendLG(Address, Command, NumberOfRepeats).");
306307

src/ir_NEC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#define NEC_COMMAND_BITS 16 // Command and inverted command
5353

5454
#define NEC_BITS (NEC_ADDRESS_BITS + NEC_COMMAND_BITS)
55-
#define NEC_UNIT 560
55+
#define NEC_UNIT 560 // 21.28 periods of 38 kHz
5656

5757
#define NEC_HEADER_MARK (16 * NEC_UNIT) // 9000
5858
#define NEC_HEADER_SPACE (8 * NEC_UNIT) // 4500

src/ir_RC5_RC6.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* ir_RC%_RC6.cpp
2+
* ir_RC5_RC6.cpp
33
*
44
* Contains functions for receiving and sending RC5, RC5X Protocols
55
*
@@ -62,7 +62,7 @@ bool sLastSendToggleValue = false;
6262

6363
#define RC5_BITS (RC5_COMMAND_FIELD_BIT + RC5_TOGGLE_BIT + RC5_ADDRESS_BITS + RC5_COMMAND_BITS) // 13
6464

65-
#define RC5_UNIT 889 // (32 cycles of 36 kHz)
65+
#define RC5_UNIT 889 // 32 periods of 36 kHz (888.8888)
6666

6767
#define MIN_RC5_MARKS ((RC5_BITS + 1) / 2) // 7
6868

@@ -75,7 +75,7 @@ bool sLastSendToggleValue = false;
7575
*/
7676
void IRsend::sendRC5(uint8_t aAddress, uint8_t aCommand, uint_fast8_t aNumberOfRepeats, bool aEnableAutomaticToggle) {
7777
// Set IR carrier frequency
78-
enableIROut(36);
78+
enableIROut(RC5_RC6_KHZ);
7979

8080
uint16_t tIRData = ((aAddress & 0x1F) << RC5_COMMAND_BITS);
8181

@@ -225,7 +225,7 @@ bool IRrecv::decodeRC5() {
225225

226226
#define RC6_BITS (RC6_LEADING_BIT + RC6_MODE_BITS + RC6_TOGGLE_BIT + RC6_ADDRESS_BITS + RC6_COMMAND_BITS) // 13
227227

228-
#define RC6_UNIT 444 // (16 cycles of 36 kHz)
228+
#define RC6_UNIT 444 // 16 periods of 36 kHz (444.4444)
229229

230230
#define RC6_HEADER_MARK (6 * RC6_UNIT) // 2666
231231
#define RC6_HEADER_SPACE (2 * RC6_UNIT) // 889
@@ -240,7 +240,7 @@ bool IRrecv::decodeRC5() {
240240
*/
241241
void IRsend::sendRC6(uint32_t aRawData, uint8_t aNumberOfBitsToSend) {
242242
// Set IR carrier frequency
243-
enableIROut(36);
243+
enableIROut(RC5_RC6_KHZ);
244244

245245
// Header
246246
mark(RC6_HEADER_MARK);
@@ -271,7 +271,7 @@ void IRsend::sendRC6(uint32_t aRawData, uint8_t aNumberOfBitsToSend) {
271271
*/
272272
void IRsend::sendRC6(uint64_t data, uint8_t nbits) {
273273
// Set IR carrier frequency
274-
enableIROut(36);
274+
enableIROut(RC5_RC6_KHZ);
275275

276276
// Header
277277
mark(RC6_HEADER_MARK);
@@ -464,7 +464,7 @@ bool IRrecv::decodeRC6() {
464464
*/
465465
void IRsend::sendRC5(uint32_t data, uint8_t nbits) {
466466
// Set IR carrier frequency
467-
enableIROut(36);
467+
enableIROut(RC5_RC6_KHZ);
468468

469469
// Start
470470
mark(RC5_UNIT);
@@ -488,7 +488,7 @@ void IRsend::sendRC5(uint32_t data, uint8_t nbits) {
488488
*/
489489
void IRsend::sendRC5ext(uint8_t addr, uint8_t cmd, bool toggle) {
490490
// Set IR carrier frequency
491-
enableIROut(36);
491+
enableIROut(RC5_RC6_KHZ);
492492

493493
uint8_t addressBits = 5;
494494
uint8_t commandBits = 7;

src/ir_Samsung.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#define SAMSUNG_BITS (SAMSUNG_ADDRESS_BITS + SAMSUNG_COMMAND16_BITS)
5757
#define SAMSUNG48_BITS (SAMSUNG_ADDRESS_BITS + SAMSUNG_COMMAND32_BITS)
5858

59-
#define SAMSUNG_UNIT 550
59+
#define SAMSUNG_UNIT 553 // 21 periods of 38 kHz (552,631)
6060
#define SAMSUNG_HEADER_MARK (8 * SAMSUNG_UNIT) // 4400
6161
#define SAMSUNG_HEADER_SPACE (8 * SAMSUNG_UNIT) // 4400
6262
#define SAMSUNG_BIT_MARK SAMSUNG_UNIT
@@ -73,7 +73,7 @@
7373
* Repeat commands should be sent in a 110 ms raster.
7474
*/
7575
void IRsend::sendSamsungRepeat() {
76-
enableIROut(38);
76+
enableIROut(SAMSUNG_KHZ); // 38 kHz
7777
mark(SAMSUNG_HEADER_MARK);
7878
space(SAMSUNG_HEADER_SPACE);
7979
mark(SAMSUNG_BIT_MARK);
@@ -88,7 +88,7 @@ void IRsend::sendSamsung(uint16_t aAddress, uint16_t aCommand, uint_fast8_t aNum
8888
}
8989

9090
// Set IR carrier frequency
91-
enableIROut(38);
91+
enableIROut(SAMSUNG_KHZ);
9292

9393
// Header
9494
mark(SAMSUNG_HEADER_MARK);
@@ -254,7 +254,7 @@ bool IRrecv::decodeSAMSUNG(decode_results *aResults) {
254254
// Old version with MSB first
255255
void IRsend::sendSAMSUNG(unsigned long data, int nbits) {
256256
// Set IR carrier frequency
257-
enableIROut(38);
257+
enableIROut(SAMSUNG_KHZ);
258258

259259
// Header
260260
mark(SAMSUNG_HEADER_MARK);

0 commit comments

Comments
 (0)