mirror of
https://github.com/anklimov/lighthub
synced 2025-12-09 21:29:49 +03:00
pre-release, save2flash, mdns bugs, dmx, .....
This commit is contained in:
@@ -28,7 +28,7 @@ int in_ccs811::Setup()
|
||||
digitalWrite(WAK_PIN,LOW);
|
||||
#endif
|
||||
|
||||
Serial.println("CCS811 Init");
|
||||
debugSerial.println("CCS811 Init");
|
||||
|
||||
Wire.begin(); //Inialize I2C Harware
|
||||
Wire.setClock(4000);
|
||||
@@ -41,7 +41,7 @@ Wire.setClock(4000);
|
||||
//if (returnCode != CCS811Core::CCS811_Stat_SUCCESS)
|
||||
{
|
||||
Serial.print("CCS811 Init error ");
|
||||
//Serial.println(ccs811.statusString(returnCode));
|
||||
//debugSerial.println(ccs811.statusString(returnCode));
|
||||
printDriverError(returnCode);
|
||||
return 0;
|
||||
}
|
||||
@@ -61,16 +61,16 @@ return 1;
|
||||
int in_hdc1080::Setup()
|
||||
{
|
||||
if (HDC1080ready) {debugSerial<<F("hdc1080 is already initialized")<<endl; return 0;}
|
||||
Serial.println("HDC1080 Init ");
|
||||
debugSerial.println("HDC1080 Init ");
|
||||
Wire.begin(); //Inialize I2C Harware
|
||||
// Default settings:
|
||||
// - Heater off
|
||||
// - 14 bit Temperature and Humidity Measurement Resolutions
|
||||
hdc1080.begin(0x40);
|
||||
Serial.print("Manufacturer ID=0x");
|
||||
Serial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
|
||||
Serial.print("Device ID=0x");
|
||||
Serial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
|
||||
debugSerial.print("Manufacturer ID=0x");
|
||||
debugSerial.println(hdc1080.readManufacturerId(), HEX); // 0x5449 ID of Texas Instruments
|
||||
debugSerial.print("Device ID=0x");
|
||||
debugSerial.println(hdc1080.readDeviceId(), HEX); // 0x1050 ID of the device
|
||||
printSerialNumber();
|
||||
HDC1080ready = true;
|
||||
return 1;
|
||||
@@ -91,15 +91,15 @@ int in_hdc1080::Poll(short cause)
|
||||
int reg;
|
||||
if (cause!=POLLING_SLOW) return 0;
|
||||
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;}
|
||||
Serial.print("HDC Status=");
|
||||
Serial.println(reg=hdc1080.readRegister().rawData,HEX);
|
||||
debugSerial.print("HDC Status=");
|
||||
debugSerial.println(reg=hdc1080.readRegister().rawData,HEX);
|
||||
if (reg!=0xff)
|
||||
{
|
||||
Serial.print(" T=");
|
||||
Serial.print(t=hdc1080.readTemperature());
|
||||
Serial.print("C, RH=");
|
||||
Serial.print(h=hdc1080.readHumidity());
|
||||
Serial.println("%");
|
||||
debugSerial.print(" T=");
|
||||
debugSerial.print(t=hdc1080.readTemperature());
|
||||
debugSerial.print("C, RH=");
|
||||
debugSerial.print(h=hdc1080.readHumidity());
|
||||
debugSerial.println("%");
|
||||
|
||||
|
||||
#ifdef M5STACK
|
||||
@@ -125,7 +125,7 @@ if (reg!=0xff)
|
||||
}
|
||||
else //ESP I2C glitch
|
||||
{
|
||||
Serial.println("I2C Reset");
|
||||
debugSerial.println("I2C Reset");
|
||||
i2cReset();
|
||||
}
|
||||
return INTERVAL_SLOW_POLLING;
|
||||
@@ -147,15 +147,15 @@ int in_ccs811::Poll(short cause)
|
||||
CCS811Core::status returnCode = ccs811.readAlgorithmResults();
|
||||
printDriverError(returnCode);
|
||||
float co2,tvoc;
|
||||
Serial.print(" CO2[");
|
||||
debugSerial.print(" CO2[");
|
||||
//Returns calculated CO2 reading
|
||||
Serial.print(co2 = ccs811.getCO2());
|
||||
Serial.print("] tVOC[");
|
||||
debugSerial.print(co2 = ccs811.getCO2());
|
||||
debugSerial.print("] tVOC[");
|
||||
//Returns calculated TVOC reading
|
||||
|
||||
Serial.print(tvoc = ccs811.getTVOC());
|
||||
Serial.print("] baseline[");
|
||||
Serial.print(ccs811Baseline = ccs811.getBaseline());
|
||||
debugSerial.print(tvoc = ccs811.getTVOC());
|
||||
debugSerial.print("] baseline[");
|
||||
debugSerial.print(ccs811Baseline = ccs811.getBaseline());
|
||||
|
||||
#ifdef M5STACK
|
||||
M5.Lcd.print(" CO2[");
|
||||
@@ -181,7 +181,7 @@ int in_ccs811::Poll(short cause)
|
||||
publish(co2,"/CO2");
|
||||
publish(tvoc,"/TVOC");
|
||||
publish(ccs811Baseline,"/base");}
|
||||
Serial.println("]");
|
||||
debugSerial.println("]");
|
||||
printSensorError();
|
||||
|
||||
#ifdef WAK_PIN
|
||||
@@ -192,11 +192,11 @@ int in_ccs811::Poll(short cause)
|
||||
}
|
||||
|
||||
void in_hdc1080::printSerialNumber() {
|
||||
Serial.print("Device Serial Number=");
|
||||
debugSerial.print("Device Serial Number=");
|
||||
HDC1080_SerialNumber sernum = hdc1080.readSerialNumber();
|
||||
char format[16];
|
||||
sprintf(format, "%02X-%04X-%04X", sernum.serialFirst, sernum.serialMid, sernum.serialLast);
|
||||
Serial.println(format);
|
||||
debugSerial.println(format);
|
||||
}
|
||||
|
||||
//printDriverError decodes the CCS811Core::status type and prints the
|
||||
@@ -209,22 +209,22 @@ void in_ccs811::printDriverError( CCS811Core::status errorCode )
|
||||
switch ( errorCode )
|
||||
{
|
||||
case CCS811Core::SENSOR_SUCCESS:
|
||||
Serial.print("SUCCESS");
|
||||
debugSerial.print("SUCCESS");
|
||||
break;
|
||||
case CCS811Core::SENSOR_ID_ERROR:
|
||||
Serial.print("ID_ERROR");
|
||||
debugSerial.print("ID_ERROR");
|
||||
break;
|
||||
case CCS811Core::SENSOR_I2C_ERROR:
|
||||
Serial.print("I2C_ERROR");
|
||||
debugSerial.print("I2C_ERROR");
|
||||
break;
|
||||
case CCS811Core::SENSOR_INTERNAL_ERROR:
|
||||
Serial.print("INTERNAL_ERROR");
|
||||
debugSerial.print("INTERNAL_ERROR");
|
||||
break;
|
||||
case CCS811Core::SENSOR_GENERIC_ERROR:
|
||||
Serial.print("GENERIC_ERROR");
|
||||
debugSerial.print("GENERIC_ERROR");
|
||||
break;
|
||||
default:
|
||||
Serial.print("Unspecified error.");
|
||||
debugSerial.print("Unspecified error.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,18 +236,18 @@ void in_ccs811::printSensorError()
|
||||
|
||||
if ( error == 0xFF ) //comm error
|
||||
{
|
||||
Serial.println("Failed to get ERROR_ID register.");
|
||||
debugSerial.println("Failed to get ERROR_ID register.");
|
||||
}
|
||||
else
|
||||
{
|
||||
//Serial.print("");
|
||||
if (error & 1 << 5) Serial.print("Error: HeaterSupply");
|
||||
if (error & 1 << 4) Serial.print("Error: HeaterFault");
|
||||
if (error & 1 << 3) Serial.print("Error: MaxResistance");
|
||||
if (error & 1 << 2) Serial.print("Error: MeasModeInvalid");
|
||||
if (error & 1 << 1) Serial.print("Error: ReadRegInvalid");
|
||||
if (error & 1 << 0) Serial.print("Error: MsgInvalid");
|
||||
Serial.println();
|
||||
//debugSerial.print("");
|
||||
if (error & 1 << 5) debugSerial.print("Error: HeaterSupply");
|
||||
if (error & 1 << 4) debugSerial.print("Error: HeaterFault");
|
||||
if (error & 1 << 3) debugSerial.print("Error: MaxResistance");
|
||||
if (error & 1 << 2) debugSerial.print("Error: MeasModeInvalid");
|
||||
if (error & 1 << 1) debugSerial.print("Error: ReadRegInvalid");
|
||||
if (error & 1 << 0) debugSerial.print("Error: MsgInvalid");
|
||||
debugSerial.println();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -82,8 +82,8 @@ void out_AC::InsertData(byte data[], size_t size){
|
||||
}
|
||||
*/
|
||||
|
||||
Serial.print ("Power=");
|
||||
Serial.println(power);
|
||||
debugSerial.print ("Power=");
|
||||
debugSerial.println(power);
|
||||
|
||||
if (power & 0x08)
|
||||
publishTopic(item->itemArr->name, "ON", "/quiet");
|
||||
@@ -189,7 +189,7 @@ void SendData(byte req[], size_t size){
|
||||
AC_Serial.write(req, size - 1);
|
||||
AC_Serial.write(getCRC(req, size-1));
|
||||
AC_Serial.flush();
|
||||
|
||||
/*
|
||||
Serial.print("<<");
|
||||
for (int i=0; i < size-1; i++)
|
||||
{
|
||||
@@ -203,6 +203,7 @@ void SendData(byte req[], size_t size){
|
||||
}
|
||||
}
|
||||
Serial.println();
|
||||
*/
|
||||
}
|
||||
|
||||
inline unsigned char toHex( char ch ){
|
||||
@@ -214,7 +215,7 @@ inline unsigned char toHex( char ch ){
|
||||
int out_AC::Setup()
|
||||
{
|
||||
abstractOut::Setup();
|
||||
Serial.println("AC Init");
|
||||
debugSerial.println("AC Init");
|
||||
AC_Serial.begin(9600);
|
||||
driverStatus = CST_INITIALIZED;
|
||||
return 1;
|
||||
@@ -222,7 +223,7 @@ return 1;
|
||||
|
||||
int out_AC::Stop()
|
||||
{
|
||||
Serial.println("AC De-Init");
|
||||
debugSerial.println("AC De-Init");
|
||||
|
||||
driverStatus = CST_UNKNOWN;
|
||||
return 1;
|
||||
@@ -246,7 +247,7 @@ if (cause!=POLLING_SLOW) return 0;
|
||||
//if (now - prevPolling > INTERVAL_AC_POLLING) {
|
||||
if (isTimeOver(prevPolling,millis(),INTERVAL_AC_POLLING)) {
|
||||
prevPolling = millisNZ();
|
||||
Serial.println ("Polling");
|
||||
debugSerial.println ("Polling");
|
||||
SendData(qstn, sizeof(qstn)/sizeof(byte)); //Опрос кондиционера
|
||||
}
|
||||
delay(100);
|
||||
|
||||
@@ -187,7 +187,7 @@ else
|
||||
|
||||
int out_Modbus::Stop()
|
||||
{
|
||||
Serial.println("Modbus De-Init");
|
||||
debugSerial.println("Modbus De-Init");
|
||||
|
||||
delete store;
|
||||
item->setPersistent(NULL);
|
||||
|
||||
@@ -50,7 +50,7 @@ int out_Motor::Setup()
|
||||
{
|
||||
abstractOut::Setup();
|
||||
getConfig();
|
||||
Serial.println("Motor Init");
|
||||
debugSerial.println("Motor Init");
|
||||
pinMode(pinUp,OUTPUT);
|
||||
pinMode(pinDown,OUTPUT);
|
||||
|
||||
@@ -70,7 +70,7 @@ return 1;
|
||||
|
||||
int out_Motor::Stop()
|
||||
{
|
||||
Serial.println("Motor De-Init");
|
||||
debugSerial.println("Motor De-Init");
|
||||
digitalWrite(pinUp,INACTIVE);
|
||||
digitalWrite(pinDown,INACTIVE);
|
||||
|
||||
@@ -240,7 +240,7 @@ else
|
||||
|
||||
}
|
||||
else //Target zone
|
||||
{ Serial.println("Target");
|
||||
{ debugSerial.println("Target");
|
||||
digitalWrite(pinUp,INACTIVE);
|
||||
digitalWrite(pinDown,INACTIVE);
|
||||
item->setExt(0);
|
||||
|
||||
@@ -113,7 +113,7 @@ else
|
||||
|
||||
int out_pid::Stop()
|
||||
{
|
||||
Serial.println("PID De-Init");
|
||||
debugSerial.println("PID De-Init");
|
||||
if (store) delete (store->pid);
|
||||
delete store;
|
||||
item->setPersistent(NULL);
|
||||
|
||||
@@ -45,7 +45,7 @@ int out_SPILed::Setup()
|
||||
{
|
||||
abstractOut::Setup();
|
||||
getConfig();
|
||||
Serial.println("SPI-LED Init");
|
||||
debugSerial.println("SPI-LED Init");
|
||||
|
||||
if (!leds)
|
||||
{
|
||||
@@ -69,7 +69,7 @@ return 1;
|
||||
|
||||
int out_SPILed::Stop()
|
||||
{
|
||||
Serial.println("SPI-LED De-Init");
|
||||
debugSerial.println("SPI-LED De-Init");
|
||||
//FastLED.addLeds<TM1809, DATA_PIN, BRG>(leds, NUM_LEDS);
|
||||
#ifdef ADAFRUIT_LED
|
||||
leds->clear();
|
||||
|
||||
@@ -134,7 +134,7 @@ else
|
||||
|
||||
int out_UARTbridge::Stop()
|
||||
{
|
||||
Serial.println("UARTbridge De-Init");
|
||||
debugSerial.println("UARTbridge De-Init");
|
||||
|
||||
udpClientA.stop();
|
||||
udpClientB.stop();
|
||||
|
||||
Reference in New Issue
Block a user