-
Notifications
You must be signed in to change notification settings - Fork 0
/
ir_Daikin.h
1194 lines (1134 loc) · 39.6 KB
/
ir_Daikin.h
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 2016 sillyfrog
// Copyright 2017 sillyfrog, crankyoldgit
// Copyright 2018-2020 crankyoldgit
// Copyright 2019 pasna (IRDaikin160 class / Daikin176 class)
/// @file
/// @brief Support for Daikin A/C protocols.
/// @see Daikin http://harizanov.com/2012/02/control-daikin-air-conditioner-over-the-internet/
/// @see Daikin https://github.com/mharizanov/Daikin-AC-remote-control-over-the-Internet/tree/master/IRremote
/// @see Daikin http://rdlab.cdmt.vn/project-2013/daikin-ir-protocol
/// @see Daikin https://github.com/blafois/Daikin-IR-Reverse
/// @see Daikin128 https://github.com/crankyoldgit/IRremoteESP8266/issues/827
/// @see Daikin152 https://github.com/crankyoldgit/IRremoteESP8266/issues/873
/// @see Daikin152 https://github.com/ToniA/arduino-heatpumpir/blob/master/DaikinHeatpumpARC480A14IR.cpp
/// @see Daikin152 https://github.com/ToniA/arduino-heatpumpir/blob/master/DaikinHeatpumpARC480A14IR.h
/// @see Daikin160 https://github.com/crankyoldgit/IRremoteESP8266/issues/731
/// @see Daikin2 https://docs.google.com/spreadsheets/d/1f8EGfIbBUo2B-CzUFdrgKQprWakoYNKM80IKZN4KXQE/edit#gid=236366525&range=B25:D32
/// @see Daikin2 https://github.com/crankyoldgit/IRremoteESP8266/issues/582
/// @see Daikin2 https://www.daikin.co.nz/sites/default/files/daikin-split-system-US7-FTXZ25-50NV1B.pdf
/// @see Daikin216 https://github.com/crankyoldgit/IRremoteESP8266/issues/689
/// @see Daikin216 https://github.com/danny-source/Arduino_DY_IRDaikin
/// @see Daikin64 https://github.com/crankyoldgit/IRremoteESP8266/issues/1064
// Supports:
// Brand: Daikin, Model: ARC433** remote (DAIKIN)
// Brand: Daikin, Model: ARC477A1 remote (DAIKIN2)
// Brand: Daikin, Model: FTXZ25NV1B A/C (DAIKIN2)
// Brand: Daikin, Model: FTXZ35NV1B A/C (DAIKIN2)
// Brand: Daikin, Model: FTXZ50NV1B A/C (DAIKIN2)
// Brand: Daikin, Model: ARC433B69 remote (DAIKIN216)
// Brand: Daikin, Model: ARC423A5 remote (DAIKIN160)
// Brand: Daikin, Model: FTE12HV2S A/C
// Brand: Daikin, Model: BRC4C153 remote (DAIKIN176)
// Brand: Daikin, Model: FFQ35B8V1B A/C (DAIKIN176)
// Brand: Daikin, Model: BRC4C151 remote (DAIKIN176)
// Brand: Daikin, Model: 17 Series A/C (DAIKIN128)
// Brand: Daikin, Model: FTXB12AXVJU A/C (DAIKIN128)
// Brand: Daikin, Model: FTXB09AXVJU A/C (DAIKIN128)
// Brand: Daikin, Model: BRC52B63 remote (DAIKIN128)
// Brand: Daikin, Model: ARC480A5 remote (DAIKIN152)
// Brand: Daikin, Model: FFN-C/FCN-F Series A/C (DAIKIN64)
// Brand: Daikin, Model: DGS01 remote (DAIKIN64)
// Brand: Daikin, Model: M Series A/C (DAIKIN)
// Brand: Daikin, Model: FTXM-M A/C (DAIKIN)
// Brand: Daikin, Model: ARC466A33 remote (DAIKIN)
#ifndef IR_DAIKIN_H_
#define IR_DAIKIN_H_
#ifndef UNIT_TEST
#include <Arduino.h>
#endif
#include "IRrecv.h"
#include "IRremoteESP8266.h"
#include "IRsend.h"
#ifdef UNIT_TEST
#include "IRsend_test.h"
#endif
/// Native representation of a Daikin A/C message.
union DaikinESPProtocol{
uint8_t raw[kDaikinStateLength]; ///< The state of the IR remote.
struct {
// Byte 0~5
uint64_t :48;
// Byte 6
uint64_t :4;
uint64_t Comfort :1;
uint64_t :3;
// Byte 7
uint64_t Sum1 :8; // checksum of the first part
// Byte 8~12
uint64_t :40;
// Byte 13~14
uint64_t CurrentTime :11; // Current time, mins past midnight
uint64_t CurrentDay :3; // Day of the week (SUN=1, MON=2, ..., SAT=7)
uint64_t :2;
// Byte 15
uint64_t Sum2 :8; // checksum of the second part
// Byte 16~20
uint64_t :40;
// Byte 21
uint64_t Power :1;
uint64_t OnTimer :1;
uint64_t OffTimer :1;
uint64_t :1; // always 1
uint64_t Mode :3;
uint64_t :1;
// Byte 22
uint64_t :1;
uint64_t Temp :7; // Temp should be between 10 - 32
// Byte 23
uint64_t :8;
// Byte 24
uint64_t SwingV :4; // 0000 = off, 1111 = on
uint64_t Fan :4;
// Byte 25
uint64_t SwingH :4; // 0000 = off, 1111 = on
uint64_t :4;
// Byte 26~28
uint64_t OnTime :12; // timer mins past midnight
uint64_t OffTime :12; // timer mins past midnight
// Byte 29
uint64_t Powerful :1;
uint64_t :4;
uint64_t Quiet :1;
uint64_t :2;
// Byte 30~31
uint64_t :0;
// Byte 32
uint8_t :1;
uint8_t Sensor :1;
uint8_t Econo :1;
uint8_t :4;
uint8_t WeeklyTimer :1;
// Byte 33
uint8_t :1;
uint8_t Mold :1;
uint8_t :6;
// Byte 34
uint8_t Sum3 :8; // checksum of the third part
};
};
// Constants
const uint8_t kDaikinAuto = 0b000; // temp 25
const uint8_t kDaikinDry = 0b010; // temp 0xc0 = 96 degrees c
const uint8_t kDaikinCool = 0b011;
const uint8_t kDaikinHeat = 0b100; // temp 23
const uint8_t kDaikinFan = 0b110; // temp not shown, but 25
const uint8_t kDaikinMinTemp = 10; // Celsius
const uint8_t kDaikinMaxTemp = 32; // Celsius
const uint8_t kDaikinFanMin = 1;
const uint8_t kDaikinFanMed = 3;
const uint8_t kDaikinFanMax = 5;
const uint8_t kDaikinFanAuto = 0b1010; // 10 / 0xA
const uint8_t kDaikinFanQuiet = 0b1011; // 11 / 0xB
const uint8_t kDaikinSwingOn = 0b1111;
const uint8_t kDaikinSwingOff = 0b0000;
const uint16_t kDaikinHeaderLength = 5;
const uint8_t kDaikinSections = 3;
const uint8_t kDaikinSection1Length = 8;
const uint8_t kDaikinSection2Length = 8;
const uint8_t kDaikinSection3Length =
kDaikinStateLength - kDaikinSection1Length - kDaikinSection2Length;
const uint8_t kDaikinByteChecksum1 = 7;
const uint8_t kDaikinByteChecksum2 = 15;
// const uint8_t kDaikinBitEye = 0b10000000;
const uint16_t kDaikinUnusedTime = 0x600;
const uint8_t kDaikinBeepQuiet = 1;
const uint8_t kDaikinBeepLoud = 2;
const uint8_t kDaikinBeepOff = 3;
const uint8_t kDaikinLightBright = 1;
const uint8_t kDaikinLightDim = 2;
const uint8_t kDaikinLightOff = 3;
const uint8_t kDaikinCurBit = kDaikinStateLength;
const uint8_t kDaikinCurIndex = kDaikinStateLength + 1;
const uint8_t kDaikinTolerance = 35;
const uint16_t kDaikinMarkExcess = kMarkExcess;
const uint16_t kDaikinHdrMark = 3650; // kDaikinBitMark * 8
const uint16_t kDaikinHdrSpace = 1623; // kDaikinBitMark * 4
const uint16_t kDaikinBitMark = 428;
const uint16_t kDaikinZeroSpace = 428;
const uint16_t kDaikinOneSpace = 1280;
const uint16_t kDaikinGap = 29000;
// Note bits in each octet swapped so can be sent as a single value
const uint64_t kDaikinFirstHeader64 =
0b1101011100000000000000001100010100000000001001111101101000010001;
/// Native representation of a Daikin2 A/C message.
union Daikin2Protocol{
struct{
uint8_t pad[3];
uint8_t raw[kDaikin2StateLength]; ///< The state of the IR remote.
};
struct {
// Byte -3~4
uint64_t :64;
// Byte 5~6
uint64_t CurrentTime :12;
uint64_t :3;
uint64_t Power2 :1;
// Byte 7
uint64_t :4;
uint64_t Light :2;
uint64_t Beep :2;
// Byte 8
uint64_t FreshAir :1;
uint64_t :2;
uint64_t Mold :1;
uint64_t :1;
uint64_t Clean :1;
uint64_t :1;
uint64_t FreshAirHigh :1;
// Byte 9~12
uint64_t :32;
// Byte 13
uint64_t :7;
uint64_t EyeAuto :1;
// Byte 14~16
uint64_t :24;
// Byte 17
uint64_t SwingH :8;
// Byte 18
uint64_t SwingV :4;
uint64_t :4;
// Byte 19
uint64_t Sum1 :8;
// Byte 20
uint64_t :8;
// Byte 21~24
uint64_t :32;
// Byte 25
uint64_t Power :1;
uint64_t OnTimer :1;
uint64_t OffTimer :1;
uint64_t :1;
uint64_t Mode :3;
uint64_t :1;
// Byte 26
uint64_t :1;
uint64_t Temp :7;
// Byte 27
uint64_t :8;
// Byte 28
uint64_t :4;
uint64_t Fan :4;
// Byte 29
uint64_t :8;
// Byte 30~32
/// @see https://github.com/crankyoldgit/IRremoteESP8266/pull/1264
uint64_t OnTime :12;
uint64_t OffTime :12;
// Byte 33
uint64_t Powerful :1;
uint64_t :4;
uint64_t Quiet :1;
uint64_t :2;
// Byte 34~35
uint64_t :16;
// Byte 36
uint64_t :1;
uint64_t Eye :1;
uint64_t Econo :1;
uint64_t :1;
uint64_t Purify :1;
uint64_t SleepTimer :1;
uint64_t :2;
// Byte 37
uint8_t :8;
// Byte 38
uint8_t Sum2 :8;
};
};
const uint16_t kDaikin2Freq = 36700; // Modulation Frequency in Hz.
const uint16_t kDaikin2LeaderMark = 10024;
const uint16_t kDaikin2LeaderSpace = 25180;
const uint16_t kDaikin2Gap = kDaikin2LeaderMark + kDaikin2LeaderSpace;
const uint16_t kDaikin2HdrMark = 3500;
const uint16_t kDaikin2HdrSpace = 1728;
const uint16_t kDaikin2BitMark = 460;
const uint16_t kDaikin2OneSpace = 1270;
const uint16_t kDaikin2ZeroSpace = 420;
const uint16_t kDaikin2Sections = 2;
const uint16_t kDaikin2Section1Length = 20;
const uint16_t kDaikin2Section2Length = 19;
const uint8_t kDaikin2Tolerance = 5; // Extra percentage tolerance
const uint8_t kDaikin2SwingVHighest = 0x1;
const uint8_t kDaikin2SwingVHigh = 0x2;
const uint8_t kDaikin2SwingVUpperMiddle = 0x3;
const uint8_t kDaikin2SwingVLowerMiddle = 0x4;
const uint8_t kDaikin2SwingVLow = 0x5;
const uint8_t kDaikin2SwingVLowest = 0x6;
const uint8_t kDaikin2SwingVBreeze = 0xC;
const uint8_t kDaikin2SwingVCirculate = 0xD;
const uint8_t kDaikin2SwingVOff = 0xE;
const uint8_t kDaikin2SwingVAuto = 0xF; // A.k.a "Swing"
const uint8_t kDaikin2SwingVSwing = kDaikin2SwingVAuto;
const uint8_t kDaikin2SwingHWide = 0xA3;
const uint8_t kDaikin2SwingHLeftMax = 0xA8;
const uint8_t kDaikin2SwingHLeft = 0xA9;
const uint8_t kDaikin2SwingHMiddle = 0xAA;
const uint8_t kDaikin2SwingHRight = 0xAB;
const uint8_t kDaikin2SwingHRightMax = 0xAC;
const uint8_t kDaikin2SwingHAuto = 0xBE; // A.k.a "Swing"
const uint8_t kDaikin2SwingHOff = 0xBF;
const uint8_t kDaikin2SwingHSwing = kDaikin2SwingHAuto;
const uint8_t kDaikin2MinCoolTemp = 18; // Min temp (in C) when in Cool mode.
/// Native representation of a Daikin216 A/C message.
union Daikin216Protocol{
uint8_t raw[kDaikin216StateLength]; ///< The state of the IR remote.
struct {
// Byte 0~6
uint8_t pad0[7];
// Byte 7
uint8_t Sum1 :8;
// Byte 8~12
uint8_t pad1[5];
// Byte 13
uint8_t Power :1;
uint8_t :3;
uint8_t Mode :3;
uint8_t :1;
// Byte 14
uint8_t :1;
uint8_t Temp :6;
uint8_t :1;
// Byte 15
uint8_t :8;
// Byte 16
uint8_t SwingV :4;
uint8_t Fan :4;
// Byte 17
uint8_t SwingH :4;
uint8_t :4;
// Byte 18~20
uint8_t pad2[3];
// Byte 21
uint8_t Powerful :1;
uint8_t :0;
// Byte 22~25
uint8_t pad3[4];
// Byte 26
uint8_t Sum2 :8;
};
};
const uint16_t kDaikin216Freq = 38000; // Modulation Frequency in Hz.
const uint16_t kDaikin216HdrMark = 3440;
const uint16_t kDaikin216HdrSpace = 1750;
const uint16_t kDaikin216BitMark = 420;
const uint16_t kDaikin216OneSpace = 1300;
const uint16_t kDaikin216ZeroSpace = 450;
const uint16_t kDaikin216Gap = 29650;
const uint16_t kDaikin216Sections = 2;
const uint16_t kDaikin216Section1Length = 8;
const uint16_t kDaikin216Section2Length = kDaikin216StateLength -
kDaikin216Section1Length;
const uint8_t kDaikin216SwingOn = 0b1111;
const uint8_t kDaikin216SwingOff = 0b0000;
/// Native representation of a Daikin160 A/C message.
union Daikin160Protocol{
uint8_t raw[kDaikin160StateLength]; ///< The state of the IR remote.
struct {
// Byte 0~5
uint8_t pad0[6];
// Byte 6
uint8_t Sum1 :8;
// Byte 7~11
uint8_t pad1[5];
// Byte 12
uint8_t Power :1;
uint8_t :3;
uint8_t Mode :3;
uint8_t :1;
// Byte 13
uint8_t :4;
uint8_t SwingV :4;
// Byte 14~15
uint8_t pad2[2];
// Byte 16
uint8_t :1;
uint8_t Temp :6;
uint8_t :1;
// Byte 17
uint8_t Fan :4;
uint8_t :4;
// Byte 18
uint8_t :8;
// Byte 19
uint8_t Sum2 :8;
};
};
const uint16_t kDaikin160Freq = 38000; // Modulation Frequency in Hz.
const uint16_t kDaikin160HdrMark = 5000;
const uint16_t kDaikin160HdrSpace = 2145;
const uint16_t kDaikin160BitMark = 342;
const uint16_t kDaikin160OneSpace = 1786;
const uint16_t kDaikin160ZeroSpace = 700;
const uint16_t kDaikin160Gap = 29650;
const uint16_t kDaikin160Sections = 2;
const uint16_t kDaikin160Section1Length = 7;
const uint16_t kDaikin160Section2Length = kDaikin160StateLength -
kDaikin160Section1Length;
const uint8_t kDaikin160SwingVLowest = 0x1;
const uint8_t kDaikin160SwingVLow = 0x2;
const uint8_t kDaikin160SwingVMiddle = 0x3;
const uint8_t kDaikin160SwingVHigh = 0x4;
const uint8_t kDaikin160SwingVHighest = 0x5;
const uint8_t kDaikin160SwingVAuto = 0xF;
/// Native representation of a Daikin176 A/C message.
union Daikin176Protocol{
uint8_t raw[kDaikin176StateLength]; ///< The state of the IR remote.
struct {
// Byte 0~5
uint8_t pad0[6];
// Byte 6
uint8_t Sum1 :8;
// Byte 7~11
uint8_t pad1[5];
// Byte 12
uint8_t :4;
uint8_t AltMode :3;
uint8_t :1;
// Byte 13
uint8_t ModeButton :8;
// Byte 14
uint8_t Power :1;
uint8_t :3;
uint8_t Mode :3;
uint8_t :1;
// Byte 15~16
uint8_t pad2[2];
// Byte 17
uint8_t :1;
uint8_t Temp :6;
uint8_t :1;
// Byte 18
uint8_t SwingH :4;
uint8_t Fan :4;
// Byte 19~20
uint8_t pad3[2];
// Byte 21
uint8_t Sum2 :8;
};
};
const uint16_t kDaikin176Freq = 38000; // Modulation Frequency in Hz.
const uint16_t kDaikin176HdrMark = 5070;
const uint16_t kDaikin176HdrSpace = 2140;
const uint16_t kDaikin176BitMark = 370;
const uint16_t kDaikin176OneSpace = 1780;
const uint16_t kDaikin176ZeroSpace = 710;
const uint16_t kDaikin176Gap = 29410;
const uint16_t kDaikin176Sections = 2;
const uint16_t kDaikin176Section1Length = 7;
const uint16_t kDaikin176Section2Length = kDaikin176StateLength -
kDaikin176Section1Length;
const uint8_t kDaikin176Fan = 0b000; // 0
const uint8_t kDaikin176Heat = 0b001; // 1
const uint8_t kDaikin176Cool = 0b010; // 2
const uint8_t kDaikin176Auto = 0b011; // 3
const uint8_t kDaikin176Dry = 0b111; // 7
const uint8_t kDaikin176ModeButton = 0b00000100;
const uint8_t kDaikin176DryFanTemp = 17; // Dry/Fan mode is always 17 Celsius.
const uint8_t kDaikin176FanMax = 3;
const uint8_t kDaikin176SwingHAuto = 0x5;
const uint8_t kDaikin176SwingHOff = 0x6;
/// Native representation of a Daikin128 A/C message.
union Daikin128Protocol{
uint8_t raw[kDaikin128StateLength]; ///< The state of the IR remote.
struct {
// Byte 0
uint8_t :8;
// Byte 1
uint8_t Mode :4;
uint8_t Fan :4;
// Byte 2
uint8_t ClockMins :8;
// Byte 3
uint8_t ClockHours :8;
// Byte 4
uint8_t OnHours :6;
uint8_t OnHalfHour :1;
uint8_t OnTimer :1;
// Byte 5
uint8_t OffHours :6;
uint8_t OffHalfHour :1;
uint8_t OffTimer :1;
// Byte 6
uint8_t Temp :8;
// Byte 7
uint8_t SwingV :1;
uint8_t Sleep :1;
uint8_t :1; // always 1
uint8_t Power :1;
uint8_t Sum1 :4;
// Byte 8
uint8_t :8;
// Byte 9
uint8_t Ceiling :1;
uint8_t :1;
uint8_t Econo :1;
uint8_t Wall :1;
uint8_t :4;
// Byte 10~14
uint8_t pad[5];
// Byte 15
uint8_t Sum2 :8;
};
};
const uint16_t kDaikin128Freq = 38000; // Modulation Frequency in Hz.
const uint16_t kDaikin128LeaderMark = 9800;
const uint16_t kDaikin128LeaderSpace = 9800;
const uint16_t kDaikin128HdrMark = 4600;
const uint16_t kDaikin128HdrSpace = 2500;
const uint16_t kDaikin128BitMark = 350;
const uint16_t kDaikin128OneSpace = 954;
const uint16_t kDaikin128ZeroSpace = 382;
const uint16_t kDaikin128Gap = 20300;
const uint16_t kDaikin128FooterMark = kDaikin128HdrMark;
const uint16_t kDaikin128Sections = 2;
const uint16_t kDaikin128SectionLength = 8;
const uint8_t kDaikin128Dry = 0b00000001;
const uint8_t kDaikin128Cool = 0b00000010;
const uint8_t kDaikin128Fan = 0b00000100;
const uint8_t kDaikin128Heat = 0b00001000;
const uint8_t kDaikin128Auto = 0b00001010;
const uint8_t kDaikin128FanAuto = 0b0001;
const uint8_t kDaikin128FanHigh = 0b0010;
const uint8_t kDaikin128FanMed = 0b0100;
const uint8_t kDaikin128FanLow = 0b1000;
const uint8_t kDaikin128FanPowerful = 0b0011;
const uint8_t kDaikin128FanQuiet = 0b1001;
const uint8_t kDaikin128MinTemp = 16; // C
const uint8_t kDaikin128MaxTemp = 30; // C
const uint8_t kDaikin128BitWall = 0b00001000;
const uint8_t kDaikin128BitCeiling = 0b00000001;
/// Native representation of a Daikin152 A/C message.
union Daikin152Protocol{
uint8_t raw[kDaikin152StateLength]; ///< The state of the IR remote.
struct {
// Byte 0~4
uint8_t pad0[5];
// Byte 5
uint8_t Power :1;
uint8_t :3;
uint8_t Mode :3;
uint8_t :1;
// Byte 6
uint8_t :1;
uint8_t Temp :7;
// Byte 7
uint8_t :8;
// Byte 8
uint8_t SwingV :4;
uint8_t Fan :4;
// Byte 9~12
uint8_t pad1[4];
// Byte 13
uint8_t Powerful :1;
uint8_t :4;
uint8_t Quiet :1;
uint8_t :2;
// Byte 14~15
uint8_t pad2[2];
// Byte 16
uint8_t :1;
uint8_t Comfort :1;
uint8_t Econo :1;
uint8_t Sensor :1;
uint8_t :4;
// Byte 17
uint8_t :8;
// Byte 18
uint8_t Sum :8;
};
};
const uint16_t kDaikin152Freq = 38000; // Modulation Frequency in Hz.
const uint8_t kDaikin152LeaderBits = 5;
const uint16_t kDaikin152HdrMark = 3492;
const uint16_t kDaikin152HdrSpace = 1718;
const uint16_t kDaikin152BitMark = 433;
const uint16_t kDaikin152OneSpace = 1529;
const uint16_t kDaikin152ZeroSpace = kDaikin152BitMark;
const uint16_t kDaikin152Gap = 25182;
const uint8_t kDaikin152DryTemp = kDaikin2MinCoolTemp; // Celsius
const uint8_t kDaikin152FanTemp = 0x60; // 96 Celsius
/// Native representation of a Daikin64 A/C message.
union Daikin64Protocol{
uint64_t raw; ///< The state of the IR remote.
struct {
uint8_t :8;
uint8_t Mode :4;
uint8_t Fan :4;
uint8_t ClockMins :8;
uint8_t ClockHours :8;
uint8_t OnHours :6;
uint8_t OnHalfHour :1;
uint8_t OnTimer :1;
uint8_t OffHours :6;
uint8_t OffHalfHour :1;
uint8_t OffTimer :1;
uint8_t Temp :8;
uint8_t SwingV :1;
uint8_t Sleep :1;
uint8_t :1;
uint8_t Power :1;
uint8_t Sum :4;
};
};
const uint16_t kDaikin64HdrMark = kDaikin128HdrMark;
const uint16_t kDaikin64BitMark = kDaikin128BitMark;
const uint16_t kDaikin64HdrSpace = kDaikin128HdrSpace;
const uint16_t kDaikin64OneSpace = kDaikin128OneSpace;
const uint16_t kDaikin64ZeroSpace = kDaikin128ZeroSpace;
const uint16_t kDaikin64LdrMark = kDaikin128LeaderMark;
const uint16_t kDaikin64Gap = kDaikin128Gap;
const uint16_t kDaikin64LdrSpace = kDaikin128LeaderSpace;
const uint16_t kDaikin64Freq = kDaikin128Freq; // Hz.
const uint8_t kDaikin64Overhead = 9;
const int8_t kDaikin64ToleranceDelta = 5; // +5%
const uint64_t kDaikin64KnownGoodState = 0x7C16161607204216;
const uint8_t kDaikin64Dry = 0b001;
const uint8_t kDaikin64Cool = 0b010;
const uint8_t kDaikin64Fan = 0b100;
const uint8_t kDaikin64FanAuto = 0b0001;
const uint8_t kDaikin64FanLow = 0b1000;
const uint8_t kDaikin64FanMed = 0b0100;
const uint8_t kDaikin64FanHigh = 0b0010;
const uint8_t kDaikin64FanQuiet = 0b1001;
const uint8_t kDaikin64FanTurbo = 0b0011;
const uint8_t kDaikin64MinTemp = 16; // Celsius
const uint8_t kDaikin64MaxTemp = 30; // Celsius
const uint8_t kDaikin64ChecksumOffset = 60;
const uint8_t kDaikin64ChecksumSize = 4; // Mask 0b1111 << 59
// Legacy defines.
#define DAIKIN_COOL kDaikinCool
#define DAIKIN_HEAT kDaikinHeat
#define DAIKIN_FAN kDaikinFan
#define DAIKIN_AUTO kDaikinAuto
#define DAIKIN_DRY kDaikinDry
#define DAIKIN_MIN_TEMP kDaikinMinTemp
#define DAIKIN_MAX_TEMP kDaikinMaxTemp
#define DAIKIN_FAN_MIN kDaikinFanMin
#define DAIKIN_FAN_MAX kDaikinFanMax
#define DAIKIN_FAN_AUTO kDaikinFanAuto
#define DAIKIN_FAN_QUIET kDaikinFanQuiet
/// Class for handling detailed Daikin 280-bit A/C messages.
class IRDaikinESP {
public:
explicit IRDaikinESP(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
#if SEND_DAIKIN
void send(const uint16_t repeat = kDaikinDefaultRepeat);
/// Run the calibration to calculate uSec timing offsets for this platform.
/// @return The uSec timing offset needed per modulation of the IR Led.
/// @note This will produce a 65ms IR signal pulse at 38kHz.
/// Only ever needs to be run once per object instantiation, if at all.
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif
void begin(void);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setFan(const uint8_t fan);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
void setSwingVertical(const bool on);
bool getSwingVertical(void) const;
void setSwingHorizontal(const bool on);
bool getSwingHorizontal(void) const;
bool getQuiet(void) const;
void setQuiet(const bool on);
bool getPowerful(void) const;
void setPowerful(const bool on);
void setSensor(const bool on);
bool getSensor(void) const;
void setEcono(const bool on);
bool getEcono(void) const;
void setMold(const bool on);
bool getMold(void) const;
void setComfort(const bool on);
bool getComfort(void) const;
void enableOnTimer(const uint16_t starttime);
void disableOnTimer(void);
uint16_t getOnTime(void) const;
bool getOnTimerEnabled(void) const;
void enableOffTimer(const uint16_t endtime);
void disableOffTimer(void);
uint16_t getOffTime(void) const;
bool getOffTimerEnabled(void) const;
void setCurrentTime(const uint16_t mins_since_midnight);
uint16_t getCurrentTime(void) const;
void setCurrentDay(const uint8_t day_of_week);
uint8_t getCurrentDay(void) const;
void setWeeklyTimerEnable(const bool on);
bool getWeeklyTimerEnable(void) const;
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[],
const uint16_t length = kDaikinStateLength);
static bool validChecksum(uint8_t state[],
const uint16_t length = kDaikinStateLength);
static uint8_t convertMode(const stdAc::opmode_t mode);
static uint8_t convertFan(const stdAc::fanspeed_t speed);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend; ///< instance of the IR send class
#else
/// @cond IGNORE
IRsendTest _irsend; ///< instance of the testing IR send class
/// @endcond
#endif
// # of bytes per command
DaikinESPProtocol _;
void stateReset(void);
void checksum(void);
};
/// Class for handling detailed Daikin 312-bit A/C messages.
/// @note Code by crankyoldgit, Reverse engineering analysis by sheppy99
class IRDaikin2 {
public:
explicit IRDaikin2(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
#if SEND_DAIKIN2
void send(const uint16_t repeat = kDaikin2DefaultRepeat);
/// Run the calibration to calculate uSec timing offsets for this platform.
/// @return The uSec timing offset needed per modulation of the IR Led.
/// @note This will produce a 65ms IR signal pulse at 38kHz.
/// Only ever needs to be run once per object instantiation, if at all.
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif
void begin(void);
void on(void);
void off(void);
void setPower(const bool state);
bool getPower(void) const;
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setFan(const uint8_t fan);
uint8_t getFan(void) const;
uint8_t getMode(void) const;
void setMode(const uint8_t mode);
void setSwingVertical(const uint8_t position);
uint8_t getSwingVertical(void) const;
void setSwingHorizontal(const uint8_t position);
uint8_t getSwingHorizontal(void) const;
bool getQuiet(void) const;
void setQuiet(const bool on);
bool getPowerful(void) const;
void setPowerful(const bool on);
void setEcono(const bool on);
bool getEcono(void) const;
void setEye(const bool on);
bool getEye(void) const;
void setEyeAuto(const bool on);
bool getEyeAuto(void) const;
void setPurify(const bool on);
bool getPurify(void) const;
void setMold(const bool on);
bool getMold(void) const;
void enableOnTimer(const uint16_t starttime);
void disableOnTimer(void);
uint16_t getOnTime(void) const;
bool getOnTimerEnabled(void) const;
void enableSleepTimer(const uint16_t sleeptime);
void disableSleepTimer(void);
uint16_t getSleepTime(void) const;
bool getSleepTimerEnabled(void) const;
void enableOffTimer(const uint16_t endtime);
void disableOffTimer(void);
uint16_t getOffTime(void) const;
bool getOffTimerEnabled(void) const;
void setCurrentTime(const uint16_t time);
uint16_t getCurrentTime(void) const;
void setBeep(const uint8_t beep);
uint8_t getBeep(void) const;
void setLight(const uint8_t light);
uint8_t getLight(void) const;
void setClean(const bool on);
bool getClean(void) const;
void setFreshAir(const bool on);
bool getFreshAir(void) const;
void setFreshAirHigh(const bool on);
bool getFreshAirHigh(void) const;
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[]);
static bool validChecksum(uint8_t state[],
const uint16_t length = kDaikin2StateLength);
static uint8_t convertMode(const stdAc::opmode_t mode);
static uint8_t convertFan(const stdAc::fanspeed_t speed);
static uint8_t convertSwingV(const stdAc::swingv_t position);
static uint8_t convertSwingH(const stdAc::swingh_t position);
static stdAc::swingv_t toCommonSwingV(const uint8_t setting);
static stdAc::swingh_t toCommonSwingH(const uint8_t setting);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend; ///< instance of the IR send class
#else
/// @cond IGNORE
IRsendTest _irsend; ///< instance of the testing IR send class
/// @endcond
#endif
// # of bytes per command
Daikin2Protocol _;
void stateReset(void);
void checksum(void);
void clearOnTimerFlag(void);
void clearSleepTimerFlag(void);
};
/// Class for handling detailed Daikin 216-bit A/C messages.
class IRDaikin216 {
public:
explicit IRDaikin216(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
#if SEND_DAIKIN216
void send(const uint16_t repeat = kDaikin216DefaultRepeat);
/// Run the calibration to calculate uSec timing offsets for this platform.
/// @return The uSec timing offset needed per modulation of the IR Led.
/// @note This will produce a 65ms IR signal pulse at 38kHz.
/// Only ever needs to be run once per object instantiation, if at all.
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif
void begin(void);
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[]);
static bool validChecksum(uint8_t state[],
const uint16_t length = kDaikin216StateLength);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
static uint8_t convertMode(const stdAc::opmode_t mode);
void setFan(const uint8_t fan);
uint8_t getFan(void) const;
static uint8_t convertFan(const stdAc::fanspeed_t speed);
void setSwingVertical(const bool on);
bool getSwingVertical(void) const;
void setSwingHorizontal(const bool on);
bool getSwingHorizontal(void) const;
void setQuiet(const bool on);
bool getQuiet(void) const;
void setPowerful(const bool on);
bool getPowerful(void) const;
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend; ///< instance of the IR send class
#else
/// @cond IGNORE
IRsendTest _irsend; ///< instance of the testing IR send class
/// @endcond
#endif
// # of bytes per command
Daikin216Protocol _;
void stateReset(void);
void checksum(void);
};
/// Class for handling detailed Daikin 160-bit A/C messages.
class IRDaikin160 {
public:
explicit IRDaikin160(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
#if SEND_DAIKIN160
void send(const uint16_t repeat = kDaikin160DefaultRepeat);
/// Run the calibration to calculate uSec timing offsets for this platform.
/// @return The uSec timing offset needed per modulation of the IR Led.
/// @note This will produce a 65ms IR signal pulse at 38kHz.
/// Only ever needs to be run once per object instantiation, if at all.
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif
void begin(void);
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[]);
static bool validChecksum(uint8_t state[],
const uint16_t length = kDaikin160StateLength);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
static uint8_t convertMode(const stdAc::opmode_t mode);
void setFan(const uint8_t fan);
uint8_t getFan(void) const;
static uint8_t convertFan(const stdAc::fanspeed_t speed);
void setSwingVertical(const uint8_t position);
uint8_t getSwingVertical(void) const;
static uint8_t convertSwingV(const stdAc::swingv_t position);
static stdAc::swingv_t toCommonSwingV(const uint8_t setting);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend; ///< instance of the IR send class
#else
/// @cond IGNORE
IRsendTest _irsend; ///< instance of the testing IR send class
/// @endcond
#endif
// # of bytes per command
Daikin160Protocol _;
void stateReset(void);
void checksum(void);
};
/// Class for handling detailed Daikin 176-bit A/C messages.
class IRDaikin176 {
public:
explicit IRDaikin176(const uint16_t pin, const bool inverted = false,
const bool use_modulation = true);
#if SEND_DAIKIN176
void send(const uint16_t repeat = kDaikin176DefaultRepeat);
/// Run the calibration to calculate uSec timing offsets for this platform.
/// @return The uSec timing offset needed per modulation of the IR Led.
/// @note This will produce a 65ms IR signal pulse at 38kHz.
/// Only ever needs to be run once per object instantiation, if at all.
int8_t calibrate(void) { return _irsend.calibrate(); }
#endif
void begin(void);
uint8_t* getRaw(void);
void setRaw(const uint8_t new_code[]);
static bool validChecksum(uint8_t state[],
const uint16_t length = kDaikin176StateLength);
void on(void);
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setMode(const uint8_t mode);
uint8_t getMode(void) const;
static uint8_t convertMode(const stdAc::opmode_t mode);
void setFan(const uint8_t fan);
uint8_t getFan(void) const;
static uint8_t convertFan(const stdAc::fanspeed_t speed);
void setSwingHorizontal(const uint8_t position);
uint8_t getSwingHorizontal(void) const;
static uint8_t convertSwingH(const stdAc::swingh_t position);
static stdAc::fanspeed_t toCommonFanSpeed(const uint8_t speed);
static stdAc::opmode_t toCommonMode(const uint8_t mode);
static stdAc::swingh_t toCommonSwingH(const uint8_t setting);
stdAc::state_t toCommon(void) const;
String toString(void) const;
#ifndef UNIT_TEST
private:
IRsend _irsend; ///< instance of the IR send class
#else
/// @cond IGNORE
IRsendTest _irsend; ///< instance of the testing IR send class
/// @endcond
#endif
// # of bytes per command
Daikin176Protocol _;
uint8_t _saved_temp; ///< The previously user requested temp value.
void stateReset(void);
void checksum(void);
};
/// Class for handling detailed Daikin 128-bit A/C messages.
/// @note Code by crankyoldgit. Analysis by Daniel Vena