Skip to content

Commit

Permalink
Initial PlatformIO configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
forkineye committed Sep 20, 2021
1 parent c2b1ac2 commit cebf298
Show file tree
Hide file tree
Showing 12 changed files with 262 additions and 126 deletions.
21 changes: 12 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
platformio_user.ini
secrets.h
*.ino.generic.bin
*.gz
*.pyc
6 changes: 0 additions & 6 deletions .vscode/arduino.json

This file was deleted.

46 changes: 0 additions & 46 deletions .vscode/c_cpp_properties.json

This file was deleted.

7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
50 changes: 0 additions & 50 deletions .vscode/settings.json

This file was deleted.

30 changes: 16 additions & 14 deletions ESPixelStick/ESPixelStick.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*
*/

#include <Arduino.h>

// Core
#include "src/ESPixelStick.h"
#include "src/EFUpdate.h"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ESPixelStick/src/input/InputE131.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
39 changes: 39 additions & 0 deletions include/README
Original file line number Diff line number Diff line change
@@ -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
46 changes: 46 additions & 0 deletions lib/README
Original file line number Diff line number Diff line change
@@ -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 <Foo.h>
#include <Bar.h>

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
106 changes: 106 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit cebf298

Please sign in to comment.