diff --git a/.gitignore b/.gitignore index e168915..5dac9f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -build/ -sdkconfig.old \ No newline at end of file +.pioenvs +.piolibdeps +.clang_complete +.gcc-flags.json diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b16849..8a2eed0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,10 +1,9 @@ build: - image: espressif/esp32-ci-env - variables: - SDK_PATH: "$CI_PROJECT_DIR" - IDF_PATH: "$CI_PROJECT_DIR" + image: eclipse/platformio script: - - make all +# - platformio lib -g install 1 +# - platformio ci --board=esp32thing + - platformio run artifacts: paths: - - "*.bin" \ No newline at end of file + - "*.bin" diff --git a/Makefile b/Makefile deleted file mode 100644 index be43ff4..0000000 --- a/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# -# This is a project Makefile. It is assumed the directory this Makefile resides in is a -# project subdirectory. -# - -PROJECT_NAME := app-template - -include $(IDF_PATH)/make/project.mk \ No newline at end of file diff --git a/lib/readme.txt b/lib/readme.txt new file mode 100644 index 0000000..dbadc3d --- /dev/null +++ b/lib/readme.txt @@ -0,0 +1,36 @@ + +This directory is intended for the project specific (private) libraries. +PlatformIO will compile them to static libraries and link to executable file. + +The source code of each library should be placed in separate directory, like +"lib/private_lib/[here are source files]". + +For example, see how can be organized `Foo` and `Bar` libraries: + +|--lib +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| |--Foo +| | |- Foo.c +| | |- Foo.h +| |- readme.txt --> THIS FILE +|- platformio.ini +|--src + |- main.c + +Then in `src/main.c` you should use: + +#include +#include + +// rest H/C/CPP code + +PlatformIO will find your libraries automatically, configure preprocessor's +include paths and build them. + +More information about PlatformIO Library Dependency Finder +- http://docs.platformio.org/page/librarymanager/ldf.html diff --git a/main/.gitkeep b/main/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/main/component.mk b/main/component.mk deleted file mode 100644 index e19e22a..0000000 --- a/main/component.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -# Main component makefile. -# -# This Makefile can be left empty. By default, it will take the sources in the -# src/ directory, compile them and link them into lib(subdirectory_name).a -# in the build directory. This behaviour is entirely configurable, -# please read the ESP-IDF documents if you need to do this. -# \ No newline at end of file diff --git a/main/main.c b/main/main.c deleted file mode 100644 index 911c913..0000000 --- a/main/main.c +++ /dev/null @@ -1,41 +0,0 @@ -#include "freertos/FreeRTOS.h" -#include "esp_wifi.h" -#include "esp_system.h" -#include "esp_event.h" -#include "esp_event_loop.h" -#include "nvs_flash.h" -#include "driver/gpio.h" - -esp_err_t event_handler(void *ctx, system_event_t *event) -{ - return ESP_OK; -} - -void app_main(void) -{ - nvs_flash_init(); - tcpip_adapter_init(); - ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - ESP_ERROR_CHECK( esp_wifi_init(&cfg) ); - ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) ); - ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) ); - wifi_config_t sta_config = { - .sta = { - .ssid = "access_point_name", - .password = "password", - .bssid_set = false - } - }; - ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) ); - ESP_ERROR_CHECK( esp_wifi_start() ); - ESP_ERROR_CHECK( esp_wifi_connect() ); - - gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT); - int level = 0; - while (true) { - gpio_set_level(GPIO_NUM_4, level); - level = !level; - vTaskDelay(300 / portTICK_PERIOD_MS); - } -} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..777d273 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:esp32thing] +platform = espressif32 +board = esp32thing +framework = arduino diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..b87a9e5 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,34 @@ +/** + * Blink + * + * Turns on an LED on for one second, + * then off for one second, repeatedly. + * + * https://github.com/platformio/platformio-examples/tree/develop/espressif + */ +#include "Arduino.h" + +#ifndef LED_BUILTIN +#define LED_BUILTIN 13 +#endif + +void setup() +{ + // initialize LED digital pin as an output. + pinMode(LED_BUILTIN, OUTPUT); +} + +void loop() +{ + // turn the LED on (HIGH is the voltage level) + digitalWrite(LED_BUILTIN, HIGH); + + // wait for a second + delay(1000); + + // turn the LED off by making the voltage LOW + digitalWrite(LED_BUILTIN, LOW); + + // wait for a second + delay(1000); +}