mirror of
https://github.com/Theaninova/Arduino-IRremote.git
synced 2025-12-13 01:46:21 +00:00
Completed adding recs80 sending and decoding
I have tested it using two arduinos (one for sending and the other for receiving) and have achieved a 90% (estimate) success rate.
This commit is contained in:
@@ -56,6 +56,7 @@ void encoding (decode_results *results)
|
||||
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
|
||||
case PANASONIC: Serial.print("PANASONIC"); break ;
|
||||
case DENON: Serial.print("Denon"); break ;
|
||||
case RECS80: Serial.print("RECS80"); break ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ version=2.4.0
|
||||
author=shirriff, z3t0
|
||||
maintainer=z3t0
|
||||
sentence=Send and receive infrared signals with multiple protocols
|
||||
paragraph=See more at https://github.com/z3t0/Arduino-IRremote
|
||||
category=Communication
|
||||
url=https://github.com/z3t0/Arduino-IRremote
|
||||
architectures=*
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
#define DECODE_LEGO_PF 0 // NOT WRITTEN
|
||||
#define SEND_LEGO_PF 1
|
||||
|
||||
#define DECODE_RECS80 0 // NOT WRITTEN
|
||||
#define DECODE_RECS80 1 // NOT WRITTEN
|
||||
#define SEND_RECS80 1 // Still being tested
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -122,13 +122,14 @@ typedef
|
||||
DENON,
|
||||
PRONTO,
|
||||
LEGO_PF,
|
||||
RECS80,
|
||||
}
|
||||
decode_type_t;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Set DEBUG to 1 for lots of lovely debug output
|
||||
//
|
||||
#define DEBUG 0
|
||||
#define DEBUG 0
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Debug directives
|
||||
@@ -254,6 +255,10 @@ class IRrecv
|
||||
# if DECODE_LEGO_PF
|
||||
bool decodeLegoPowerFunctions (decode_results *results) ;
|
||||
# endif
|
||||
|
||||
# if DECODE_RECS80
|
||||
bool decodeRECS80(decode_results *results);
|
||||
# endif
|
||||
} ;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -355,7 +360,7 @@ class IRsend
|
||||
# endif
|
||||
//......................................................................
|
||||
# if SEND_RECS80
|
||||
void sendRECS80 (uint8_t address, uint8_t address_nbit, uint8_t command, uint8_t command_nbit) ;
|
||||
void sendRECS80 (uint16_t data) ;
|
||||
# endif
|
||||
|
||||
#ifdef USE_SOFT_CARRIER
|
||||
|
||||
@@ -89,7 +89,7 @@ EXTERN volatile irparams_t irparams;
|
||||
#define UTOL (1.0 + (TOLERANCE/100.))
|
||||
|
||||
// Minimum gap between IR transmissions
|
||||
#define _GAP 5000
|
||||
#define _GAP 8000
|
||||
#define GAP_TICKS (_GAP/USECPERTICK)
|
||||
|
||||
#define TICKS_LOW(us) ((int)(((us)*LTOL/USECPERTICK)))
|
||||
|
||||
@@ -85,6 +85,11 @@ int IRrecv::decode (decode_results *results)
|
||||
if (decodeLegoPowerFunctions(results)) return true ;
|
||||
#endif
|
||||
|
||||
#if DECODE_RECS80
|
||||
DBG_PRINTLN("Attempting RECS80 decode");
|
||||
if (decodeRECS80(results)) return true;
|
||||
#endif
|
||||
|
||||
// decodeHash returns a hash on any input.
|
||||
// Thus, it needs to be last in the list.
|
||||
// If you add any decodes, add them before this.
|
||||
|
||||
@@ -5,15 +5,16 @@
|
||||
// Documentation : http://www.sbprojects.com/knowledge/ir/recs80.php
|
||||
|
||||
#define RECS80_MARK 158
|
||||
#define RECS80_ONE_SPACE 7426
|
||||
#define RECS80_ZERO_SPACE 4898
|
||||
#define RECS80_ONE_SPACE 7432
|
||||
#define RECS80_ZERO_SPACE 4902
|
||||
#define RECS80_BITS 12
|
||||
#define RECS80_BITS_DATA 9
|
||||
#define RECS80_ADDRESS_BITS 3
|
||||
#define RECS80_COMMAND_BITS 6
|
||||
|
||||
#if SEND_RECS80
|
||||
|
||||
void IRsend::sendRECS80 (uint8_t address, uint8_t address_nbit, uint8_t command, uint8_t command_nbit) {
|
||||
// address: 1 - 3 bits
|
||||
// command: 1 - 7 bits
|
||||
|
||||
void IRsend::sendRECS80 (uint16_t data) {
|
||||
// Set IR carrier frequency
|
||||
enableIROut(38);
|
||||
|
||||
@@ -21,11 +22,11 @@ void IRsend::sendRECS80 (uint8_t address, uint8_t address_nbit, uint8_t command,
|
||||
mark(RECS80_MARK);
|
||||
space(RECS80_ONE_SPACE);
|
||||
|
||||
// Address
|
||||
for (uint8_t mask = 1 << (address_nbit - 1); mask; mask >>=1) {
|
||||
// Data: address and command
|
||||
for (uint16_t mask = 1 << (RECS80_COMMAND_BITS + RECS80_ADDRESS_BITS - 1); mask; mask >>=1) {
|
||||
mark(RECS80_MARK);
|
||||
|
||||
if (address & mask) {
|
||||
if (data & mask) {
|
||||
space(RECS80_ONE_SPACE);
|
||||
} else {
|
||||
space(RECS80_ZERO_SPACE);
|
||||
@@ -33,18 +34,59 @@ void IRsend::sendRECS80 (uint8_t address, uint8_t address_nbit, uint8_t command,
|
||||
|
||||
}
|
||||
|
||||
// Command
|
||||
for (uint8_t mask = 1 << (command_nbit - 1); mask; mask >>=1) {
|
||||
mark(RECS80_MARK);
|
||||
|
||||
if (command & mask) {
|
||||
space(RECS80_ONE_SPACE);
|
||||
} else {
|
||||
space(RECS80_ZERO_SPACE);
|
||||
}
|
||||
|
||||
}
|
||||
mark(RECS80_MARK);
|
||||
space(0);
|
||||
}
|
||||
|
||||
|
||||
#endif // SEND_RECS80
|
||||
|
||||
#if DECODE_RECS80
|
||||
|
||||
bool IRrecv::decodeRECS80 (decode_results *results)
|
||||
{
|
||||
long data = 0;
|
||||
long offset = 1;
|
||||
|
||||
// Check that there is enough data
|
||||
if (irparams.rawlen < (2 * RECS80_BITS) - 2) {
|
||||
|
||||
DBG_PRINTLN("Not long enough");
|
||||
DBG_PRINTLN(irparams.rawlen);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initial mark and space
|
||||
if (!MATCH_MARK(results->rawbuf[offset++], RECS80_MARK)) return false;
|
||||
if (!MATCH_SPACE(results->rawbuf[offset++], RECS80_ONE_SPACE)) return false;
|
||||
|
||||
// Data: Address and command stored as one variable
|
||||
for (int i = 0; i < (RECS80_ADDRESS_BITS + RECS80_COMMAND_BITS); i++) {
|
||||
if (!MATCH_MARK(results->rawbuf[offset++], RECS80_MARK)) return false;
|
||||
|
||||
// One
|
||||
if (MATCH_MARK(results->rawbuf[offset], RECS80_ONE_SPACE))
|
||||
data = (data << 1) | 1;
|
||||
|
||||
// Zero
|
||||
else if (MATCH_MARK(results->rawbuf[offset], RECS80_ZERO_SPACE))
|
||||
data = (data << 1) | 0;
|
||||
|
||||
else return false;
|
||||
offset++;
|
||||
}
|
||||
|
||||
if (!MATCH_MARK(results->rawbuf[offset], RECS80_MARK)) return false;
|
||||
|
||||
// Success
|
||||
results->decode_type = RECS80;
|
||||
results->bits = RECS80_BITS_DATA;
|
||||
results->value = data;
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user