LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
owTerm.h
Go to the documentation of this file.
1/* Copyright © 2017-2020 Andrey Klimov. All rights reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14
15Homepage: http://lazyhome.ru
16GIT: https://github.com/anklimov/lighthub
17e-mail anklimov@gmail.com
18
19*/
20
21//define APU_OFF
31#pragma once
32
33#define SW_AUX0 0x40
34#define SW_AUX1 0x80
35#define SW_STAT0 0x4
36#define SW_STAT1 0x8
37#define SW_OUT0 0x20
38#define SW_OUT1 0x10
39#define SW_MASK 0xF
40#define SW_INMASK 0xFC
41
42//#define recheck_interval 5
43//#define check_circle 2000/t_count
44
45#define SW_FIND 1
46#define SW_DOUBLECHECK 2 //Doublecheck required
47#define SW_PULSE0 4 //Pulse Reset started
48#define SW_PULSE1 8 //Pulse Reset stsrted
49#define SW_PULSE_P0 0x10 //Pulse reset in process
50#define SW_PULSE_P1 0x20 //Pulse reset in process
51#define SW_CHANGED_P0 0x40 //Changes while pulse in progress
52#define SW_CHANGED_P1 0x80 //Changes while pulse in progress
53#define SW_PULSE0_R 0x100 //Pulse Reset requested
54#define SW_PULSE1_R 0x200 //Pulse Reset requested
55
56
57//#define recheck_interval 5
58//#define check_circle 2000/t_count
59
60#if not defined (OW_DEVICES_LIMIT)
61#define t_max 20 //Maximum number of 1w devices
62#else
63#define t_max OW_DEVICES_LIMIT
64#endif
65
66#define TEMPERATURE_PRECISION 12 //9
67
68#ifndef OWIRE_DISABLE
69
70#include <DallasTemperature.h>
71#include "aJSON.h"
72
74extern aJsonObject *owArr;
75
76//typedef void (*owChangedType) (int , DeviceAddress, float) ;
77
78#ifndef USE_1W_PIN
79#define DS2482_100_I2C_TO_1W_BRIDGE // HW driver
80#include <Wire.h>
81 #ifndef ARDUINO_ARCH_STM32F1
82 #include <DS2482_OneWire.h>
83 #endif
84#else
85#include <OneWire.h> //Software driver
86#define wireReset reset
87#define wireSearch search
88#endif
89
90
92extern OneWire *oneWire;
94extern DallasTemperature *sensors;
95
100int owUpdate();
106int owSetup();
111void owLoop();
116void setupOwIdle(void (*)()) ;
120void owSearch();
121
122#endif
aJsonObject * owArr
Definition main.cpp:128
OneWire * oneWire
1-Wire bus handle (DS2482 bridge or software pin driver).
Definition owTerm.cpp:34
int owSetup()
Initializes the 1-Wire bus and the temperature sensors, and applies the configured resolution.
Definition owTerm.cpp:123
void owLoop()
Periodic poll: reads each configured sensor and publishes its temperature to the item's /val subtopic...
Definition owTerm.cpp:293
void setupOwIdle(void(*ptr)())
Registers an idle callback invoked between 1-Wire operations.
Definition owTerm.cpp:304
DallasTemperature * sensors
DallasTemperature manager on top of the 1-Wire bus.
Definition owTerm.cpp:35
void owSearch()
Triggers a 1-Wire device search/update.
Definition owTerm.cpp:39
int owUpdate()
Scans the 1-Wire bus and logs the devices it finds.
Definition owTerm.cpp:91