Skip to content

Commit

Permalink
Completed platformio blog
Browse files Browse the repository at this point in the history
  • Loading branch information
anurag3301 committed Aug 5, 2024
1 parent 73bedb6 commit e1d3d03
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions blog/content/nvim-platformio-lua.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,47 @@ return {

And that's you have `nvim-platformio.lua` and `PlatformIO` ready to be used 🥳.

# Usage

### Setup a project
1. Create a new directory for the project and cd into it, in my case ill be using a ESP32.
```
mkdir esp_project
cd esp_project
```
2. Open neovim and run `:Pioinit`, this will open a telescope picker where you can fuzzy find and select the board you want to use. Then press enter.

{{ image(src="/img/pioinit.gif", position="left") }}

3. After selecting the board, you'll have option to select the desired framework such as `Arduino`, `ESP-IDF`, `STM32 Cube` etc. And press enter.
4. Now a toggleterm window will pop up which will run the `pio` project setup command and install any missing tools or dependencies.
5. Now you should have a `PlatformIO` project setup with `.ccls` file which will let your `LSP` make aware of the include path for the libraries.
6. Open the `src/main.c` file and write the code. In my case I wrote a simple `ESP-IDF` code which blink led and print to Serial line.
```c
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/gpio.h"
#include "esp_log.h"

#define BLINK_GPIO 12

void app_main() {
gpio_pad_select_gpio(BLINK_GPIO);
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
while(1) {
gpio_set_level(BLINK_GPIO, 1);
ESP_LOGI("LED", "LED ON");
vTaskDelay(1000 / portTICK_PERIOD_MS);
gpio_set_level(BLINK_GPIO, 0);
ESP_LOGI("LED", "LED OFF");
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
```
7. Compile and flash the code by running `:Piorun`.
8. Open the serial monitor to see the output by running `:Piomon`

This was a brief introduction to `PlatformIO` and `nvim-platformio.lua`.
>+ **Run `:help PlatformIO`** to see the detailed usage and option for each command.
>+ Checkout [platformio.ini](https://docs.platformio.org/en/latest/projectconf/sections/env/index.html) docs for project configuration.
>+ [PlatformIO cli](https://docs.platformio.org/en/latest/core/userguide/index.html) to extend usage.
Binary file added blog/static/img/pioinit.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e1d3d03

Please sign in to comment.