mirror of
https://github.com/anklimov/lighthub
synced 2025-12-12 14:49:50 +03:00
M5STACK platform added
This commit is contained in:
@@ -28,7 +28,7 @@ e-mail anklimov@gmail.com
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(ESP8266)
|
||||
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||
#ifndef DMX_DISABLE
|
||||
DMXESPSerial dmxout;
|
||||
#endif
|
||||
|
||||
@@ -43,6 +43,12 @@ extern DMXESPSerial dmxout;
|
||||
#define DmxWrite dmxout.write
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#include <ESPDMX.h>
|
||||
extern DMXESPSerial dmxout;
|
||||
#define DmxWrite dmxout.write
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
#include <DmxDue.h>
|
||||
#define DmxWrite dmxout.write
|
||||
|
||||
@@ -134,8 +134,8 @@ int Input::poll(short cause) {
|
||||
|
||||
if (!isValid()) return -1;
|
||||
#ifndef CSSHDC_DISABLE
|
||||
in_ccs811 ccs811(this);
|
||||
in_hdc1080 hdc1080(this);
|
||||
in_ccs811 _ccs811(this);
|
||||
in_hdc1080 _hdc1080(this);
|
||||
#endif
|
||||
|
||||
switch (cause) {
|
||||
@@ -167,10 +167,10 @@ switch (cause) {
|
||||
{
|
||||
#ifndef CSSHDC_DISABLE
|
||||
case IN_CCS811:
|
||||
ccs811.Poll();
|
||||
_ccs811.Poll();
|
||||
break;
|
||||
case IN_HDC1080:
|
||||
hdc1080.Poll();
|
||||
_hdc1080.Poll();
|
||||
break;
|
||||
#endif
|
||||
#ifndef DHT_DISABLE
|
||||
|
||||
@@ -691,7 +691,7 @@ wifiManager.setTimeout(30);
|
||||
#ifdef W5500_CS_PIN
|
||||
Ethernet.w5500_cspin = W5500_CS_PIN;
|
||||
debugSerial<<F("Use W5500 pin: ");
|
||||
debugSerial<<(Ethernet.w5500_cspin);
|
||||
debugSerial<<(Ethernet.w5500_cspin)<<endl;
|
||||
#endif
|
||||
IPAddress ip, dns, gw, mask;
|
||||
int res = 1;
|
||||
@@ -1331,6 +1331,11 @@ void setup_main() {
|
||||
memset(&UniqueID,0,sizeof(UniqueID));
|
||||
#endif
|
||||
|
||||
#if defined(M5STACK)
|
||||
// Initialize the M5Stack object
|
||||
M5.begin();
|
||||
#endif
|
||||
|
||||
setupCmdArduino();
|
||||
printFirmwareVersionAndBuildOptions();
|
||||
|
||||
@@ -1557,6 +1562,11 @@ void setupCmdArduino() {
|
||||
}
|
||||
|
||||
void loop_main() {
|
||||
#if defined(M5STACK)
|
||||
// Initialize the M5Stack object
|
||||
M5.update();
|
||||
#endif
|
||||
|
||||
wdt_res();
|
||||
cmdPoll();
|
||||
if (lanLoop() > HAVE_IP_ADDRESS) {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "options.h"
|
||||
|
||||
#if defined(M5STACK)
|
||||
#include <M5Stack.h>
|
||||
#endif
|
||||
|
||||
#if defined(__SAM3X8E__)
|
||||
#include <DueFlashStorage.h>
|
||||
#include <watchdog.h>
|
||||
|
||||
@@ -3,10 +3,14 @@
|
||||
#include "options.h"
|
||||
#include "Streaming.h"
|
||||
|
||||
#ifndef CSSHDC_DISABLE
|
||||
#if defined(M5STACK)
|
||||
#include <M5Stack.h>
|
||||
#endif
|
||||
|
||||
#ifndef CSSHDC_DISABLE
|
||||
static ClosedCube_HDC1080 hdc1080;
|
||||
static CCS811 ccs811(CCS811_ADDR);
|
||||
|
||||
CCS811 ccs811(CCS811_ADDR);
|
||||
ClosedCube_HDC1080 hdc1080;
|
||||
long ccs811Baseline;
|
||||
|
||||
static bool HDC1080ready = false;
|
||||
@@ -35,8 +39,16 @@ Wire.begin(); //Inialize I2C Harware
|
||||
printDriverError(returnCode);
|
||||
return 0;
|
||||
}
|
||||
ccs811.setBaseline(62000);
|
||||
//ccs811.setBaseline(62000);
|
||||
CCS811ready = true;
|
||||
|
||||
//returnCode = ccs811.setDriveMode(1);
|
||||
//printDriverError(returnCode);
|
||||
|
||||
delay(2000);Poll();
|
||||
delay(2000);Poll();
|
||||
delay(2000);Poll();
|
||||
delay(2000);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -81,6 +93,19 @@ if (reg!=0xff)
|
||||
Serial.print("C, RH=");
|
||||
Serial.print(h=hdc1080.readHumidity());
|
||||
Serial.println("%");
|
||||
|
||||
|
||||
#ifdef M5STACK
|
||||
M5.Lcd.print(" T=");
|
||||
//Returns calculated CO2 reading
|
||||
M5.Lcd.print(t=hdc1080.readTemperature());
|
||||
M5.Lcd.print("C, RH=");
|
||||
//Returns calculated TVOC reading
|
||||
|
||||
M5.Lcd.print(h=hdc1080.readHumidity());
|
||||
M5.Lcd.print("%\n");
|
||||
#endif
|
||||
|
||||
publish(t,"/T");
|
||||
publish(h,"/H");
|
||||
if (CCS811ready) ccs811.setEnvironmentalData(h,t);
|
||||
@@ -99,8 +124,10 @@ int in_ccs811::Poll()
|
||||
#ifdef WAK_PIN
|
||||
digitalWrite(WAK_PIN,LOW);
|
||||
#endif
|
||||
delay(1);
|
||||
//Check to see if data is ready with .dataAvailable()
|
||||
if (ccs811.dataAvailable())
|
||||
//if (1)
|
||||
{
|
||||
//If so, have the sensor read and calculate the results.
|
||||
//Get them later
|
||||
@@ -117,6 +144,19 @@ int in_ccs811::Poll()
|
||||
Serial.print("] baseline[");
|
||||
Serial.print(ccs811Baseline = ccs811.getBaseline());
|
||||
|
||||
#ifdef M5STACK
|
||||
M5.Lcd.print(" CO2[");
|
||||
//Returns calculated CO2 reading
|
||||
M5.Lcd.print(co2 = ccs811.getCO2());
|
||||
M5.Lcd.print("] tVOC[");
|
||||
//Returns calculated TVOC reading
|
||||
|
||||
M5.Lcd.print(tvoc = ccs811.getTVOC());
|
||||
M5.Lcd.print("]\n");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
publish(co2,"/CO2");
|
||||
publish(tvoc,"/TVOC");
|
||||
publish(ccs811Baseline,"/base");
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
#endif
|
||||
|
||||
#if defined (ARDUINO_ARCH_ESP32)
|
||||
#ifndef WAK_PIN
|
||||
#define WAK_PIN 17
|
||||
#endif
|
||||
#undef WAK_PIN
|
||||
//#ifndef WAK_PIN
|
||||
//#define WAK_PIN 17
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_AVR)
|
||||
|
||||
@@ -164,7 +164,11 @@
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#undef _dmxin
|
||||
#undef _modbus
|
||||
#undef _dmxout
|
||||
|
||||
#ifndef DMX_DISABLE
|
||||
#define _espdmx
|
||||
#endif
|
||||
//#undef _dmxout
|
||||
#undef modbusSerial
|
||||
#endif
|
||||
|
||||
@@ -189,6 +193,10 @@
|
||||
#define strncpy_P strncpy
|
||||
#endif
|
||||
|
||||
//#ifdef M5STACK
|
||||
//#define debugSerial M5.Lcd
|
||||
//#endif
|
||||
|
||||
#ifndef debugSerial
|
||||
#define debugSerial Serial
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user