| LightHub v4.0.0 Smarthome controller firmware

owTerm.h
Go to the documentation of this file.
1 /* Copyright © 2017-2020 Andrey Klimov. All rights reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14
15 Homepage: http://lazyhome.ru
16 GIT: https://github.com/anklimov/lighthub
17 e-mail anklimov@gmail.com
18
19 */
20
21 //define APU_OFF
22 #pragma once
23
24 #define SW_AUX0 0x40
25 #define SW_AUX1 0x80
26 #define SW_STAT0 0x4
27 #define SW_STAT1 0x8
28 #define SW_OUT0 0x20
29 #define SW_OUT1 0x10
30 #define SW_MASK 0xF
31 #define SW_INMASK 0xFC
32
33 #define recheck_interval 5
34 #define check_circle 2000/t_count
35
36 #define SW_FIND 1
37 #define SW_DOUBLECHECK 2 //Doublecheck required
38 #define SW_PULSE0 4 //Pulse Reset started
39 #define SW_PULSE1 8 //Pulse Reset stsrted
40 #define SW_PULSE_P0 0x10 //Pulse reset in process
41 #define SW_PULSE_P1 0x20 //Pulse reset in process
42 #define SW_CHANGED_P0 0x40 //Changes while pulse in progress
43 #define SW_CHANGED_P1 0x80 //Changes while pulse in progress
44 #define SW_PULSE0_R 0x100 //Pulse Reset requested
45 #define SW_PULSE1_R 0x200 //Pulse Reset requested
46
47
48 #define recheck_interval 5
49 #define check_circle 2000/t_count
50
51 #if not defined (OW_DEVICES_LIMIT)
52 #define t_max 20 //Maximum number of 1w devices
53 #else
54 #define t_max OW_DEVICES_LIMIT
55 #endif
56
57 #define TEMPERATURE_PRECISION 12 //9
58
59 #ifndef OWIRE_DISABLE
60
61 #include <DallasTemperature.h>
62 #include "aJSON.h"
63
64 extern aJsonObject *owArr;
65
66 typedef void (*owChangedType) (int , DeviceAddress, float) ;
67
68 #ifndef USE_1W_PIN
69 #define DS2482_100_I2C_TO_1W_BRIDGE // HW driver
70 #include <Wire.h>
71 #ifndef ARDUINO_ARCH_STM32F1
72 #include <DS2482_OneWire.h>
73 #endif
74 #else
75 #include <OneWire.h> //Software driver
76 #define wireReset reset
77 #define wireSearch search
78 #endif
79
80
81 extern OneWire *oneWire;
82
83 extern DallasTemperature *sensors;
84 extern DeviceAddress *term ;
85 extern int *regs ;
86 extern uint16_t *wstat;
87 extern int t_count;
88 extern short si;
89
90 extern owChangedType owChanged;
91
92
93
94 int owUpdate();
95 int owSetup(owChangedType owCh);
96 void owLoop();
97 void setupOwIdle(void (*)()) ;
98 int owFind(DeviceAddress addr);
99 void owAdd (DeviceAddress addr);
100
101 #endif
setupOwIdle
void setupOwIdle(void(*)())
Definition: owTerm.cpp:250
owFind
int owFind(DeviceAddress addr)
Definition: owTerm.cpp:223
owUpdate
int owUpdate()
Definition: owTerm.cpp:50
owSetup
int owSetup(owChangedType owCh)
Definition: owTerm.cpp:101
owChanged
owChangedType owChanged
Definition: owTerm.cpp:41
owArr
aJsonObject * owArr
Definition: main.cpp:100
si
short si
Definition: owTerm.cpp:37
t_count
int t_count
Definition: owTerm.cpp:38
wstat
uint16_t * wstat
Definition: owTerm.cpp:34
oneWire
OneWire * oneWire
Definition: owTerm.cpp:30
owChangedType
void(* owChangedType)(int, DeviceAddress, float)
Definition: owTerm.h:66
owAdd
void owAdd(DeviceAddress addr)
Definition: owTerm.cpp:228
term
DeviceAddress * term
Definition: owTerm.cpp:32
owLoop
void owLoop()
Definition: owTerm.cpp:213
sensors
DallasTemperature * sensors
Definition: owTerm.cpp:35
regs
int * regs