initial commit
All checks were successful
Deploy docs / build-and-deploy (push) Successful in 3s

This commit is contained in:
sid 2026-02-23 20:34:35 +01:00
commit 95a533c876
451 changed files with 18255 additions and 0 deletions

View file

@ -0,0 +1 @@
use flake

6
templates/dev/esp-blink/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
.cache/
.direnv/
build/
managed_components/
sdkconfig
sdkconfig.old

View file

@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_set_property(MINIMAL_BUILD ON)
project(blink)

View file

@ -0,0 +1,33 @@
# ESP32 blink template
Set `BLINK_GPIO` to your LED pin in [`main/main.c`](./main/main.c).
## Clean the build directory
```bash
idf.py fullclean
```
## Set the build target
```bash
idf.py set-target esp32s3
```
## Open configuration menu
```bash
idf.py menuconfig
```
## Build the project
```bash
idf.py all
```
## Flash the binary
```bash
idf.py flash
```

View file

@ -0,0 +1,103 @@
{
description = "A blink template for ESP32";
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
esp = {
url = "github:mirrexagon/nixpkgs-esp-dev";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
esp,
pre-commit-hooks,
...
}:
let
pname = "blink"; # Also change this in CMakeLists.txt
version = "0.1.0";
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
nixpkgsFor = forAllSystems (
system:
import nixpkgs {
inherit system;
overlays = [
self.overlays.default
esp.overlays.default
];
}
);
in
{
overlays.default = final: prev: { };
packages = forAllSystems (system: { });
devShells = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
in
{
default = esp.devShells."${system}".default;
}
);
formatter = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
config = self.checks.${system}.pre-commit-check.config;
inherit (config) package configFile;
script = ''
${pkgs.lib.getExe package} run --all-files --config ${configFile}
'';
in
pkgs.writeShellScriptBin "pre-commit-run" script
);
checks = forAllSystems (
system:
let
pkgs = nixpkgsFor.${system};
flakePkgs = self.packages.${system};
in
{
build-packages = pkgs.linkFarm "flake-packages-${system}" flakePkgs;
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt = {
enable = true;
};
clang-format = {
enable = true;
types_or = nixpkgs.lib.mkForce [
"c"
"cpp"
];
};
};
};
}
);
};
}

View file

@ -0,0 +1,4 @@
idf_component_register(
SRCS "main.c"
INCLUDE_DIRS "."
)

View file

@ -0,0 +1,2 @@
dependencies:
espressif/led_strip: "^3.0.0"

View file

@ -0,0 +1,33 @@
#include "driver/gpio.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <stdio.h>
static const char *TAG = "BLINK";
#define BLINK_GPIO 38
#define BLINK_PERIOD 1000
static uint8_t s_led_state = 0;
static void blink_led(void) { gpio_set_level(BLINK_GPIO, s_led_state); }
static void configure_led(void) {
ESP_LOGI(TAG, "Example configured to blink GPIO LED!");
gpio_reset_pin(BLINK_GPIO);
gpio_set_direction(BLINK_GPIO, GPIO_MODE_OUTPUT);
}
static void delay_ms(uint32_t ms) { vTaskDelay(pdMS_TO_TICKS(ms)); }
void app_main(void) {
configure_led();
while (1) {
ESP_LOGI(TAG, "Turning the LED %s!", s_led_state == true ? "ON" : "OFF");
blink_led();
s_led_state = !s_led_state;
delay_ms(BLINK_PERIOD);
}
}