99 lines
2.1 KiB
C
99 lines
2.1 KiB
C
#ifndef __MAIN__
|
|
#define __MAIN__
|
|
|
|
#include <Arduino.h>
|
|
//#include <ArduinoOTA.h>
|
|
#include <Ticker.h>
|
|
#include <WiFi.h>
|
|
#include <WiFiMulti.h>
|
|
|
|
extern "C" {
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/timers.h"
|
|
}
|
|
//#include <AsyncMqttClient.h>
|
|
#include <leds.h>
|
|
#include "MHZ19.h"
|
|
#include <Wire.h>
|
|
//#include "HTU21D.h"
|
|
#include <RunningMedian.h>
|
|
#include <Adafruit_HTU21DF.h>
|
|
#include <EEPROM.h>
|
|
#include <AsyncTCP.h>
|
|
#include <ESPAsyncWebServer.h>
|
|
#include <WebSerial.h>
|
|
#include <AsyncElegantOTA.h>
|
|
#include <SoftwareSerial.h>
|
|
#include <SerialTransfer.h>
|
|
#include <PubSubClient.h>
|
|
#include "CG_RadSens.h"
|
|
|
|
#define BAUDRATE 9600
|
|
|
|
#define LIGHT_SENS 36 //VP
|
|
#define MOVE_SENS 39 //VN
|
|
|
|
|
|
#define LED_WHITE 26 //25
|
|
#define PWM_WHITE 0
|
|
#define LED_BLUE 25 //26
|
|
#define PWM_BLUE 1
|
|
#define POWER 27 //27
|
|
#define TXD2 17
|
|
#define RXD2 16
|
|
#define LED_R 13
|
|
#define LED_G 15
|
|
#define LED_B 2
|
|
#define RECIVER 18
|
|
|
|
#define TOPIC "home/bigroom/"
|
|
#define HNAME "BigRoom"
|
|
|
|
//WiFiMulti wifiMulti;
|
|
//const uint32_t connectTimeoutMs = 5000;
|
|
|
|
byte periodMotion;
|
|
int8_t curDelay;
|
|
uint16_t spLight, dbLight;
|
|
uint8_t timeLight;
|
|
byte levelBlue, levelWhite;
|
|
bool move, lightWhite;
|
|
float temp, hum;
|
|
bool bLamp, wLamp, reciever;
|
|
uint8_t statLamp;
|
|
|
|
CG_RadSens radSens(RS_DEFAULT_I2C_ADDRESS); /*Constructor of the class ClimateGuard_RadSens1v2,
|
|
sets the address parameter of I2C sensor.
|
|
Default address: 0x66.*/
|
|
|
|
AsyncWebServer server(80);
|
|
struct I2cTxStruct {
|
|
//byte mode, hue, saturation, bright;
|
|
byte mode, r, g, b;
|
|
};
|
|
|
|
#define SSRX 26
|
|
#define SSTX 25
|
|
|
|
I2cTxStruct txData = {0, 0x0F, 0x0F, 0x0F};
|
|
I2cTxStruct txDataN;
|
|
I2cTxStruct txDataF;
|
|
uint8_t mode = 0;
|
|
bool forceNight = false;
|
|
|
|
bool newTxData;
|
|
void transmitData();
|
|
|
|
EspSoftwareSerial::UART lampSerial;
|
|
SerialTransfer myTransfer;
|
|
|
|
long lastReconnectAttempt = 0;
|
|
WiFiClient espClient;
|
|
PubSubClient client(espClient);
|
|
|
|
boolean reconnect();
|
|
void callback(char* topic, byte* payload, unsigned int length);
|
|
|
|
|
|
#endif // __MAIN__
|