-
Notifications
You must be signed in to change notification settings - Fork 835
/
ir_Mitsubishi.cpp
1727 lines (1566 loc) · 68.8 KB
/
ir_Mitsubishi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2009 Ken Shirriff
// Copyright 2017-2021 David Conran
// Copyright 2019 Mark Kuchel
// Copyright 2018 Denes Varga
/// @file
/// @brief Support for Mitsubishi protocols.
/// Mitsubishi (TV) decoding added from https://github.com/z3t0/Arduino-IRremote
/// Mitsubishi (TV) sending & Mitsubishi A/C support added by David Conran
/// @see GlobalCache's Control Tower's Mitsubishi TV data.
/// @see https://github.com/marcosamarinho/IRremoteESP8266/blob/master/ir_Mitsubishi.cpp
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/441
/// @see https://github.com/r45635/HVAC-IR-Control/blob/master/HVAC_ESP8266/HVAC_ESP8266.ino#L84
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/619
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/888
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/947
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1398
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1399
/// @see https://github.com/kuchel77
#include "ir_Mitsubishi.h"
#include <algorithm>
#include <cstring>
#ifndef ARDUINO
#include <string>
#endif
#include "IRrecv.h"
#include "IRsend.h"
#include "IRtext.h"
#include "IRutils.h"
#include "ir_Tcl.h"
// Constants
// Mitsubishi TV
// period time is 1/33000Hz = 30.303 uSeconds (T)
const uint16_t kMitsubishiTick = 30;
const uint16_t kMitsubishiBitMarkTicks = 10;
const uint16_t kMitsubishiBitMark = kMitsubishiBitMarkTicks * kMitsubishiTick;
const uint16_t kMitsubishiOneSpaceTicks = 70;
const uint16_t kMitsubishiOneSpace = kMitsubishiOneSpaceTicks * kMitsubishiTick;
const uint16_t kMitsubishiZeroSpaceTicks = 30;
const uint16_t kMitsubishiZeroSpace =
kMitsubishiZeroSpaceTicks * kMitsubishiTick;
const uint16_t kMitsubishiMinCommandLengthTicks = 1786;
const uint16_t kMitsubishiMinCommandLength =
kMitsubishiMinCommandLengthTicks * kMitsubishiTick;
const uint16_t kMitsubishiMinGapTicks = 936;
const uint16_t kMitsubishiMinGap = kMitsubishiMinGapTicks * kMitsubishiTick;
// Mitsubishi Projector (HC3000)
const uint16_t kMitsubishi2HdrMark = 8400;
const uint16_t kMitsubishi2HdrSpace = kMitsubishi2HdrMark / 2;
const uint16_t kMitsubishi2BitMark = 560;
const uint16_t kMitsubishi2ZeroSpace = 520;
const uint16_t kMitsubishi2OneSpace = kMitsubishi2ZeroSpace * 3;
const uint16_t kMitsubishi2MinGap = 28500;
// Mitsubishi A/C
const uint16_t kMitsubishiAcHdrMark = 3400;
const uint16_t kMitsubishiAcHdrSpace = 1750;
const uint16_t kMitsubishiAcBitMark = 450;
const uint16_t kMitsubishiAcOneSpace = 1300;
const uint16_t kMitsubishiAcZeroSpace = 420;
const uint16_t kMitsubishiAcRptMark = 440;
const uint16_t kMitsubishiAcRptSpace = 15500;
const uint8_t kMitsubishiAcExtraTolerance = 5;
// Mitsubishi 136 bit A/C
const uint16_t kMitsubishi136HdrMark = 3324;
const uint16_t kMitsubishi136HdrSpace = 1474;
const uint16_t kMitsubishi136BitMark = 467;
const uint16_t kMitsubishi136OneSpace = 1137;
const uint16_t kMitsubishi136ZeroSpace = 351;
const uint32_t kMitsubishi136Gap = kDefaultMessageGap;
// Mitsubishi 112 bit A/C
const uint16_t kMitsubishi112HdrMark = 3450;
const uint16_t kMitsubishi112HdrSpace = 1696;
const uint16_t kMitsubishi112BitMark = 450;
const uint16_t kMitsubishi112OneSpace = 1250;
const uint16_t kMitsubishi112ZeroSpace = 385;
const uint32_t kMitsubishi112Gap = kDefaultMessageGap;
// Total tolerance percentage to use for matching the header mark.
const uint8_t kMitsubishi112HdrMarkTolerance = 5;
using irutils::addBoolToString;
using irutils::addFanToString;
using irutils::addIntToString;
using irutils::addLabeledString;
using irutils::addModeToString;
using irutils::addSwingHToString;
using irutils::addSwingVToString;
using irutils::addTempToString;
using irutils::addTempFloatToString;
using irutils::minsToString;
#if SEND_MITSUBISHI
/// Send the supplied Mitsubishi 16-bit message.
/// Status: STABLE / Working.
/// @param[in] data The message to be sent.
/// @param[in] nbits The number of bits of message to be sent.
/// @param[in] repeat The number of times the command is to be repeated.
/// @note This protocol appears to have no header.
/// @see https://github.com/marcosamarinho/IRremoteESP8266/blob/master/ir_Mitsubishi.cpp
/// @see GlobalCache's Control Tower's Mitsubishi TV data.
void IRsend::sendMitsubishi(uint64_t data, uint16_t nbits, uint16_t repeat) {
sendGeneric(0, 0, // No Header
kMitsubishiBitMark, kMitsubishiOneSpace, kMitsubishiBitMark,
kMitsubishiZeroSpace, kMitsubishiBitMark, kMitsubishiMinGap,
kMitsubishiMinCommandLength, data, nbits, 33, true, repeat, 50);
}
#endif // SEND_MITSUBISHI
#if DECODE_MITSUBISHI
/// Decode the supplied Mitsubishi 16-bit message.
/// Status: STABLE / Working.
/// @param[in,out] results Ptr to the data to decode & where to store the result
/// @param[in] offset The starting index to use when attempting to decode the
/// raw data. Typically/Defaults to kStartOffset.
/// @param[in] nbits The number of data bits to expect.
/// @param[in] strict Flag indicating if we should perform strict matching.
/// @return True if it can decode it, false if it can't.
/// @note This protocol appears to have no header.
/// @see GlobalCache's Control Tower's Mitsubishi TV data.
bool IRrecv::decodeMitsubishi(decode_results *results, uint16_t offset,
const uint16_t nbits, const bool strict) {
if (strict && nbits != kMitsubishiBits)
return false; // Request is out of spec.
uint64_t data = 0;
// Match Data + Footer
if (!matchGeneric(results->rawbuf + offset, &data,
results->rawlen - offset, nbits,
0, 0, // No header
kMitsubishiBitMark, kMitsubishiOneSpace,
kMitsubishiBitMark, kMitsubishiZeroSpace,
kMitsubishiBitMark, kMitsubishiMinGap,
true, 30)) return false;
// Success
results->decode_type = MITSUBISHI;
results->bits = nbits;
results->value = data;
results->address = 0;
results->command = 0;
return true;
}
#endif // DECODE_MITSUBISHI
#if SEND_MITSUBISHI2
/// Send a supplied second variant Mitsubishi 16-bit message.
/// Status: BETA / Probably works.
/// @param[in] data The message to be sent.
/// @param[in] nbits The number of bits of message to be sent.
/// @param[in] repeat The number of times the command is to be repeated.
/// @note Based on a Mitsubishi HC3000 projector's remote.
/// This protocol appears to have a mandatory in-protocol repeat.
/// That is in *addition* to the entire message needing to be sent twice
/// for the device to accept the command. That is separate from the repeat.
/// i.e. Allegedly, the real remote requires the "Off" button pressed twice.
/// You will need to add a suitable gap yourself.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/441
void IRsend::sendMitsubishi2(uint64_t data, uint16_t nbits, uint16_t repeat) {
for (uint16_t i = 0; i <= repeat; i++) {
// First half of the data.
sendGeneric(kMitsubishi2HdrMark, kMitsubishi2HdrSpace, kMitsubishi2BitMark,
kMitsubishi2OneSpace, kMitsubishi2BitMark,
kMitsubishi2ZeroSpace, kMitsubishi2BitMark,
kMitsubishi2HdrSpace, data >> (nbits / 2), nbits / 2, 33, true,
0, 50);
// Second half of the data.
sendGeneric(0, 0, // No header for the second data block
kMitsubishi2BitMark, kMitsubishi2OneSpace, kMitsubishi2BitMark,
kMitsubishi2ZeroSpace, kMitsubishi2BitMark, kMitsubishi2MinGap,
data & ((1 << (nbits / 2)) - 1), nbits / 2, 33, true, 0, 50);
}
}
#endif // SEND_MITSUBISHI2
#if DECODE_MITSUBISHI2
/// Decode the supplied second variation of a Mitsubishi 16-bit message.
/// Status: STABLE / Working.
/// @param[in,out] results Ptr to the data to decode & where to store the result
/// @param[in] offset The starting index to use when attempting to decode the
/// raw data. Typically/Defaults to kStartOffset.
/// @param[in] nbits The number of data bits to expect.
/// @param[in] strict Flag indicating if we should perform strict matching.
/// @return True if it can decode it, false if it can't.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/441
bool IRrecv::decodeMitsubishi2(decode_results *results, uint16_t offset,
const uint16_t nbits, const bool strict) {
if (results->rawlen <= 2 * nbits + kHeader + (kFooter * 2) - 1 + offset)
return false; // Shorter than shortest possibly expected.
if (strict && nbits != kMitsubishiBits)
return false; // Request is out of spec.
results->value = 0;
// Header
if (!matchMark(results->rawbuf[offset++], kMitsubishi2HdrMark)) return false;
if (!matchSpace(results->rawbuf[offset++], kMitsubishi2HdrSpace))
return false;
for (uint8_t i = 0; i < 2; i++) {
// Match Data + Footer
uint16_t used;
uint64_t data = 0;
used = matchGeneric(results->rawbuf + offset, &data,
results->rawlen - offset, nbits / 2,
0, 0, // No header
kMitsubishi2BitMark, kMitsubishi2OneSpace,
kMitsubishi2BitMark, kMitsubishi2ZeroSpace,
kMitsubishi2BitMark, kMitsubishi2HdrSpace,
i % 2);
if (!used) return false;
offset += used;
results->value <<= (nbits / 2);
results->value |= data;
}
// Success
results->decode_type = MITSUBISHI2;
results->bits = nbits;
results->address = GETBITS64(results->value, nbits / 2, nbits / 2);
results->command = GETBITS64(results->value, 0, nbits / 2);
return true;
}
#endif // DECODE_MITSUBISHI2
#if SEND_MITSUBISHI_AC
/// Send a Mitsubishi 144-bit A/C formatted message. (MITSUBISHI_AC)
/// Status: STABLE / Working.
/// @param[in] data The message to be sent.
/// @param[in] nbytes The number of bytes of message to be sent.
/// @param[in] repeat The number of times the command is to be repeated.
void IRsend::sendMitsubishiAC(const unsigned char data[], const uint16_t nbytes,
const uint16_t repeat) {
if (nbytes < kMitsubishiACStateLength)
return; // Not enough bytes to send a proper message.
sendGeneric(kMitsubishiAcHdrMark, kMitsubishiAcHdrSpace, kMitsubishiAcBitMark,
kMitsubishiAcOneSpace, kMitsubishiAcBitMark,
kMitsubishiAcZeroSpace, kMitsubishiAcRptMark,
kMitsubishiAcRptSpace, data, nbytes, 38, false, repeat, 50);
}
#endif // SEND_MITSUBISHI_AC
#if DECODE_MITSUBISHI_AC
/// Decode the supplied Mitsubish 144-bit A/C message.
/// Status: BETA / Probably works
/// @param[in,out] results Ptr to the data to decode & where to store the result
/// @param[in] offset The starting index to use when attempting to decode the
/// raw data. Typically/Defaults to kStartOffset.
/// @param[in] nbits The number of data bits to expect.
/// @param[in] strict Flag indicating if we should perform strict matching.
/// @see https://www.analysir.com/blog/2015/01/06/reverse-engineering-mitsubishi-ac-infrared-protocol/
bool IRrecv::decodeMitsubishiAC(decode_results *results, uint16_t offset,
const uint16_t nbits,
const bool strict) {
// Compliance
if (strict && nbits != kMitsubishiACBits) return false; // Out of spec.
// Do we need to look for a repeat?
const uint16_t expected_repeats = strict ? kMitsubishiACMinRepeat : kNoRepeat;
// Enough data?
if (results->rawlen <= (nbits * 2 + kHeader + kFooter) *
(expected_repeats + 1) + offset - 1) return false;
uint16_t save[kStateSizeMax];
// Handle repeats if we need too.
for (uint16_t r = 0; r <= expected_repeats; r++) {
// Header + Data + Footer
uint16_t used = matchGeneric(results->rawbuf + offset, results->state,
results->rawlen - offset, nbits,
kMitsubishiAcHdrMark, kMitsubishiAcHdrSpace,
kMitsubishiAcBitMark, kMitsubishiAcOneSpace,
kMitsubishiAcBitMark, kMitsubishiAcZeroSpace,
kMitsubishiAcRptMark, kMitsubishiAcRptSpace,
r < expected_repeats, // At least?
_tolerance + kMitsubishiAcExtraTolerance,
0, false);
if (!used) return false; // No match.
offset += used;
if (r) { // Is this a repeat?
// Repeats are expected to be exactly the same.
if (std::memcmp(save, results->state, nbits / 8) != 0) return false;
} else { // It is the first message.
// Compliance
if (strict) {
// Data signature check.
static const uint8_t signature[5] = {0x23, 0xCB, 0x26, 0x01, 0x00};
if (std::memcmp(results->state, signature, 5) != 0) return false;
// Checksum verification.
if (!IRMitsubishiAC::validChecksum(results->state)) return false;
}
// Save a copy of the state to compare with.
std::memcpy(save, results->state, nbits / 8);
}
}
// Success.
results->decode_type = MITSUBISHI_AC;
results->bits = nbits;
return true;
}
#endif // DECODE_MITSUBISHI_AC
// Code to emulate Mitsubishi A/C IR remote control unit.
// Inspired and derived from the work done at:
// https://github.com/r45635/HVAC-IR-Control
/// Class constructor
/// @param[in] pin GPIO to be used when sending.
/// @param[in] inverted Is the output signal to be inverted?
/// @param[in] use_modulation Is frequency modulation to be used?
/// @warning Consider this very alpha code. Seems to work, but not validated.
IRMitsubishiAC::IRMitsubishiAC(const uint16_t pin, const bool inverted,
const bool use_modulation)
: _irsend(pin, inverted, use_modulation) { stateReset(); }
/// Reset the state of the remote to a known good state/sequence.
void IRMitsubishiAC::stateReset(void) {
// The state of the IR remote in IR code form.
// Known good state obtained from:
// https://github.com/r45635/HVAC-IR-Control/blob/master/HVAC_ESP8266/HVAC_ESP8266.ino#L108
static const uint8_t kReset[kMitsubishiACStateLength] = {
0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x08, 0x06, 0x30, 0x45, 0x67};
setRaw(kReset);
}
/// Set up hardware to be able to send a message.
void IRMitsubishiAC::begin(void) { _irsend.begin(); }
#if SEND_MITSUBISHI_AC
/// Send the current internal state as an IR message.
/// @param[in] repeat Nr. of times the message will be repeated.
void IRMitsubishiAC::send(const uint16_t repeat) {
_irsend.sendMitsubishiAC(getRaw(), kMitsubishiACStateLength, repeat);
}
#endif // SEND_MITSUBISHI_AC
/// Get a PTR to the internal state/code for this protocol.
/// @return PTR to a code for this protocol based on the current internal state.
uint8_t *IRMitsubishiAC::getRaw(void) {
checksum();
return _.raw;
}
/// Set the internal state from a valid code for this protocol.
/// @param[in] data A valid code for this protocol.
void IRMitsubishiAC::setRaw(const uint8_t *data) {
std::memcpy(_.raw, data, kMitsubishiACStateLength);
}
/// Calculate and set the checksum values for the internal state.
void IRMitsubishiAC::checksum(void) {
_.Sum = calculateChecksum(_.raw);
}
/// Verify the checksum is valid for a given state.
/// @param[in] data The array to verify the checksum of.
/// @return true, if the state has a valid checksum. Otherwise, false.
bool IRMitsubishiAC::validChecksum(const uint8_t *data) {
return calculateChecksum(data) == data[kMitsubishiACStateLength - 1];
}
/// Calculate the checksum for a given state.
/// @param[in] data The value to calc the checksum of.
/// @return The calculated checksum value.
uint8_t IRMitsubishiAC::calculateChecksum(const uint8_t *data) {
return sumBytes(data, kMitsubishiACStateLength - 1);
}
/// Set the requested power state of the A/C to on.
void IRMitsubishiAC::on(void) { setPower(true); }
/// Set the requested power state of the A/C to off.
void IRMitsubishiAC::off(void) { setPower(false); }
/// Change the power setting.
/// @param[in] on true, the setting is on. false, the setting is off.
void IRMitsubishiAC::setPower(bool on) {
_.Power = on;
}
/// Get the value of the current power setting.
/// @return true, the setting is on. false, the setting is off.
bool IRMitsubishiAC::getPower(void) const {
return _.Power;
}
/// Set the temperature.
/// @param[in] degrees The temperature in degrees celsius.
/// @note The temperature resolution is 0.5 of a degree.
void IRMitsubishiAC::setTemp(const float degrees) {
// Make sure we have desired temp in the correct range.
float celsius = std::max(degrees, kMitsubishiAcMinTemp);
celsius = std::min(celsius, kMitsubishiAcMaxTemp);
// Convert to integer nr. of half degrees.
uint8_t nrHalfDegrees = celsius * 2;
// Do we have a half degree celsius?
_.HalfDegree = nrHalfDegrees & 1;
_.Temp = static_cast<uint8_t>(nrHalfDegrees / 2 - kMitsubishiAcMinTemp);
// If temp is modified, iSave10C cannot be ON (because temp is then > 10C)
setISave10C(false);
}
/// Get the current temperature setting.
/// @return The current setting for temp. in degrees celsius.
/// @note The temperature resolution is 0.5 of a degree.
float IRMitsubishiAC::getTemp(void) const {
return _.Temp + kMitsubishiAcMinTemp + (_.HalfDegree ? 0.5 : 0);
}
/// Set the speed of the fan.
/// @param[in] speed The desired setting. 0 is auto, 1-5 is speed, 6 is silent.
void IRMitsubishiAC::setFan(const uint8_t speed) {
uint8_t fan = speed;
// Bounds check
if (fan > kMitsubishiAcFanSilent)
fan = kMitsubishiAcFanMax; // Set the fan to maximum if out of range.
// Auto has a special bit.
_.FanAuto = (fan == kMitsubishiAcFanAuto);
if (fan >= kMitsubishiAcFanMax)
fan--; // There is no spoon^H^H^Heed 5 (max), pretend it doesn't exist.
_.Fan = fan;
}
/// Get the current fan speed setting.
/// @return The current fan speed/mode.
uint8_t IRMitsubishiAC::getFan(void) const {
uint8_t fan = _.Fan;
if (fan == kMitsubishiAcFanMax) return kMitsubishiAcFanSilent;
return fan;
}
/// Get the operating mode setting of the A/C.
/// @return The current operating mode setting.
uint8_t IRMitsubishiAC::getMode(void) const {
return _.Mode;
}
/// Set the operating mode of the A/C.
/// @param[in] mode The desired operating mode.
void IRMitsubishiAC::setMode(const uint8_t mode) {
// If we get an unexpected mode, default to AUTO.
switch (mode) {
case kMitsubishiAcAuto: _.raw[8] = 0b00110000; break;
case kMitsubishiAcCool: _.raw[8] = 0b00110110; break;
case kMitsubishiAcDry: _.raw[8] = 0b00110010; break;
case kMitsubishiAcHeat: _.raw[8] = 0b00110000; break;
case kMitsubishiAcFan: _.raw[8] = 0b00110111; break;
default:
_.raw[8] = 0b00110000;
_.Mode = kMitsubishiAcAuto;
return;
}
_.Mode = mode;
// iSave10C can only be on in Heat mode.
if (mode != kMitsubishiAcHeat) {
setISave10C(false);
}
}
/// Set the iSave10C (i-SAVE) mode of the A/C.
/// @param[in] state true, the setting is on. false, the setting is off.
/// @note Normal minimum temp is 16C; i-SAVE mode works as gate to enable AC
/// to use 10C as setting. However, when Remote control shows 10C, it still
/// emits 16C on the "Temp" bits, and instead it uses other bits to indicate
/// a target temp of 10C.
/// Slightly strange, but I guess it's to keep compatibility to systems
/// without i-SAVE.
/// i-SAVE only has this 10C functionality when the AC is already in Heat mode.
/// In all other modes, minimum temp is 16C.
/// I have found no other difference between normal Heat mode and i-SAVE
/// other than the ability to go to 10C.
/// In this implementation, i-SAVE mode is ONLY used to enable the AC
/// temperature setting to 10C. Therefore "Temp" is set to 16 disregarding
/// what the remote shows, and mode is set to Heat.
void IRMitsubishiAC::setISave10C(const bool state) {
if (state) setMode(kMitsubishiAcHeat);
if (state) setTemp(kMitsubishiAcMinTemp);
_.iSave10C = state;
}
/// Get the iSave10C (i-SAVE) mode of the A/C.
/// @return true, the setting is on. false, the setting is off.
bool IRMitsubishiAC::getISave10C(void) const {
return _.iSave10C;
}
/// Set the requested iSee mode.
/// @param[in] state requested iSee mode.
void IRMitsubishiAC::setISee(const bool state) {
_.ISee = state;
}
/// Get the iSee mode of the A/C.
/// @return The iSee mode setting.
bool IRMitsubishiAC::getISee(void) const {
return _.ISee;
}
/// Set the requested Ecocool mode.
/// @param[in] state requested Ecocool mode.
void IRMitsubishiAC::setEcocool(const bool state) {
_.Ecocool = state;
}
/// Get the Ecocool mode of the A/C.
/// @return The Ecocool mode setting.
bool IRMitsubishiAC::getEcocool(void) const {
return _.Ecocool;
}
/// Set the requested Absense Detect mode.
/// @param[in] state requested Absense Detect mode.
void IRMitsubishiAC::setAbsenseDetect(const bool state) {
_.AbsenseDetect = state;
}
/// Get the Absense Detect mode of the A/C.
/// @return The Absense Detect mode setting.
bool IRMitsubishiAC::getAbsenseDetect(void) const {
return _.AbsenseDetect;
}
/// Set the requested Direct/Indirect mode. Only works if I-See mode is ON.
/// @param[in] mode requested Direct/Indirect mode.
void IRMitsubishiAC::setDirectIndirect(const uint8_t mode) {
if (_.ISee) {
_.DirectIndirect = std::min(mode, kMitsubishiAcDirect); // bounds check
} else {
_.DirectIndirect = 0;
}
}
/// Get the Direct/Indirect mode of the A/C.
/// @return The native mode setting.
uint8_t IRMitsubishiAC::getDirectIndirect(void) const {
return _.DirectIndirect;
}
/// Set the requested Natural Flow mode.
/// @param[in] state requested Natural Flow mode.
void IRMitsubishiAC::setNaturalFlow(const bool state) {
_.NaturalFlow = state;
}
/// Get the Natural Flow mode of the A/C.
/// @return The Natural Flow mode setting.
bool IRMitsubishiAC::getNaturalFlow(void) const {
return _.NaturalFlow;
}
/// Set the requested vane (Vertical Swing) operation mode of the a/c unit.
/// @note On some models, this represents the Right vertical vane.
/// @param[in] position The position/mode to set the vane to.
void IRMitsubishiAC::setVane(const uint8_t position) {
uint8_t pos = std::min(position, kMitsubishiAcVaneAutoMove); // bounds check
_.VaneBit = 1;
_.Vane = pos;
}
/// Get the Vane (Vertical Swing) mode of the A/C.
/// @note On some models, this represents the Right vertical vane.
/// @return The native position/mode setting.
uint8_t IRMitsubishiAC::getVane(void) const {
return _.Vane;
}
/// Set the requested Left Vane (Vertical Swing) operation mode of the a/c unit.
/// @param[in] position The position/mode to set the vane to.
void IRMitsubishiAC::setVaneLeft(const uint8_t position) {
_.VaneLeft = std::min(position, kMitsubishiAcVaneAutoMove); // bounds check
}
/// Get the Left Vane (Vertical Swing) mode of the A/C.
/// @return The native position/mode setting.
uint8_t IRMitsubishiAC::getVaneLeft(void) const { return _.VaneLeft; }
/// Set the requested wide-vane (Horizontal Swing) operation mode of the a/c.
/// @param[in] position The position/mode to set the wide vane to.
void IRMitsubishiAC::setWideVane(const uint8_t position) {
_.WideVane = std::min(position, kMitsubishiAcWideVaneAuto);
}
/// Get the Wide Vane (Horizontal Swing) mode of the A/C.
/// @return The native position/mode setting.
uint8_t IRMitsubishiAC::getWideVane(void) const {
return _.WideVane;
}
/// Get the clock time of the A/C unit.
/// @return Nr. of 10 minute increments past midnight.
/// @note 1 = 1/6 hour (10 minutes). e.g. 4pm = 48.
uint8_t IRMitsubishiAC::getClock(void) const { return _.Clock; }
/// Set the clock time on the A/C unit.
/// @param[in] clock Nr. of 10 minute increments past midnight.
/// @note 1 = 1/6 hour (10 minutes). e.g. 6am = 36.
void IRMitsubishiAC::setClock(const uint8_t clock) {
_.Clock = clock;
}
/// Get the desired start time of the A/C unit.
/// @return Nr. of 10 minute increments past midnight.
/// @note 1 = 1/6 hour (10 minutes). e.g. 4pm = 48.
uint8_t IRMitsubishiAC::getStartClock(void) const { return _.StartClock; }
/// Set the desired start time of the A/C unit.
/// @param[in] clock Nr. of 10 minute increments past midnight.
/// @note 1 = 1/6 hour (10 minutes). e.g. 8pm = 120.
void IRMitsubishiAC::setStartClock(const uint8_t clock) {
_.StartClock = clock;
}
/// Get the desired stop time of the A/C unit.
/// @return Nr. of 10 minute increments past midnight.
/// @note 1 = 1/6 hour (10 minutes). e.g. 10pm = 132.
uint8_t IRMitsubishiAC::getStopClock(void) const { return _.StopClock; }
/// Set the desired stop time of the A/C unit.
/// @param[in] clock Nr. of 10 minute increments past midnight.
/// @note 1 = 1/6 hour (10 minutes). e.g. 10pm = 132.
void IRMitsubishiAC::setStopClock(const uint8_t clock) {
_.StopClock = clock;
}
/// Get the timers active setting of the A/C.
/// @return The current timers enabled.
/// @note Possible values: kMitsubishiAcNoTimer,
/// kMitsubishiAcStartTimer, kMitsubishiAcStopTimer,
/// kMitsubishiAcStartStopTimer
uint8_t IRMitsubishiAC::getTimer(void) const {
return _.Timer;
}
/// Set the timers active setting of the A/C.
/// @param[in] timer The timer code indicating which ones are active.
/// @note Possible values: kMitsubishiAcNoTimer,
/// kMitsubishiAcStartTimer, kMitsubishiAcStopTimer,
/// kMitsubishiAcStartStopTimer
void IRMitsubishiAC::setTimer(const uint8_t timer) {
_.Timer = timer;
}
/// Convert a stdAc::opmode_t enum into its native mode.
/// @param[in] mode The enum to be converted.
/// @return The native equivalent of the enum.
uint8_t IRMitsubishiAC::convertMode(const stdAc::opmode_t mode) {
switch (mode) {
case stdAc::opmode_t::kCool: return kMitsubishiAcCool;
case stdAc::opmode_t::kHeat: return kMitsubishiAcHeat;
case stdAc::opmode_t::kDry: return kMitsubishiAcDry;
case stdAc::opmode_t::kFan: return kMitsubishiAcFan;
default: return kMitsubishiAcAuto;
}
}
/// Convert a stdAc::fanspeed_t enum into it's native speed.
/// @param[in] speed The enum to be converted.
/// @return The native equivalent of the enum.
uint8_t IRMitsubishiAC::convertFan(const stdAc::fanspeed_t speed) {
switch (speed) {
case stdAc::fanspeed_t::kMin: return kMitsubishiAcFanSilent;
case stdAc::fanspeed_t::kLow: return kMitsubishiAcFanRealMax - 3;
case stdAc::fanspeed_t::kMedium: return kMitsubishiAcFanRealMax - 2;
case stdAc::fanspeed_t::kHigh: return kMitsubishiAcFanRealMax - 1;
case stdAc::fanspeed_t::kMax: return kMitsubishiAcFanRealMax;
default: return kMitsubishiAcFanAuto;
}
}
/// Convert a stdAc::swingv_t enum into it's native setting.
/// @param[in] position The enum to be converted.
/// @return The native equivalent of the enum.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1399
/// @see https://github.com/crankyoldgit/IRremoteESP8266/pull/1401
uint8_t IRMitsubishiAC::convertSwingV(const stdAc::swingv_t position) {
switch (position) {
case stdAc::swingv_t::kHighest: return kMitsubishiAcVaneHighest;
case stdAc::swingv_t::kHigh: return kMitsubishiAcVaneHigh;
case stdAc::swingv_t::kMiddle: return kMitsubishiAcVaneMiddle;
case stdAc::swingv_t::kLow: return kMitsubishiAcVaneLow;
case stdAc::swingv_t::kLowest: return kMitsubishiAcVaneLowest;
// These model Mitsubishi A/C have two automatic settings.
// 1. A typical up & down oscillation. (Native Swing)
// 2. The A/C determines where the best placement for the vanes, outside of
// user control. (Native Auto)
// Native "Swing" is what we consider "Auto" in stdAc. (Case 1)
case stdAc::swingv_t::kAuto: return kMitsubishiAcVaneSwing;
// Native "Auto" doesn't have a good match for this in stdAc. (Case 2)
// So we repurpose stdAc's "Off" (and anything else) to be Native Auto.
default: return kMitsubishiAcVaneAuto;
}
}
/// Convert a stdAc::swingh_t enum into it's native setting.
/// @param[in] position The enum to be converted.
/// @return The native equivalent of the enum.
uint8_t IRMitsubishiAC::convertSwingH(const stdAc::swingh_t position) {
switch (position) {
case stdAc::swingh_t::kLeftMax: return kMitsubishiAcWideVaneLeftMax;
case stdAc::swingh_t::kLeft: return kMitsubishiAcWideVaneLeft;
case stdAc::swingh_t::kMiddle: return kMitsubishiAcWideVaneMiddle;
case stdAc::swingh_t::kRight: return kMitsubishiAcWideVaneRight;
case stdAc::swingh_t::kRightMax: return kMitsubishiAcWideVaneRightMax;
case stdAc::swingh_t::kWide: return kMitsubishiAcWideVaneWide;
case stdAc::swingh_t::kAuto: return kMitsubishiAcWideVaneAuto;
default: return kMitsubishiAcWideVaneMiddle;
}
}
/// Convert a native mode into its stdAc equivalent.
/// @param[in] mode The native setting to be converted.
/// @return The stdAc equivalent of the native setting.
stdAc::opmode_t IRMitsubishiAC::toCommonMode(const uint8_t mode) {
switch (mode) {
case kMitsubishiAcCool: return stdAc::opmode_t::kCool;
case kMitsubishiAcHeat: return stdAc::opmode_t::kHeat;
case kMitsubishiAcDry: return stdAc::opmode_t::kDry;
case kMitsubishiAcFan: return stdAc::opmode_t::kFan;
default: return stdAc::opmode_t::kAuto;
}
}
/// Convert a native fan speed into its stdAc equivalent.
/// @param[in] speed The native setting to be converted.
/// @return The stdAc equivalent of the native setting.
stdAc::fanspeed_t IRMitsubishiAC::toCommonFanSpeed(const uint8_t speed) {
switch (speed) {
case kMitsubishiAcFanRealMax: return stdAc::fanspeed_t::kMax;
case kMitsubishiAcFanRealMax - 1: return stdAc::fanspeed_t::kHigh;
case kMitsubishiAcFanRealMax - 2: return stdAc::fanspeed_t::kMedium;
case kMitsubishiAcFanRealMax - 3: return stdAc::fanspeed_t::kLow;
case kMitsubishiAcFanSilent: return stdAc::fanspeed_t::kMin;
default: return stdAc::fanspeed_t::kAuto;
}
}
/// Convert a native vertical swing postion to it's common equivalent.
/// @param[in] pos A native position to convert.
/// @return The common vertical swing position.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/1399
/// @see https://github.com/crankyoldgit/IRremoteESP8266/pull/1401
stdAc::swingv_t IRMitsubishiAC::toCommonSwingV(const uint8_t pos) {
switch (pos) {
case kMitsubishiAcVaneHighest: return stdAc::swingv_t::kHighest;
case kMitsubishiAcVaneHigh: return stdAc::swingv_t::kHigh;
case kMitsubishiAcVaneMiddle: return stdAc::swingv_t::kMiddle;
case kMitsubishiAcVaneLow: return stdAc::swingv_t::kLow;
case kMitsubishiAcVaneLowest: return stdAc::swingv_t::kLowest;
// These model Mitsubishi A/C have two automatic settings.
// 1. A typical up & down oscillation. (Native Swing)
// 2. The A/C determines where the best placement for the vanes, outside of
// user control. (Native Auto)
// Native "Auto" doesn't have a good match for this in stdAc. (Case 2)
// So we repurpose stdAc's "Off" to be Native Auto.
case kMitsubishiAcVaneAuto: return stdAc::swingv_t::kOff;
// Native "Swing" is what we consider "Auto" in stdAc. (Case 1)
default: return stdAc::swingv_t::kAuto;
}
}
/// Convert a native horizontal swing postion to it's common equivalent.
/// @param[in] pos A native position to convert.
/// @return The common horizontal swing position.
stdAc::swingh_t IRMitsubishiAC::toCommonSwingH(const uint8_t pos) {
switch (pos) {
case kMitsubishiAcWideVaneLeftMax: return stdAc::swingh_t::kLeftMax;
case kMitsubishiAcWideVaneLeft: return stdAc::swingh_t::kLeft;
case kMitsubishiAcWideVaneMiddle: return stdAc::swingh_t::kMiddle;
case kMitsubishiAcWideVaneRight: return stdAc::swingh_t::kRight;
case kMitsubishiAcWideVaneRightMax: return stdAc::swingh_t::kRightMax;
case kMitsubishiAcWideVaneWide: return stdAc::swingh_t::kWide;
default: return stdAc::swingh_t::kAuto;
}
}
/// Convert the current internal state into its stdAc::state_t equivalent.
/// @return The stdAc equivalent of the native settings.
stdAc::state_t IRMitsubishiAC::toCommon(void) const {
stdAc::state_t result{};
result.protocol = decode_type_t::MITSUBISHI_AC;
result.model = -1; // No models used.
result.power = _.Power;
result.mode = toCommonMode(_.Mode);
result.celsius = true;
result.degrees = getTemp();
result.fanspeed = toCommonFanSpeed(getFan());
result.swingv = toCommonSwingV(_.Vane);
result.swingh = toCommonSwingH(_.WideVane);
result.quiet = getFan() == kMitsubishiAcFanSilent;
// Not supported.
result.turbo = false;
result.clean = false;
result.econo = false;
result.filter = false;
result.light = false;
result.beep = false;
result.sleep = -1;
result.clock = -1;
return result;
}
/// Change the Weekly Timer Enabled setting.
/// @param[in] on true, the setting is on. false, the setting is off.
void IRMitsubishiAC::setWeeklyTimerEnabled(const bool on) {
_.WeeklyTimer = on;
}
/// Get the value of the WeeklyTimer Enabled setting.
/// @return true, the setting is on. false, the setting is off.
bool IRMitsubishiAC::getWeeklyTimerEnabled(void) const { return _.WeeklyTimer; }
/// Convert the internal state into a human readable string.
/// @return A string containing the settings in human-readable form.
String IRMitsubishiAC::toString(void) const {
String result = "";
result.reserve(110); // Reserve some heap for the string to reduce fragging.
result += addBoolToString(_.Power, kPowerStr, false);
result += addModeToString(_.Mode, kMitsubishiAcAuto, kMitsubishiAcCool,
kMitsubishiAcHeat, kMitsubishiAcDry,
kMitsubishiAcFan);
result += addTempFloatToString(getTemp());
result += addFanToString(getFan(), kMitsubishiAcFanRealMax,
kMitsubishiAcFanRealMax - 3,
kMitsubishiAcFanAuto, kMitsubishiAcFanQuiet,
kMitsubishiAcFanRealMax - 2);
result += addSwingVToString(_.Vane, kMitsubishiAcVaneAuto,
kMitsubishiAcVaneHighest, kMitsubishiAcVaneHigh,
kMitsubishiAcVaneAuto, // Upper Middle unused.
kMitsubishiAcVaneMiddle,
kMitsubishiAcVaneAuto, // Lower Middle unused.
kMitsubishiAcVaneLow, kMitsubishiAcVaneLowest,
kMitsubishiAcVaneAuto, kMitsubishiAcVaneSwing,
// Below are unused.
kMitsubishiAcVaneAuto, kMitsubishiAcVaneAuto);
result += addSwingHToString(_.WideVane, kMitsubishiAcWideVaneAuto,
kMitsubishiAcWideVaneLeftMax,
kMitsubishiAcWideVaneLeft,
kMitsubishiAcWideVaneMiddle,
kMitsubishiAcWideVaneRight,
kMitsubishiAcWideVaneRightMax,
kMitsubishiAcWideVaneAuto, // Unused
kMitsubishiAcWideVaneAuto, // Unused
kMitsubishiAcWideVaneAuto, // Unused
kMitsubishiAcWideVaneAuto, // Unused
kMitsubishiAcWideVaneWide);
result += addLabeledString(minsToString(_.Clock * 10), kClockStr);
result += addLabeledString(minsToString(_.StartClock * 10), kOnTimerStr);
result += addLabeledString(minsToString(_.StopClock * 10), kOffTimerStr);
result += kCommaSpaceStr;
result += kTimerStr;
result += kColonSpaceStr;
switch (_.Timer) {
case kMitsubishiAcNoTimer:
result += '-';
break;
case kMitsubishiAcStartTimer:
result += kStartStr;
break;
case kMitsubishiAcStopTimer:
result += kStopStr;
break;
case kMitsubishiAcStartStopTimer:
result += kStartStr;
result += '+';
result += kStopStr;
break;
default:
result += F("? (");
result += _.Timer;
result += ')';
}
result += addBoolToString(_.WeeklyTimer, kWeeklyTimerStr);
result += addBoolToString(_.iSave10C, k10CHeatStr);
result += addBoolToString(_.ISee, kISeeStr);
result += addBoolToString(_.Ecocool, kEconoStr);
result += addBoolToString(_.AbsenseDetect, kAbsenseDetectStr);
result += addIntToString(_.DirectIndirect, kDirectIndirectModeStr);
result += addBoolToString(_.NaturalFlow, kFreshStr);
return result;
}
#if SEND_MITSUBISHI136
/// Send a Mitsubishi 136-bit A/C message. (MITSUBISHI136)
/// Status: BETA / Probably working. Needs to be tested against a real device.
/// @param[in] data The message to be sent.
/// @param[in] nbytes The number of bytes of message to be sent.
/// @param[in] repeat The number of times the command is to be repeated.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/888
void IRsend::sendMitsubishi136(const unsigned char data[],
const uint16_t nbytes,
const uint16_t repeat) {
if (nbytes < kMitsubishi136StateLength)
return; // Not enough bytes to send a proper message.
sendGeneric(kMitsubishi136HdrMark, kMitsubishi136HdrSpace,
kMitsubishi136BitMark, kMitsubishi136OneSpace,
kMitsubishi136BitMark, kMitsubishi136ZeroSpace,
kMitsubishi136BitMark, kMitsubishi136Gap,
data, nbytes, 38, false, repeat, 50);
}
#endif // SEND_MITSUBISHI136
#if DECODE_MITSUBISHI136
/// Decode the supplied Mitsubishi 136-bit A/C message. (MITSUBISHI136)
/// Status: STABLE / Reported as working.
/// @param[in,out] results Ptr to the data to decode & where to store the result
/// @param[in] offset The starting index to use when attempting to decode the
/// raw data. Typically/Defaults to kStartOffset.
/// @param[in] nbits The number of data bits to expect.
/// @param[in] strict Flag indicating if we should perform strict matching.
/// @see https://github.com/crankyoldgit/IRremoteESP8266/issues/888
bool IRrecv::decodeMitsubishi136(decode_results *results, uint16_t offset,
const uint16_t nbits,
const bool strict) {
if (nbits % 8 != 0) return false; // Not a multiple of an 8 bit byte.
if (strict) { // Do checks to see if it matches the spec.
if (nbits != kMitsubishi136Bits) return false;
}
uint16_t used = matchGeneric(results->rawbuf + offset, results->state,
results->rawlen - offset, nbits,
kMitsubishi136HdrMark, kMitsubishi136HdrSpace,
kMitsubishi136BitMark, kMitsubishi136OneSpace,
kMitsubishi136BitMark, kMitsubishi136ZeroSpace,
kMitsubishi136BitMark, kMitsubishi136Gap,
true, _tolerance, 0, false);
if (!used) return false;
if (strict) {
// Header validation: Codes start with 0x23CB26
if (results->state[0] != 0x23 || results->state[1] != 0xCB ||
results->state[2] != 0x26) return false;
if (!IRMitsubishi136::validChecksum(results->state, nbits / 8))
return false;
}
results->decode_type = MITSUBISHI136;
results->bits = nbits;
return true;
}
#endif // DECODE_MITSUBISHI136
// Code to emulate Mitsubishi 136bit A/C IR remote control unit.
/// Class constructor
/// @param[in] pin GPIO to be used when sending.
/// @param[in] inverted Is the output signal to be inverted?
/// @param[in] use_modulation Is frequency modulation to be used?
IRMitsubishi136::IRMitsubishi136(const uint16_t pin, const bool inverted,
const bool use_modulation)
: _irsend(pin, inverted, use_modulation) { stateReset(); }
/// Reset the state of the remote to a known good state/sequence.
void IRMitsubishi136::stateReset(void) {
// The state of the IR remote in IR code form.
// Known good state obtained from:
// https://docs.google.com/spreadsheets/d/1f8EGfIbBUo2B-CzUFdrgKQprWakoYNKM80IKZN4KXQE/edit#gid=312397579&range=A10
static const uint8_t kReset[kMitsubishi136StateLength] = {
0x23, 0xCB, 0x26, 0x21, 0x00, 0x40, 0xC2, 0xC7, 0x04};
std::memcpy(_.raw, kReset, kMitsubishi136StateLength);
}
/// Calculate the checksum for the current internal state of the remote.
void IRMitsubishi136::checksum(void) {
for (uint8_t i = 0; i < 6; i++)
_.raw[kMitsubishi136PowerByte + 6 + i] =
~_.raw[kMitsubishi136PowerByte + i];
}
/// Verify the checksum is valid for a given state.
/// @param[in] data The array to verify the checksum of.
/// @param[in] len The length of the data array.
/// @return true, if the state has a valid checksum. Otherwise, false.
bool IRMitsubishi136::validChecksum(const uint8_t *data, const uint16_t len) {
if (len < kMitsubishi136StateLength) return false;
const uint16_t half = (len - kMitsubishi136PowerByte) / 2;
for (uint8_t i = 0; i < half; i++) {
// This variable is needed to avoid the warning: (known compiler issue)
// warning: comparison of promoted ~unsigned with unsigned [-Wsign-compare]
const uint8_t inverted = ~data[kMitsubishi136PowerByte + half + i];
if (data[kMitsubishi136PowerByte + i] != inverted) return false;
}
return true;
}
/// Set up hardware to be able to send a message.
void IRMitsubishi136::begin(void) { _irsend.begin(); }
#if SEND_MITSUBISHI136
/// Send the current internal state as an IR message.
/// @param[in] repeat Nr. of times the message will be repeated.
void IRMitsubishi136::send(const uint16_t repeat) {
_irsend.sendMitsubishi136(getRaw(), kMitsubishi136StateLength, repeat);
}
#endif // SEND_MITSUBISHI136
/// Get a PTR to the internal state/code for this protocol.
/// @return PTR to a code for this protocol based on the current internal state.