M5STACK platform added

This commit is contained in:
2019-06-01 11:37:28 +03:00
parent 1303c106b5
commit ea088ca47d
11 changed files with 140 additions and 19 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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) {

View File

@@ -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>

View File

@@ -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");

View File

@@ -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)

View File

@@ -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