esp32 support, build_flags_{ENVNAME}.sh now can be used and edited in IDE!

This commit is contained in:
livello
2018-07-04 01:22:00 +03:00
parent 797ce5d4ce
commit 09726be883
12 changed files with 161 additions and 100 deletions

View File

@@ -28,7 +28,7 @@ e-mail anklimov@gmail.com
#endif
#endif
#if defined(__ESP__)
#if defined(ESP8266)
#ifndef DMX_DISABLE
DMXESPSerial dmxout;
#endif
@@ -236,7 +236,7 @@ void DMXoutSetup(int channels)
#endif
#if defined(__ESP__)
#if defined(ESP8266)
dmxout.init(channels);
#endif

View File

@@ -38,7 +38,7 @@ e-mail anklimov@gmail.com
#define DmxWrite DmxSimple.write
#endif
#if defined(__ESP__)
#if defined(ESP8266)
#include <ESPDMX.h>
extern DMXESPSerial dmxout;
#define DmxWrite dmxout.write

View File

@@ -33,6 +33,14 @@ extern PubSubClient mqttClient;
static volatile long encoder_value[6];
#endif
#if defined(ESP8266)
static volatile long encoder_value[6];
#endif
#if defined(ARDUINO_ARCH_ESP32)
static volatile long encoder_value[6];
#endif
#if defined(__SAM3X8E__)
static short encoder_irq_map[54];
static long encoder_value[54];
@@ -216,7 +224,7 @@ void Input::dht22Poll() {
}
void Input::printFloatValueToStr(float temp, char *valstr) {
#if defined(__ESP__)
#if defined(ESP8266)
sprintf(valstr, "%2.1f", temp);
#endif
#if defined(__AVR__)

View File

@@ -186,7 +186,7 @@ void Item::copyPar (aJsonObject *itemV)
}
*/
#ifdef ESP32
#if defined(ARDUINO_ARCH_ESP32)
void analogWrite(int pin, int val)
{
//TBD
@@ -218,6 +218,7 @@ int Item::Ctrl(char * payload, boolean send){
case -1: //Not known command
case -2: //JSON input (not implemented yet
break;
#if not defined(ARDUINO_ARCH_ESP32) and not defined(ESP8266)
case -3: //RGB color in #RRGGBB notation
{
CRGB rgb;
@@ -231,6 +232,7 @@ int Item::Ctrl(char * payload, boolean send){
}
break;
}
#endif
case CMD_ON:
// if (item.getEnableCMD(500) || lanStatus == 4)

View File

@@ -77,12 +77,20 @@ EthernetClient ethClient;
EthernetClient ethClient;
#endif
#ifdef __ESP__
#ifdef ESP8266
#include <ESP8266WiFi.h>
#include <user_interface.h>
WiFiClient ethClient;
#endif
#ifdef ARDUINO_ARCH_ESP32
#include <WiFiClient.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <EEPROM.h>
WiFiClient ethClient;
#endif
lan_status lanStatus = INITIAL_STATE;
const char outprefix[] PROGMEM = OUTTOPIC;
@@ -270,7 +278,7 @@ lan_status lanLoop() {
{
#ifndef __ESP__
#if defined(__AVR__) || defined(__SAM3X8E__)
wdt_dis();
if (lanStatus > 0)
switch (Ethernet.maintain()) {
@@ -395,8 +403,7 @@ void ip_ready_config_loaded_connecting_to_broker() {
}
void onInitialStateInitLAN() {
#ifdef __ESP__
#ifdef WIFI_MANAGER_DISABLE
#if defined(ESP8266) and defined(WIFI_MANAGER_DISABLE)
if(!wifiInitialized) {
WiFi.mode(WIFI_STA);
Serial.print(F("WIFI AP/Password:"));
@@ -408,15 +415,40 @@ void onInitialStateInitLAN() {
wifiInitialized = true;
}
#endif
if (WiFi.status() == WL_CONNECTED) {
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
lanStatus=HAVE_IP_ADDRESS;//1;
}
#ifdef ARDUINO_ARCH_ESP32
if(!wifiInitialized) {
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Serial.print(F("WIFI AP/Password:"));
Serial.print(QUOTE(ESP_WIFI_AP));
Serial.print(F("/"));
Serial.println(QUOTE(ESP_WIFI_PWD));
WiFi.begin(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
int wifi_connection_wait = 10000;
while (WiFi.status() != WL_CONNECTED && wifi_connection_wait > 0) {
delay(500);
wifi_connection_wait -= 500;
Serial.print(".");
}
wifiInitialized = true;
}
#endif
#if not defined(__ESP__)
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
if (WiFi.status() == WL_CONNECTED) {
Serial.print(F("WiFi connected. IP address: "));
Serial.println(WiFi.localIP());
lanStatus = HAVE_IP_ADDRESS;//1;
} else
{
Serial.println(F("Problem with WiFi connected"));
nextLanCheckTime = millis() + DHCP_RETRY_INTERVAL/5;
}
#endif
#if defined(__AVR__) || defined(__SAM3X8E__)
IPAddress ip, dns, gw, mask;
int res = 1;
Serial.println(F("Starting lan"));
@@ -956,7 +988,7 @@ lan_status getConfig(int arg_cnt, char **args)
return READ_RE_CONFIG;//-11; //Load from NVRAM
}
#endif
#if defined(__ESP__)
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
HTTPClient httpClient;
String fullURI = "http://";
fullURI+=configServer;
@@ -1047,7 +1079,7 @@ void setup_main() {
ArtnetSetup();
#endif
#if defined(__ESP__) and not defined(WIFI_MANAGER_DISABLE)
#if defined(ESP8266) and not defined(WIFI_MANAGER_DISABLE)
WiFiManager wifiManager;
#if defined(ESP_WIFI_AP) and defined(ESP_WIFI_PWD)
wifiManager.autoConnect(QUOTE(ESP_WIFI_AP), QUOTE(ESP_WIFI_PWD));
@@ -1060,6 +1092,10 @@ void setup_main() {
//TODO: checkForRemoteSketchUpdate();
}
#ifdef MMMMMM
errro!!!
#endif
void printFirmwareVersionAndBuildOptions() {
Serial.print(F("\nLazyhome.ru LightHub controller "));
Serial.println(F(QUOTE(PIO_SRC_REV)));

View File

@@ -14,18 +14,24 @@
#define DHCP_RETRY_INTERVAL 60000
#endif
#if defined(__AVR__)
#if defined(ESP8266)
#define wdt_en() wdt_enable(WDTO_8S)
#define wdt_dis() wdt_disable()
#define wdt_res() wdt_reset()
#endif
#if defined(__ESP__)
#ifdef ARDUINO_ARCH_ESP32
#define wdt_res()
#define wdt_en()
#define wdt_dis()
#endif
//#if defined(ESP8266)
//#define wdt_res()
//#define wdt_en()
//#define wdt_dis()
//#endif
#if defined(WATCH_DOG_TICKER_DISABLE) && defined(__AVR__)
#define wdt_en() wdt_disable()
#define wdt_dis() wdt_disable()
@@ -63,16 +69,13 @@
#include <EEPROM.h>
#endif
#if defined(__ESP__)
#if defined(ESP8266)
#include <FS.h> //this needs to be first, or it all crashes and burns...
#include <EEPROM.h>
#include <ESP8266HTTPClient.h>
#ifndef WIFI_MANAGER_DISABLE
#include <WiFiManager.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#endif
#endif
@@ -88,11 +91,19 @@
#endif
#if defined(__AVR__) || defined(__SAM3X8E__) || defined(ESP8266)
#ifdef Wiz5500
#include <Ethernet2.h>
#else
#include <Ethernet.h>
#endif
#endif
#ifdef ARDUINO_ARCH_ESP32
#include <SPI.h>
#include <Ethernet3.h>
#endif
#ifdef _artnet
#include <Artnet.h>
@@ -122,12 +133,9 @@ enum lan_status {
void mqttCallback(char *topic, byte *payload, unsigned int length);
//#ifndef __ESP__
void printIPAddress(IPAddress ipAddress);
//#endif
void printMACAddress();
void restoreState();

View File

@@ -95,10 +95,6 @@
#define LAN_INIT_DELAY 500
#endif
#if defined(ESP8266)
#define __ESP__
#endif
#if defined(__AVR__)
//All options available
#ifdef CONTROLLINO
@@ -116,7 +112,7 @@
#define dmxin DmxDue1
#endif
#if defined(__ESP__)
#if defined(ESP8266)
#undef _dmxin
#undef _modbus
#ifndef DMX_DISABLE

View File

@@ -80,7 +80,7 @@ int getInt(char **chan) {
}
#if defined(ESP8266)
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
unsigned long freeRam ()
{return system_get_free_heap_size();}
#endif