Skip to content

Commit

Permalink
add Support for sending Piooneer 64bit codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpalczewski committed Oct 6, 2018
1 parent 0417978 commit 8cc8af2
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/IRremoteESP8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@
#define DECODE_PANASONIC_AC true
#define SEND_PANASONIC_AC true

#define SEND_PIONEER true

#if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \
DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \
DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \
Expand Down Expand Up @@ -267,6 +269,7 @@ enum decode_type_t {
LUTRON,
ELECTRA_AC,
PANASONIC_AC,
PIONEER, // Technically not a protocol, but an encoding.
};

// Message lengths & required repeat values
Expand Down Expand Up @@ -332,6 +335,7 @@ const uint16_t kPanasonicBits = 48;
const uint32_t kPanasonicManufacturer = 0x4004;
const uint16_t kPanasonicAcStateLength = 27;
const uint16_t kPanasonicAcBits = kPanasonicAcStateLength * 8;
const uint16_t kPioneerBits = 64;
const uint16_t kProntoMinLength = 6;
const uint16_t kRC5RawBits = 14;
const uint16_t kRC5Bits = kRC5RawBits - 2;
Expand Down Expand Up @@ -420,6 +424,7 @@ const uint16_t kWhynterBits = 32;
#define TOSHIBA_AC_STATE_LENGTH kToshibaACStateLength
#define TROTEC_COMMAND_LENGTH kTrotecStateLength
#define WHYNTER_BITS kWhynterBits
#define PIONEER_BITS kPioneerBits

// Turn on Debugging information by uncommenting the following line.
// #define DEBUG 1
Expand Down
3 changes: 3 additions & 0 deletions src/IRsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@ void IRsend::send(uint16_t type, uint64_t data, uint16_t nbits) {
#endif
#if SEND_GICABLE
case GICABLE: sendGICable(data, nbits); break;
#endif
#if SEND_PIONEER
case PIONEER: sendPioneer(data, nbits); break;
#endif
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/IRsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ void send(uint16_t type, uint64_t data, uint16_t nbits);
uint16_t nbytes = kPanasonicAcStateLength,
uint16_t repeat = kNoRepeat);
#endif
#if (SEND_PIONEER)
void sendPioneer(uint64_t data, uint16_t nbits = kPioneerBits,
uint16_t repeat = kNoRepeat);
#endif

protected:
#ifdef UNIT_TEST
Expand Down
102 changes: 102 additions & 0 deletions src/ir_Pioneer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2009 Ken Shirriff
// Copyright 2017 David Conran
// Copyright 2018 Kamil Palczewski

#define __STDC_LIMIT_MACROS
#include <stdint.h>
#include <algorithm>
#include "IRrecv.h"
#include "IRsend.h"
#include "IRutils.h"
#include <Arduino.h>

// PPPP III OOO N N EEEE EEEE RRRR
// P P I O O NN N E E R R
// PPPP I O O N N N EEE EEE RRRR
// P I O O N NN E E R R
// P III OOO N N EEEE EEEE R RR

// NEC originally added from https://github.com/shirriff/Arduino-IRremote/

// Constants
// Ref:
// http://www.sbprojects.com/knowledge/ir/nec.php

const uint16_t kNecTick = 560;
const uint16_t kNecHdrMarkTicks = 16;
const uint16_t kNecHdrMark = kNecHdrMarkTicks * kNecTick;
const uint16_t kNecHdrSpaceTicks = 8;
const uint16_t kNecHdrSpace = kNecHdrSpaceTicks * kNecTick;
const uint16_t kNecBitMarkTicks = 1;
const uint16_t kNecBitMark = kNecBitMarkTicks * kNecTick;
const uint16_t kNecOneSpaceTicks = 3;
const uint16_t kNecOneSpace = kNecOneSpaceTicks * kNecTick;
const uint16_t kNecZeroSpaceTicks = 1;
const uint16_t kNecZeroSpace = kNecZeroSpaceTicks * kNecTick;
const uint16_t kPioneerCodeSeparatorTicks = 989;
const uint16_t kNecRptSpaceTicks = 4;
const uint16_t kNecRptSpace = kNecRptSpaceTicks * kNecTick;
const uint16_t kNecRptLength = 4;
const uint16_t kNecMinCommandLengthTicks = 193;
const uint32_t kNecMinCommandLength = kNecMinCommandLengthTicks * kNecTick;
const uint32_t kNecMinGap = kNecMinCommandLength -
(kNecHdrMark + kNecHdrSpace + kNECBits * (kNecBitMark + kNecOneSpace) +
kNecBitMark);
const uint16_t kNecMinGapTicks = kNecMinCommandLengthTicks -
(kNecHdrMarkTicks + kNecHdrSpaceTicks +
kNECBits * (kNecBitMarkTicks + kNecOneSpaceTicks) +
kNecBitMarkTicks);

#if (SEND_PIONEER)
// Send a raw NEC(Renesas) formatted message.
//
// Args:
// data: The message to be sent.
// nbits: The number of bits of the message to be sent. Typically kNECBits.
// repeat: The number of times the command is to be repeated.
//
// Status: STABLE / Known working.
//
// Ref:
// http://www.sbprojects.com/knowledge/ir/nec.php
void IRsend::sendPioneer(uint64_t data, uint16_t nbits, uint16_t repeat) {

// prepare codes
uint64_t NECcode1 = data;
uint64_t NECcode2;
NECcode1 >>= 32; // 1st code
NECcode2 = data & 0xffffffffUL; // 2nd code

// send 1st NEC code
sendGeneric(kNecHdrMark, kNecHdrSpace,
kNecBitMark, kNecOneSpace,
kNecBitMark, kNecZeroSpace,
kNecBitMark, kNecMinGap, kNecMinCommandLength,
NECcode1, nbits/2, 38, true, 0, // Repeats are handled later.
33);

// send space between the codes
sendGeneric(kNecBitMark, kPioneerCodeSeparatorTicks,
0, 0, 0, 0, //No actual data sent.
0, 0, 0,
0, 0, 38, true, 0, // Repeats are handled later.
33);

// send 2nd NEC code
sendGeneric(kNecHdrMark, kNecHdrSpace,
kNecBitMark, kNecOneSpace,
kNecBitMark, kNecZeroSpace,
kNecBitMark, kNecMinGap, kNecMinCommandLength,
NECcode2, nbits/2, 38, true, 0, // Repeats are handled later.
33);
// Optional command repeat sequence.

if (repeat)
sendGeneric(kNecHdrMark, kNecRptSpace,
0, 0, 0, 0, // No actual data sent.
kNecBitMark, kNecMinGap, kNecMinCommandLength,
0, 0, // No data to be sent.
38, true, repeat - 1, // We've already sent a one message.
33);
}
#endif

0 comments on commit 8cc8af2

Please sign in to comment.