Skip to content

Commit

Permalink
Added Kaseikyo Panasonic decode.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminJo committed Jul 15, 2022
1 parent 33abc2d commit f98b4bb
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 126 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ The **tone library (using timer 2) is still available**. You can use it alternat
https://www.mikrocontroller.net/topic/irmp-infrared-multi-protocol-decoder?goto=6996113#6996137
# Revision History
### Version 3.6.2
- Added Kaseikyo Panasonic decode.
### Version 3.6.1
- Fixed NO_LED_FEEDBACK_CODE bug.
Expand Down
97 changes: 35 additions & 62 deletions examples/AllProtocols/AllProtocols.ino
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,6 @@
*
*/

/*
* Activate the type of LCD you use
* Default is serial LCD with 2 rows of 16 characters (1602).
*/
//#define USE_PARALLEL_LCD
#if !defined(USE_PARALLEL_LCD) && !defined(USE_NO_LCD)
#define USE_SERIAL_LCD
#endif

/*
* Define the size of your LCD
*/
#if !defined(USE_2004_LCD)
#define USE_1602_LCD
#endif
//#define USE_2004_LCD

/*
* Imports and definitions for LCD
*/
#if defined(USE_SERIAL_LCD)
#include <LiquidCrystal_I2C.h> // Use an up to date library version which has the init method
#endif
#if defined(USE_PARALLEL_LCD)
#include <LiquidCrystal.h>
#endif

#if defined(USE_1602_LCD)
// definitions for a 1602 LCD
#define LCD_COLUMNS 16
#define LCD_ROWS 2
#endif
#if defined(USE_2004_LCD)
// definitions for a 2004 LCD
#define LCD_COLUMNS 20
#define LCD_ROWS 4
#endif


#include <Arduino.h>

#include "PinDefinitionsAndMore.h"
Expand Down Expand Up @@ -95,12 +56,32 @@

IRMP_DATA irmp_data;

#if defined(USE_SERIAL_LCD) && defined(USE_PARALLEL_LCD)
#error Cannot use parallel and serial LCD simultaneously
/*
* Activate the type of LCD you use
* Default is serial LCD with 2 rows of 16 characters (1602).
*/
//#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
#include <LiquidCrystal_I2C.h> // Use an up to date library version, which has the init method
#endif

#if defined(USE_SERIAL_LCD) || defined(USE_PARALLEL_LCD)
#define USE_LCD
/*
* Define the size of your LCD
*/
//#define USE_2004_LCD
#if defined(USE_2004_LCD)
// definitions for a 2004 LCD
#define LCD_COLUMNS 20
#define LCD_ROWS 4
#else
#define USE_1602_LCD
// definitions for a 1602 LCD
#define LCD_COLUMNS 16
#define LCD_ROWS 2
#endif

#if defined(USE_SERIAL_LCD)
Expand All @@ -110,21 +91,21 @@ LiquidCrystal_I2C myLCD(0x27, LCD_COLUMNS, LCD_ROWS); // set the LCD address to
LiquidCrystal myLCD(4, 5, 6, 7, 8, 9);
#endif

#if defined(__AVR__) && !(defined(__AVR_ATmega4809__) || defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__))
#if defined(USE_SERIAL_LCD) || defined(USE_PARALLEL_LCD)
#define USE_LCD
# if defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
// For cyclically display of VCC
#include "ADCUtils.hpp"
#define MILLIS_BETWEEN_VOLTAGE_PRINT 5000
uint32_t volatile sMillisOfLastVoltagePrint;
# endif
#endif

void handleReceivedIRData();
void irmp_result_print_LCD();
void printIRResultOnLCD();

bool volatile sIRMPDataAvailable = false;

#if defined(__AVR__) && !(defined(__AVR_ATmega4809__) || defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__))
uint32_t volatile sMillisOfLastVoltagePrint;
#endif

void setup()
{
Serial.begin(115200);
Expand All @@ -140,10 +121,10 @@ void setup()
irmp_register_complete_callback_function(&handleReceivedIRData);

Serial.print(F("Ready to receive IR signals of protocols: "));
irmp_print_active_protocols (&Serial);
irmp_print_active_protocols(&Serial);
Serial.println(F("at pin " STR(IRMP_INPUT_PIN)));

#if defined(__AVR__) && !(defined(__AVR_ATmega4809__) || defined(__AVR_ATtiny1616__) || defined(__AVR_ATtiny3216__) || defined(__AVR_ATtiny3217__))
#if defined(USE_LCD) && defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
getVCCVoltageMillivoltSimple(); // to initialize ADC mux and reference
#endif

Expand Down Expand Up @@ -179,14 +160,14 @@ void loop()
# if defined(USE_SERIAL_LCD)
disableIRTimerInterrupt(); // disable timer interrupt, since it disturbs the serial output
# endif
irmp_result_print_LCD();
printIRResultOnLCD();
# if defined(USE_SERIAL_LCD)
enableIRTimerInterrupt();
# endif
#endif
}

#if defined(__AVR__) && defined(ADATE)
#if defined(USE_LCD) && defined(__AVR__) && defined(ADCSRA) && defined(ADATE)
/*
* Periodically print VCC
*/
Expand All @@ -195,18 +176,12 @@ void loop()
sMillisOfLastVoltagePrint = millis();
uint16_t tVCC = getVCCVoltageMillivoltSimple();

Serial.print(F("VCC="));
Serial.print(tVCC);
Serial.println(F("mV"));

# if defined(USE_LCD)
myLCD.setCursor(10, 0);
myLCD.print(' ');
myLCD.print(tVCC / 1000);
myLCD.print('.');
myLCD.print(((tVCC + 5) / 10) % 100);
myLCD.print('V');
# endif
}
#endif
}
Expand Down Expand Up @@ -244,15 +219,14 @@ void handleReceivedIRData()
* 3 milliseconds for repeat output
*
*/
void irmp_result_print_LCD()
void printIRResultOnLCD()
{
#if defined(USE_LCD)
static uint8_t sLastProtocolIndex;
static uint16_t sLastProtocolAddress;

# if (LCD_ROWS >= 4)
static uint8_t sLastCommandPrintPosition = 13;

const uint8_t tStartRow = 2;

# else
Expand Down Expand Up @@ -285,7 +259,6 @@ void irmp_result_print_LCD()
* Show protocol name
*/
myLCD.setCursor(0, tStartRow);
myLCD.print(F("P="));
# if defined(__AVR__)
const char *tProtocolStringPtr = (char*) pgm_read_word(&irmp_protocol_names[irmp_data.protocol]);
myLCD.print((__FlashStringHelper*) (tProtocolStringPtr));
Expand Down
4 changes: 2 additions & 2 deletions src/TinyIRReceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ void handleReceivedTinyIRData(uint16_t aAddress, uint8_t aCommand, bool isRepeat
*/
#define lowerValue25Percent(aDuration) (aDuration - (aDuration / 4))
#define upperValue25Percent(aDuration) (aDuration + (aDuration / 4))
#define lowerValue(aDuration) (aDuration - (aDuration / 2))
#define upperValue(aDuration) (aDuration + (aDuration / 2))
#define lowerValue50Percent(aDuration) (aDuration / 2) // (aDuration - (aDuration / 2))
#define upperValue50Percent(aDuration) (aDuration + (aDuration / 2))

/*
* The states for the state machine
Expand Down
8 changes: 5 additions & 3 deletions src/TinyIRReceiver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* No parity check is done!
* On a completely received IR command, the user function handleReceivedIRData(uint16_t aAddress, uint8_t aCommand, bool isRepetition)
* is called in Interrupt context but with interrupts being enabled to enable use of delay() etc.
* is called in interrupt context but with interrupts being enabled to enable use of delay() etc.
* !!!!!!!!!!!!!!!!!!!!!!
* Functions called in interrupt context should be running as short as possible,
* so if you require longer action, save the data (address + command) and handle them in the main loop.
Expand Down Expand Up @@ -187,7 +187,8 @@ void IRPinChangeInterruptHandler(void)

else if (tState == IR_RECEIVER_STATE_WAITING_FOR_DATA_MARK) {
// Check data space length
if (tMicrosOfMarkOrSpace >= lowerValue(NEC_ZERO_SPACE) && tMicrosOfMarkOrSpace <= upperValue(NEC_ONE_SPACE)) {
if (tMicrosOfMarkOrSpace >= lowerValue50Percent(NEC_ZERO_SPACE)
&& tMicrosOfMarkOrSpace <= upperValue50Percent(NEC_ONE_SPACE)) {
// We have a valid bit here
tState = IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE;
if (tMicrosOfMarkOrSpace >= 2 * NEC_UNIT) {
Expand Down Expand Up @@ -228,7 +229,8 @@ void IRPinChangeInterruptHandler(void)

else if (tState == IR_RECEIVER_STATE_WAITING_FOR_DATA_SPACE) {
// Check data mark length
if (tMicrosOfMarkOrSpace >= lowerValue(NEC_BIT_MARK) && tMicrosOfMarkOrSpace <= upperValue(NEC_BIT_MARK)) {
if (tMicrosOfMarkOrSpace >= lowerValue50Percent(NEC_BIT_MARK)
&& tMicrosOfMarkOrSpace <= upperValue50Percent(NEC_BIT_MARK)) {
/*
* We have a valid mark here, check for transmission complete
*/
Expand Down
7 changes: 0 additions & 7 deletions src/irmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,6 @@ void irmp_register_complete_callback_function(void (*aCompleteCallbackFunction)(
# define IRMP_SUPPORT_MITSU_HEAVY_PROTOCOL 0
#endif

#if IRMP_SUPPORT_PANASONIC_PROTOCOL == 1 && IRMP_SUPPORT_KASEIKYO_PROTOCOL == 1
# warning PANASONIC protocol conflicts wih KASEIKYO, please enable only one of both protocols
# warning PANASONIC protocol disabled
# undef IRMP_SUPPORT_PANASONIC_PROTOCOL
# define IRMP_SUPPORT_PANASONIC_PROTOCOL 0
#endif

#if IRMP_SUPPORT_RC5_PROTOCOL == 1 && IRMP_SUPPORT_ORTEK_PROTOCOL == 1
# warning RC5 protocol conflicts wih ORTEK, please enable only one of both protocols
# warning ORTEK protocol disabled
Expand Down
Loading

0 comments on commit f98b4bb

Please sign in to comment.