supla-device
Loading...
Searching...
No Matches
SuplaSomfy.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLASOMFY_H_
5#define SRC_SUPLASOMFY_H_
6
7#include "Arduino.h"
8
9#define DEBUG_SOMFY
10
11// ----- DO NOT CHANGE -----
12#define FRAME_SIZE 7 // Somfy RTS frame size
13#define BASIC_TIME 604 // Basic time [us]
14// -------------------------
15
16typedef uint8_t somfy_frame_t;
17typedef union {
18 struct {
19 uint8_t byte1;
20 uint8_t byte2;
21 } svalue;
22 uint8_t tvalue[2];
23 uint16_t ivalue;
25typedef union {
26 struct {
27 uint8_t byte1;
28 uint8_t byte2;
29 uint8_t byte3;
30 } svalue;
31 uint8_t tvalue[3];
32 uint32_t ivalue : 24;
34
35enum /*class*/ ControlButtons {
36 STOP = 0x1, // [My] Stop or move to favourite position
37 UP = 0x2, // [Up] Move Up
38 MYUP = 0x3, // [My + Up] Set upper motor limit in initial
39 // programming mode
40 DOWN = 0x4, // [Down] Move Down
41 MYDOWN =
42 0x5, // [My + Down] Set lower motor limit in initial programming mode
43 UPDOWN = 0x6, // [Up + Down] Change motor limit and initial
44 // programming mode
45 PROG = 0x8, // [Prog] Registering / Deregistering remotes
46 SUN = 0x9, // [Sun + Flag] Enable sun and wind detector (SUN and FLAG
47 // TIME on the Telis Soliris RC)
48 FLAG = 0xA // [Flag] Disable sun detector (FLAG TIME on the Telis
49 // Soliris RC)
50};
51
53 somfy_rollingcode_t rollingCode;
54 somfy_remotesn_t remoteControl;
55};
56
58 private:
59 uint8_t _dataPin;
60 somfy_remote_t _remote;
61
62 void SendBitZero(void);
63 void SendBitOne(void);
64 uint8_t Checksum(somfy_frame_t *frame);
65 void Obfuscation(somfy_frame_t *frame);
66 void SendCommand(somfy_frame_t *frame, uint8_t sync);
67
68 public:
69 explicit SuplaSomfy(uint8_t dataPin);
70 ~SuplaSomfy(void);
71 void SetRemote(somfy_remote_t remote);
72 somfy_remote_t GetRemote(void);
73 void PushButton(ControlButtons pushButton);
74
75#if defined DEBUG_SOMFY
76 void PrintHex8(uint8_t *data, uint8_t length);
77#endif
78};
79
80#endif // SRC_SUPLASOMFY_H_
Definition SuplaSomfy.h:57
Definition SuplaSomfy.h:52
Definition SuplaSomfy.h:25
Definition SuplaSomfy.h:17