-
Notifications
You must be signed in to change notification settings - Fork 833
/
IRac.cpp
5060 lines (4958 loc) · 185 KB
/
IRac.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 2019 David Conran
// Provide a universal/standard interface for sending A/C nessages.
// It does not provide complete and maximum granular control but tries
// to offer most common functionality across all supported devices.
#include "IRac.h"
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include <string.h>
#ifndef ARDUINO
#include <string>
#endif
#include <cmath>
#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_MATH_TR1)
using std::roundf;
#else
using ::roundf;
#endif
#include "IRsend.h"
#include "IRremoteESP8266.h"
#include "IRtext.h"
#include "IRutils.h"
#include "ir_Airton.h"
#include "ir_Airwell.h"
#include "ir_Amcor.h"
#include "ir_Argo.h"
#include "ir_Bosch.h"
#include "ir_Carrier.h"
#include "ir_Coolix.h"
#include "ir_Corona.h"
#include "ir_Daikin.h"
#include "ir_Ecoclim.h"
#include "ir_Electra.h"
#include "ir_Fujitsu.h"
#include "ir_Haier.h"
#include "ir_Hitachi.h"
#include "ir_Kelon.h"
#include "ir_Kelvinator.h"
#include "ir_LG.h"
#include "ir_Midea.h"
#include "ir_Mitsubishi.h"
#include "ir_MitsubishiHeavy.h"
#include "ir_Neoclima.h"
#include "ir_Panasonic.h"
#include "ir_Rhoss.h"
#include "ir_Samsung.h"
#include "ir_Sanyo.h"
#include "ir_Sharp.h"
#include "ir_Tcl.h"
#include "ir_Technibel.h"
#include "ir_Teco.h"
#include "ir_Toshiba.h"
#include "ir_Transcold.h"
#include "ir_Trotec.h"
#include "ir_Truma.h"
#include "ir_Vestel.h"
#include "ir_Voltas.h"
#include "ir_Whirlpool.h"
// On the ESP8266 platform we need to use a special version of string handling
// functions to handle the strings stored in the flash address space.
#ifndef STRCASECMP
#if defined(ESP8266)
#define STRCASECMP(LHS, RHS) \
strcasecmp_P(LHS, reinterpret_cast<const char*>(RHS))
#else // ESP8266
#define STRCASECMP(LHS, RHS) strcasecmp(LHS, RHS)
#endif // ESP8266
#endif // STRCASECMP
#ifndef UNIT_TEST
#define OUTPUT_DECODE_RESULTS_FOR_UT(ac)
#else
/* NOTE: THIS IS NOT A DOXYGEN COMMENT (would require ENABLE_PREPROCESSING-YES)
/// If compiling for UT *and* a test receiver @c IRrecv is provided via the
/// @c _utReceived param, this injects an "output" gadget @c _lastDecodeResults
/// into the @c IRAc::sendAc method, so that the UT code may parse the "sent"
/// value and drive further assertions
///
/// @note The @c decode_results "returned" is a shallow copy (empty rawbuf),
/// mostly b/c the class does not have a custom/deep copy c-tor
/// and defining it would be an overkill for this purpose
/// @note For future maintainers: If @c IRAc class is ever refactored to use
/// polymorphism (static or dynamic)... this macro should be removed
/// and replaced with proper GMock injection.
*/
#define OUTPUT_DECODE_RESULTS_FOR_UT(ac) \
{ \
if (_utReceiver) { \
_lastDecodeResults = nullptr; \
(ac)._irsend.makeDecodeResult(); \
if (_utReceiver->decode(&(ac)._irsend.capture)) { \
_lastDecodeResults = std::unique_ptr<decode_results>( \
new decode_results((ac)._irsend.capture)); \
_lastDecodeResults->rawbuf = nullptr; \
} \
} \
}
#endif // UNIT_TEST
/// Class constructor
/// @param[in] pin Gpio pin to use when transmitting IR messages.
/// @param[in] inverted true, gpio output defaults to high. false, to low.
/// @param[in] use_modulation true means use frequency modulation. false, don't.
IRac::IRac(const uint16_t pin, const bool inverted, const bool use_modulation) {
_pin = pin;
_inverted = inverted;
_modulation = use_modulation;
this->markAsSent();
}
/// Initialise the given state with the supplied settings.
/// @param[out] state A Ptr to where the settings will be stored.
/// @param[in] vendor The vendor/protocol type.
/// @param[in] model The A/C model if applicable.
/// @param[in] power The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] celsius Temperature units. True is Celsius, False is Fahrenheit.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] swingh The horizontal swing setting.
/// @param[in] quiet Run the device in quiet/silent mode.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] econo Run the device in economical mode.
/// @param[in] light Turn on the LED/Display mode.
/// @param[in] filter Turn on the (ion/pollen/etc) filter mode.
/// @param[in] clean Turn on the self-cleaning mode. e.g. Mould, dry filters etc
/// @param[in] beep Enable/Disable beeps when receiving IR messages.
/// @param[in] sleep Nr. of minutes for sleep mode.
/// -1 is Off, >= 0 is on. Some devices it is the nr. of mins to run for.
/// Others it may be the time to enter/exit sleep mode.
/// i.e. Time in Nr. of mins since midnight.
/// @param[in] clock The time in Nr. of mins since midnight. < 0 is ignore.
void IRac::initState(stdAc::state_t *state,
const decode_type_t vendor, const int16_t model,
const bool power, const stdAc::opmode_t mode,
const float degrees, const bool celsius,
const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const stdAc::swingh_t swingh,
const bool quiet, const bool turbo, const bool econo,
const bool light, const bool filter, const bool clean,
const bool beep, const int16_t sleep,
const int16_t clock) {
state->protocol = vendor;
state->model = model;
state->power = power;
state->mode = mode;
state->degrees = degrees;
state->celsius = celsius;
state->fanspeed = fan;
state->swingv = swingv;
state->swingh = swingh;
state->quiet = quiet;
state->turbo = turbo;
state->econo = econo;
state->light = light;
state->filter = filter;
state->clean = clean;
state->beep = beep;
state->sleep = sleep;
state->clock = clock;
}
/// Initialise the given state with the supplied settings.
/// @param[out] state A Ptr to where the settings will be stored.
/// @note Sets all the parameters to reasonable base/automatic defaults.
void IRac::initState(stdAc::state_t *state) {
stdAc::state_t def;
*state = def;
}
/// Get the current internal A/C climate state.
/// @return A Ptr to a state containing the current (to be sent) settings.
stdAc::state_t IRac::getState(void) { return next; }
/// Get the previous internal A/C climate state that should have already been
/// sent to the device. i.e. What the A/C unit should already be set to.
/// @return A Ptr to a state containing the previously sent settings.
stdAc::state_t IRac::getStatePrev(void) { return _prev; }
/// Is the given protocol supported by the IRac class?
/// @param[in] protocol The vendor/protocol type.
/// @return true if the protocol is supported by this class, otherwise false.
bool IRac::isProtocolSupported(const decode_type_t protocol) {
switch (protocol) {
#if SEND_AIRTON
case decode_type_t::AIRTON:
#endif // SEND_AIRTON
#if SEND_AIRWELL
case decode_type_t::AIRWELL:
#endif // SEND_AIRWELL
#if SEND_AMCOR
case decode_type_t::AMCOR:
#endif
#if SEND_ARGO
case decode_type_t::ARGO:
#endif
#if SEND_BOSCH144
case decode_type_t::BOSCH144:
#endif
#if SEND_CARRIER_AC64
case decode_type_t::CARRIER_AC64:
#endif // SEND_CARRIER_AC64
#if SEND_COOLIX
case decode_type_t::COOLIX:
#endif
#if SEND_CORONA_AC
case decode_type_t::CORONA_AC:
#endif
#if SEND_DAIKIN
case decode_type_t::DAIKIN:
#endif
#if SEND_DAIKIN128
case decode_type_t::DAIKIN128:
#endif
#if SEND_DAIKIN152
case decode_type_t::DAIKIN152:
#endif
#if SEND_DAIKIN160
case decode_type_t::DAIKIN160:
#endif
#if SEND_DAIKIN176
case decode_type_t::DAIKIN176:
#endif
#if SEND_DAIKIN2
case decode_type_t::DAIKIN2:
#endif
#if SEND_DAIKIN216
case decode_type_t::DAIKIN216:
#endif
#if SEND_DAIKIN64
case decode_type_t::DAIKIN64:
#endif
#if SEND_DELONGHI_AC
case decode_type_t::DELONGHI_AC:
#endif
#if SEND_ECOCLIM
case decode_type_t::ECOCLIM:
#endif
#if SEND_ELECTRA_AC
case decode_type_t::ELECTRA_AC:
#endif
#if SEND_FUJITSU_AC
case decode_type_t::FUJITSU_AC:
#endif
#if SEND_GOODWEATHER
case decode_type_t::GOODWEATHER:
#endif
#if SEND_GREE
case decode_type_t::GREE:
#endif
#if SEND_HAIER_AC
case decode_type_t::HAIER_AC:
#endif
#if SEND_HAIER_AC160
case decode_type_t::HAIER_AC160:
#endif // SEND_HAIER_AC160
#if SEND_HAIER_AC176
case decode_type_t::HAIER_AC176:
#endif // SEND_HAIER_AC176
#if SEND_HAIER_AC_YRW02
case decode_type_t::HAIER_AC_YRW02:
#endif
#if SEND_HITACHI_AC
case decode_type_t::HITACHI_AC:
#endif
#if SEND_HITACHI_AC1
case decode_type_t::HITACHI_AC1:
#endif
#if SEND_HITACHI_AC264
case decode_type_t::HITACHI_AC264:
#endif
#if SEND_HITACHI_AC296
case decode_type_t::HITACHI_AC296:
#endif
#if SEND_HITACHI_AC344
case decode_type_t::HITACHI_AC344:
#endif
#if SEND_HITACHI_AC424
case decode_type_t::HITACHI_AC424:
#endif
#if SEND_KELON
case decode_type_t::KELON:
#endif
#if SEND_KELVINATOR
case decode_type_t::KELVINATOR:
#endif
#if SEND_LG
case decode_type_t::LG:
case decode_type_t::LG2:
#endif
#if SEND_MIDEA
case decode_type_t::MIDEA:
#endif // SEND_MIDEA
#if SEND_MIRAGE
case decode_type_t::MIRAGE:
#endif // SEND_MIRAGE
#if SEND_MITSUBISHI_AC
case decode_type_t::MITSUBISHI_AC:
#endif
#if SEND_MITSUBISHI112
case decode_type_t::MITSUBISHI112:
#endif
#if SEND_MITSUBISHI136
case decode_type_t::MITSUBISHI136:
#endif
#if SEND_MITSUBISHIHEAVY
case decode_type_t::MITSUBISHI_HEAVY_88:
case decode_type_t::MITSUBISHI_HEAVY_152:
#endif
#if SEND_NEOCLIMA
case decode_type_t::NEOCLIMA:
#endif
#if SEND_PANASONIC_AC
case decode_type_t::PANASONIC_AC:
#endif
#if SEND_PANASONIC_AC32
case decode_type_t::PANASONIC_AC32:
#endif
#if SEND_RHOSS
case decode_type_t::RHOSS:
#endif
#if SEND_SAMSUNG_AC
case decode_type_t::SAMSUNG_AC:
#endif
#if SEND_SANYO_AC
case decode_type_t::SANYO_AC:
#endif
#if SEND_SANYO_AC88
case decode_type_t::SANYO_AC88:
#endif
#if SEND_SHARP_AC
case decode_type_t::SHARP_AC:
#endif
#if SEND_TCL112AC
case decode_type_t::TCL112AC:
#endif
#if SEND_TECHNIBEL_AC
case decode_type_t::TECHNIBEL_AC:
#endif
#if SEND_TECO
case decode_type_t::TECO:
#endif
#if SEND_TEKNOPOINT
case decode_type_t::TEKNOPOINT:
#endif // SEND_TEKNOPOINT
#if SEND_TOSHIBA_AC
case decode_type_t::TOSHIBA_AC:
#endif
#if SEND_TRANSCOLD
case decode_type_t::TRANSCOLD:
#endif
#if SEND_TROTEC
case decode_type_t::TROTEC:
#endif
#if SEND_TROTEC_3550
case decode_type_t::TROTEC_3550:
#endif // SEND_TROTEC_3550
#if SEND_TRUMA
case decode_type_t::TRUMA:
#endif // SEND_TRUMA
#if SEND_VESTEL_AC
case decode_type_t::VESTEL_AC:
#endif
#if SEND_VOLTAS
case decode_type_t::VOLTAS:
#endif
#if SEND_YORK
case decode_type_t::YORK:
#endif
case decode_type_t::WHIRLPOOL_AC:
return true;
default:
return false;
}
}
#if SEND_AIRTON
/// Send an Airton 56-bit A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRAirtonAc object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] light Turn on the LED/Display mode.
/// @param[in] econo Run the device in economical mode.
/// @param[in] filter Turn on the (ion/pollen/health/etc) filter mode.
/// @param[in] sleep Nr. of minutes for sleep mode.
/// @note -1 is Off, >= 0 is on.
void IRac::airton(IRAirtonAc *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const bool turbo,
const bool light, const bool econo, const bool filter,
const int16_t sleep) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingV(swingv != stdAc::swingv_t::kOff);
// No Quiet setting available.
ac->setLight(light);
ac->setHealth(filter);
ac->setTurbo(turbo);
ac->setEcono(econo);
// No Clean setting available.
// No Beep setting available.
ac->setSleep(sleep >= 0); // Convert to a boolean.
ac->send();
}
#endif // SEND_AIRTON
#if SEND_AIRWELL
/// Send an Airwell A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRAirwellAc object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
void IRac::airwell(IRAirwellAc *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan) {
ac->begin();
ac->setPowerToggle(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
// No Swing setting available.
// No Quiet setting available.
// No Light setting available.
// No Filter setting available.
// No Turbo setting available.
// No Economy setting available.
// No Clean setting available.
// No Beep setting available.
// No Sleep setting available.
ac->send();
}
#endif // SEND_AIRWELL
#if SEND_AMCOR
/// Send an Amcor A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRAmcorAc object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
void IRac::amcor(IRAmcorAc *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
const stdAc::fanspeed_t fan) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
// No Swing setting available.
// No Quiet setting available.
// No Light setting available.
// No Filter setting available.
// No Turbo setting available.
// No Economy setting available.
// No Clean setting available.
// No Beep setting available.
// No Sleep setting available.
ac->send();
}
#endif // SEND_AMCOR
#if SEND_ARGO
/// Send an Argo A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRArgoAC object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading in degrees
/// Celsius.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] sleep Nr. of minutes for sleep mode.
/// @note -1 is Off, >= 0 is on.
void IRac::argo(IRArgoAC *ac,
const bool on, const stdAc::opmode_t mode, const float degrees,
const float sensorTemp, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const bool iFeel,
const bool turbo, const int16_t sleep) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(static_cast<uint8_t>(roundf(degrees)));
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(roundf(sensorTemp)));
}
ac->setiFeel(iFeel);
ac->setFan(ac->convertFan(fan));
ac->setFlap(ac->convertSwingV(swingv));
// No Quiet setting available.
// No Light setting available.
// No Filter setting available.
ac->setMax(turbo);
// No Economy setting available.
// No Clean setting available.
// No Beep setting available.
ac->setNight(sleep >= 0); // Convert to a boolean.
ac->send();
}
/// Send an Argo A/C WREM-3 AC **control** message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRArgoAC_WREM3 object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The set temperature setting in degrees Celsius.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading in degrees
/// Celsius.
/// @warning The @c sensorTemp param is assumed to be in 0..255 range (uint8_t)
/// The overflow is *not* checked, though.
/// @note The value is rounded to nearest integer, rounding halfway cases
/// away from zero. E.g. 1.5 [C] becomes 2 [C].
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] night Enable night mode (raises temp by +1*C after 1h).
/// @param[in] econo Enable eco mode (limits power consumed).
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] filter Enable filter mode
/// @param[in] light Enable device display/LEDs
void IRac::argoWrem3_ACCommand(IRArgoAC_WREM3 *ac, const bool on,
const stdAc::opmode_t mode, const float degrees, const float sensorTemp,
const stdAc::fanspeed_t fan, const stdAc::swingv_t swingv, const bool iFeel,
const bool night, const bool econo, const bool turbo, const bool filter,
const bool light) {
ac->begin();
ac->setMessageType(argoIrMessageType_t::AC_CONTROL);
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(roundf(sensorTemp)));
}
ac->setiFeel(iFeel);
ac->setFan(ac->convertFan(fan));
ac->setFlap(ac->convertSwingV(swingv));
ac->setNight(night);
ac->setEco(econo);
ac->setMax(turbo);
ac->setFilter(filter);
ac->setLight(light);
// No Clean setting available.
// No Beep setting available - always beeps in this mode :)
ac->send();
}
/// Send an Argo A/C WREM-3 iFeel (room temp) silent (no beep) report.
/// @param[in, out] ac A Ptr to an IRArgoAC_WREM3 object to use.
/// @param[in] sensorTemp The room (iFeel) temperature setting
/// in degrees Celsius.
/// @warning The @c sensorTemp param is assumed to be in 0..255 range (uint8_t)
/// The overflow is *not* checked, though.
/// @note The value is rounded to nearest integer, rounding halfway cases
/// away from zero. E.g. 1.5 [C] becomes 2 [C].
void IRac::argoWrem3_iFeelReport(IRArgoAC_WREM3 *ac, const float sensorTemp) {
ac->begin();
ac->setMessageType(argoIrMessageType_t::IFEEL_TEMP_REPORT);
ac->setSensorTemp(static_cast<uint8_t>(roundf(sensorTemp)));
ac->send();
}
/// Send an Argo A/C WREM-3 Config command.
/// @param[in, out] ac A Ptr to an IRArgoAC_WREM3 object to use.
/// @param[in] param The parameter ID.
/// @param[in] value The parameter value.
/// @param[in] safe If true, will only allow setting the below parameters
/// in order to avoid accidentally setting a restricted
/// vendor-specific param and breaking the A/C device
/// @note Known parameters (P<xx>, where xx is the @c param)
/// P05 - Temperature Scale (0-Celsius, 1-Fahrenheit)
/// P06 - Transmission channel (0..3)
/// P12 - ECO mode power input limit (30..99, default: 75)
void IRac::argoWrem3_ConfigSet(IRArgoAC_WREM3 *ac, const uint8_t param,
const uint8_t value, bool safe /*= true*/) {
if (safe) {
switch (param) {
case 5: // temp. scale (note this is likely excess as not transmitted)
if (value > 1) { return; /* invalid */ }
break;
case 6: // channel (note this is likely excess as not transmitted)
if (value > 3) { return; /* invalid */ }
break;
case 12: // eco power limit
if (value < 30 || value > 99) { return; /* invalid */ }
break;
default:
return; /* invalid */
}
}
ac->begin();
ac->setMessageType(argoIrMessageType_t::CONFIG_PARAM_SET);
ac->setConfigEntry(param, value);
ac->send();
}
/// Send an Argo A/C WREM-3 Delay timer command.
/// @param[in, out] ac A Ptr to an IRArgoAC_WREM3 object to use.
/// @param[in] on Whether the unit is currently on. The timer, upon elapse
/// will toggle this state
/// @param[in] currentTime currentTime in minutes, starting from 00:00
/// @note For timer mode, this value is not really used much so can be zero.
/// @param[in] delayMinutes Number of minutes after which the @c on state should
/// be toggled
/// @note Schedule timers are not exposed via this interface
void IRac::argoWrem3_SetTimer(IRArgoAC_WREM3 *ac, bool on,
const uint16_t currentTime, const uint16_t delayMinutes) {
ac->begin();
ac->setMessageType(argoIrMessageType_t::TIMER_COMMAND);
ac->setPower(on);
ac->setTimerType(argoTimerType_t::DELAY_TIMER);
ac->setCurrentTimeMinutes(currentTime);
// Note: Day of week is not set (no need)
ac->setDelayTimerMinutes(delayMinutes);
ac->send();
}
#endif // SEND_ARGO
#if SEND_BOSCH144
/// Send a Bosch144 A/C message with the supplied settings.
/// @note May result in multiple messages being sent.
/// @param[in, out] ac A Ptr to an IRBosch144AC object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] quiet Run the device in quiet/silent mode.
/// @note -1 is Off, >= 0 is on.
void IRac::bosch144(IRBosch144AC *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const bool quiet) {
ac->begin();
ac->setPower(on);
if (!on) {
// after turn off AC no more commands should
// be accepted
ac->send();
return;
}
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setMode(ac->convertMode(mode));
ac->setQuiet(quiet);
ac->send(); // Send the state, which will also power on the unit.
// The following are all options/settings that create their own special
// messages. Often they only make sense to be sent after the unit is turned
// on. For instance, assuming a person wants to have the a/c on and in turbo
// mode. If we send the turbo message, it is ignored if the unit is off.
// Hence we send the special mode/setting messages after a normal message
// which will turn on the device.
// No Filter setting available.
// No Beep setting available.
// No Clock setting available.
// No Econo setting available.
// No Sleep setting available.
}
#endif // SEND_BOSCH144
#if SEND_CARRIER_AC64
/// Send a Carrier 64-bit A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRCarrierAc64 object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] sleep Nr. of minutes for sleep mode.
/// @note -1 is Off, >= 0 is on.
void IRac::carrier64(IRCarrierAc64 *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const int16_t sleep) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingV((int8_t)swingv >= 0);
// No Quiet setting available.
// No Light setting available.
// No Filter setting available.
// No Turbo setting available.
// No Economy setting available.
// No Clean setting available.
// No Beep setting available.
ac->setSleep(sleep >= 0); // Convert to a boolean.
ac->send();
}
#endif // SEND_CARRIER_AC64
#if SEND_COOLIX
/// Send a Coolix A/C message with the supplied settings.
/// @note May result in multiple messages being sent.
/// @param[in, out] ac A Ptr to an IRCoolixAC object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] sensorTemp The room (iFeel) temperature sensor reading in degrees
/// Celsius.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] swingh The horizontal swing setting.
/// @param[in] iFeel Whether to enable iFeel (remote temp) mode on the A/C unit.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] light Turn on the LED/Display mode.
/// @param[in] clean Turn on the self-cleaning mode. e.g. Mould, dry filters etc
/// @param[in] sleep Nr. of minutes for sleep mode.
/// @note -1 is Off, >= 0 is on.
void IRac::coolix(IRCoolixAC *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const float sensorTemp,
const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const stdAc::swingh_t swingh,
const bool iFeel, const bool turbo, const bool light,
const bool clean, const int16_t sleep) {
ac->begin();
ac->setPower(on);
if (!on) {
// after turn off AC no more commands should
// be accepted
ac->send();
return;
}
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
// No Filter setting available.
// No Beep setting available.
// No Clock setting available.
// No Econo setting available.
// No Quiet setting available.
if (sensorTemp != kNoTempValue) {
ac->setSensorTemp(static_cast<uint8_t>(roundf(sensorTemp)));
} else {
ac->clearSensorTemp();
}
ac->setZoneFollow(iFeel);
ac->send(); // Send the state, which will also power on the unit.
// The following are all options/settings that create their own special
// messages. Often they only make sense to be sent after the unit is turned
// on. For instance, assuming a person wants to have the a/c on and in turbo
// mode. If we send the turbo message, it is ignored if the unit is off.
// Hence we send the special mode/setting messages after a normal message
// which will turn on the device.
if (swingv != stdAc::swingv_t::kOff || swingh != stdAc::swingh_t::kOff) {
// Swing has a special command that needs to be sent independently.
ac->setSwing();
ac->send();
}
if (turbo) {
// Turbo has a special command that needs to be sent independently.
ac->setTurbo();
ac->send();
}
if (sleep >= 0) {
// Sleep has a special command that needs to be sent independently.
ac->setSleep();
ac->send();
}
if (light) {
// Light has a special command that needs to be sent independently.
ac->setLed();
ac->send();
}
if (clean) {
// Clean has a special command that needs to be sent independently.
ac->setClean();
ac->send();
}
}
#endif // SEND_COOLIX
#if SEND_CORONA_AC
/// Send a Corona A/C message with the supplied settings.
/// @note May result in multiple messages being sent.
/// @param[in, out] ac A Ptr to an IRCoronaAc object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] econo Run the device in economical mode.
void IRac::corona(IRCoronaAc *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const bool econo) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingVToggle(swingv != stdAc::swingv_t::kOff);
// No Quiet setting available.
// No Light setting available.
// No Filter setting available.
// No Turbo setting available.
ac->setEcono(econo);
// No Clean setting available.
// No Beep setting available.
// No Sleep setting available.
ac->send();
}
#endif // SEND_CARRIER_AC64
#if SEND_DAIKIN
/// Send a Daikin A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRDaikinESP object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] swingh The horizontal swing setting.
/// @param[in] quiet Run the device in quiet/silent mode.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] econo Run the device in economical mode.
/// @param[in] clean Turn on the self-cleaning mode. e.g. Mould, dry filters etc
void IRac::daikin(IRDaikinESP *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const stdAc::swingh_t swingh,
const bool quiet, const bool turbo, const bool econo,
const bool clean) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingVertical((int8_t)swingv >= 0);
ac->setSwingHorizontal((int8_t)swingh >= 0);
ac->setQuiet(quiet);
// No Light setting available.
// No Filter setting available.
ac->setPowerful(turbo);
ac->setEcono(econo);
ac->setMold(clean);
// No Beep setting available.
// No Sleep setting available.
// No Clock setting available.
ac->send();
}
#endif // SEND_DAIKIN
#if SEND_DAIKIN128
/// Send a Daikin 128-bit A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRDaikin128 object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] quiet Run the device in quiet/silent mode.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] light Turn on the LED/Display mode.
/// @param[in] econo Run the device in economical mode.
/// @param[in] sleep Nr. of minutes for sleep mode. -1 is Off, >= 0 is on.
/// @param[in] clock The time in Nr. of mins since midnight. < 0 is ignore.
void IRac::daikin128(IRDaikin128 *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv,
const bool quiet, const bool turbo, const bool light,
const bool econo, const int16_t sleep, const int16_t clock) {
ac->begin();
ac->setPowerToggle(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingVertical((int8_t)swingv >= 0);
// No Horizontal Swing setting avaliable.
ac->setQuiet(quiet);
ac->setLightToggle(light ? kDaikin128BitWall : 0);
// No Filter setting available.
ac->setPowerful(turbo);
ac->setEcono(econo);
// No Clean setting available.
// No Beep setting available.
ac->setSleep(sleep > 0);
if (clock >= 0) ac->setClock(clock);
ac->send();
}
#endif // SEND_DAIKIN128
#if SEND_DAIKIN152
/// Send a Daikin 152-bit A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRDaikin152 object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] quiet Run the device in quiet/silent mode.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] econo Run the device in economical mode.
void IRac::daikin152(IRDaikin152 *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv,
const bool quiet, const bool turbo, const bool econo) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingV((int8_t)swingv >= 0);
// No Horizontal Swing setting avaliable.
ac->setQuiet(quiet);
// No Light setting available.
// No Filter setting available.
ac->setPowerful(turbo);
ac->setEcono(econo);
// No Clean setting available.
// No Beep setting available.
// No Sleep setting available.
// No Clock setting available.
ac->send();
}
#endif // SEND_DAIKIN152
#if SEND_DAIKIN160
/// Send a Daikin 160-bit A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRDaikin160 object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
void IRac::daikin160(IRDaikin160 *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingVertical(ac->convertSwingV(swingv));
ac->send();
}
#endif // SEND_DAIKIN160
#if SEND_DAIKIN176
/// Send a Daikin 176-bit A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRDaikin176 object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingh The horizontal swing setting.
void IRac::daikin176(IRDaikin176 *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingh_t swingh) {
ac->begin();
ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees);
ac->setFan(ac->convertFan(fan));
ac->setSwingHorizontal(ac->convertSwingH(swingh));
ac->send();
}
#endif // SEND_DAIKIN176
#if SEND_DAIKIN2
/// Send a Daikin2 A/C message with the supplied settings.
/// @param[in, out] ac A Ptr to an IRDaikin2 object to use.
/// @param[in] on The power setting.
/// @param[in] mode The operation mode setting.
/// @param[in] degrees The temperature setting in degrees.
/// @param[in] fan The speed setting for the fan.
/// @param[in] swingv The vertical swing setting.
/// @param[in] swingh The horizontal swing setting.
/// @param[in] quiet Run the device in quiet/silent mode.
/// @param[in] turbo Run the device in turbo/powerful mode.
/// @param[in] light Turn on the LED/Display mode.
/// @param[in] econo Run the device in economical mode.
/// @param[in] filter Turn on the (ion/pollen/etc) filter mode.
/// @param[in] clean Turn on the self-cleaning mode. e.g. Mould, dry filters etc
/// @param[in] beep Enable/Disable beeps when receiving IR messages.
/// @param[in] sleep Nr. of minutes for sleep mode. -1 is Off, >= 0 is on.
/// @param[in] clock The time in Nr. of mins since midnight. < 0 is ignore.
void IRac::daikin2(IRDaikin2 *ac,
const bool on, const stdAc::opmode_t mode,
const float degrees, const stdAc::fanspeed_t fan,
const stdAc::swingv_t swingv, const stdAc::swingh_t swingh,
const bool quiet, const bool turbo, const bool light,
const bool econo, const bool filter, const bool clean,