Skip to content

Commit

Permalink
Merge pull request #3433 from TD-er/build/external_CSS_JS
Browse files Browse the repository at this point in the history
[Cleanup] Reduce build size to allow minimal_OTA builds for 1M
  • Loading branch information
TD-er authored Dec 27, 2020
2 parents c530b08 + c343c17 commit fb3c4ea
Show file tree
Hide file tree
Showing 63 changed files with 1,404 additions and 1,042 deletions.
23 changes: 22 additions & 1 deletion platformio_esp32_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[esp32_common]
extends = common, core_esp32_2_0_0
lib_ignore = ESP8266WiFi, ESP8266Ping, ESP8266WebServer, ESP8266HTTPUpdateServer, ESP8266mDNS, IRremoteESP8266, ESPEasy_ESP8266Ping, ESP32_ping, HeatpumpIR
lib_deps = https://github.com/TD-er/ESPEasySerial.git#v2.0.5, Adafruit ILI9341, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO
lib_deps = https://github.com/TD-er/ESPEasySerial.git#v2.0.5, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO
board_build.f_flash = 80000000L
board_build.flash_mode = dout
board_upload.maximum_size = 1900544
Expand Down Expand Up @@ -92,6 +92,27 @@ lib_ignore = AS_BH1750, ESP8266WiFi, ESP8266Ping, ESP8266WebServe
build_flags = ${esp32_common.build_flags}
-DPLUGIN_BUILD_NORMAL_IRext

[env:energy_ESP32_4M316k]
extends = esp32_common
platform = ${esp32_common.platform}
lib_deps = ${esp32_common.lib_deps}, ServoESP32
build_flags = ${esp32_common.build_flags}
-DFEATURE_ARDUINO_OTA
-D PLUGIN_ENERGY_COLLECTION
board = esp32dev
extra_scripts = ${esp32_common.extra_scripts}

[env:display_ESP32_4M316k]
extends = esp32_common
platform = ${esp32_common.platform}
lib_deps = ${esp32_common.lib_deps}, ServoESP32
build_flags = ${esp32_common.build_flags}
-DFEATURE_ARDUINO_OTA
-D PLUGIN_DISPLAY_COLLECTION
board = esp32dev
extra_scripts = ${esp32_common.extra_scripts}


; Custom: 4096k version --------------------------
[env:custom_ESP32_4M316k_ETH]
extends = env:custom_ESP32_4M316k
Expand Down
2 changes: 1 addition & 1 deletion platformio_esp82xx_base.ini
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extends = common
board_build.f_cpu = 80000000L
build_flags = ${debug_flags.build_flags} ${mqtt_flags.build_flags} -DHTTPCLIENT_1_1_COMPATIBLE=0
build_unflags = -DDEBUG_ESP_PORT
lib_deps = https://github.com/TD-er/ESPEasySerial.git#v2.0.5, Adafruit ILI9341, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO
lib_deps = https://github.com/TD-er/ESPEasySerial.git#v2.0.5, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit GFX Library, LOLIN_EPD, Adafruit BusIO, bblanchon/ArduinoJson @ ^6.17.2
lib_ignore = ${esp82xx_defaults.lib_ignore}, IRremoteESP8266, HeatpumpIR, SD(esp8266), SDFS, LittleFS(esp8266), ServoESP32
board = esp12e
monitor_filters = esp8266_exception_decoder
Expand Down
26 changes: 24 additions & 2 deletions platformio_esp82xx_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build_flags = ${regular_platform_alt_wifi.build_flags}


[esp8266_custom_common]
;lib_ignore = ESP32_ping, ESP32WebServer, ServoESP32, ESP32HTTPUpdateServer, Adafruit GFX Library, LOLIN_EPD, Adafruit ILI9341
;lib_ignore = ESP32_ping, ESP32WebServer, ServoESP32, ESP32HTTPUpdateServer, Adafruit GFX Library, LOLIN_EPD, adafruit/Adafruit ILI9341 @ ^1.5.6
lib_ignore = ESP32_ping, ESP32WebServer, ServoESP32, ESP32HTTPUpdateServer, IRremoteESP8266, HeatpumpIR
extra_scripts = pre:tools/pio/pre_custom_esp82xx.py
${extra_scripts_esp8266.extra_scripts}
Expand All @@ -44,7 +44,7 @@ platform_packages = ${regular_platform.platform_packages}
build_flags = ${regular_platform.build_flags}
${esp8266_4M1M.build_flags}
-DPLUGIN_BUILD_CUSTOM
lib_ignore = LittleFS, ESP32_ping, ESP32WebServer, ServoESP32, ESP32HTTPUpdateServer, Adafruit GFX Library, LOLIN_EPD, Adafruit ILI9341, Adafruit BusIO, Adafruit NeoPixel, Adafruit Motor Shield V2 Library, RN2xx3 Arduino Library
lib_ignore = LittleFS, ESP32_ping, ESP32WebServer, ServoESP32, ESP32HTTPUpdateServer, Adafruit GFX Library, LOLIN_EPD, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit BusIO, Adafruit NeoPixel, Adafruit Motor Shield V2 Library, RN2xx3 Arduino Library
extra_scripts = ${esp8266_custom_common.extra_scripts}


Expand Down Expand Up @@ -466,6 +466,28 @@ platform_packages = ${dev.platform_packages}
build_flags = ${dev.build_flags}
${esp8266_4M1M.build_flags}

;;; Collection builds ************************************************
; Collection of similar plugins for a specific use case ;
; for example "Display" or "energy meter" ;
; *********************************************************************

; energy : 4096k version ----------------------------
[env:energy_ESP8266_4M1M]
extends = esp8266_4M1M
platform = ${regular_platform.platform}
platform_packages = ${regular_platform.platform_packages}
build_flags = ${regular_platform.build_flags}
${esp8266_4M1M.build_flags}
-D PLUGIN_ENERGY_COLLECTION

; display : 4096k version ----------------------------
[env:display_ESP8266_4M1M]
extends = esp8266_4M1M
platform = ${regular_platform.platform}
platform_packages = ${regular_platform.platform_packages}
build_flags = ${regular_platform.build_flags}
${esp8266_4M1M.build_flags}
-D PLUGIN_DISPLAY_COLLECTION


;;; HARDWARE SPECIFIC VERSIONS ***********************************************************
Expand Down
2 changes: 1 addition & 1 deletion platformio_special_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ build_flags = ${regular_platform.build_flags}
${debug_pio.build_flags}
${esp8266_4M1M.build_flags}
-DPLUGIN_BUILD_CUSTOM
lib_ignore = LittleFS, ESP32_ping, ESP32WebServer, ServoESP32, ESP32HTTPUpdateServer, Adafruit GFX Library, LOLIN_EPD, Adafruit ILI9341, Adafruit BusIO, Adafruit NeoPixel, Adafruit Motor Shield V2 Library, RN2xx3 Arduino Library
lib_ignore = LittleFS, ESP32_ping, ESP32WebServer, ServoESP32, ESP32HTTPUpdateServer, Adafruit GFX Library, LOLIN_EPD, adafruit/Adafruit ILI9341 @ ^1.5.6, Adafruit BusIO, Adafruit NeoPixel, Adafruit Motor Shield V2 Library, RN2xx3 Arduino Library
extra_scripts = ${extra_scripts_esp8266.extra_scripts}


Expand Down
2 changes: 2 additions & 0 deletions src/ESPEasy.ino
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,12 @@ void setup()
}

log += RTC.bootCounter;
#ifndef BUILD_NO_DEBUG
log += F(" Last Action before Reboot: ");
log += ESPEasy_Scheduler::decodeSchedulerId(lastMixedSchedulerId_beforereboot);
log += F(" Last systime: ");
log += RTC.lastSysTime;
#endif
}
//cold boot (RTC memory empty)
else
Expand Down
7 changes: 3 additions & 4 deletions src/_C004.ino
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,15 @@ bool do_process_c004_delay_queue(int controller_number, const C004_queue_element

if (element.sensorType == Sensor_VType::SENSOR_TYPE_STRING) {
postDataStr += F("&status=");
postDataStr += element.txt; // FIXME TD-er: Is this correct?
postDataStr += element.txt[0]; // FIXME TD-er: Is this correct?
// See: https://nl.mathworks.com/help/thingspeak/writedata.html
} else {
byte valueCount = getValueCountForTask(element.TaskIndex);
for (byte x = 0; x < valueCount; x++)
for (byte x = 0; x < element.valueCount; x++)
{
postDataStr += F("&field");
postDataStr += element.idx + x;
postDataStr += '=';
postDataStr += formatUserVarNoCheck(element.TaskIndex, x);
postDataStr += element.txt[x];
}
}
String hostName = F("api.thingspeak.com"); // PM_CZ: HTTP requests must contain host headers.
Expand Down
116 changes: 60 additions & 56 deletions src/_C007.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

#include "src/ESPEasyCore/Serial.h"

//#######################################################################################################
//########################### Controller Plugin 007: Emoncms ############################################
//#######################################################################################################
// #######################################################################################################
// ########################### Controller Plugin 007: Emoncms ############################################
// #######################################################################################################

#define CPLUGIN_007
#define CPLUGIN_ID_007 7
#define CPLUGIN_NAME_007 "Emoncms"
# define CPLUGIN_007
# define CPLUGIN_ID_007 7
# define CPLUGIN_NAME_007 "Emoncms"


bool CPlugin_007(CPlugin::Function function, struct EventStruct *event, String& string)
Expand All @@ -19,65 +19,64 @@ bool CPlugin_007(CPlugin::Function function, struct EventStruct *event, String&
switch (function)
{
case CPlugin::Function::CPLUGIN_PROTOCOL_ADD:
{
Protocol[++protocolCount].Number = CPLUGIN_ID_007;
Protocol[protocolCount].usesMQTT = false;
Protocol[protocolCount].usesAccount = false;
Protocol[protocolCount].usesPassword = true;
Protocol[protocolCount].defaultPort = 80;
Protocol[protocolCount].usesID = true;
break;
}
{
Protocol[++protocolCount].Number = CPLUGIN_ID_007;
Protocol[protocolCount].usesMQTT = false;
Protocol[protocolCount].usesAccount = false;
Protocol[protocolCount].usesPassword = true;
Protocol[protocolCount].defaultPort = 80;
Protocol[protocolCount].usesID = true;
break;
}

case CPlugin::Function::CPLUGIN_GET_DEVICENAME:
{
string = F(CPLUGIN_NAME_007);
break;
}
{
string = F(CPLUGIN_NAME_007);
break;
}

case CPlugin::Function::CPLUGIN_INIT:
{
success = init_c007_delay_queue(event->ControllerIndex);
break;
}
{
success = init_c007_delay_queue(event->ControllerIndex);
break;
}

case CPlugin::Function::CPLUGIN_EXIT:
{
exit_c007_delay_queue();
break;
}
{
exit_c007_delay_queue();
break;
}

case CPlugin::Function::CPLUGIN_PROTOCOL_SEND:
{
if (C007_DelayHandler == nullptr) {
break;
}

if (event->sensorType == Sensor_VType::SENSOR_TYPE_STRING) {
addLog(LOG_LEVEL_ERROR, F("emoncms : No support for Sensor_VType::SENSOR_TYPE_STRING"));
break;
}
const byte valueCount = getValueCountForTask(event->TaskIndex);
if (valueCount == 0 || valueCount > 3) {
addLog(LOG_LEVEL_ERROR, F("emoncms : Unknown sensortype or too many sensor values"));
break;
}
success = C007_DelayHandler->addToQueue(C007_queue_element(event));
Scheduler.scheduleNextDelayQueue(ESPEasy_Scheduler::IntervalTimer_e::TIMER_C007_DELAY_QUEUE, C007_DelayHandler->getNextScheduleTime());
{
if (C007_DelayHandler == nullptr) {
break;
}

case CPlugin::Function::CPLUGIN_FLUSH:
{
process_c007_delay_queue();
delay(0);
if (event->sensorType == Sensor_VType::SENSOR_TYPE_STRING) {
addLog(LOG_LEVEL_ERROR, F("emoncms : No support for Sensor_VType::SENSOR_TYPE_STRING"));
break;
}
const byte valueCount = getValueCountForTask(event->TaskIndex);

default:
if ((valueCount == 0) || (valueCount > VARS_PER_TASK)) {
addLog(LOG_LEVEL_ERROR, F("emoncms : Unknown sensortype or too many sensor values"));
break;
}
success = C007_DelayHandler->addToQueue(C007_queue_element(event));
Scheduler.scheduleNextDelayQueue(ESPEasy_Scheduler::IntervalTimer_e::TIMER_C007_DELAY_QUEUE, C007_DelayHandler->getNextScheduleTime());
break;
}

case CPlugin::Function::CPLUGIN_FLUSH:
{
process_c007_delay_queue();
delay(0);
break;
}

default:
break;
}
return success;
}
Expand All @@ -89,29 +88,34 @@ bool do_process_c007_delay_queue(int controller_number, const C007_queue_element

bool do_process_c007_delay_queue(int controller_number, const C007_queue_element& element, ControllerSettingsStruct& ControllerSettings) {
WiFiClient client;
if (!try_connect_host(controller_number, client, ControllerSettings))

if (!try_connect_host(controller_number, client, ControllerSettings)) {
return false;
}

String url = F("/emoncms/input/post.json?node=");

url += Settings.Unit;
url += F("&json=");
const byte valueCount = getValueCountForTask(element.TaskIndex);
for (byte i = 0; i < valueCount; ++i) {

for (byte i = 0; i < element.valueCount; ++i) {
url += (i == 0) ? F("{") : F(",");
url += F("field");
url += element.idx + i;
url += ":";
url += formatUserVarNoCheck(element.TaskIndex, i);
url += element.txt[i];
}
url += "}";
url += F("&apikey=");
url += getControllerPass(element.controller_idx, ControllerSettings); // "0UDNN17RW6XAS2E5" // api key

if (Settings.SerialLogLevel >= LOG_LEVEL_DEBUG_MORE)
if (Settings.SerialLogLevel >= LOG_LEVEL_DEBUG_MORE) {
serialPrintln(url);
}

return send_via_http(controller_number, client,
create_http_get_request(controller_number, ControllerSettings, url),
ControllerSettings.MustCheckReply);
create_http_get_request(controller_number, ControllerSettings, url),
ControllerSettings.MustCheckReply);
}
#endif

#endif // ifdef USES_C007
12 changes: 2 additions & 10 deletions src/_C009.ino
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,8 @@ bool CPlugin_009(CPlugin::Function function, struct EventStruct *event, String&
break;
}

byte valueCount = getValueCountForTask(event->TaskIndex);
C009_queue_element element(event);

for (byte x = 0; x < valueCount; x++)
{
element.txt[x] = formatUserVarNoCheck(event, x);
}
// FIXME TD-er must define a proper move operator
success = C009_DelayHandler->addToQueue(C009_queue_element(element));
success = C009_DelayHandler->addToQueue(C009_queue_element(event));
Scheduler.scheduleNextDelayQueue(ESPEasy_Scheduler::IntervalTimer_e::TIMER_C009_DELAY_QUEUE, C009_DelayHandler->getNextScheduleTime());
break;
}
Expand Down Expand Up @@ -144,9 +137,8 @@ bool do_process_c009_delay_queue(int controller_number, const C009_queue_element

// Create nested SENSOR json object
JsonObject SENSOR = data.createNestedObject(String(F("SENSOR")));
byte valueCount = getValueCountForTask(element.TaskIndex);
// char itemNames[valueCount][2];
for (byte x = 0; x < valueCount; x++)
for (byte x = 0; x < element.valueCount; x++)
{
// Each sensor value get an own object (0..n)
// sprintf(itemNames[x],"%d",x);
Expand Down
Loading

0 comments on commit fb3c4ea

Please sign in to comment.