IRremote
ir_BoseWave.hpp
Go to the documentation of this file.
1 /*
2  * ir_BoseWave.cpp
3  *
4  * Contains functions for receiving and sending Bose IR Protocol
5  *
6  * This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
7  *
8  */
9 #ifndef _IR_BOSEWAVE_HPP
10 #define _IR_BOSEWAVE_HPP
11 
12 // This block must be located after the includes of other *.hpp files
13 //#define LOCAL_DEBUG // This enables debug output only for this file - only for development
14 #include "LocalDebugLevelStart.h"
15 
19 //==============================================================================
20 // BBBB OOO SSSS EEEEE
21 // B B O O S E
22 // BB B O O SSS EEEE
23 // B B O O S E
24 // BBBB OOO SSSS EEEEE
25 //==============================================================================
26 // see http://lirc.sourceforge.net/remotes/bose/WAVERADIO
27 // see: https://www.mikrocontroller.net/articles/IRMP_-_english#BOSE
28 //
29 // Support for Bose Wave Radio CD initially provided by https://github.com/uvotguy.
30 //
31 // As seen on my oscilloscope, there is no repeat code. Instead, when I
32 // press and hold a button on my remote, it sends a command, makes a 51.2ms space,
33 // and resends the command again, and so on.
34 // 38 kHz, LSB first, 1 start bit + 8 bit data + 8 bit inverted data + 1 stop bit.
35 #define BOSEWAVE_BITS 16 // Command and inverted command
36 
37 #define BOSEWAVE_HEADER_MARK 1014 // 1014 are 39 clock periods (I counted 3 times!)
38 #define BOSEWAVE_HEADER_SPACE 1468 // 1468(measured), 1456 are 56 clock periods
39 #define BOSEWAVE_BIT_MARK 520 // 520 are 20 clock periods
40 #define BOSEWAVE_ZERO_SPACE 468 // 468 are 18 clock periods
41 #define BOSEWAVE_ONE_SPACE 1468 // 1468(measured), 1456 are 56 clock periods
42 
43 #define BOSEWAVE_REPEAT_PERIOD 75000
44 #define BOSEWAVE_REPEAT_DISTANCE 50000
45 #define BOSEWAVE_MAXIMUM_REPEAT_DISTANCE 62000
46 
50 
51 /************************************
52  * Start of send and decode functions
53  ************************************/
54 
55 void IRsend::sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats) {
56 
57  // send 8 command bits and then 8 inverted command bits LSB first
58  uint16_t tData = ((~aCommand) << 8) | aCommand;
59  sendPulseDistanceWidth_P(&BoseWaveProtocolConstants, tData, BOSEWAVE_BITS, aNumberOfRepeats);
60 }
61 
63 
64  if (!checkHeader_P(&BoseWaveProtocolConstants)) {
65  return false;
66  }
67 
68  // Check we have enough data +4 for initial gap, start bit mark and space + stop bit mark
69  if (decodedIRData.rawlen != (2 * BOSEWAVE_BITS) + 4) {
70  DEBUG_PRINT(F("Bose: Data length="));
72  DEBUG_PRINTLN(F(" is not 36"));
73  return false;
74  }
75 
76  decodePulseDistanceWidthData_P(&BoseWaveProtocolConstants, BOSEWAVE_BITS);
77 
78  // Stop bit
80  DEBUG_PRINTLN(F("Bose: Stop bit mark length is wrong"));
81  return false;
82  }
83 
84  // Success
85 // decodedIRData.flags = IRDATA_FLAGS_IS_LSB_FIRST; // Not required, since this is the start value
86  uint16_t tDecodedValue = decodedIRData.decodedRawData;
87  uint8_t tCommandNotInverted = tDecodedValue & 0xFF; // comes first and is in the lower bits (LSB first :-))
88  uint8_t tCommandInverted = tDecodedValue >> 8;
89  // parity check for command. Use this variant to avoid compiler warning "comparison of promoted ~unsigned with unsigned [-Wsign-compare]"
90  if ((tCommandNotInverted ^ tCommandInverted) != 0xFF) {
91  DEBUG_PRINTLN(F("Bose: Command and inverted command check failed"));
92  return false;
93  }
94  decodedIRData.command = tCommandNotInverted;
97 
98  // check for repeat
100 
101  return true;
102 }
103 
105 #include "LocalDebugLevelEnd.h"
106 
107 #endif // _IR_BOSEWAVE_HPP
MICROS_PER_TICK
#define MICROS_PER_TICK
microseconds per clock interrupt tick
Definition: IRremote.hpp:133
BOSEWAVE_HEADER_SPACE
#define BOSEWAVE_HEADER_SPACE
Definition: ir_BoseWave.hpp:38
IRData::numberOfBits
uint16_t numberOfBits
Number of bits received for data (address + command + parity) - to determine protocol length if diffe...
Definition: IRremoteInt.h:173
DEBUG_PRINT
#define DEBUG_PRINT(...)
Definition: LocalDebugLevelStart.h:79
IRsend::aNumberOfRepeats
void int_fast8_t aNumberOfRepeats
Definition: IRremoteInt.h:528
IRrecv::decodePulseDistanceWidthData_P
void decodePulseDistanceWidthData_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM, uint_fast8_t aNumberOfBits, IRRawlenType aStartOffset=3)
Definition: IRReceive.hpp:1112
MICROS_IN_ONE_MILLI
#define MICROS_IN_ONE_MILLI
Definition: IRremote.hpp:217
IRrecv::checkHeader_P
bool checkHeader_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM)
Definition: IRReceive.hpp:1228
IRsend::sendBoseWave
void sendBoseWave(uint8_t aCommand, int_fast8_t aNumberOfRepeats=NO_REPEATS)
Definition: ir_BoseWave.hpp:55
PROTOCOL_IS_PULSE_DISTANCE
#define PROTOCOL_IS_PULSE_DISTANCE
Definition: IRProtocol.h:151
BOSEWAVE
@ BOSEWAVE
Definition: IRProtocol.h:103
IRrecv::checkForRepeatSpaceTicksAndSetFlag
void checkForRepeatSpaceTicksAndSetFlag(uint16_t aMaximumRepeatSpaceTicks)
Definition: IRReceive.hpp:1248
PROGMEM
struct PulseDistanceWidthProtocolConstants const BoseWaveProtocolConstants PROGMEM
Definition: ir_BoseWave.hpp:47
LocalDebugLevelStart.h
BOSEWAVE_MAXIMUM_REPEAT_DISTANCE
#define BOSEWAVE_MAXIMUM_REPEAT_DISTANCE
Definition: ir_BoseWave.hpp:45
PulseDistanceWidthProtocolConstants
Definition: IRProtocol.h:139
IRsend::sendPulseDistanceWidth_P
void sendPulseDistanceWidth_P(PulseDistanceWidthProtocolConstants const *aProtocolConstantsPGM, IRDecodedRawDataType aData, uint_fast8_t aNumberOfBits, int_fast8_t aNumberOfRepeats)
Definition: IRSend.hpp:1158
BOSEWAVE_ZERO_SPACE
#define BOSEWAVE_ZERO_SPACE
Definition: ir_BoseWave.hpp:40
IRrecv::decodedIRData
IRData decodedIRData
Definition: IRremoteInt.h:401
BOSEWAVE_BIT_MARK
#define BOSEWAVE_BIT_MARK
Definition: ir_BoseWave.hpp:39
PROTOCOL_IS_LSB_FIRST
#define PROTOCOL_IS_LSB_FIRST
Definition: IRProtocol.h:157
BOSEWAVE_HEADER_MARK
#define BOSEWAVE_HEADER_MARK
Definition: ir_BoseWave.hpp:37
IRData::command
uint16_t command
Decoded command, Distance protocol (tMarkTicksShort << 8) | tSpaceTicksShort.
Definition: IRremoteInt.h:165
IRData::decodedRawData
IRDecodedRawDataType decodedRawData
Up to 32/64 bit decoded raw data, to be used for send<protocol>Raw functions.
Definition: IRremoteInt.h:167
BOSEWAVE_ONE_SPACE
#define BOSEWAVE_ONE_SPACE
Definition: ir_BoseWave.hpp:41
matchMark
bool matchMark(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros)
Compensate for marks exceeded by demodulator hardware.
Definition: IRReceive.hpp:1327
BOSEWAVE_KHZ
#define BOSEWAVE_KHZ
Definition: IRProtocol.h:167
BOSEWAVE_REPEAT_PERIOD
#define BOSEWAVE_REPEAT_PERIOD
Definition: ir_BoseWave.hpp:43
irparams_struct::rawbuf
IRRawbufType rawbuf[RAW_BUFFER_LENGTH]
raw data / tick counts per mark/space. With 8 bit we can only store up to 12.7 ms....
Definition: IRremoteInt.h:147
IRrecv::irparams
irparams_struct irparams
Definition: IRremoteInt.h:400
DEBUG_PRINTLN
#define DEBUG_PRINTLN(...)
Definition: LocalDebugLevelStart.h:80
IRrecv::decodeBoseWave
bool decodeBoseWave()
Definition: ir_BoseWave.hpp:62
IRData::rawlen
IRRawlenType rawlen
Counter of entries in rawbuf of last received frame.
Definition: IRremoteInt.h:182
BOSEWAVE_BITS
#define BOSEWAVE_BITS
Definition: ir_BoseWave.hpp:35
IRData::protocol
decode_type_t protocol
UNKNOWN, NEC, SONY, RC5, PULSE_DISTANCE, ...
Definition: IRremoteInt.h:163
IRsend::aCommand
void aCommand
Definition: IRremoteInt.h:617
LocalDebugLevelEnd.h