this is going to be a somewhat lengthy post, because I try to give you all the information neccessary while describing the project it is embedded in.
What I thought to be a simple project got a bit out of hand now So I am looking for anyone interested in helping me wrapping my head around developing for ESPEasy.
Also, if I am missing some obvious solution that doesn't involve hacking away at the code that I didn't think of, I would love to hear from you!
My main problem related to the topic is as follows:
Currently I try to debug my fork of P141 & P142 to make them directly adressable or react to TaskValueSetAndRun in a predictable way.
I tried to locate every resource available for developers, but I could only find bits and pieces across different websites and GitHub repositories. Some questions that are still open for me: What functions can be passed to a plugin? What is the structure of common objects like event?
So i decided to debug my way through the code and look at the variable stacks to see what I could use for my logic.
- Breakpoint works (only 1 hardware breakpoint possible)
- Watch expression works (only 1 hardware watchpoint possible)
- Temporary hardware assisted breakpoints working
- Step over nearly always causes an exeption
- Variable values are <optimized away> quite often
- Variable values are diplayed as <anonymous union> containing some blob (?) data
- Often the variable value is <error: cannot access memory at address 0x...>
What I think the problem is:
I cannot compile with compiler optimization turned off (-O0). I have to use -O1 or -Og, leading to the results you see in the screenshot.
When I try to compile with -O0, I get a compiler error like this:
Code: Select all
-DDEBC:\Users\xxx\.platformio\packages\framework-arduinoespressif8266@src-a516163d55c87c23296626d8ca889c7e\tools\sdk\libc\xtensa-lx106-elf\include/sys/pgmspace.h:107:1: error: a15 cannot be used in asm here UG -DBUILD_DEBUG -DDEBUG_ESP_PORT=Serial "-I.pio\libdeps\deb } ug_ ^ ESP8*** [.pio\build\debug_ESP8285_1M\libfef\Adafruit GFX Library_ID13\Adafruit_GFX.cpp.o] Error 1
Since then I tried a variety of board, package and tree version combinations, but to no avail, so I suspect Adafruit GFX to be the culprit.
Here are my compiler flags, maybe I haved missed something:
Code: Select all
-c -fno-rtti -std=c++11 -mtarget-align -mlongcalls -mtext-section-literals -falign-functions=4 -U__STRICT_ANSI__ -ffunction-sections -fdata-sections -fno-exceptions -Wall -Og -fvar-tracking -fvar-tracking-assignments -g3 -ggdb3 -DUSE_CUSTOM_H -DPLATFORMIO=40304 -DESP8266 -DARDUINO_ARCH_ESP8266 -DARDUINO_ESP8266_WEMOS_D1MINILITE -DBUILD_GIT=\"\" -DVTABLES_IN_FLASH -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH -DPUYA_SUPPORT=1 -DCORE_POST_2_5_0 -DBEARSSL_SSL_BASIC -DCORE_POST_2_6_0 -DPIO_FRAMEWORK_ARDUINO_ESPRESSIF_SDK22x_190703 -DSIZE_1M -DMQTT_MAX_PACKET_SIZE=1024 -DHTTPCLIENT_1_1_COMPATIBLE=0 -DESP8285 -DF_CPU=80000000L -D__ets__ -DICACHE_FLASH -DARDUINO=10805 -DARDUINO_BOARD=\"PLATFORMIO_D1_MINI_LITE\" -DFLASHMODE_DOUT -DLWIP_OPEN_SRC -DNONOSDK22x_190703=1 -DTCP_MSS=1460 -DLWIP_FEATURES=0 -DLWIP_IPV6=0 -D__PLATFORMIO_BUILD_DEBUG__ -DDEBUG -DBUILD_DEBUG -DDEBUG_ESP_PORT=Serial
I want to build a dimmer for 2 led strip panels, controlling 2 sides of a light box. I want to use a home automation platform for this and plan to do more projects after I finished this. Right now I'm using OpenHAB, but the decision is not final. I want to do this with one D1 mini lite. There my trouble began, because I still don't know how to address these devices (in ESPEasy terms) directly. So here's what I did:
Steps of the project:
- build a controller for 2 LED strips to be controlled by OpenHAB (works, directly issuing PWM,<GPIO>,<n> commands control led brightness)
- learn that I can't use the same plugin for 2 devices, because the first one to receive incoming commands executes and there is no way right now to address a device directly
- learn that 2 different plugins don't help either, because they use the same commands
- Dug into the Controller Code to learn that you can make it queue a PLUGIN_WRITE if the last segment of your MQTT topic is a number (it ignores the payload and takes the last part of the topic as value, the remainder is issued as command. Same problem as #2)
- learn that Rules triggered on MQTTimport don't work either, because TaskValueSetAndRun triggers PLUGIN_DEVICE_READ instead of PLUGIN_DEVICE_WRITE (learned that later). So the values get updated, but not the device/plugin/task.
- Windows 10
- VSCode 1.45.1 (recent version)
- PlatformIO (Core 4.3.4, Home 3.2.2)
- D1 mini lite
- ESPEasy mega-20200608
Hoping to understand ESPeasy better