diff --git a/include/hasp_conf.h b/include/hasp_conf.h index 3ba35170..32ddcfd5 100644 --- a/include/hasp_conf.h +++ b/include/hasp_conf.h @@ -48,7 +48,7 @@ #include "hasp_spiffs.h" #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) -#include "lv_zifont.h" +// #include "lv_zifont.h" #endif #endif @@ -88,6 +88,10 @@ #include "hasp_slave.h" #endif +#if HASP_USE_ETHERNET>0 +#include "hasp_ethernet.h" +#endif + #endif #ifndef FPSTR diff --git a/include/lv_conf.h b/include/lv_conf.h index 244aa61a..85829f49 100644 --- a/include/lv_conf.h +++ b/include/lv_conf.h @@ -80,7 +80,7 @@ typedef int16_t lv_coord_t; # define LV_MEM_SIZE (12 * 1024U) // 12KB #endif #ifndef LV_MEM_SIZE -# define LV_MEM_SIZE (64 * 1024U) // 48KB +# define LV_MEM_SIZE (20 * 1024U) // 48KB #endif /* Complier prefix for a big array declaration */ diff --git a/platformio.ini b/platformio.ini index 0a6cfa80..84f3a1a8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -153,7 +153,53 @@ build_flags = -D HASP_INPUT_PIN=PD15 ; User Button K1 on DevEBox board -D STM32_SERIAL1 ; Set this option to use Serial1 as default sersial port, leave out if using Serial2 -D HAL_ETH_MODULE_ENABLED=1 ; enable ethernet support - -D LAN8742A_PHY_ADDRESS=0x01U ; set LAN8720 address + -D LAN8742A_PHY_ADDRESS=0x01U ; set LAN8720 PHY address + +lib_deps = + ${env.lib_deps} + Ticker@^3.1.5 + ; STM32duino LwIP@^2.1.2 + ; STM32duino STM32Ethernet@^1.0.5 + https://github.com/stm32duino/LwIP.git + https://github.com/stm32duino/STM32Ethernet.git + +src_filter = +<*> -<.git/> -<.svn/> - - - - - + + +;*************************************************** + +[env:DevEBox_STM32F4xx] +platform = ststm32 +board = black_f407zg +board_build.mcu = stm32f407vgt6 +; upload_protocol = dfu +upload_protocol = stlink +debug_tool = stlink +monitor_port = COM19 ; To change the port, use platform_override.ini +build_flags = + ${env.build_flags} + ${flags.stm32_flags} + -I include/stm32f4 +; -- TFT_eSPI build options ------------------------ + ${lcd.lolin24} + ;-D TFT_MISO=PB4 ;Default + ;-D TFT_MOSI=PB5 ;Default + ;-D TFT_SCLK=PB3 ;Default + -D TFT_CS=PE13 ;D8 + -D TFT_DC=PE14 ;D3 + -D TFT_BCKL=-1 ;None, configurable via web UI (e.g. 2 for D4) + -D TOUCH_CS=PA6 ;NC + -D TFT_RST=-1 ;D4 + -D STM32 + -D TFT_SPI3 + -D USE_DMA_TO_TFT + -D HASP_USE_TASMOTA_SLAVE=1 + -D HASP_OUTPUT_PIN=PA1 ; User LED D2 on DevEBox board + -D HASP_INPUT_PIN=PA0 ; User Button K1 on DevEBox board + -D STM32_SERIAL1 ; Set this option to use Serial1 as default sersial port, leave out if using Serial2 + -D HASP_USE_ETHERNET=1 + -D HAL_ETH_MODULE_ENABLED=1 + -D LAN8742A_PHY_ADDRESS=0x01U + ; -D DP83848_PHY_ADDRESS=0x01U lib_deps = ${env.lib_deps} diff --git a/src/hasp_ethernet.cpp b/src/hasp_ethernet.cpp new file mode 100644 index 00000000..8c30ab9b --- /dev/null +++ b/src/hasp_ethernet.cpp @@ -0,0 +1,33 @@ +#include +#include "ArduinoJson.h" +#include "ArduinoLog.h" +#include "hasp_conf.h" + +#if HASP_USE_ETHERNET>0 + +#include +#include +#include + +EthernetClient EthClient; + +void ethernetSetup() +{ + // start Ethernet and UDP + Log.notice(F("ETH: Begin Ethernet")); + + if (Ethernet.begin() == 0) { + Log.notice(F("ETH: Failed to configure Ethernet using DHCP")); + } else { + IPAddress ip = Ethernet.localIP(); + Log.notice(F("ETH: DHCP Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]); + } +} + +void ethernetLoop(void) +{ + Ethernet.maintain(); +} + + +#endif \ No newline at end of file diff --git a/src/hasp_ethernet.h b/src/hasp_ethernet.h new file mode 100644 index 00000000..0b2b6947 --- /dev/null +++ b/src/hasp_ethernet.h @@ -0,0 +1,7 @@ +#ifndef HASP_ETHERNET_H +#define HASP_ETHERNET_H + +void ethernetSetup(); +void ethernetLoop(void); + +#endif \ No newline at end of file diff --git a/src/hasp_slave.cpp b/src/hasp_slave.cpp index 0a4eed71..7ae71a3c 100644 --- a/src/hasp_slave.cpp +++ b/src/hasp_slave.cpp @@ -1,7 +1,7 @@ /********************* * INCLUDES *********************/ -#if HASP_USE_SLAVE>0 +#if HASP_USE_TASMOTA_SLAVE>0 #include "hasp_slave.h" #include diff --git a/src/main.cpp b/src/main.cpp index c4a259d8..eadd500f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -78,6 +78,10 @@ void setup() #endif // WIFI +#if HASP_USE_ETHERNET + ethernetSetup(); +#endif + #if HASP_USE_TASMOTA_SLAVE slaveSetup(); #endif @@ -139,6 +143,10 @@ void loop() #endif // WIFI +#if HASP_USE_ETHERNET + ethernetLoop(); +#endif + #if HASP_USE_TASMOTA_SLAVE slaveLoop(); #endif // TASMOTASLAVE