First commit
This commit is contained in:
39
VT_ESP8266/include/README
Normal file
39
VT_ESP8266/include/README
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
This directory is intended for project header files.
|
||||
|
||||
A header file is a file containing C declarations and macro definitions
|
||||
to be shared between several project source files. You request the use of a
|
||||
header file in your project source file (C, C++, etc) located in `src` folder
|
||||
by including it, with the C preprocessing directive `#include'.
|
||||
|
||||
```src/main.c
|
||||
|
||||
#include "header.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Including a header file produces the same results as copying the header file
|
||||
into each source file that needs it. Such copying would be time-consuming
|
||||
and error-prone. With a header file, the related declarations appear
|
||||
in only one place. If they need to be changed, they can be changed in one
|
||||
place, and programs that include the header file will automatically use the
|
||||
new version when next recompiled. The header file eliminates the labor of
|
||||
finding and changing all the copies as well as the risk that a failure to
|
||||
find one copy will result in inconsistencies within a program.
|
||||
|
||||
In C, the usual convention is to give header files names that end with `.h'.
|
||||
It is most portable to use only letters, digits, dashes, and underscores in
|
||||
header file names, and at most one dot.
|
||||
|
||||
Read more about using header files in official GCC documentation:
|
||||
|
||||
* Include Syntax
|
||||
* Include Operation
|
||||
* Once-Only Headers
|
||||
* Computed Includes
|
||||
|
||||
https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html
|
||||
21
VT_ESP8266/include/leds.h
Normal file
21
VT_ESP8266/include/leds.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef __LEDS_H__
|
||||
#define __LEDS_H__
|
||||
#include <Arduino.h>
|
||||
#include <PCF8574.h>
|
||||
|
||||
class leds
|
||||
{
|
||||
private:
|
||||
int ledPin;
|
||||
bool inv, state;
|
||||
int onMS;
|
||||
unsigned long curMS;
|
||||
PCF8574 *_pcf;
|
||||
public:
|
||||
leds(PCF8574 *pcf, int ledPin, int onms = 300, bool inverse = false);
|
||||
//~leds();
|
||||
void start();
|
||||
void tick();
|
||||
};
|
||||
|
||||
#endif
|
||||
119
VT_ESP8266/include/main.h
Normal file
119
VT_ESP8266/include/main.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#include <Arduino.h>
|
||||
#include <RotaryEncoder.h>
|
||||
#include <Wire.h>
|
||||
#include "ClosedCube_HDC1080.h"
|
||||
#include <OneButton.h>
|
||||
#include <PCF8574.h>
|
||||
#include <LiquidCrystal_PCF8574.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include <pcf_butt.h>
|
||||
#include <I2C_eeprom.h>
|
||||
//#include <PubSubClient.h>
|
||||
#include <OneWire.h>
|
||||
#include <DallasTemperature.h>
|
||||
#include <leds.h>
|
||||
#include <Ticker.h>
|
||||
#include <AsyncMqttClient.h>
|
||||
|
||||
#define DEBUG
|
||||
#define WIFI_SSID "wf-home"
|
||||
#define WIFI_PASSWORD "0ndthnrf"
|
||||
#define MY_HOSTNAME "ESP8266_GW"
|
||||
#define MQTT_SERV "192.168.1.250"
|
||||
|
||||
#define MAX_PAGE (4)
|
||||
#define MAX_HSP (99)
|
||||
#define MAX_HDB (99)
|
||||
#define MAX_TWORK (99)
|
||||
#define MAX_TPAUSE (99)
|
||||
#define MAX_LCDPAUSE (99)
|
||||
|
||||
//#define LIGHT_SENS D0
|
||||
#define VENT_VANNA (D0)
|
||||
#define ASDA (D1)
|
||||
#define ASCL (D2)
|
||||
#define ENC_A (D3)
|
||||
#define ENC_B (D4)
|
||||
#define ONE_WIRE (D5)
|
||||
#define VENT_TUAL (D6)
|
||||
#define BUTT_ENC (D7)
|
||||
|
||||
#define LIGHT_SENS (0)
|
||||
#define LED_RED (4)
|
||||
#define LED_BLUE (5)
|
||||
#define LED_GREEN (6)
|
||||
#define LED_YELLOW (7)
|
||||
#define FLOOD (1)
|
||||
#define Q_C (3)
|
||||
#define Q_H (2)
|
||||
|
||||
ClosedCube_HDC1080 hdc1080;
|
||||
|
||||
unsigned long cRun;
|
||||
int8_t page;
|
||||
float hum, temp;
|
||||
float cTemp, hTemp;
|
||||
uint8_t pcf_w;
|
||||
uint8_t LCDtimeout, LCDsec;
|
||||
bool modeEdit;
|
||||
uint8_t itemEdit;
|
||||
uint16_t adc;
|
||||
float mws;
|
||||
long curPos;
|
||||
bool vvannaSent1, vvannaSent0;
|
||||
|
||||
AsyncMqttClient mqttClient;
|
||||
Ticker mqttReconnectTimer;
|
||||
WiFiEventHandler wifiConnectHandler;
|
||||
WiFiEventHandler wifiDisconnectHandler;
|
||||
Ticker wifiReconnectTimer;
|
||||
const char* mqtt_server = "192.168.1.250";
|
||||
char v[12];
|
||||
|
||||
struct contacts
|
||||
{
|
||||
bool QC;
|
||||
bool QH;
|
||||
bool Flood;
|
||||
} wconts;
|
||||
|
||||
struct wCnt
|
||||
{
|
||||
float QC;
|
||||
float QH;
|
||||
} wCounter, oldwCounter;
|
||||
|
||||
struct wUst{
|
||||
uint8_t hSP;
|
||||
uint8_t hDB;
|
||||
} wUstavki, oldwUstavki;
|
||||
|
||||
struct stTualVent
|
||||
{
|
||||
uint8_t tWork;
|
||||
uint8_t tPause;
|
||||
} ventUst, oldventUst;
|
||||
|
||||
void printSerialNumber();
|
||||
void buttClick();
|
||||
void chkCount();
|
||||
// void callback(char* topic, byte* payload, unsigned int length);
|
||||
// void reconnect();
|
||||
void showLCD(uint8_t page, bool chgd);
|
||||
void chkEnc();
|
||||
void getTemps();
|
||||
void buttLongClick();
|
||||
void chkLight();
|
||||
void connectToWifi();
|
||||
void connectToMqtt();
|
||||
|
||||
void onWifiConnect(const WiFiEventStationModeGotIP& event);
|
||||
void onWifiDisconnect(const WiFiEventStationModeDisconnected& event);
|
||||
void onMqttConnect(bool sessionPresent);
|
||||
void onMqttDisconnect(AsyncMqttClientDisconnectReason reason);
|
||||
void onMqttSubscribe(uint16_t packetId, uint8_t qos);
|
||||
void onMqttUnsubscribe(uint16_t packetId);
|
||||
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total);
|
||||
void onMqttPublish(uint16_t packetId);
|
||||
|
||||
void sendData();
|
||||
18
VT_ESP8266/include/pcf_butt.h
Normal file
18
VT_ESP8266/include/pcf_butt.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __PCF_BUTT__
|
||||
#define __PCF_BUTT__
|
||||
|
||||
class pcf_butt
|
||||
{
|
||||
private:
|
||||
bool lastState;
|
||||
bool curState;
|
||||
public:
|
||||
pcf_butt();
|
||||
pcf_butt(bool state);
|
||||
void update(bool state);
|
||||
bool chngUp(bool state);
|
||||
bool chngDown(bool state);
|
||||
~pcf_butt();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user