Merge branch '0.2.0' of https://github.com/fvanroie/hasp-lvgl into 0.2.0

This commit is contained in:
fvanroie 2020-11-03 23:00:33 +01:00
commit c1a6aca093
8 changed files with 144 additions and 8 deletions

View File

@ -107,6 +107,21 @@
#endif
#if HASP_USE_ETHERNET > 0
#if defined(ARDUINO_ARCH_ESP32)
#include <ETH.h>
#define ETH_ADDR 0
#define ETH_POWER_PIN -1
#define ETH_MDC_PIN 23
#define ETH_MDIO_PIN 18
#define NRST 5
#define ETH_TYPE ETH_PHY_LAN8720
#define ETH_CLKMODE ETH_CLOCK_GPIO17_OUT
#include "hasp_ethernet_esp32.h"
#warning Using ESP32 Ethernet LAN8720
#else
#if USE_BUILTIN_ETHERNET > 0
#include <LwIP.h>
#include <STM32Ethernet.h>
@ -121,6 +136,7 @@
#endif
#include "hasp_ethernet.h"
#endif
#endif
#if HASP_USE_MQTT > 0
#include "hasp_mqtt.h"

View File

@ -4,7 +4,7 @@
#include "hasp_conf.h"
#include "hasp_hal.h"
#if HASP_USE_ETHERNET > 0
#if HASP_USE_ETHERNET > 0 && !defined(ARDUINO_ARCH_ESP32)
EthernetClient EthClient;
IPAddress ip;

View File

@ -0,0 +1,64 @@
#include <Arduino.h>
#include "ArduinoJson.h"
#include "ArduinoLog.h"
#include "hasp_conf.h"
#include "hasp_hal.h"
#if HASP_USE_ETHERNET > 0
IPAddress ip;
void EthernetEvent(WiFiEvent_t event)
{
switch (event) {
case SYSTEM_EVENT_ETH_START:
Log.notice(F(LOG_ETH_CTR "Started"));
//set eth hostname here
ETH.setHostname("esp32-ethernet");
break;
case SYSTEM_EVENT_ETH_CONNECTED:
Log.notice(F(LOG_ETH_CTR "Connected"));
break;
case SYSTEM_EVENT_ETH_GOT_IP:
Log.notice(F(LOG_ETH_CTR "MAC Address %s"), ETH.macAddress().c_str());
ip = ETH.localIP();
Log.notice(F(LOG_ETH_CTR "IPv4: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
if (ETH.fullDuplex()) {
Log.notice(F(LOG_ETH_CTR "FULL_DUPLEX"));
}
Log.notice(F(LOG_ETH_CTR "LINK_SPEED %d Mbps"), ETH.linkSpeed());
eth_connected = true;
break;
case SYSTEM_EVENT_ETH_DISCONNECTED:
Log.notice(F(LOG_ETH_CTR "Disconnected"));
eth_connected = false;
break;
case SYSTEM_EVENT_ETH_STOP:
Log.notice(F(LOG_ETH_CTR "Stopped"));
eth_connected = false;
break;
default:
break;
}
}
void ethernetSetup()
{
WiFi.onEvent(EthernetEvent);
ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE, ETH_CLKMODE);
}
void ethernetLoop(void)
{
//
}
bool ethernetEvery5Seconds()
{
Log.warning(F(LOG_ETH_CTR "%s"), eth_connected ? F("ONLINE") : F("OFFLINE"));
return eth_connected;
}
#endif

13
src/hasp_ethernet_esp32.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef HASP_ETHERNET_ESP32_H
#define HASP_ETHERNET_ESP32_H
#define LOG_ETH_CTR "ETH: "
static bool eth_connected = false;
void ethernetSetup();
void ethernetLoop(void);
bool ethernetEvery5Seconds();
#endif

View File

@ -1514,7 +1514,11 @@ void webStart()
(WiFi.getMode() != WIFI_STA ? WiFi.softAPIP().toString().c_str() : WiFi.localIP().toString().c_str()));
#else
IPAddress ip;
#if defined(ARDUINO_ARCH_ESP32)
ip = ETH.localIP();
#else
ip = Ethernet.localIP();
#endif
Log.notice(F("HTTP: Server started @ http://%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
#endif
}

View File

@ -73,13 +73,14 @@ static void kb_event_cb(lv_obj_t * event_kb, lv_event_t event)
strncpy(pass, lv_textarea_get_text(obj), sizeof(pass));
settings[FPSTR(F_CONFIG_PASS)] = pass;
}
#if HASP_USE_WIFI > 0
if(strlen(ssid) > 0) {
wifiSetConfig(settings.as<JsonObject>());
if(wifiTestConnection()) {
dispatchReboot(true);
}
}
#endif
} else if(event == LV_EVENT_CANCEL) {
oobeSetPage(0);
@ -296,6 +297,9 @@ static void oobe_calibrate_cb(lv_obj_t * ta, lv_event_t event)
bool oobeSetup()
{
#if HASP_USE_ETHERNET > 0
if (eth_connected) return false;
#endif
#if HASP_USE_WIFI > 0
char ssid[32];
char pass[32];

View File

@ -9,8 +9,8 @@
| | ... | ${property}=${property} | ${data}=${data}
| | ${time} | Get Time | epoch
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
| | ${topic} | Set Variable | hasp/plate37/command
| | ${restopic} | Set Variable | hasp/plate37/state/json
| | ${topic} | Set Variable | hasp/platetelemetry/command
| | ${restopic} | Set Variable | hasp/platetelemetry/state/json
| | ${qos} | Set Variable | 1
| | ${message} | Set Variable | ${property}=${data}
| | ${result} | Set Variable | {"${property}":"${data}"}
@ -31,8 +31,8 @@
| | ... | ${property}=${property} | ${data}=${data}
| | ${time} | Get Time | epoch
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
| | ${topic} | Set Variable | hasp/plate37/command
| | ${restopic} | Set Variable | hasp/plate37/state/page
| | ${topic} | Set Variable | hasp/platetelemetry/command
| | ${restopic} | Set Variable | hasp/platetelemetry/state/page
| | ${qos} | Set Variable | 1
| | ${message} | Set Variable | ${property}=${data}
| | Subscribe Async | client.id=${client} | topic=${restopic}
@ -50,8 +50,8 @@
| | ... | ${property}=${property} | ${data}=${data}
| | ${time} | Get Time | epoch
| | ${client} | Catenate | SEPARATOR=. | robot.mqtt | ${time}
| | ${topic} | Set Variable | hasp/plate37/command/${property}
| | ${restopic} | Set Variable | hasp/plate37/state/page
| | ${topic} | Set Variable | hasp/platetelemetry/command/${property}
| | ${restopic} | Set Variable | hasp/platetelemetry/state/page
| | ${qos} | Set Variable | 1
| | ${message} | Set Variable | ${data}
| | Connect | ${broker.uri} | ${port} | ${client.id} | ${clean_session}

View File

@ -0,0 +1,35 @@
;***************************************************;
; Lilygo®Ttgo ESP32 with Lolin TFT 2.4" ;
; - T-Internet-Poe ESP32-WROOM ;
; - LAN8720A with POE ;
; - ili9341 TFT ;
; - xpt2606 touch controller ;
;***************************************************;
[env:ttgo_esp32-lolintft24]
platform = espressif32@^1.12.0
board = esp32dev
upload_protocol = espota ; Use ArduinoOTA after flashing over serial
upload_port = 10.4.70.37 ; 10.4.0.198 ; IP of the ESP
upload_flags =
--port=3232
;upload_port = COM9 ; To change the port, use platform_override.ini
monitor_port = COM9 ; To change the port, use platform_override.ini
board_build.partitions = esp32_partition_app1300k_spiffs1216k.csv ; default.csv
build_flags =
${flags.esp32_flags}
; -- TFT_eSPI build options ------------------------
${lcd.lolin24}
-D TFT_MISO=2
-D TFT_MOSI=15
-D TFT_SCLK=14
-D TFT_DC=4
-D TFT_CS=33
-D TFT_RST=12 ; RST
-D TFT_BCKL=16 ; None, configurable via web UI (e.g. 21)
-D TOUCH_CS=32 ; (can also be 22 or 16)
; -- Options ----------------------------------------
-D HASP_USE_TELNET=1
-D HASP_USE_ETHERNET=1
-D HASP_USE_WIFI=0