Improved DistanceProtocol decoder output and minor changes

This commit is contained in:
Armin 2022-06-27 01:18:44 +02:00
parent 0c4d269e93
commit fe3bafe5f5
18 changed files with 153 additions and 159 deletions

View File

@ -386,7 +386,7 @@ Modify them by enabling / disabling them, or change the values if applicable.
| `USE_NO_SEND_PWM` | disabled | Use no carrier PWM, just simulate an **active low** receiver signal. Overrides `SEND_PWM_BY_TIMER` definition. |
| `USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN` | disabled | Use or simulate open drain output mode at send pin. **Attention, active state of open drain is LOW**, so connect the send LED between positive supply and send pin! |
| `EXCLUDE_EXOTIC_PROTOCOLS` | disabled | If activated, BOSEWAVE, WHYNTER and LEGO_PF are excluded in `decode()` and in sending with `IrSender.write()`. Saves up to 650 bytes program memory. |
| `EXCLUDE_UNIVERSAL_PROTOCOLS` | disabled | If activated, the universal decoder for pulse width or pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in `decode()`. Saves up to 1000 bytes program memory. |
| `EXCLUDE_UNIVERSAL_PROTOCOLS` | disabled | If activated, the universal decoder for pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in `decode()`. Saves up to 1000 bytes program memory. |
| `DECODE_<Protocol name>` | all | Selection of individual protocol(s) to be decoded. You can specify multiple protocols. See [here](https://github.com/Arduino-IRremote/Arduino-IRremote/blob/master/src/IRremote.hpp#L98-L121) |
| `MARK_EXCESS_MICROS` | 20 | MARK_EXCESS_MICROS is subtracted from all marks and added to all spaces before decoding, to compensate for the signal forming of different IR receiver modules. |
| `RECORD_GAP_MICROS` | 5000 | Minimum gap between IR transmissions, to detect the end of a protocol.<br/>Must be greater than any space of a protocol e.g. the NEC header space of 4500 µs.<br/>Must be smaller than any gap between a command and a repeat; e.g. the retransmission gap for Sony is around 24 ms.<br/>Keep in mind, that this is the delay between the end of the received command and the start of decoding. |

View File

@ -4,6 +4,7 @@ See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-I
## 3.7.1
- SendRaw now supports bufferlenght > 255.
- Improved DistanceProtocol decoder output.
## 3.7.0
- Changed TOLERANCE to TOLERANCE_FOR_DECODERS_MARK_OR_SPACE_MATCHING and documented it.
@ -56,7 +57,7 @@ See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-I
- Moved blink13() back to IRrecv class.
- Added Kaseikyo convenience functions like sendKaseikyo_Denon().
- Improved / adjusted LG protocol and added class Aircondition_LG based on real hardware supplied by makerspace 201 (https://wiki.hackerspaces.org/ZwoNullEins) from Cologne.
- Improved universal decoder for pulse width or pulse distance protocols to support more than 32 bits.
- Improved universal decoder for pulse distance protocols to support more than 32 bits.
- Added mbed support.
## 3.3.0
@ -64,7 +65,7 @@ See also the commit log at github: https://github.com/Arduino-IRremote/Arduino-I
- Fixed error for AVR timer1. Thanks to alexbarcelo.
- New example IRremoteExtensionTest.
- Enabled megaAVR 0-series devices.
- Added universal decoder for pulse width or pulse distance protocols.
- Added universal decoder for pulse distance protocols.
## 3.2.0
- Fix for ESP32 send Error, removed `USE_SOFT_SEND_PWM` macro.

View File

@ -29,6 +29,8 @@
#ifndef _IR_COMMAND_DISPATCHER_H
#define _IR_COMMAND_DISPATCHER_H
#include <stdint.h>
/*
* For command mapping file
*/

View File

@ -192,7 +192,7 @@ void sendCode(storedIRDataStruct *aIRDataToSend) {
IrSender.write(&aIRDataToSend->receivedIRData, DEFAULT_NUMBER_OF_REPEATS_TO_SEND);
Serial.print(F("Sent: "));
printIRResultShort(&Serial, &aIRDataToSend->receivedIRData);
printIRResultShort(&Serial, &aIRDataToSend->receivedIRData, false);
}
}

View File

@ -63,7 +63,6 @@
//#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 INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include <IRremote.hpp>
@ -80,9 +79,6 @@
#endif
void setup() {
#if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
pinMode(_IR_TIMING_TEST_PIN, OUTPUT);
#endif
#if FLASHEND >= 0x3FFF // For 16k flash or more, like ATtiny1604. Code does not fit in program memory of ATtiny85 etc.
pinMode(DEBUG_BUTTON_PIN, INPUT_PULLUP);
#endif

View File

@ -44,7 +44,6 @@
//#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 INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include <IRremote.hpp>

View File

@ -32,7 +32,7 @@
#include <Arduino.h>
// select only NEC and the universal decoder for pulse width or pulse distance protocols
// select only NEC and the universal decoder for pulse distance protocols
#define DECODE_NEC // Includes Apple and Onkyo
#define DECODE_DISTANCE // in case NEC is not received correctly
@ -42,7 +42,6 @@
//#define USE_NO_SEND_PWM
//#define NO_LED_FEEDBACK_CODE // saves 500 bytes program memory
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
#define INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include <IRremote.hpp>
@ -51,10 +50,6 @@
#define DELAY_AFTER_LOOP 5000
void setup() {
#if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
pinMode(_IR_TIMING_TEST_PIN, OUTPUT);
#endif
Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)
delay(4000); // To be able to connect Serial monitor after reset or power up and before first print out. Do not wait for an attached Serial Monitor!

View File

@ -50,11 +50,10 @@
//#define DECODE_MAGIQUEST
//#define DECODE_WHYNTER
//#define DECODE_DISTANCE // universal decoder for pulse width or pulse distance protocols
//#define DECODE_DISTANCE // universal decoder for pulse distance protocols
//#define DECODE_HASH // special decoder for all protocols
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
//#define INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
#include <Arduino.h>

View File

@ -39,10 +39,11 @@
//#define EXCLUDE_EXOTIC_PROTOCOLS
//#define SEND_PWM_BY_TIMER
//#define USE_NO_SEND_PWM
//#define NO_LED_FEEDBACK_CODE // saves 500 bytes program memory
#define NO_LED_FEEDBACK_CODE // saves 500 bytes program memory
#define MARK_EXCESS_MICROS 10 // Adapt it to your IR receiver module. See also IRremote.h.
//#define TRACE // For internal usage
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
#define INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols
#if FLASHEND >= 0x1FFF // For 8k flash or more, like ATtiny85
#define DECODE_DENON // Includes Sharp
@ -57,7 +58,7 @@
#define DECODE_SONY
#define DECODE_PANASONIC // the same as DECODE_KASEIKYO
#define DECODE_DISTANCE // universal decoder for pulse width or pulse distance protocols
#define DECODE_DISTANCE // universal decoder for pulse distance protocols
#define DECODE_HASH // special decoder for all protocols
#endif
@ -71,14 +72,6 @@
#define DECODE_WHYNTER
#endif
//#define SEND_PWM_BY_TIMER
//#define USE_NO_SEND_PWM
//#define _IR_MEASURE_TIMING
#define MARK_EXCESS_MICROS 10 // Adapt it to your IR receiver module. See also IRremote.h.
#define NO_LED_FEEDBACK_CODE // halves ISR duration
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
#define INFO // To see valuable informations from universal decoder for pulse width or pulse distance protocols
#include "PinDefinitionsAndMore.h" //Define macros for input and output pin etc.
#include <IRremote.hpp>
@ -97,9 +90,6 @@
void setup() {
pinMode(DEBUG_BUTTON_PIN, INPUT_PULLUP);
#if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
pinMode(_IR_TIMING_TEST_PIN, OUTPUT);
#endif
Serial.begin(115200);
#if defined(__AVR_ATmega32U4__) || defined(SERIAL_PORT_USBVIRTUAL) || defined(SERIAL_USB) /*stm32duino*/|| defined(USBCON) /*STM32_stm32*/|| defined(SERIALUSB_PID) || defined(ARDUINO_attiny3217)

View File

@ -105,6 +105,9 @@ void IRrecv::begin(uint_fast8_t aReceivePin, bool aEnableLEDFeedback, uint_fast8
// Set pin mode once
pinMode(irparams.IRReceivePin, INPUT);
#if defined(_IR_MEASURE_TIMING) && defined(_IR_TIMING_TEST_PIN)
pinMode(_IR_TIMING_TEST_PIN, OUTPUT);
#endif
start();
}
@ -356,7 +359,7 @@ bool IRrecv::decode() {
#endif
/*
* Try the universal decoder for pulse width or pulse distance protocols
* Try the universal decoder for pulse distance protocols
*/
#if defined(DECODE_DISTANCE)
IR_TRACE_PRINTLN(F("Attempting universal Distance decode"));
@ -854,13 +857,14 @@ void CheckForRecordGapsMicros(Print *aSerial, IRData *aIRDataPtr) {
* Check if protocol is not detected and detected space between two transmissions
* is smaller than known value for protocols (Sony with around 24 ms)
*/
if (aIRDataPtr->protocol <= PULSE_WIDTH && aIRDataPtr->rawDataPtr->rawbuf[0] < RECORD_GAP_MICROS_WARNING_THRESHOLD) {
if (aIRDataPtr->protocol <= PULSE_WIDTH
&& aIRDataPtr->rawDataPtr->rawbuf[0] < (RECORD_GAP_MICROS_WARNING_THRESHOLD / MICROS_PER_TICK)) {
aSerial->println();
aSerial->print(F("Space between two detected transmission is greater than "));
aSerial->print(RECORD_GAP_MICROS);
aSerial->print(F(" but smaller than the minimal gap of "));
aSerial->print(F("Space of "));
aSerial->print(aIRDataPtr->rawDataPtr->rawbuf[0] * MICROS_PER_TICK);
aSerial->print(F(" us between two detected transmission is smaller than the minimal gap of "));
aSerial->print(RECORD_GAP_MICROS_WARNING_THRESHOLD);
aSerial->println(F(" known for a protocol."));
aSerial->println(F(" us known for a protocol."));
aSerial->println(F("If you get unexpected results, try to increase the RECORD_GAP_MICROS in IRremote.h."));
aSerial->println();
}
@ -930,7 +934,7 @@ void printActiveIRProtocols(Print *aSerial) {
*
* @param aSerial The Print object on which to write, for Arduino you can use &Serial.
*/
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, unsigned int aLeadingSpaceTicks) {
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap) {
aSerial->print(F("Protocol="));
aSerial->print(getProtocolString(aIRDataPtr->protocol));
if (aIRDataPtr->protocol == UNKNOWN) {
@ -970,9 +974,9 @@ void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, unsigned int aLeadin
aSerial->print(F("Auto-"));
}
aSerial->print(F("Repeat"));
if (aLeadingSpaceTicks != 0) {
if (aPrintGap) {
aSerial->print(F(" gap="));
aSerial->print((uint32_t) aLeadingSpaceTicks * MICROS_PER_TICK);
aSerial->print((uint32_t) aIRDataPtr->rawDataPtr->rawbuf[0] * MICROS_PER_TICK);
aSerial->print(F("us"));
}
}
@ -1012,7 +1016,7 @@ void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, unsigned int aLeadin
* @param aSerial The Print object on which to write, for Arduino you can use &Serial.
*/
void IRrecv::printIRResultShort(Print *aSerial) {
::printIRResultShort(aSerial, &decodedIRData, decodedIRData.rawDataPtr->rawbuf[0]);
::printIRResultShort(aSerial, &decodedIRData, true);
}
/**

View File

@ -50,7 +50,7 @@
* - USE_NO_SEND_PWM Use no carrier PWM, just simulate an **active low** receiver signal. Overrides SEND_PWM_BY_TIMER definition.
* - USE_OPEN_DRAIN_OUTPUT_FOR_SEND_PIN Use or simulate open drain output mode at send pin. Attention, active state of open drain is LOW, so connect the send LED between positive supply and send pin!
* - EXCLUDE_EXOTIC_PROTOCOLS If activated, BOSEWAVE, WHYNTER and LEGO_PF are excluded in decode() and in sending with IrSender.write().
* - EXCLUDE_UNIVERSAL_PROTOCOLS If activated, the universal decoder for pulse width or pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in decode().
* - EXCLUDE_UNIVERSAL_PROTOCOLS If activated, the universal decoder for pulse distance protocols and decodeHash (special decoder for all protocols) are excluded in decode().
* - DECODE_* Selection of individual protocols to be decoded. See below.
* - MARK_EXCESS_MICROS Value is subtracted from all marks and added to all spaces before decoding, to compensate for the signal forming of different IR receiver modules.
* - RECORD_GAP_MICROS Minimum gap between IR transmissions, to detect the end of a protocol.
@ -58,7 +58,7 @@
* - NO_LED_FEEDBACK_CODE This completely disables the LED feedback code for send and receive.
* - IR_INPUT_IS_ACTIVE_HIGH Enable it if you use a RF receiver, which has an active HIGH output signal.
* - IR_SEND_DUTY_CYCLE_PERCENT Duty cycle of IR send signal.
* - MICROS_PER_TICK Resolution of the raw input buffer data. Corresponds to 2 pulses of each 26.3 µs at 38 kHz.
* - MICROS_PER_TICK Resolution of the raw input buffer data. Corresponds to 2 pulses of each 26.3 us at 38 kHz.
* - IR_USE_AVR_TIMER* Selection of timer to be used for generating IR receiving sample interval.
*/
@ -122,7 +122,7 @@
# endif
# if !defined(EXCLUDE_UNIVERSAL_PROTOCOLS)
#define DECODE_DISTANCE // universal decoder for pulse width or pulse distance protocols - requires up to 750 bytes additional program memory
#define DECODE_DISTANCE // universal decoder for pulse distance protocols - requires up to 750 bytes additional program memory
#define DECODE_HASH // special decoder for all protocols - requires up to 250 bytes additional program memory
# endif
# endif
@ -307,7 +307,7 @@
# if defined(DECODE_DENON ) // Includes Sharp
#include "ir_Denon.hpp"
# endif
# if defined(DECODE_DISTANCE) // universal decoder for pulse width or pulse distance protocols - requires up to 750 bytes additional program memory
# if defined(DECODE_DISTANCE) // universal decoder for pulse distance protocols - requires up to 750 bytes additional program memory
#include "ir_DistanceProtocol.hpp"
# endif
# if defined(DECODE_JVC)

View File

@ -97,24 +97,6 @@ struct irparams_struct {
unsigned int rawbuf[RAW_BUFFER_LENGTH]; ///< raw data / tick counts per mark/space, first entry is the length of the gap between previous and current command
};
/*
* Info directives for all sources not only local!
* Can be disabled to save program memory
*/
#if defined(INFO)
# define IR_INFO_PRINT(...) Serial.print(__VA_ARGS__)
# define IR_INFO_PRINTLN(...) Serial.println(__VA_ARGS__)
#else
/**
* If INFO, print the arguments, otherwise do nothing.
*/
# define IR_INFO_PRINT(...) void()
/**
* If INFO, print the arguments as a line, otherwise do nothing.
*/
# define IR_INFO_PRINTLN(...) void()
#endif
/*
* Debug directives
*/
@ -150,11 +132,11 @@ struct irparams_struct {
#define IRDATA_FLAGS_IS_REPEAT 0x01
#define IRDATA_FLAGS_IS_AUTO_REPEAT 0x02
#define IRDATA_FLAGS_PARITY_FAILED 0x04 ///< the current (autorepeat) frame violated parity check
#define IRDATA_TOGGLE_BIT_MASK 0x08
#define IRDATA_FLAGS_EXTRA_INFO 0x10 ///< there is unexpected extra info not contained in address and data (e.g. Kaseikyo unknown vendor ID)
#define IRDATA_TOGGLE_BIT_MASK 0x08 ///< is set if RC5 or RC6 toggle bit is set
#define IRDATA_FLAGS_EXTRA_INFO 0x10 ///< there is extra info not contained in address and data (e.g. Kaseikyo unknown vendor ID)
#define IRDATA_FLAGS_WAS_OVERFLOW 0x40 ///< irparams.rawlen is 0 in this case to avoid endless OverflowFlag
#define IRDATA_FLAGS_IS_LSB_FIRST 0x00
#define IRDATA_FLAGS_IS_MSB_FIRST 0x80 ///< Just for info. Value is simply determined by the protocol
#define IRDATA_FLAGS_IS_MSB_FIRST 0x80 ///< Just for info. Value is mainly determined by the protocol
/**
* Data structure for the user application, available as decodedIRData.
@ -164,10 +146,10 @@ struct IRData {
decode_type_t protocol; ///< UNKNOWN, NEC, SONY, RC5, ...
uint16_t address; ///< Decoded address
uint16_t command; ///< Decoded command
uint16_t extra; ///< Used by MagiQuest and for Kaseikyo unknown vendor ID. Ticks used for decoding Distance protocol.
uint16_t extra; ///< Contains MagiQuest magnitude, Kaseikyo unknown vendor ID and Distance protocol (SpaceTicksShort << 8) | SpaceTicksLong.
uint16_t numberOfBits; ///< Number of bits received for data (address + command + parity) - to determine protocol length if different length are possible.
uint8_t flags; ///< See IRDATA_FLAGS_* definitions above
uint32_t decodedRawData; ///< Up to 32 bit decoded raw data, used for sendRaw functions.
uint32_t decodedRawData; ///< Up to 32 bit decoded raw data, to be used for send functions.
irparams_struct *rawDataPtr; ///< Pointer of the raw timing data to be decoded. Mainly the data buffer filled by receiving ISR.
};
@ -183,8 +165,8 @@ struct decode_results {
bool isRepeat; // deprecated, moved to decodedIRData.flags ///< True if repeat of value is detected
// next 3 values are copies of irparams values - see IRremoteint.h
unsigned int *rawbuf; // deprecated, moved to decodedIRData.rawDataPtr->rawbuf ///< Raw intervals in 50uS ticks
uint_fast8_t rawlen; // deprecated, moved to decodedIRData.rawDataPtr->rawlen ///< Number of records in rawbuf
unsigned int *rawbuf; // deprecated, moved to decodedIRData.rawDataPtr->rawbuf ///< Raw intervals in 50uS ticks
uint_fast8_t rawlen; // deprecated, moved to decodedIRData.rawDataPtr->rawlen ///< Number of records in rawbuf
bool overflow; // deprecated, moved to decodedIRData.flags ///< true if IR raw code too long
};
@ -336,7 +318,7 @@ bool MATCH_SPACE(unsigned int measured_ticks, unsigned int desired_us);
int getMarkExcessMicros();
void printActiveIRProtocols(Print *aSerial);
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, unsigned int aLeadingSpaceDuration = 0);
void printIRResultShort(Print *aSerial, IRData *aIRDataPtr, bool aPrintGap);
/****************************************************
* Feedback LED related functions

View File

@ -105,7 +105,7 @@ union LGProtocol {
uint32_t Fan :3;
uint32_t FanExt :1;
uint32_t Temp :4;
uint32_t Mode :4;
uint32_t Mode :4; // highest bit 1 => Set temperature and ventilation by mode
uint32_t Function :3;
uint32_t SwitchOnMask :1; /* Content is 0 when switching from off to on */
uint32_t Signature :8; /* Content is 0x88, LG_ADDRESS */

View File

@ -1,7 +1,7 @@
/*
* ac_LG.hpp
*
* Contains functions for receiving and sending LG air conditioner IR Protocol
* Contains functions for sending LG air conditioner IR Protocol
* There is no state plausibility check, e.g. you can send fan speed in Mode D and change temperature in mode F
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
@ -9,7 +9,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2021 Armin Joachimsmeyer
* Copyright (c) 2021-2022 Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -34,7 +34,11 @@
#define _AC_LG_HPP
#include <Arduino.h>
//#define INFO // save program memory and suppress info output from the LG-AC driver.
#if defined(INFO) && !defined(LOCAL_INFO)
#define LOCAL_INFO
#else
//#define LOCAL_INFO // This enables info output only for this file
#endif
//#define DEBUG // for more output from the LG-AC driver.
#include "IRremoteInt.h"
#include "ac_LG.h" // useful constants
@ -59,8 +63,10 @@ const int AC_FAN_WALL[SIZE_OF_FAN_SPEED_MAPPING_TABLE] = { 0, 2, 4, 5 }; // 0 ->
void Aircondition_LG::setType(bool aIsWallType) {
ACIsWallType = aIsWallType;
IR_INFO_PRINT(F("Set wall type to "));
IR_INFO_PRINTLN(aIsWallType);
#if defined(LOCAL_INFO)
Serial.print(F("Set wall type to "));
Serial.println(aIsWallType);
#endif
}
void Aircondition_LG::printMenu(Print *aSerial) {
@ -245,10 +251,12 @@ bool Aircondition_LG::sendCommandAndParameter(char aCommand, int aParameter) {
void Aircondition_LG::sendIRCommand(uint16_t aCommand) {
IR_INFO_PRINT(F("Send code=0x"));
IR_INFO_PRINT(aCommand, HEX);
IR_INFO_PRINT(F(" | 0b"));
IR_INFO_PRINTLN(aCommand, BIN);
#if defined(LOCAL_INFO)
Serial.print(F("Send code=0x"));
Serial.print(aCommand, HEX);
Serial.print(F(" | 0b"));
Serial.println(aCommand, BIN);
#endif
IrSender.sendLG((uint8_t) LG_ADDRESS, aCommand, 0, false, useLG2Protocol);
}
@ -259,12 +267,14 @@ void Aircondition_LG::sendIRCommand(uint16_t aCommand) {
void Aircondition_LG::sendTemperatureFanSpeedAndMode() {
uint8_t tTemperature = Temperature;
IR_INFO_PRINT(F("Send temperature="));
IR_INFO_PRINT(tTemperature);
IR_INFO_PRINT(F(" fan intensity="));
IR_INFO_PRINT(FanIntensity);
IR_INFO_PRINT(F(" mode="));
IR_INFO_PRINTLN((char )Mode);
#if defined(LOCAL_INFO)
Serial.print(F("Send temperature="));
Serial.print(tTemperature);
Serial.print(F(" fan intensity="));
Serial.print(FanIntensity);
Serial.print(F(" mode="));
Serial.println((char )Mode);
#endif
WordUnion tIRCommand;
tIRCommand.UWord = 0;

View File

@ -51,7 +51,12 @@
#define DISTANCE_DO_MSB_DECODING PROTOCOL_IS_LSB_FIRST // this results in the same decodedRawData as e.g. the NEC and Kaseikyo/Panasonic decoder
//#define DISTANCE_DO_MSB_DECODING PROTOCOL_IS_MSB_FIRST // this resembles the JVC, Denon
//#define INFO // Activate this to save program memory and suppress info output.
#if defined(INFO) && !defined(LOCAL_INFO)
#define LOCAL_INFO
#else
#define LOCAL_INFO // This enables info output only for this file
#endif
//#define DEBUG // Activate this for lots of lovely debug output from this decoder.
#include "IRremoteInt.h" // evaluates the DEBUG for IR_DEBUG_PRINT
//#include "LongUnion.h"
@ -79,6 +84,9 @@ void printDurations(uint8_t aArray[], uint8_t aMaxIndex) {
}
#endif
/*
* @return false if more than 2 distinct duration values found
*/
bool aggregateArrayCounts(uint8_t aArray[], uint8_t aMaxIndex, uint8_t *aShortIndex, uint8_t *aLongIndex) {
uint8_t tSum = 0;
uint16_t tWeightedSum = 0;
@ -156,15 +164,17 @@ bool IRrecv::decodeDistance() {
*/
uint8_t tMarkTicksShort = 0;
uint8_t tMarkTicksLong = 0;
if (!aggregateArrayCounts(tDurationArray, tMaxDurationIndex, &tMarkTicksShort, &tMarkTicksLong)) {
IR_DEBUG_PRINT(F("PULSE_DISTANCE: "));
IR_DEBUG_PRINTLN(F("Mark aggregation failed, more than 2 distinct mark duration values found"));
}
bool tSuccess = aggregateArrayCounts(tDurationArray, tMaxDurationIndex, &tMarkTicksShort, &tMarkTicksLong);
#if defined(DEBUG)
Serial.println(F("Mark:"));
printDurations(tDurationArray, tMaxDurationIndex);
#endif
if (!tSuccess) {
IR_DEBUG_PRINT(F("PULSE_DISTANCE: "));
IR_DEBUG_PRINTLN(F("Mark aggregation failed, more than 2 distinct mark duration values found"));
}
// Reset duration array
memset(tDurationArray, 0, sizeof(tDurationArray));
@ -187,17 +197,18 @@ bool IRrecv::decodeDistance() {
*/
uint8_t tSpaceTicksShort = 0;
uint8_t tSpaceTicksLong = 0;
if (!aggregateArrayCounts(tDurationArray, tMaxDurationIndex, &tSpaceTicksShort, &tSpaceTicksLong)) {
IR_DEBUG_PRINT(F("PULSE_DISTANCE: "));
IR_DEBUG_PRINTLN(F("Space aggregation failed, more than 2 distinct space duration values found"));
return false;
}
tSuccess = aggregateArrayCounts(tDurationArray, tMaxDurationIndex, &tSpaceTicksShort, &tSpaceTicksLong);
#if defined(DEBUG)
Serial.println(F("Space:"));
printDurations(tDurationArray, tMaxDurationIndex);
#endif
if (!tSuccess) {
IR_DEBUG_PRINT(F("PULSE_DISTANCE: "));
IR_DEBUG_PRINTLN(F("Space aggregation failed, more than 2 distinct space duration values found"));
return false;
}
// skip leading start and trailing stop bit.
uint16_t tNumberOfBits = (decodedIRData.rawDataPtr->rawlen / 2) - 2;
decodedIRData.numberOfBits = tNumberOfBits;
@ -213,7 +224,7 @@ bool IRrecv::decodeDistance() {
* Kaseikyo: 48. 69, 35, 9, 0, 9, 26
* Sony: 12|15|20, 48, 12, 12, 24, 12, 0 // the only known pulse width protocol
*/
IR_DEBUG_PRINT(F("Protocol characteristic for a " STR(MICROS_PER_TICK) " us tick: "));
IR_DEBUG_PRINT(F("Protocol characteristics for a " STR(MICROS_PER_TICK) " us tick: "));
IR_DEBUG_PRINT(decodedIRData.numberOfBits);
IR_DEBUG_PRINT(F(", "));
IR_DEBUG_PRINT(decodedIRData.rawDataPtr->rawbuf[1]);
@ -256,30 +267,56 @@ bool IRrecv::decodeDistance() {
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
} else {
#if defined(LOCAL_INFO)
/*
* Print usage :-)
*/
if (i == 0) {
// Print protocol timing only once
IR_INFO_PRINTLN();
IR_INFO_PRINT(F("PULSE_DISTANCE:"));
IR_INFO_PRINT(F(" HeaderMarkMicros="));
IR_INFO_PRINT(decodedIRData.rawDataPtr->rawbuf[1] * MICROS_PER_TICK);
IR_INFO_PRINT(F(" HeaderSpaceMicros="));
IR_INFO_PRINT(decodedIRData.rawDataPtr->rawbuf[2] * MICROS_PER_TICK);
IR_INFO_PRINT(F(" MarkMicros="));
IR_INFO_PRINT(tMarkTicksShort * MICROS_PER_TICK);
IR_INFO_PRINT(F(" OneSpaceMicros="));
IR_INFO_PRINT(tSpaceTicksLong * MICROS_PER_TICK);
IR_INFO_PRINT(F(" ZeroSpaceMicros="));
IR_INFO_PRINT(tSpaceTicksShort * MICROS_PER_TICK);
IR_INFO_PRINT(F(" NumberOfBits="));
IR_INFO_PRINT(decodedIRData.numberOfBits);
IR_INFO_PRINT(F(" DecodedRawData:"));
// Print this only once
Serial.println();
Serial.println(F("PULSE_DISTANCE: Send with:"));
Serial.println(F(" IrSender.enableIROut(38);"));
Serial.print(F(" IrSender.mark("));
Serial.print(decodedIRData.rawDataPtr->rawbuf[1] * MICROS_PER_TICK);
Serial.println(F(");"));
Serial.print(F(" IrSender.space("));
Serial.print(decodedIRData.rawDataPtr->rawbuf[2] * MICROS_PER_TICK);
Serial.println(F(");"));
}
IR_INFO_PRINT(F(" 0x"));
IR_INFO_PRINT(decodedIRData.decodedRawData, HEX);
Serial.print(F(" IrSender.sendPulseDistanceWidthData("));
Serial.print(tMarkTicksShort * MICROS_PER_TICK); // aOneMarkMicros
Serial.print(F(", "));
Serial.print(tSpaceTicksLong * MICROS_PER_TICK); // aOneSpaceMicros
Serial.print(F(", "));
Serial.print(tMarkTicksShort * MICROS_PER_TICK); // aZeroMarkMicros
Serial.print(F(", "));
Serial.print(tSpaceTicksShort * MICROS_PER_TICK); // aZeroSpaceMicros
Serial.print(F(", 0x"));
Serial.print(decodedIRData.decodedRawData, HEX); // aData
if (tNumberOfBits < 32) {
Serial.print(F(", "));
Serial.print(tNumberOfBits); // aNumberOfBits
} else {
Serial.print(F(", 32"));
}
if (DISTANCE_DO_MSB_DECODING) {
Serial.print(F(", true, ")); // aMSBfirst
} else {
Serial.print(F(", false, ")); // aMSBfirst
}
if (i == tNumberOfAdditionalLong) {
Serial.println(F("true);")); // aSendStopBit - true for last data set
Serial.println();
} else {
Serial.println(F("false);"));// aSendStopBit
}
#endif
tStartIndex += 64;
tNumberOfBits -= 32;
}
IR_INFO_PRINTLN();
}
// Store ticks used for decoding in extra
@ -312,31 +349,9 @@ bool IRrecv::decodeDistance() {
IR_DEBUG_PRINTLN(F("Decode failed"));
return false;
}
if (i == 0) {
// Print protocol timing and length only once
IR_INFO_PRINTLN();
IR_INFO_PRINT(F("PULSE_WIDTH:"));
IR_INFO_PRINT(F(" HeaderMarkMicros="));
IR_INFO_PRINT(decodedIRData.rawDataPtr->rawbuf[1] * MICROS_PER_TICK);
IR_INFO_PRINT(F(" HeaderSpaceMicros="));
IR_INFO_PRINT(decodedIRData.rawDataPtr->rawbuf[2] * MICROS_PER_TICK);
IR_INFO_PRINT(F(" OneMarkMicros="));
IR_INFO_PRINT(tMarkTicksLong * MICROS_PER_TICK);
IR_INFO_PRINT(F(" ZeroMarkMicros="));
IR_INFO_PRINT(tMarkTicksShort * MICROS_PER_TICK);
IR_INFO_PRINT(F(" SpaceMicros="));
IR_INFO_PRINT(tSpaceTicksShort * MICROS_PER_TICK);
IR_INFO_PRINT(F(" NumberOfBits="));
IR_INFO_PRINT(decodedIRData.numberOfBits);
IR_INFO_PRINT(F(" DecodedRawData:"));
}
IR_INFO_PRINT(F(" 0x"));
IR_INFO_PRINT(decodedIRData.decodedRawData, HEX);
tStartIndex += 64;
tNumberOfBits -= 32;
}
IR_INFO_PRINTLN();
// Store ticks used for decoding in extra
decodedIRData.extra = (tMarkTicksShort << 8) | tMarkTicksLong;
@ -345,7 +360,9 @@ bool IRrecv::decodeDistance() {
}
if (DISTANCE_DO_MSB_DECODING) {
decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST;
decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST | IRDATA_FLAGS_EXTRA_INFO;
} else {
decodedIRData.flags = IRDATA_FLAGS_EXTRA_INFO;
}
return true;

View File

@ -49,15 +49,17 @@
// P A A N N A A SSSS OOO N N IIIII CCCC
//==============================================================================
// see: http://www.hifi-remote.com/johnsfine/DecodeIR.html#Panasonic and http://www.hifi-remote.com/johnsfine/DecodeIR.html#Kaseikyo
// 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}
// see: http://www.remotecentral.com/cgi-bin/mboard/rc-pronto/thread.cgi?26152
// The first two (8-bit) bytes are always 2 and 32 (These identify Panasonic within the Kaseikyo standard)
// The next two bytes are 4 independent 4-bit fields or Device and Subdevice
// The second to last byte is the function and the last byte is xor of the three bytes before it.
// 0_______ 1_______ 2______ 3_______ 4_______ 5
// 76543210 76543210 76543210 76543210 76543210 76543210
// 00000010 00100000 Dev____ Sub Dev Fun____ XOR( B2, B3, B4)
// LSB first, start bit + 16 Vendor + 4 Parity(of vendor) + 4 Genre1 + 4 Genre2 + 10 Command + 2 ID + 8 Parity + stop bit
// The first two (8-bit) bytes contains the vendor code.
// There are multiple interpretations of the next fields:
// 1. 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}
// 2. The next two bytes are 4 independent 4-bit fields or Device and Subdevice
// The second to last byte is the function and the last byte is xor of the three bytes before it.
// 0_______ 1_______ 2______ 3_______ 4_______ 5
// 76543210 76543210 76543210 76543210 76543210 76543210
// 00000010 00100000 Dev____ Sub Dev Fun____ XOR( B2, B3, B4)
// 3. LSB first, start bit + 16 Vendor + 4 Parity(of vendor) + 4 Genre1 + 4 Genre2 + 10 Command + 2 ID + 8 Parity + stop bit
//
// We reduce it to: start bit + 16 Vendor + 16 Address + 8 Command + 8 Parity + stop bit
//
#define KASEIKYO_VENDOR_ID_BITS 16
@ -247,8 +249,7 @@ bool IRrecv::decodeKaseikyo() {
if (tProtocol != KASEIKYO) {
decodedIRData.flags |= IRDATA_FLAGS_EXTRA_INFO;
// Include vendor ID in address
decodedIRData.extra |= tVendorId;
decodedIRData.extra = tVendorId; // Store vendor ID
}
if (tValue.UByte.HighByte != tParity) {

View File

@ -1,7 +1,7 @@
/*
* ir_MagiQuest.hpp
*
* Contains functions for receiving and sending LG IR Protocol in "raw" and standard format with 16 or 8 bit address and 8 bit command
* Contains functions for receiving and sending MagiQuest Protocol
* Based off the Magiquest fork of Arduino-IRremote by mpflaga https://github.com/mpflaga/Arduino-IRremote/
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
@ -9,7 +9,7 @@
************************************************************************************
* MIT License
*
* Copyright (c) 2017-2021 E. Stuart Hicks <ehicks@binarymagi.com>, Armin Joachimsmeyer
* Copyright (c) 2017-2022 E. Stuart Hicks <ehicks@binarymagi.com>, Armin Joachimsmeyer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -445,15 +445,13 @@ bool IRrecv::decodeRC6() {
}
} else {
// RC6A
decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST | IRDATA_FLAGS_EXTRA_INFO;
decodedIRData.flags = IRDATA_FLAGS_IS_MSB_FIRST;
if ((tValue.UByte.MidLowByte & 0x80) != 0) {
decodedIRData.flags = IRDATA_TOGGLE_BIT_MASK | IRDATA_FLAGS_IS_MSB_FIRST | IRDATA_FLAGS_EXTRA_INFO;
decodedIRData.flags = IRDATA_TOGGLE_BIT_MASK | IRDATA_FLAGS_IS_MSB_FIRST;
}
tValue.UByte.MidLowByte &= 0x87F; // mask toggle bit
decodedIRData.command = tValue.UByte.LowByte;
decodedIRData.address = tValue.UByte.MidLowByte;
// get extra info
decodedIRData.extra = tValue.UWord.HighWord;
}
// check for repeat, do not check toggle bit yet