supla-device
Loading...
Searching...
No Matches
SuplaSomfy.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
16 Library for Somfy RTS remote controller
17 Author: Maciej Królewski
18 Using documantation: https://pushstack.wordpress.com/somfy-rts-protocol/
19*/
20
21#ifndef SRC_SUPLASOMFY_H_
22#define SRC_SUPLASOMFY_H_
23
24#include "Arduino.h"
25
26#define DEBUG_SOMFY
27
28// ----- DO NOT CHANGE -----
29#define FRAME_SIZE 7 // Somfy RTS frame size
30#define BASIC_TIME 604 // Basic time [us]
31// -------------------------
32
33typedef uint8_t somfy_frame_t;
34typedef union {
35 struct {
36 uint8_t byte1;
37 uint8_t byte2;
38 } svalue;
39 uint8_t tvalue[2];
40 uint16_t ivalue;
42typedef union {
43 struct {
44 uint8_t byte1;
45 uint8_t byte2;
46 uint8_t byte3;
47 } svalue;
48 uint8_t tvalue[3];
49 uint32_t ivalue : 24;
51
52enum /*class*/ ControlButtons {
53 STOP = 0x1, // [My] Stop or move to favourite position
54 UP = 0x2, // [Up] Move Up
55 MYUP = 0x3, // [My + Up] Set upper motor limit in initial
56 // programming mode
57 DOWN = 0x4, // [Down] Move Down
58 MYDOWN =
59 0x5, // [My + Down] Set lower motor limit in initial programming mode
60 UPDOWN = 0x6, // [Up + Down] Change motor limit and initial
61 // programming mode
62 PROG = 0x8, // [Prog] Registering / Deregistering remotes
63 SUN = 0x9, // [Sun + Flag] Enable sun and wind detector (SUN and FLAG
64 // TIME on the Telis Soliris RC)
65 FLAG = 0xA // [Flag] Disable sun detector (FLAG TIME on the Telis
66 // Soliris RC)
67};
68
70 somfy_rollingcode_t rollingCode;
71 somfy_remotesn_t remoteControl;
72};
73
74class SuplaSomfy {
75 private:
76 uint8_t _dataPin;
77 somfy_remote_t _remote;
78
79 void SendBitZero(void);
80 void SendBitOne(void);
81 uint8_t Checksum(somfy_frame_t *frame);
82 void Obfuscation(somfy_frame_t *frame);
83 void SendCommand(somfy_frame_t *frame, uint8_t sync);
84
85 public:
86 explicit SuplaSomfy(uint8_t dataPin);
87 ~SuplaSomfy(void);
88 void SetRemote(somfy_remote_t remote);
89 somfy_remote_t GetRemote(void);
90 void PushButton(ControlButtons pushButton);
91
92#if defined DEBUG_SOMFY
93 void PrintHex8(uint8_t *data, uint8_t length);
94#endif
95};
96
97#endif // SRC_SUPLASOMFY_H_
Definition SuplaSomfy.h:69
Definition SuplaSomfy.h:42
Definition SuplaSomfy.h:34