Analyzed Denon code table and therefore changed Denon from MSB to LSB first.

This commit is contained in:
Armin 2022-11-17 01:06:10 +01:00
parent 7892d5c33b
commit 2c234ebded
10 changed files with 235 additions and 125 deletions

View File

@ -24,6 +24,7 @@ See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-I
- Added TinyIRSender.hpp and MinimalSender example, renamed TinyReceiver.h to TinyIR.h.
- Added DISABLE_CODE_FOR_RECEIVER to save program memory and RAM if receiving functionality is not required.
- Extracted protocol functions used by receive and send to IRProtocol.hpp.
- Analyzed Denon code table and therefore changed Denon from MSB to LSB first.
## 3.9.0
- Improved documentation with the help of [ElectronicsArchiver}(https://github.com/ElectronicsArchiver).

View File

@ -60,27 +60,35 @@
//#define RECORD_GAP_MICROS 12000 // Activate it for some LG air conditioner protocols
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
//#define DECODE_NEC // Includes Apple and Onkyo
#include "PinDefinitionsAndMore.h" // Define macros for input and output pin etc.
#include <IRremote.hpp>
#if defined(APPLICATION_PIN)
#define DEBUG_BUTTON_PIN APPLICATION_PIN // if low, print timing for each received data set
#else
#define DEBUG_BUTTON_PIN 6
#endif
/*
* Activate the type of LCD you use
* Default is serial LCD with 2 rows of 16 characters (1602).
* Default is parallel LCD with 2 rows of 16 characters (1602).
* Serial LCD has the disadvantage, that the first repeat is not detected,
* because of the long lasting serial communication.
*/
//#define USE_NO_LCD
//#define USE_PARALLEL_LCD
#if defined(USE_PARALLEL_LCD)
#include "LiquidCrystal.h"
#elif !defined(USE_NO_LCD)
#define USE_SERIAL_LCD
#if defined(USE_SERIAL_LCD)
#include "LiquidCrystal_I2C.h" // Use an up to date library version, which has the init method
#elif !defined(USE_NO_LCD)
#include "LiquidCrystal.h"
#define USE_PARALLEL_LCD
#endif
#if defined(USE_PARALLEL_LCD)
#define DEBUG_BUTTON_PIN 11
#endif
#if !defined(DEBUG_BUTTON_PIN)
# if defined(APPLICATION_PIN)
#define DEBUG_BUTTON_PIN APPLICATION_PIN // if low, print timing for each received data set
# else
#define DEBUG_BUTTON_PIN 6
# endif
#endif
#if defined(USE_SERIAL_LCD) || defined(USE_PARALLEL_LCD)
@ -91,21 +99,26 @@
# if defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
// For cyclically display of VCC
#include "ADCUtils.hpp"
#define MILLIS_BETWEEN_VOLTAGE_PRINT 5000
#define MILLIS_BETWEEN_VOLTAGE_PRINT 5000
#define LCD_VOLTAGE_START_INDEX 11
uint32_t volatile sMillisOfLastVoltagePrint;
bool ProtocolStringOverwritesVoltage;
# endif
#define LCD_IR_COMMAND_START_INDEX 9
static uint8_t sLastProtocolIndex;
#endif
#endif // defined(USE_SERIAL_LCD) || defined(USE_PARALLEL_LCD)
#if defined(USE_SERIAL_LCD)
LiquidCrystal_I2C myLCD(0x27, LCD_COLUMNS, LCD_ROWS); // set the LCD address to 0x27 for a 20 chars and 2 line display
LiquidCrystal_I2C myLCD(0x27, LCD_COLUMNS, LCD_ROWS); // set the LCD address to 0x27 for a 16 chars and 2 line display
#endif
#if defined(USE_PARALLEL_LCD)
LiquidCrystal myLCD(4, 5, 6, 7, 8, 9);
//LiquidCrystal myLCD(7, 8, 3, 4, 5, 6);
#endif
void printIRResultOnLCD();
size_t printHex(uint16_t aHexByteValue);
void printSpaces(uint_fast8_t aNumberOfSpacesToPrint);
void setup() {
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
@ -127,9 +140,14 @@ void setup() {
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
Serial.print(F("Ready to receive IR signals of protocols: "));
printActiveIRProtocols (&Serial);
printActiveIRProtocols(&Serial);
Serial.println(F("at pin " STR(IR_RECEIVE_PIN)));
#if defined(USE_SERIAL_LCD)
Serial.println(
F("With serial LCD connection, the first repeat is not detected, because of the long lasting serial communication!"));
#endif
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
Serial.print(F("Debug button pin is "));
Serial.println(DEBUG_BUTTON_PIN);
@ -155,11 +173,11 @@ void setup() {
#endif
#if defined(USE_LCD)
myLCD.setCursor(0, 0);
myLCD.print(F("IRRemote v" VERSION_IRREMOTE));
myLCD.setCursor(0, 1);
myLCD.print(F(__DATE__));
#endif
}
void loop() {
@ -202,18 +220,15 @@ void loop() {
/*
* Periodically print VCC
*/
if (millis() - sMillisOfLastVoltagePrint > MILLIS_BETWEEN_VOLTAGE_PRINT) {
if (!ProtocolStringOverwritesVoltage && millis() - sMillisOfLastVoltagePrint > MILLIS_BETWEEN_VOLTAGE_PRINT) {
sMillisOfLastVoltagePrint = millis();
uint16_t tVCC = getVCCVoltageMillivoltSimple();
myLCD.setCursor(10, 0);
myLCD.print(' ');
myLCD.print(tVCC / 1000);
myLCD.print('.');
myLCD.print(((tVCC + 5) / 10) % 100);
char tVoltageString[5];
dtostrf(tVCC / 1000.0, 4, 2, tVoltageString);
myLCD.setCursor(LCD_VOLTAGE_START_INDEX, 0);
myLCD.print(tVoltageString);
myLCD.print('V');
sLastProtocolIndex = 0; // enable new printing of protocol
}
#endif
@ -229,70 +244,66 @@ void loop() {
*/
void printIRResultOnLCD() {
#if defined(USE_LCD)
static uint16_t sLastProtocolAddress;
static uint16_t sLastCommand;
static uint16_t sLastProtocolIndex;
static uint16_t sLastProtocolAddress = 4711;
static uint16_t sLastCommand = 0;
static uint8_t sLastCommandPrintPosition;
bool tDisplayWasCleared = false;
/*
* Print only if protocol or address has changed
*/
if (sLastProtocolIndex != IrReceiver.decodedIRData.protocol || sLastProtocolAddress != IrReceiver.decodedIRData.address) {
if (sLastProtocolIndex != IrReceiver.decodedIRData.protocol) {
sLastProtocolIndex = IrReceiver.decodedIRData.protocol;
sLastProtocolAddress = IrReceiver.decodedIRData.address;
myLCD.clear(); // includes a delay of 2 ms
tDisplayWasCleared = true;
/*
* Show protocol name
* Show protocol name and handle overwrite over Voltage
*/
myLCD.setCursor(0, 0);
myLCD.print(getProtocolString(IrReceiver.decodedIRData.protocol));
uint_fast8_t tProtocolStringLength = myLCD.print(getProtocolString(IrReceiver.decodedIRData.protocol));
# if defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
if (tProtocolStringLength > LCD_VOLTAGE_START_INDEX) {
// we overwrite the voltage -> clear rest of line and inhibit new printing of voltage
ProtocolStringOverwritesVoltage = true;
if (tProtocolStringLength < LCD_COLUMNS) {
printSpaces(LCD_COLUMNS - tProtocolStringLength);
}
} else {
ProtocolStringOverwritesVoltage = false;
printSpaces(LCD_VOLTAGE_START_INDEX - tProtocolStringLength);
}
# else
printSpaces(LCD_COLUMNS - tProtocolStringLength);
# endif
}
if (sLastProtocolAddress == 4711 || sLastProtocolAddress != IrReceiver.decodedIRData.address) {
sLastProtocolAddress = IrReceiver.decodedIRData.address;
/*
* Show address
*/
myLCD.setCursor(0, 1);
myLCD.print(F("A=0x"));
myLCD.print(IrReceiver.decodedIRData.address, HEX);
} else {
/*
* Show or clear repetition flag
*/
myLCD.setCursor(15, 1);
if (IrReceiver.decodedIRData.flags & (IRDATA_FLAGS_IS_REPEAT)) {
myLCD.print('R');
return; // Since it is a repetition, printed data has not changed
} else {
myLCD.print(' ');
}
myLCD.print(F("A="));
uint_fast8_t tAddressStringLength = printHex(IrReceiver.decodedIRData.address);
printSpaces((LCD_IR_COMMAND_START_INDEX - 2) - tAddressStringLength);
}
/*
* Command prefix
* Print command
*/
uint16_t tCommand = IrReceiver.decodedIRData.command;
// check if prefix position must change
if (tDisplayWasCleared || (sLastCommand > 0x100 && tCommand < 0x100) || (sLastCommand < 0x100 && tCommand > 0x100)) {
// Check if prefix position must change
if (sLastCommand == 0 || (sLastCommand > 0x100 && tCommand < 0x100) || (sLastCommand < 0x100 && tCommand > 0x100)) {
sLastCommand = tCommand;
/*
* Print prefix of command
*/
myLCD.setCursor(9, 1);
/*
* Print prefix for 8/16 bit commands
*/
if (tCommand >= 0x100) {
myLCD.print(F("0x"));
sLastCommandPrintPosition = 11;
// save 2 characters here
sLastCommandPrintPosition = 9;
} else {
myLCD.print(F("C=0x"));
sLastCommandPrintPosition = 13;
myLCD.setCursor(LCD_IR_COMMAND_START_INDEX, 1);
myLCD.print(F("C="));
sLastCommandPrintPosition = 11;
}
}
@ -300,12 +311,33 @@ void printIRResultOnLCD() {
* Command data
*/
myLCD.setCursor(sLastCommandPrintPosition, 1);
if (IrReceiver.decodedIRData.command < 0x10) {
// leading 0
myLCD.print('0');
printHex(tCommand);
/*
* Show or clear repetition flag
*/
if (IrReceiver.decodedIRData.flags & (IRDATA_FLAGS_IS_REPEAT)) {
myLCD.print('R');
return; // Since it is a repetition, printed data has not changed
} else {
myLCD.print(' ');
}
myLCD.print(tCommand, HEX);
#endif // defined(USE_LCD)
}
size_t printHex(uint16_t aHexByteValue) {
myLCD.print(F("0x"));
size_t tPrintSize = 2;
if (aHexByteValue < 0x10 || (aHexByteValue > 0x100 && aHexByteValue < 0x1000)) {
myLCD.print('0'); // leading 0
tPrintSize++;
}
return myLCD.print(aHexByteValue, HEX) + tPrintSize;
}
void printSpaces(uint_fast8_t aNumberOfSpacesToPrint) {
for (uint_fast8_t i = 0; i < aNumberOfSpacesToPrint; ++i) {
myLCD.print(' ');
}
}

View File

@ -10,9 +10,14 @@ inline size_t LiquidCrystal_I2C::write(uint8_t value) {
return 1;
}
#if !defined(USE_SOFT_I2C_MASTER) && __has_include("SoftI2CMasterConfig.h")
#define USE_SOFT_I2C_MASTER
#endif
#if defined(USE_SOFT_I2C_MASTER)
#define USE_SOFT_I2C_MASTER_H_AS_PLAIN_INCLUDE
#include "SoftI2CMaster.h"
//#define USE_SOFT_I2C_MASTER_H_AS_PLAIN_INCLUDE
#include "SoftI2CMasterConfig.h" // Include configuration for sources
#include "SoftI2CMaster.h" // include sources
#elif defined(USE_SOFT_WIRE)
#define USE_SOFTWIRE_H_AS_PLAIN_INCLUDE
#include "SoftWire.h"

View File

@ -0,0 +1,52 @@
START ../src/ReceiveDump.cpp from Nov 12 2022
Using library version 4.0.0
Ready to receive IR signals of protocols: NEC/NEC2/Onkyo/Apple, Panasonic/Kaseikyo, Denon/Sharp, Sony, RC5, RC6, LG, JVC, Samsung, Whynter, Lego Power Functions, Bosewave , MagiQuest, Universal Pulse Distance Width, Hash at pin 2
5000 us is the (minimum) gap, after which the start of a new IR packet is assumed
20 us are subtracted from all marks and added to all spaces for decoding
Protocol=Samsung Address=0x707 Command=0x4 Raw-Data=0xFB040707 32 bits LSB first
Send with: IrSender.sendSamsung(0x707, 0x4, <numberOfRepeats>);
Raw result in internal ticks (50 us) - with leading gap
rawData[68]:
-27948
+90,-84
+12,-32 +12,-32 +12,-32 +12,-11
+11,-11 +11,-11 +11,-11 +11,-11
+12,-32 +12,-32 +12,-32 +12,-10
+12,-10 +12,-10 +12,-10 +12,-11
+11,-11 +11,-11 +11,-33 +11,-11
+11,-11 +11,-11 +11,-11 +11,-11
+12,-32 +12,-32 +12,-10 +12,-32
+12,-32 +12,-32 +12,-32 +12,-32
+12
Sum: 1200
Raw result in microseconds - with leading gap
rawData[68]:
-1397400
+4500,-4200
+ 600,-1600 + 600,-1600 + 600,-1600 + 600,- 550
+ 550,- 550 + 550,- 550 + 550,- 550 + 550,- 550
+ 600,-1600 + 600,-1600 + 600,-1600 + 600,- 500
+ 600,- 500 + 600,- 500 + 600,- 500 + 600,- 550
+ 550,- 550 + 550,- 550 + 550,-1650 + 550,- 550
+ 550,- 550 + 550,- 550 + 550,- 550 + 550,- 550
+ 600,-1600 + 600,-1600 + 600,- 500 + 600,-1600
+ 600,-1600 + 600,-1600 + 600,-1600 + 600,-1600
+ 600
Sum: 60000
Result as internal ticks (50 us) array - compensated with MARK_EXCESS_MICROS=20
uint8_t rawTicks[67] = {90,84, 12,32, 12,32, 12,32, 12,11, 11,11, 11,11, 11,11, 11,11, 12,32, 12,32, 12,32, 12,10, 12,10, 12,10, 12,10, 12,11, 11,11, 11,11, 11,33, 11,11, 11,11, 11,11, 11,11, 11,11, 12,32, 12,32, 12,10, 12,32, 12,32, 12,32, 12,32, 12,32, 12}; // Protocol=Samsung Address=0x707 Command=0x4 Raw-Data=0xFB040707 32 bits LSB first
Result as microseconds array - compensated with MARK_EXCESS_MICROS=20
uint16_t rawData[67] = {4480,4220, 580,1620, 580,1620, 580,1620, 580,570, 530,570, 530,570, 530,570, 530,570, 580,1620, 580,1620, 580,1620, 580,520, 580,520, 580,520, 580,520, 580,570, 530,570, 530,570, 530,1670, 530,570, 530,570, 530,570, 530,570, 530,570, 580,1620, 580,1620, 580,520, 580,1620, 580,1620, 580,1620, 580,1620, 580,1620, 580}; // Protocol=Samsung Address=0x707 Command=0x4 Raw-Data=0xFB040707 32 bits LSB first
uint16_t address = 0x707;
uint16_t command = 0x4;
uint32_t data = 0xFB040707;
Pronto Hex as string
char prontoData[] = "0000 006D 0022 0000 00AE 00A1 0018 003D 0018 003D 0018 003D 0018 0014 0016 0014 0016 0014 0016 0014 0016 0014 0018 003D 0018 003D 0018 003D 0018 0012 0018 0012 0018 0012 0018 0012 0018 0014 0016 0014 0016 0014 0016 003F 0016 0014 0016 0014 0016 0014 0016 0014 0016 0014 0018 003D 0018 003D 0018 0012 0018 003D 0018 003D 0018 003D 0018 003D 0018 003D 0018 06C3 ";

View File

@ -337,26 +337,26 @@ rawData[100]:
Sum: 67700
Send Denon
Protocol=Denon Address=0x11 Command=0x76 Raw-Data=0x45D8 15 bits MSB first
Protocol=Denon Address=0x11 Command=0x76 Raw-Data=0xED1 15 bits LSB first
Send with: IrSender.sendDenon(0x11, 0x76, <numberOfRepeats>);
rawData[32]:
-1064700
+ 300,-1800 + 250,- 800 + 250,- 750 + 350,- 700
+ 300,-1800 + 250,- 800 + 250,-1800 + 300,-1750
+ 350,-1750 + 300,- 750 + 250,-1800 + 300,-1750
-1073050
+ 250,-1800 + 250,- 800 + 250,- 800 + 250,- 800
+ 250,-1800 + 250,- 850 + 200,-1800 + 300,-1750
+ 300,- 750 + 300,-1800 + 250,-1800 + 250,-1800
+ 300,- 750 + 300,- 750 + 250,- 800 + 250
Sum: 23100
Sum: 23050
Send Denon/Sharp variant
Protocol=Sharp Address=0x11 Command=0x76 Raw-Data=0x45DA 15 bits MSB first
Protocol=Sharp Address=0x11 Command=0x76 Raw-Data=0x4ED1 15 bits LSB first
Send with: IrSender.sendSharp(0x11, 0x76, <numberOfRepeats>);
rawData[32]:
-1025400
+ 300,-1750 + 300,- 750 + 300,- 750 + 300,- 750
+ 250,-1800 + 300,- 750 + 300,-1750 + 300,-1750
+ 300,-1800 + 300,- 700 + 350,-1750 + 300,-1750
+ 300,- 750 + 300,-1800 + 250,- 750 + 350
Sum: 24150
-1018800
+ 200,-1800 + 300,- 750 + 250,- 800 + 250,- 750
+ 300,-1800 + 250,- 800 + 250,-1800 + 300,-1750
+ 300,- 750 + 300,-1800 + 250,-1800 + 250,-1800
+ 300,- 750 + 300,- 750 + 300,-1800 + 250
Sum: 24050
Send Sony/SIRCS with 7 command and 5 address bits
Protocol=Sony Address=0x11 Command=0x76 Raw-Data=0x8F6 12 bits LSB first

View File

@ -121,11 +121,7 @@ void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintRepeatGap
}
if (aIRDataPtr->flags & IRDATA_FLAGS_TOGGLE_BIT) {
if (aIRDataPtr->protocol == NEC) {
aSerial->print(F(" Special repeat"));
} else {
aSerial->print(F(" Toggle=1"));
}
aSerial->print(F(" Toggle=1"));
}
#if defined(DECODE_DISTANCE_WIDTH)
}

View File

@ -298,7 +298,7 @@ public:
IRData decodedIRData; // New: decoded IR data for the application
// Last decoded IR data for repeat detection
// Last decoded IR data for repeat detection and parity for Denon autorepeat
decode_type_t lastDecodedProtocol;
uint32_t lastDecodedAddress;
uint32_t lastDecodedCommand;

View File

@ -55,19 +55,35 @@
// SSSS H H A A R R P
//==============================================================================
/*
Protocol=Sharp Address=0x11 Command=0x76 Raw-Data=0x45DA 15 bits MSB first
+ 300,-1750 + 300,- 750 + 300,- 750 + 300,- 750
+ 250,-1800 + 300,- 750 + 300,-1750 + 300,-1750
+ 300,-1800 + 300,- 700 + 350,-1750 + 300,-1750
+ 300,- 750 + 300,-1800 + 250,- 750 + 350
Sum: 24150
Protocol=Denon Address=0x11 Command=0x76 Raw-Data=0xED1 15 bits LSB first
+ 200,-1800 + 300,- 750 + 300,- 800 + 200,- 800
+ 250,-1800 + 250,- 800 + 250,-1800 + 300,-1750
+ 300,- 750 + 300,-1800 + 250,-1800 + 250,-1850
+ 250,- 750 + 300,- 800 + 250,- 800 + 250
Sum: 23050
Denon/Sharp variant
Protocol=Denon Address=0x11 Command=0x76 Raw-Data=0x4ED1 15 bits LSB first
+ 200,-1800 + 300,- 750 + 250,- 800 + 250,- 750
+ 300,-1800 + 250,- 800 + 250,-1800 + 300,-1750
+ 300,- 750 + 300,-1800 + 250,-1800 + 250,-1800
+ 300,- 750 + 300,- 750 + 300,-1800 + 250
Sum: 23050
*/
/*
* https://www.mikrocontroller.net/articles/IRMP_-_english#DENON
* Denon published all their IR codes:
* http://assets.denon.com/documentmaster/us/denon%20master%20ir%20hex.xls
* Example:
* 0000 006D 0000 0020 000A 001E 000A 0046 000A 001E 000A 001E 000A 001E // 5 address bits
* 000A 001E 000A 001E 000A 0046 000A 0046 000A 0046 000A 001E 000A 0046 000A 0046 // 8 command bits
* 000A 001E 000A 001E 000A 0679 // 2 frame bits 0,0 + stop bit + space for AutoRepeat
* 000A 001E 000A 0046 000A 001E 000A 001E 000A 001E // 5 address bits
* 000A 0046 000A 0046 000A 001E 000A 001E 000A 001E 000A 0046 000A 001E 000A 001E // 8 inverted command bits
* 000A 0046 000A 0046 000A 0679 // 2 frame bits 1,1 + stop bit + space for Repeat
* From analyzing the codes for Tuner preset 1 to 8 in tab Main Zone ID#1 it is obvious, that the protocol is LSB first at least for command.
* All Denon codes with 32 as 3. value use the Kaseyikyo Denon variant.
*/
// Denon publish all their IR codes:
// https://www.mikrocontroller.net/articles/IRMP_-_english#DENON
// http://assets.denon.com/documentmaster/us/denon%20master%20ir%20hex.xls
// Having looked at the official Denon Pronto sheet and reverse engineered
// the timing values from it, it is obvious that Denon have a range of
// different timings and protocols ...the values here work for my AVR-3801 Amp!
// MSB first, no start bit, 5 address + 8 command + 2 frame + 1 stop bit - each frame 2 times
// For autorepeat frame, command and frame bits are inverted
//
@ -90,7 +106,7 @@ Sum: 24150
#define DENON_HEADER_SPACE (3 * DENON_UNIT) // 780 // The length of the Header:Space
struct PulseDistanceWidthProtocolConstants DenonProtocolConstants = { DENON, DENON_KHZ, DENON_HEADER_MARK, DENON_HEADER_SPACE,
DENON_BIT_MARK, DENON_ONE_SPACE, DENON_BIT_MARK, DENON_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT, (DENON_REPEAT_PERIOD
DENON_BIT_MARK, DENON_ONE_SPACE, DENON_BIT_MARK, DENON_ZERO_SPACE, PROTOCOL_IS_LSB_FIRST, SEND_STOP_BIT, (DENON_REPEAT_PERIOD
/ MICROS_IN_ONE_MILLI), NULL };
/************************************
@ -103,15 +119,15 @@ void IRsend::sendSharp(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOf
void IRsend::sendDenon(uint8_t aAddress, uint8_t aCommand, int_fast8_t aNumberOfRepeats, bool aSendSharp) {
// Set IR carrier frequency
enableIROut(DENON_KHZ); // 38 kHz
enableIROut (DENON_KHZ); // 38 kHz
// Shift command and add frame marker
uint16_t tCommand = aCommand << DENON_FRAME_BITS; // the lowest bits are 00 for Denon and 10 for Sharp
// Add frame marker for sharp
uint16_t tCommand = aCommand;
if (aSendSharp) {
tCommand |= 0x02;
tCommand |= 0x0200; // the 2 upper bits are 00 for Denon and 10 for Sharp
}
uint16_t tData = tCommand | ((uint16_t) aAddress << (DENON_COMMAND_BITS + DENON_FRAME_BITS));
uint16_t tInvertedData = (tData ^ 0x03FF); // Command and frame (least 10 bits) are inverted
uint16_t tData = aAddress | ((uint16_t) tCommand << DENON_ADDRESS_BITS);
uint16_t tInvertedData = (tData ^ 0x7FE); // Command and frame (upper 10 bits) are inverted
uint_fast8_t tNumberOfCommands = aNumberOfRepeats + 1;
while (tNumberOfCommands > 0) {
@ -151,7 +167,7 @@ bool IRrecv::decodeDenon() {
return false;
}
// Read the bits in
// Try to decode as Denon protocol
if (!decodePulseDistanceWidthData(&DenonProtocolConstants, DENON_BITS, 1)) {
#if defined(LOCAL_DEBUG)
Serial.print(F("Denon: "));
@ -170,19 +186,24 @@ bool IRrecv::decodeDenon() {
}
// Success
decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST;
decodedIRData.command = decodedIRData.decodedRawData >> DENON_FRAME_BITS;
decodedIRData.address = decodedIRData.command >> DENON_COMMAND_BITS;
decodedIRData.address = decodedIRData.decodedRawData & 0x1F;
decodedIRData.command = decodedIRData.decodedRawData >> DENON_ADDRESS_BITS;
uint8_t tFrameBits = (decodedIRData.command >> 8) & 0x03;
decodedIRData.command &= 0xFF;
// check for autorepeated inverted command
// Check for (auto) repeat
if (decodedIRData.rawDataPtr->rawbuf[0] < ((DENON_AUTO_REPEAT_DISTANCE + (DENON_AUTO_REPEAT_DISTANCE / 4)) / MICROS_PER_TICK)) {
repeatCount++;
if ((decodedIRData.decodedRawData & 0x01) == 0x01) {
if (tFrameBits & 0x01) {
#if defined(LOCAL_DEBUG)
Serial.print(F("Denon: "));
Serial.println(F("Autorepeat received="));
#endif
// We are in the auto repeated frame with the inverted command
decodedIRData.flags = IRDATA_FLAGS_IS_AUTO_REPEAT | IRDATA_FLAGS_IS_MSB_FIRST;
decodedIRData.flags = IRDATA_FLAGS_IS_AUTO_REPEAT;
// Check parity of consecutive received commands. There is no parity in one data set.
if ((uint8_t) lastDecodedCommand != (uint8_t) (~decodedIRData.command)) {
if ((uint8_t) lastDecodedCommand != (uint8_t)(~decodedIRData.command)) {
decodedIRData.flags |= IRDATA_FLAGS_PARITY_FAILED;
#if defined(LOCAL_DEBUG)
Serial.print(F("Denon: "));
@ -198,17 +219,18 @@ bool IRrecv::decodeDenon() {
if (repeatCount > 1) {
decodedIRData.flags |= IRDATA_FLAGS_IS_REPEAT;
}
decodedIRData.protocol = DENON; // do not know how to detect sharp here :-(
} else {
repeatCount = 0;
if (tFrameBits == 1 || tFrameBits == 2) {
decodedIRData.protocol = SHARP;
} else {
decodedIRData.protocol = DENON;
}
}
decodedIRData.numberOfBits = DENON_BITS;
uint8_t tFrameBits = decodedIRData.decodedRawData & 0x03;
if (tFrameBits == 1 || tFrameBits == 2) {
decodedIRData.protocol = SHARP;
} else {
decodedIRData.protocol = DENON;
}
return true;
}
@ -227,7 +249,7 @@ void IRsend::sendDenonRaw(uint16_t aRawData, int_fast8_t aNumberOfRepeats) {
*/
void IRsend::sendDenon(unsigned long data, int nbits) {
// Set IR carrier frequency
enableIROut(DENON_KHZ);
enableIROut (DENON_KHZ);
#if !(defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny87__) || defined(__AVR_ATtiny167__))
Serial.println(
"The function sendDenon(data, nbits) is deprecated and may not work as expected! Use sendDenonRaw(data, NumberOfRepeats) or better sendDenon(Address, Command, NumberOfRepeats).");
@ -239,7 +261,7 @@ void IRsend::sendDenon(unsigned long data, int nbits) {
// Data
sendPulseDistanceWidthData(DENON_BIT_MARK, DENON_ONE_SPACE, DENON_BIT_MARK, DENON_ZERO_SPACE, data, nbits,
PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT);
PROTOCOL_IS_MSB_FIRST, SEND_STOP_BIT);
#if !defined(DISABLE_CODE_FOR_RECEIVER)
IrReceiver.restartAfterSend();
#endif
@ -268,7 +290,7 @@ bool IRrecv::decodeDenonOld(decode_results *aResults) {
return false;
}
// Read the bits in
// Try to decode as Denon protocol
if (!decodePulseDistanceWidthData(DENON_BITS, 3, DENON_BIT_MARK, 0, DENON_ONE_SPACE, DENON_ZERO_SPACE, PROTOCOL_IS_MSB_FIRST)) {
return false;
}

View File

@ -262,6 +262,7 @@ bool IRrecv::decodeNEC() {
return false;
}
// Try to decode as NEC protocol
if (!decodePulseDistanceWidthData(&NECProtocolConstants, NEC_BITS)) {
#if defined(LOCAL_DEBUG)
Serial.print(F("NEC: "));

View File

@ -49,9 +49,10 @@
/*
* Protocol=Sony Address=0x4B9 Command=0x7 Raw-Data=0x25C87 20 bits LSB first
+2550,- 400
// 7 command bits
+1300,- 450 +1350,- 450 +1300,- 450 + 700,- 450
+ 700,- 450 + 750,- 450 + 700,- 400
// 13 address bits
// (5,8,) 13 address bits
+1300,- 500
+ 700,- 450 + 700,- 450 +1300,- 500 +1300,- 450
+1300,- 450 + 700,- 450 +1350,- 400 + 750,- 450