diff --git a/.gitignore b/.gitignore index aa27f74..ef2e711 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,20 @@ build/ +lib/idf-tools/* -pcb/panel/wombus64_led-backups/ -pcb/panel/~* -pcb/panel/#auto_saved_files# -pcb/panel/fp-info-cache -pcb/panel/wombus64_led.kicad_prl +pcb/control/* +!pcb/control/README.md +!pcb/control/revisions.txt +!pcb/control/soburg2.kicad_pcb +!pcb/control/soburg2.kicad_pro +!pcb/control/soburg2.kicad_pch -pcb/panel/soburg2-backups/ -pcb/control/~* -pcb/control/#auto_saved_files# -pcb/control/fp-info-cache -pcb/control/soburg2.kicad_prl \ No newline at end of file +pcb/panel/* +!pcb/panel/revisions.txt +!pcb/panel/wombus64_led.kicad_pcb +!pcb/panel/wombus64_led.kicad_pro +!pcb/panel/wombus64_led.kicad_pch + +sdkconfig +sdkconfig.old + +.vscode/* diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..74bdc35 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,5 @@ +[submodule "lib/esp-idf"] + path = lib/esp-idf + url = https://github.com/espressif/esp-idf.git + branch = master + ignore = all \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b70a69..5fde73f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,14 @@ -# TODO: check version cmake_minimum_required(VERSION 3.16) -include($ENV{IDF_PATH}/scripts/project.cmake) +set(PROJECT_MAIN_COMPONENT ${CMAKE_CURRENT_LIST_DIR}/src) -project(this) +set(EXTRA_COMPONENT_DIRS + ${CMAKE_CURRENT_LIST_DIR}/config + ${CMAKE_CURRENT_LIST_DIR}/src +) + +# For the esp-idf configuration +include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +project(wombus_led) diff --git a/README.md b/README.md index 7404948..24b3a11 100644 --- a/README.md +++ b/README.md @@ -29,3 +29,9 @@ Scripts are in scripts directory, named appropriately. - [ ] Microphone for sound-based effects like a spectrum analyzer This is basic but hopefully can be good platform for future WS2812b projects. + +## Scripts: +After cloning: $ ./scripts/repo-setup # installs esp-idf, sets up target configurations +To build: $ ./scripts/build.sh +To flash: $ ./scripts/flash.sh # note: flash.sh automatically builds +To monitor: $ ./scripts/monitor.sh diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt new file mode 100644 index 0000000..324cb15 --- /dev/null +++ b/config/CMakeLists.txt @@ -0,0 +1,2 @@ + +idf_component_register(SRCS "" INCLUDE_DIRS "") diff --git a/config/Kconfig.projbuild b/config/Kconfig.projbuild new file mode 100644 index 0000000..3f6bd18 --- /dev/null +++ b/config/Kconfig.projbuild @@ -0,0 +1,49 @@ +menu "Example Configuration" + + orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps" + + choice BLINK_LED + prompt "Blink LED type" + default BLINK_LED_GPIO + help + Select the LED type. A normal level controlled LED or an addressable LED strip. + The default selection is based on the Espressif DevKit boards. + You can change the default selection according to your board. + + config BLINK_LED_GPIO + bool "GPIO" + config BLINK_LED_STRIP + bool "LED strip" + endchoice + + choice BLINK_LED_STRIP_BACKEND + depends on BLINK_LED_STRIP + prompt "LED strip backend peripheral" + default BLINK_LED_STRIP_BACKEND_RMT if SOC_RMT_SUPPORTED + default BLINK_LED_STRIP_BACKEND_SPI + help + Select the backend peripheral to drive the LED strip. + + config BLINK_LED_STRIP_BACKEND_RMT + depends on SOC_RMT_SUPPORTED + bool "RMT" + config BLINK_LED_STRIP_BACKEND_SPI + bool "SPI" + endchoice + + config BLINK_GPIO + int "Blink GPIO number" + range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX + default 4 + help + GPIO number (IOxx) to blink on and off the LED. + Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to blink. + + config BLINK_PERIOD + int "Blink period in ms" + range 10 3600000 + default 500 + help + Define the blinking period in milliseconds. + +endmenu diff --git a/config/sdkconfig.defaults b/config/sdkconfig.defaults new file mode 100644 index 0000000..f86da07 --- /dev/null +++ b/config/sdkconfig.defaults @@ -0,0 +1,2 @@ + +CONFIG_BLINK_PERIOD=100 \ No newline at end of file diff --git a/lib/esp-idf b/lib/esp-idf new file mode 160000 index 0000000..4875518 --- /dev/null +++ b/lib/esp-idf @@ -0,0 +1 @@ +Subproject commit 487551888a46971a07e33caef3312fe3a6f5cf68 diff --git a/pcb/control/soburg2.kicad_pro b/pcb/control/soburg2.kicad_pro index 5de4732..dbf56a6 100644 --- a/pcb/control/soburg2.kicad_pro +++ b/pcb/control/soburg2.kicad_pro @@ -393,23 +393,18 @@ "rule_severities": { "bus_definition_conflict": "error", "bus_entry_needed": "error", + "bus_label_syntax": "error", "bus_to_bus_conflict": "error", "bus_to_net_conflict": "error", - "conflicting_netclasses": "error", "different_unit_footprint": "error", "different_unit_net": "error", "duplicate_reference": "error", "duplicate_sheet_names": "error", - "endpoint_off_grid": "warning", "extra_units": "error", "global_label_dangling": "warning", "hier_label_mismatch": "error", "label_dangling": "error", "lib_symbol_issues": "warning", - "missing_bidi_pin": "warning", - "missing_input_pin": "warning", - "missing_power_pin": "error", - "missing_unit": "warning", "multiple_net_names": "warning", "net_not_bus_member": "warning", "no_connect_connected": "warning", @@ -419,7 +414,6 @@ "pin_to_pin": "warning", "power_pin_not_driven": "error", "similar_labels": "warning", - "simulation_model_issue": "ignore", "unannotated": "error", "unit_value_mismatch": "error", "unresolved_variable": "error", @@ -437,7 +431,7 @@ "net_settings": { "classes": [ { - "bus_width": 12, + "bus_width": 12.0, "clearance": 0.2, "diff_pair_gap": 0.25, "diff_pair_via_gap": 0.25, @@ -451,11 +445,11 @@ "track_width": 0.2, "via_diameter": 0.6, "via_drill": 0.3, - "wire_width": 6 + "wire_width": 6.0 } ], "meta": { - "version": 3 + "version": 2 }, "net_colors": null, "netclass_assignments": null, @@ -587,8 +581,18 @@ "version": 1 }, "net_format_name": "", + "ngspice": { + "fix_include_paths": true, + "fix_passive_vals": false, + "meta": { + "version": 0 + }, + "model_mode": 0, + "workbook_filename": "" + }, "page_layout_descr_file": "", "plot_directory": "", + "spice_adjust_passive_values": false, "spice_current_sheet_as_root": false, "spice_external_command": "spice \"%I\"", "spice_model_current_sheet_as_root": true, diff --git a/scripts/build.sh b/scripts/build.sh index f15511d..4e9327c 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,3 +1,16 @@ -#!usr/bin/bash -# TODO: implement +#!/usr/bin/env bash +set -e + +export IDF_TOOLS_PATH=${PWD}/lib/idf-tools +export IDF_PATH=${PWD}/lib/esp-idf + +export SDKCONFIG=${PWD}/config/sdkconfig +export SDKCONFIG_DEFAULTS=${PWD}/config/sdkconfig.defaults + +. ${IDF_PATH}/export.sh + +idf.py build + +# idk how to put it in the right place +mv ${PWD}/sdkconfig ${PWD}/config/sdkconfig diff --git a/scripts/clean.sh b/scripts/clean.sh new file mode 100644 index 0000000..4265774 --- /dev/null +++ b/scripts/clean.sh @@ -0,0 +1,10 @@ + +#!/usr/bin/env bash +set -e + +export IDF_TOOLS_PATH=${PWD}/lib/idf-tools +export IDF_PATH=${PWD}/lib/esp-idf + +. ${IDF_PATH}/export.sh + +idf.py fullclean diff --git a/scripts/flash.sh b/scripts/flash.sh index f15511d..3fa43aa 100644 --- a/scripts/flash.sh +++ b/scripts/flash.sh @@ -1,3 +1,20 @@ -#!usr/bin/bash -# TODO: implement +#!/usr/bin/env bash +set -e + +export IDF_TOOLS_PATH=${PWD}/lib/idf-tools +export IDF_PATH=${PWD}/lib/esp-idf + +export SDKCONFIG=${PWD}/config/sdkconfig +export SDKCONFIG_DEFAULTS=${PWD}/config/sdkconfig.defaults + +. ${IDF_PATH}/export.sh + +idf.py fullclean +idf.py set-target esp32s3 +idf.py -b 115200 flash + +# idf.py autodetects port but use -p to specify + +# idk how to put it in the right place +mv ${PWD}/sdkconfig ${PWD}/config/sdkconfig diff --git a/scripts/monitor.sh b/scripts/monitor.sh index f15511d..4ce5a6d 100644 --- a/scripts/monitor.sh +++ b/scripts/monitor.sh @@ -1,3 +1,12 @@ -#!usr/bin/bash -# TODO: implement +#!/usr/bin/env bash +set -e + +export IDF_TOOLS_PATH=${PWD}/lib/idf-tools +export IDF_PATH=${PWD}/lib/esp-idf + +. ${IDF_PATH}/export.sh + +idf.py -b 115200 monitor + +# idf.py autodetects port but use -p to specify \ No newline at end of file diff --git a/scripts/repo_setup.sh b/scripts/repo_setup.sh new file mode 100644 index 0000000..5a3ee40 --- /dev/null +++ b/scripts/repo_setup.sh @@ -0,0 +1,16 @@ + +#!/usr/bin/env bash +set -e + +export IDF_TOOLS_PATH=${PWD}/lib/idf-tools +export IDF_PATH=${PWD}/lib/esp-idf + +# if you get python ssl module errors- make sure your python version is 3.12 or lower + +# esp-idf install scripts +bash ${IDF_PATH}/install.sh esp32s3 +source ${IDF_PATH}/export.sh + +# target +idf.py fullclean +idf.py set-target esp32s3 diff --git a/sdk.config.defaults b/sdk.config.defaults deleted file mode 100644 index e69de29..0000000 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..9a2434a --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,9 @@ + +file(GLOB SRC_FILES "*.c" "*.cpp") + +idf_component_register( + SRCS ${SRC_FILES} + PRIV_REQUIRES spi_flash + REQUIRES esp_driver_gpio + INCLUDE_DIRS "." +) \ No newline at end of file diff --git a/src/main.c b/src/main.c deleted file mode 100644 index b482c8a..0000000 --- a/src/main.c +++ /dev/null @@ -1,50 +0,0 @@ - -// Copied from official ESP-IDF repository -// https://github.com/espressif/esp-idf/blob/v5.5.1/examples/get-started/hello_world/main/hello_world_main.c - -#include -#include -#include "sdkconfig.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "esp_chip_info.h" -#include "esp_flash.h" -#include "esp_system.h" - -void app_main(void) -{ - printf("Hello world!\n"); - - /* Print chip information */ - esp_chip_info_t chip_info; - uint32_t flash_size; - esp_chip_info(&chip_info); - printf("This is %s chip with %d CPU core(s), %s%s%s%s, ", - CONFIG_IDF_TARGET, - chip_info.cores, - (chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "", - (chip_info.features & CHIP_FEATURE_BT) ? "BT" : "", - (chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "", - (chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : ""); - - unsigned major_rev = chip_info.revision / 100; - unsigned minor_rev = chip_info.revision % 100; - printf("silicon revision v%d.%d, ", major_rev, minor_rev); - if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) { - printf("Get flash size failed"); - return; - } - - printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024), - (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); - - printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size()); - - for (int i = 10; i >= 0; i--) { - printf("Restarting in %d seconds...\n", i); - vTaskDelay(1000 / portTICK_PERIOD_MS); - } - printf("Restarting now.\n"); - fflush(stdout); - esp_restart(); -} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..3263601 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,23 @@ + +#include "App.hpp" + +#include "esp_log.h" + +static const char *TAG = "main"; + +#ifdef __cplusplus +extern "C" { +#endif + +void app_main(void) { + + ESP_LOGI(TAG, "Program start"); + + App app; + int8_t status = app.main(); + ESP_LOGI(TAG, "App main returned status %d", status); +} + +#ifdef __cplusplus +} +#endif