Skip to content

Commit eb63c28

Browse files
authored
Merge pull request #3 from mrninhvn/master
Added support for Bluestar Heavy AC (crankyoldgit#2120)
2 parents b20108c + a5c6902 commit eb63c28

9 files changed

+112
-3
lines changed

src/IRrecv.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,10 @@ bool IRrecv::decode(decode_results *results, irparams_t *save,
13271327
DPRINTLN("Attempting York decode");
13281328
if (decodeYork(results, offset, kYorkBits)) return true;
13291329
#endif // DECODE_YORK
1330+
#if DECODE_BLUESTARHEAVY
1331+
DPRINTLN("Attempting BluestarHeavy decode");
1332+
if (decodeBluestarHeavy(results, offset, kBluestarHeavyBits)) return true;
1333+
#endif // DECODE_BLUESTARHEAVY
13301334
// Typically new protocols are added above this line.
13311335
}
13321336
#if DECODE_HASH

src/IRrecv.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,12 @@ class IRrecv {
913913
const uint16_t nbits = kYorkBits,
914914
const bool strict = true);
915915
#endif // DECODE_YORK
916+
#if DECODE_BLUESTARHEAVY
917+
bool decodeBluestarHeavy(decode_results *results,
918+
uint16_t offset = kStartOffset,
919+
const uint16_t nbits = kBluestarHeavyBits,
920+
const bool strict = true);
921+
#endif // DECODE_BLUESTARHEAVY
916922
};
917923

918924
#endif // IRRECV_H_

src/IRremoteESP8266.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,13 @@
959959
#define SEND_YORK _IR_ENABLE_DEFAULT_
960960
#endif // SEND_YORK
961961

962+
#ifndef DECODE_BLUESTARHEAVY
963+
#define DECODE_BLUESTARHEAVY _IR_ENABLE_DEFAULT_
964+
#endif // DECODE_BLUESTARHEAVY
965+
#ifndef SEND_BLUESTARHEAVY
966+
#define SEND_BLUESTARHEAVY _IR_ENABLE_DEFAULT_
967+
#endif // SEND_BLUESTARHEAVY
968+
962969
#if (DECODE_ARGO || DECODE_DAIKIN || DECODE_FUJITSU_AC || DECODE_GREE || \
963970
DECODE_KELVINATOR || DECODE_MITSUBISHI_AC || DECODE_TOSHIBA_AC || \
964971
DECODE_TROTEC || DECODE_HAIER_AC || DECODE_HITACHI_AC || \
@@ -977,7 +984,7 @@
977984
DECODE_KELON168 || DECODE_HITACHI_AC296 || DECODE_CARRIER_AC128 || \
978985
DECODE_DAIKIN200 || DECODE_HAIER_AC160 || DECODE_TCL96AC || \
979986
DECODE_BOSCH144 || DECODE_SANYO_AC152 || DECODE_DAIKIN312 || \
980-
DECODE_CARRIER_AC84 || DECODE_YORK || \
987+
DECODE_CARRIER_AC84 || DECODE_YORK || DECODE_BLUESTARHEAVY || \
981988
false)
982989
// Add any DECODE to the above if it uses result->state (see kStateSizeMax)
983990
// you might also want to add the protocol to hasACState function
@@ -1144,8 +1151,9 @@ enum decode_type_t {
11441151
WOWWEE,
11451152
CARRIER_AC84, // 125
11461153
YORK,
1154+
BLUESTARHEAVY,
11471155
// Add new entries before this one, and update it to point to the last entry.
1148-
kLastDecodeType = YORK,
1156+
kLastDecodeType = BLUESTARHEAVY,
11491157
};
11501158

11511159
// Message lengths & required repeat values
@@ -1172,6 +1180,8 @@ const uint16_t kArgo3TimerStateLength = 9; // Bytes
11721180
const uint16_t kArgo3ConfigStateLength = 4; // Bytes
11731181
const uint16_t kArgoDefaultRepeat = kNoRepeat;
11741182
const uint16_t kArrisBits = 32;
1183+
const uint16_t kBluestarHeavyStateLength = 13;
1184+
const uint16_t kBluestarHeavyBits = kBluestarHeavyStateLength * 8;
11751185
const uint16_t kBosch144StateLength = 18;
11761186
const uint16_t kBosch144Bits = kBosch144StateLength * 8;
11771187
const uint16_t kCoolixBits = 24;
@@ -1443,7 +1453,6 @@ const uint16_t kClimaButlerBits = 52;
14431453
const uint16_t kYorkBits = 136;
14441454
const uint16_t kYorkStateLength = 17;
14451455

1446-
14471456
// Legacy defines. (Deprecated)
14481457
#define AIWA_RC_T501_BITS kAiwaRcT501Bits
14491458
#define ARGO_COMMAND_LENGTH kArgoStateLength

src/IRsend.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,8 @@ uint16_t IRsend::defaultBits(const decode_type_t protocol) {
947947
return kXmpBits;
948948
case YORK:
949949
return kYorkBits;
950+
case BLUESTARHEAVY:
951+
return kBluestarHeavyBits;
950952
// No default amount of bits.
951953
case FUJITSU_AC:
952954
case MWM:
@@ -1583,6 +1585,11 @@ bool IRsend::send(const decode_type_t type, const uint8_t *state,
15831585
sendYork(state, nbytes);
15841586
break;
15851587
#endif // SEND_YORK
1588+
#if SEND_BLUESTARHEAVY
1589+
case BLUESTARHEAVY:
1590+
sendBluestarHeavy(state, nbytes);
1591+
break;
1592+
#endif // SEND_BLUESTARHEAVY
15861593
default:
15871594
return false;
15881595
}

src/IRsend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,11 @@ class IRsend {
899899
const uint16_t nbytes = kYorkStateLength,
900900
const uint16_t repeat = kNoRepeat);
901901
#endif // SEND_YORK
902+
#if SEND_BLUESTARHEAVY
903+
void sendBluestarHeavy(const unsigned char data[],
904+
const uint16_t nbytes = kBluestarHeavyStateLength,
905+
const uint16_t repeat = kNoRepeat);
906+
#endif // SEND_BLUESTARHEAVY
902907

903908
protected:
904909
#ifdef UNIT_TEST

src/IRtext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,8 @@ IRTEXT_CONST_BLOB_DECL(kAllProtocolNamesStr) {
559559
D_STR_CARRIER_AC84, D_STR_UNSUPPORTED) "\x0"
560560
COND(DECODE_YORK || SEND_YORK,
561561
D_STR_YORK, D_STR_UNSUPPORTED) "\x0"
562+
COND(DECODE_BLUESTARHEAVY || SEND_BLUESTARHEAVY,
563+
D_STR_BLUESTARHEAVY, D_STR_UNSUPPORTED) "\x0"
562564
///< New protocol (macro) strings should be added just above this line.
563565
"\x0" ///< This string requires double null termination.
564566
};

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: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// Copyright 2024 Harsh Bhosale (harshbhosale01)
2+
/// @file
3+
/// @brief Support for BluestarHeavy protocol
4+
5+
// Supports:
6+
// Brand: Bluestar, Model: D716LXM0535A2400313 (Remote)
7+
8+
#include "IRrecv.h"
9+
#include "IRsend.h"
10+
#include "IRutils.h"
11+
12+
const uint16_t kBluestarHeavyHdrMark = 4912;
13+
const uint16_t kBluestarHeavyBitMark = 465;
14+
const uint16_t kBluestarHeavyHdrSpace = 5058;
15+
const uint16_t kBluestarHeavyOneSpace = 572;
16+
const uint16_t kBluestarHeavyZeroSpace = 1548;
17+
const uint16_t kBluestarHeavyFreq = 38000;
18+
const uint16_t kBluestarHeavyOverhead = 3;
19+
20+
#if SEND_BLUESTARHEAVY
21+
/// Send a BluestarHeavy formatted message.
22+
/// Status: BETA / Tested.
23+
/// @param[in] data An array of bytes containing the IR command.
24+
/// It is assumed to be in MSB order for this code.
25+
/// e.g.
26+
/// @code
27+
/// uint8_t data[kBluestarHeavyStateLength] =
28+
/// {0x2A,0x00,0x20,0xD0,0x05,0xA0,0x05,0xA0,0x00,0x80,0xBA,0x02,0x23};
29+
/// @endcode
30+
/// @param[in] nbytes Nr. of bytes of data in the array.
31+
/// @param[in] repeat Nr. of times the message is to be repeated.
32+
void IRsend::sendBluestarHeavy(const uint8_t data[], const uint16_t nbytes,
33+
const uint16_t repeat) {
34+
sendGeneric(kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace,
35+
kBluestarHeavyBitMark, kBluestarHeavyOneSpace,
36+
kBluestarHeavyBitMark, kBluestarHeavyZeroSpace,
37+
kBluestarHeavyHdrMark, kDefaultMessageGap,
38+
data, nbytes, // Bytes
39+
kBluestarHeavyFreq, true, repeat, kDutyDefault);
40+
}
41+
#endif // SEND_BLUESTARHEAVY
42+
43+
#if DECODE_BLUESTARHEAVY
44+
/// Decode the supplied BluestarHeavy message.
45+
/// Status: BETA / Tested.
46+
/// @param[in,out] results Ptr to the data to decode & where to store the decode
47+
/// @param[in] offset The starting index to use when attempting to decode the
48+
/// raw data. Typically/Defaults to kStartOffset.
49+
/// @param[in] nbits The number of data bits to expect.
50+
/// @param[in] strict Flag indicating if we should perform strict matching.
51+
/// @return A boolean. True if it can decode it, false if it can't.
52+
bool IRrecv::decodeBluestarHeavy(decode_results *results, uint16_t offset,
53+
const uint16_t nbits, const bool strict) {
54+
if (strict && nbits != kBluestarHeavyBits)
55+
return false;
56+
57+
uint16_t used = 0;
58+
59+
used = matchGeneric(results->rawbuf + offset, results->state,
60+
results->rawlen - offset, nbits,
61+
kBluestarHeavyHdrMark, kBluestarHeavyHdrSpace,
62+
kBluestarHeavyBitMark, kBluestarHeavyOneSpace,
63+
kBluestarHeavyBitMark, kBluestarHeavyZeroSpace,
64+
kBluestarHeavyHdrMark, kDefaultMessageGap, true);
65+
if (used == 0) return false; // We failed to find any data.
66+
67+
// Success
68+
results->decode_type = decode_type_t::BLUESTARHEAVY;
69+
results->bits = nbits;
70+
return true;
71+
}
72+
#endif // DECODE_BLUESTARHEAVY

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

0 commit comments

Comments
 (0)