Skip to content

Commit bdeb13e

Browse files
Added support for IRsend for Bluestar Heavy AC
1 parent 702ec8b commit bdeb13e

File tree

8 files changed

+182
-4
lines changed

8 files changed

+182
-4
lines changed

src/IRremoteESP8266.h

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,13 @@
952952
#define SEND_YORK _IR_ENABLE_DEFAULT_
953953
#endif // SEND_YORK
954954

955+
#ifndef DECODE_BLUESTARHEAVY
956+
#define DECODE_BLUESTARHEAVY _IR_ENABLE_DEFAULT_
957+
#endif // DECODE_BLUESTARHEAVY
958+
#ifndef SEND_BLUESTARHEAVY
959+
#define SEND_BLUESTARHEAVY _IR_ENABLE_DEFAULT_
960+
#endif // SEND_BLUESTARHEAVY
961+
955962
#if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \
956963
DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \
957964
DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \
@@ -970,7 +977,7 @@
970977
DECODE_KELON168 || DECODE_HITACHI_AC296 || DECODE_CARRIER_AC128 || \
971978
DECODE_DAIKIN200 || DECODE_HAIER_AC160 || DECODE_TCL96AC || \
972979
DECODE_BOSCH144 || DECODE_SANYO_AC152 || DECODE_DAIKIN312 || \
973-
DECODE_CARRIER_AC84 || DECODE_YORK || \
980+
DECODE_CARRIER_AC84 || DECODE_YORK || DECODE_BLUESTARHEAVY || \
974981
false)
975982
// Add any DECODE to the above if it uses result->state (see kStateSizeMax)
976983
// you might also want to add the protocol to hasACState function
@@ -1136,9 +1143,9 @@ enum decode_type_t {
11361143
GORENJE,
11371144
WOWWEE,
11381145
CARRIER_AC84, // 125
1139-
YORK,
1146+
BLUESTARHEAVY,
11401147
// Add new entries before this one, and update it to point to the last entry.
1141-
kLastDecodeType = YORK,
1148+
kLastDecodeType = BLUESTARHEAVY,
11421149
};
11431150

11441151
// Message lengths & required repeat values
@@ -1165,6 +1172,8 @@ const uint16_t kArgo3TimerStateLength = 9; // Bytes
11651172
const uint16_t kArgo3ConfigStateLength = 4; // Bytes
11661173
const uint16_t kArgoDefaultRepeat = kNoRepeat;
11671174
const uint16_t kArrisBits = 32;
1175+
const uint16_t kBluestarHeavyStateLength = 13;
1176+
const uint16_t kBluestarHeavyBits = 104;
11681177
const uint16_t kBosch144StateLength = 18;
11691178
const uint16_t kBosch144Bits = kBosch144StateLength * 8;
11701179
const uint16_t kCoolixBits = 24;
@@ -1437,6 +1446,7 @@ const uint16_t kYorkBits = 136;
14371446
const uint16_t kYorkStateLength = 17;
14381447

14391448

1449+
14401450
// Legacy defines. (Deprecated)
14411451
#define AIWA_RC_T501_BITS kAiwaRcT501Bits
14421452
#define ARGO_COMMAND_LENGTH kArgoStateLength

src/IRsend.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
798798
return kXmpBits;
799799
case YORK:
800800
return kYorkBits;
801+
case BLUESTARHEAVY:
802+
return kBluestarHeavyBits;
801803
// No default amount of bits.
802804
case FUJITSU_AC:
803805
case MWM:
@@ -1434,6 +1436,11 @@ bool IRsend::send(const decode_type_t type, const uint8_t *state,
14341436
sendYork(state, nbytes);
14351437
break;
14361438
#endif // SEND_YORK
1439+
#if SEND_BLUESTARHEAVY
1440+
case BLUESTARHEAVY:
1441+
sendBluestarHeavy(state, nbytes);
1442+
break;
1443+
#endif // SEND_BLUESTARHEAVY
14371444
default:
14381445
return false;
14391446
}

src/IRsend.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,11 @@ class IRsend {
885885
const uint16_t nbytes = kYorkStateLength,
886886
const uint16_t repeat = kNoRepeat);
887887
#endif // SEND_YORK
888-
888+
#if SEND_BLUESTARHEAVY
889+
void sendBluestarHeavy(const unsigned char data[],
890+
const uint16_t nbytes = kBluestarHeavyStateLength,
891+
const uint16_t repeat = kNoRepeat);
892+
#endif // SEND_BLUESTARHEAVY
889893
protected:
890894
#ifdef UNIT_TEST
891895
#ifndef HIGH

src/IRtext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,8 @@ IRTEXT_CONST_BLOB_DECL(kAllProtocolNamesStr) {
555555
D_STR_CARRIER_AC84, D_STR_UNSUPPORTED) "\x0"
556556
COND(DECODE_YORK || SEND_YORK,
557557
D_STR_YORK, D_STR_UNSUPPORTED) "\x0"
558+
COND(DECODE_BLUESTARHEAVY || SEND_BLUESTARHEAVY,
559+
D_STR_BLUESTARHEAVY, D_STR_UNSUPPORTED) "\x0"
558560
///< New protocol (macro) strings should be added just above this line.
559561
"\x0" ///< This string requires double null termination.
560562
};

src/IRutils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ bool hasACState(const decode_type_t protocol) {
169169
// This is kept sorted by name
170170
case AMCOR:
171171
case ARGO:
172+
case BLUESTARHEAVY:
172173
case BOSCH144:
173174
case CARRIER_AC84:
174175
case CARRIER_AC128:

src/ir_BluestarHeavy.cpp

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
// Copyright 2020 David Conran (crankyoldgit)
2+
/// @file
3+
/// @brief Support for BluestarHeavy protocol
4+
5+
// Supports:
6+
// Brand: Bluestar, Model: TODO add device and remote
7+
8+
#include "IRrecv.h"
9+
#include "IRsend.h"
10+
#include "IRutils.h"
11+
12+
// WARNING: This probably isn't directly usable. It's a guide only.
13+
14+
// See https://github.com/crankyoldgit/IRremoteESP8266/wiki/Adding-support-for-a-new-IR-protocol
15+
// for details of how to include this in the library.
16+
const uint16_t kBluestarHeavyHdrMark = 4912;
17+
const uint16_t kBluestarHeavyBitMark = 465;
18+
const uint16_t kBluestarHeavyHdrSpace = 5058;
19+
const uint16_t kBluestarHeavyOneSpace = 1548;
20+
const uint16_t kBluestarHeavyZeroSpace = 572;
21+
const uint16_t kBluestarHeavyFreq = 38000; // Hz. (Guessing the most common frequency.)
22+
//const uint16_t kBluestarHeavyBits = 104; // Move to IRremoteESP8266.h
23+
//const uint16_t kBluestarHeavyStateLength = 13; // Move to IRremoteESP8266.h
24+
const uint16_t kBluestarHeavyOverhead = 3;
25+
// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work!
26+
27+
28+
#if SEND_BLUESTARHEAVY
29+
// Alternative >64bit function to send BLUESTARHEAVY messages
30+
// Function should be safe over 64 bits.
31+
/// Send a BluestarHeavy formatted message.
32+
/// Status: ALPHA / Untested.
33+
/// @param[in] data An array of bytes containing the IR command.
34+
/// It is assumed to be in MSB order for this code.
35+
/// e.g.
36+
/// @code
37+
/// uint8_t data[kBluestarHeavyStateLength] = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC};
38+
/// @endcode
39+
/// @param[in] nbytes Nr. of bytes of data in the array. (>=kBluestarHeavyStateLength)
40+
/// @param[in] repeat Nr. of times the message is to be repeated.
41+
void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes, const uint16_t repeat) {
42+
for (uint16_t r = 0; r <= repeat; r++) {
43+
uint16_t pos = 0;
44+
// Data Section #2
45+
// e.g.
46+
// bits = 104; bytes = 13;
47+
// *(data + pos) = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC};
48+
sendGeneric(kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace,
49+
kBluestarHeavyBitMark, kBluestarHeavyOneSpace,
50+
kBluestarHeavyBitMark, kBluestarHeavyZeroSpace,
51+
kBluestarHeavyHdrMark, kDefaultMessageGap,
52+
data + pos, 13, // Bytes
53+
kBluestarHeavyFreq, true, kNoRepeat, kDutyDefault);
54+
pos += 13; // Adjust by how many bytes of data we sent
55+
}
56+
}
57+
#endif // SEND_BLUESTARHEAVY
58+
59+
/*
60+
// DANGER: More than 64 bits detected. A uint64_t for 'data' won't work!
61+
#if DECODE_BLUESTARHEAVY
62+
// Function should be safe up to 64 bits.
63+
/// Decode the supplied BluestarHeavy message.
64+
/// Status: ALPHA / Untested.
65+
/// @param[in,out] results Ptr to the data to decode & where to store the decode
66+
/// @param[in] offset The starting index to use when attempting to decode the
67+
/// raw data. Typically/Defaults to kStartOffset.
68+
/// @param[in] nbits The number of data bits to expect.
69+
/// @param[in] strict Flag indicating if we should perform strict matching.
70+
/// @return A boolean. True if it can decode it, false if it can't.
71+
72+
73+
bool IRrecv::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) {
74+
if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset)
75+
return false; // Too short a message to match.
76+
if (strict && nbits != kBluestarHeavyBits)
77+
return false;
78+
79+
uint128_t data = 0;
80+
match_result_t data_result;
81+
82+
// Header
83+
if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark))
84+
return false;
85+
if (!matchSpace(results->rawbuf[offset++], kBluestarHeavyHdrSpace))
86+
return false;
87+
88+
// Data Section #1
89+
// e.g. data_result.data = 0xD5FED74FFA5FFA5FFF7F5CFDDC, nbits = 104
90+
data_result = matchData(&(results->rawbuf[offset]), 104,
91+
kBluestarHeavyBitMark, kBluestarHeavyOneSpace,
92+
kBluestarHeavyBitMark, kBluestarHeavyZeroSpace);
93+
offset += data_result.used;
94+
if (data_result.success == false) return false; // Fail
95+
data <<= 104; // Make room for the new bits of data.
96+
data |= data_result.data;
97+
98+
// Header
99+
if (!matchMark(results->rawbuf[offset++], kBluestarHeavyHdrMark))
100+
return false;
101+
102+
// Success
103+
results->decode_type = decode_type_t::BLUESTARHEAVY;
104+
results->bits = nbits;
105+
results->value = data;
106+
results->command = 0;
107+
results->address = 0;
108+
return true;
109+
}
110+
#endif // DECODE_BLUESTARHEAVY
111+
112+
#if DECODE_BLUESTARHEAVY
113+
// Function should be safe over 64 bits.
114+
/// Decode the supplied BluestarHeavy message.
115+
/// Status: ALPHA / Untested.
116+
/// @param[in,out] results Ptr to the data to decode & where to store the decode
117+
/// @param[in] offset The starting index to use when attempting to decode the
118+
/// raw data. Typically/Defaults to kStartOffset.
119+
/// @param[in] nbits The number of data bits to expect.
120+
/// @param[in] strict Flag indicating if we should perform strict matching.
121+
/// @return A boolean. True if it can decode it, false if it can't.
122+
bool IRrecv::decodeBluestarHeavy(decode_results *results, uint16_t offset, const uint16_t nbits, const bool strict) {
123+
if (results->rawlen < 2 * nbits + kBluestarHeavyOverhead - offset)
124+
return false; // Too short a message to match.
125+
if (strict && nbits != kBluestarHeavyBits)
126+
return false;
127+
128+
uint16_t pos = 0;
129+
uint16_t used = 0;
130+
131+
// Data Section #2
132+
// e.g.
133+
// bits = 104; bytes = 13;
134+
// *(results->state + pos) = {0xD5, 0xFE, 0xD7, 0x4F, 0xFA, 0x5F, 0xFA, 0x5F, 0xFF, 0x7F, 0x5C, 0xFD, 0xDC};
135+
used = matchGeneric(results->rawbuf + offset, results->state + pos,
136+
results->rawlen - offset, 104,
137+
kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace,
138+
kBluestarHeavyBitMark, kBluestarHeavyOneSpace,
139+
kBluestarHeavyBitMark, kBluestarHeavyZeroSpace,
140+
kBluestarHeavyHdrMark, kDefaultMessageGap, true);
141+
if (used == 0) return false; // We failed to find any data.
142+
offset += used; // Adjust for how much of the message we read.
143+
pos += 13; // Adjust by how many bytes of data we read
144+
145+
// Success
146+
results->decode_type = decode_type_t::BLUESTARHEAVY;
147+
results->bits = nbits;
148+
return true;
149+
}
150+
#endif // DECODE_BLUESTARHEAVY
151+
*/

src/locale/defaults.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,9 @@ D_STR_INDIRECT " " D_STR_MODE
751751
#ifndef D_STR_ARRIS
752752
#define D_STR_ARRIS "ARRIS"
753753
#endif // D_STR_ARRIS
754+
#ifndef D_STR_BLUESTARHEACY
755+
#define D_STR_BLUESTARHEAVY "BLUESTARHEAVY"
756+
#endif // D_STR_TESTEXAMPLE
754757
#ifndef D_STR_BOSCH
755758
#define D_STR_BOSCH "BOSCH"
756759
#endif // D_STR_BOSCH

test/ir_BluestarHeavy_test.cpp

Whitespace-only changes.

0 commit comments

Comments
 (0)