diff --git a/.gitignore b/.gitignore index d51a59fd3..72687b900 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,13 @@ -dist/*.html -node_modules -.build -*.gz -*.ino.generic.bin -.doxygen/doc -secrets.h +/.doxygen/doc/ +/.pio/ +/.vscode/ +!/.vscode/extensions.json +/dist/*.html +/node_modules/ +/ESPixelStick/data/www __pycache__ -*.pyc -ESPixelStick/data/www \ No newline at end of file +platformio_user.ini +secrets.h +*.ino.generic.bin +*.gz +*.pyc \ No newline at end of file diff --git a/.vscode/arduino.json b/.vscode/arduino.json deleted file mode 100644 index f087d2307..000000000 --- a/.vscode/arduino.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "board": "esp8266com:esp8266:generic", - "configuration": "xtal=160,vt=flash,exception=disabled,ssl=all,ResetMethod=nodemcu,CrystalFreq=26,FlashFreq=40,FlashMode=dio,eesz=1M128,led=2,sdk=nonosdk222_100,ip=hb2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200", - "sketch": "ESPixelStick.ino", - "output": ".build" -} \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index 56838ed24..000000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "configurations": [ - { - "name": "ESP8266", - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE", - "ARDUINO_ARCH_ESP8266" - ], - "includePath": [ - "${workspaceFolder}/**", - "${workspaceFolder}/../hardware/esp8266com/esp8266/tools/sdk/**", - "${workspaceFolder}/../hardware/esp8266com/esp8266/**", - "${workspaceFolder}/../libraries/**" - ], - "compilerPath": "${workspaceFolder}/../hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-gcc.exe", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "gcc-x64", - "forcedInclude": [] - }, - { - "name": "ESP32", - "defines": [ - "_DEBUG", - "UNICODE", - "_UNICODE", - "ARDUINO_ARCH_ESP32" - ], - "includePath": [ - "${workspaceFolder}/**", - "${workspaceFolder}/../hardware/espressif/esp32/tools/sdk/**", - "${workspaceFolder}/../hardware/espressif/esp32/**", - "${workspaceFolder}/../libraries/**" - ], - "compilerPath": "${workspaceFolder}/../hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc.exe", - "cStandard": "c11", - "cppStandard": "c++17", - "intelliSenseMode": "gcc-x64", - "forcedInclude": [] - } - - ], - "version": 4 -} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..e80666bfb --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index e9ac90713..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "search.exclude": { - "**/node_modules": true, - "**/.doxygen": true - }, - "js/ts.implicitProjectConfig.checkJs": true, - "files.associations": { - "array": "cpp", - "atomic": "cpp", - "*.tcc": "cpp", - "bitset": "cpp", - "cctype": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "cstdarg": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "list": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "exception": "cpp", - "fstream": "cpp", - "functional": "cpp", - "initializer_list": "cpp", - "iomanip": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "new": "cpp", - "ostream": "cpp", - "numeric": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "cinttypes": "cpp", - "regex": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "typeinfo": "cpp", - "*.inc": "cpp" - } -} \ No newline at end of file diff --git a/ESPixelStick/ESPixelStick.ino b/ESPixelStick/ESPixelStick.ino index c7e238ffb..8e111cadf 100644 --- a/ESPixelStick/ESPixelStick.ino +++ b/ESPixelStick/ESPixelStick.ino @@ -17,6 +17,8 @@ * */ +#include + // Core #include "src/ESPixelStick.h" #include "src/EFUpdate.h" @@ -332,6 +334,20 @@ void deserializeCoreHandler (DynamicJsonDocument & jsonDoc) // DEBUG_END; } +// Save configuration JSON file +void SaveConfig() +{ + // DEBUG_START; + + // Save Config + String DataToSave = serializeCore (false); + // DEBUG_V ("ConfigFileName: " + ConfigFileName); + // DEBUG_V ("DataToSave: " + DataToSave); + FileMgr.SaveConfigFile(ConfigFileName, DataToSave); + + // DEBUG_END; +} // SaveConfig + /// Load configuration file /** Loads and validates the JSON configuration file from the file system. * If no configuration file is found, a new one will be created. @@ -427,20 +443,6 @@ String serializeCore(bool pretty) return jsonConfigString; } // serializeCore -// Save configuration JSON file -void SaveConfig() -{ - // DEBUG_START; - - // Save Config - String DataToSave = serializeCore (false); - // DEBUG_V ("ConfigFileName: " + ConfigFileName); - // DEBUG_V ("DataToSave: " + DataToSave); - FileMgr.SaveConfigFile(ConfigFileName, DataToSave); - - // DEBUG_END; -} // SaveConfig - ///////////////////////////////////////////////////////// // // Main Loop diff --git a/ESPixelStick/src/input/InputE131.cpp b/ESPixelStick/src/input/InputE131.cpp index b4e149f2d..3f5e375c5 100644 --- a/ESPixelStick/src/input/InputE131.cpp +++ b/ESPixelStick/src/input/InputE131.cpp @@ -61,7 +61,7 @@ void c_InputE131::Begin () NetworkStateChanged (WiFiMgr.IsWiFiConnected (), false); // DEBUG_V (""); - e131->RegisterCallback ( (void*)this, [] (e131_packet_t* Packet, void * pThis) + e131->registerCallback ( (void*)this, [] (e131_packet_t* Packet, void * pThis) { ((c_InputE131*)pThis)->ProcessIncomingE131Data (Packet); }); diff --git a/include/README b/include/README new file mode 100644 index 000000000..194dcd432 --- /dev/null +++ b/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/lib/README b/lib/README new file mode 100644 index 000000000..6debab1e8 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 000000000..feb0ca8a4 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,106 @@ +; PlatformIO Project Configuration File for ESPixelStick +; https://docs.platformio.org/page/projectconf.html +; +; Local configuration should be done in platformio_user.ini + +[platformio] +default_envs = espsv3, d1_mini, d32_pro, d1_mini32 +src_dir = ./ESPixelStick +data_dir = ./ESPixelStick/data +build_cache_dir = ~/.buildcache +extra_configs = + platformio_user.ini + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +; Baseline build environment ; +; https://docs.platformio.org/en/latest/projectconf/section_env.html ; +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +[env] +framework = arduino +monitor_speed = 115200 +upload_speed = 921600 +lib_compat_mode = strict +lib_deps = + adafruit/Adafruit PWM Servo Driver Library @ 2.4.0 + bblanchon/ArduinoJson @ 6.18.4 + bblanchon/StreamUtils @ 1.6.1 + djgrrr/Int64String @ 1.1.1 + esphome/ESPAsyncWebServer-esphome @ 1.3.0 + forkineye/ESPAsyncE131 @ 1.0.2 + ottowinter/AsyncMqttClient-esphome @ 0.8.5 + https://github.com/natcl/Artnet ; pull latest + https://github.com/MartinMueller2003/Espalexa ; pull latest +lib_ignore = + Ethernet ; Remove once Art-Net is fixed / replaced to not depend on Ethernet in lib config + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +; ESP8266 defaults for 4MB flash ; +; https://docs.platformio.org/en/latest/platforms/espressif8266.html ; +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +[esp8266] +platform = espressif8266 @ 3.2.0 ; Arduino Core 3.0.2 +board_build.f_cpu = 160000000L +board_build.filesystem = littlefs +board_build.ldscript = eagle.flash.4m1m.ld +monitor_filters = esp8266_exception_decoder +build_flags = + -DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH + -DNDEBUG ; https://github.com/esp8266/Arduino/issues/3978 + -DFP_IN_IROM ; https://github.com/esp8266/Arduino/pull/7180 +lib_deps = + ${env.lib_deps} + me-no-dev/ESPAsyncUDP @ 0.0.0-alpha+sha.697c75a025 + ottowinter/ESPAsyncTCP-esphome @ 1.2.3 + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +; ESP32 defaults for 4MB flash ; +; https://docs.platformio.org/en/latest/platforms/espressif32.html ; +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +[esp32] +platform = espressif32 +board_build.filesystem = littlefs +board_build.partitions = min_spiffs.csv +monitor_filters = esp32_exception_decoder +lib_deps = + ${env.lib_deps} + esphome/AsyncTCP-esphome @ 1.2.2 + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +; ESP32 pulling from upstream core ; +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +[esp32git] +extends = esp32 +platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master +platform_packages = + framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.0 + +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; +; Build targets (environments) ; +;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~; + +; ESPixelStick V3 +[env:espsv3] +extends = esp8266 +board = d1_mini +build_flags = + ${esp8266.build_flags} + -DBOARD_ESPS_V3 + +; Generic Wemos D1 R2 Mini +[env:d1_mini] +extends = esp8266 +board = d1_mini + +; Lolin D32 Pro +[env:d32_pro] +extends = esp32git ; use until 2.0.0 core makes it into PlatformIO +board = lolin_d32_pro +build_flags = + -DBOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue + -mfix-esp32-psram-cache-strategy=memw + +; Generic Wemos D1 Mini 32 +[env:d1_mini32] +extends = esp32git ; use until 2.0.0 core makes it into PlatformIO +board = wemos_d1_mini32 \ No newline at end of file diff --git a/platformio_user.ini.sample b/platformio_user.ini.sample new file mode 100644 index 000000000..9b4dd7fd7 --- /dev/null +++ b/platformio_user.ini.sample @@ -0,0 +1,24 @@ +; PlatformIO local user configuration +; ** Copy this file to platformio_user.ini and edit for your local config ** +; Configurations defined here will override values defined in platformio.ini +; +; [esp8266] and [esp32] sections are inherited into [env:]: +; https://docs.platformio.org/en/latest/projectconf/section_env.html + +;[platformio] +;default_envs = espsv3 + +;[env] +;build_type = debug + +;[esp8266] +;monitor_port = COM5 +;upload_port = COM5 + +;[esp32] +;monitor_port = COM6 +;upload_port = COM6 + +;[env:espsv3] +;monitor_port = COM3 +;upload_port = COM3 \ No newline at end of file diff --git a/test/README b/test/README new file mode 100644 index 000000000..b94d0890f --- /dev/null +++ b/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html