-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from pvginkel/esp-idf-github-action
Created ESP-IDF sample project and a GitHub action to test build it
- Loading branch information
Showing
9 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Build examples for an ESP-IDF project | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: esp-idf build | ||
uses: espressif/esp-idf-ci-action@v1 | ||
with: | ||
esp_idf_version: v5.3.2 | ||
target: esp32 | ||
path: extras/idf_project_example | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/build | ||
/.vscode | ||
/managed_components | ||
/sdkconfig | ||
/dependencies.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# For more information about build system see | ||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html | ||
# The following five lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
|
||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
|
||
project(idf_project_example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
This folder contains a bare bones functional ESP-IDF project. | ||
|
||
You can create one using the **ESP-IDF: New Project** command in | ||
Visual Studio code, or use this one as a basis. If you do use this one | ||
as a basis for your own project, review the `.gitignore` file as it | ||
excludes files you would not want to exclude in a normal project. | ||
Normally only the `managed_components` and `build` folders would be | ||
excluded from version control. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FILE(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) | ||
|
||
idf_component_register( | ||
SRCS ${SOURCES} | ||
INCLUDE_DIRS "." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dependencies: | ||
FastAccelStepper: | ||
path: ../../.. | ||
# Alternatively you can point this directly at the GitHub repository: | ||
# git: https://github.com/gin66/FastAccelStepper.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#include "FastAccelStepper.h" | ||
|
||
#include <cinttypes> | ||
|
||
// As in StepperDemo for Motor 1 on ESP32 | ||
#define dirPinStepper 18 | ||
#define enablePinStepper 26 | ||
#define stepPinStepper 17 | ||
|
||
FastAccelStepperEngine engine = FastAccelStepperEngine(); | ||
FastAccelStepper *stepper = NULL; | ||
|
||
void setup() { | ||
printf("START\n"); | ||
|
||
engine.init(0); | ||
|
||
printf("Engine initialized\n"); | ||
|
||
for (uint8_t i = 0; i < 10; i++) { | ||
printf("LOOP %d\n", i); | ||
vTaskDelay(pdMS_TO_TICKS(500)); | ||
// esp_task_wdt_reset(); | ||
} | ||
stepper = engine.stepperConnectToPin(stepPinStepper); | ||
|
||
printf("Stepper connected\n"); | ||
for (uint8_t i = 0; i < 10; i++) { | ||
printf("LOOP %d\n", i); | ||
vTaskDelay(pdMS_TO_TICKS(500)); | ||
// esp_task_wdt_reset(); | ||
} | ||
|
||
if (stepper) { | ||
stepper->setDirectionPin(dirPinStepper); | ||
stepper->setEnablePin(enablePinStepper); | ||
stepper->setAutoEnable(true); | ||
|
||
// If auto enable/disable need delays, just add (one or both): | ||
// stepper->setDelayToEnable(50); | ||
// stepper->setDelayToDisable(1000); | ||
|
||
stepper->setSpeedInUs(1000); // the parameter is us/step !!! | ||
stepper->setAcceleration(100); | ||
|
||
#ifdef SUPPORT_ESP32_PULSE_COUNTER | ||
stepper->attachToPulseCounter(7); | ||
#endif | ||
|
||
printf("Stepper initialized\n"); | ||
} else { | ||
printf("No stepper\n"); | ||
} | ||
} | ||
|
||
extern "C" void app_main() { | ||
setup(); | ||
int32_t target = 0; | ||
while (true) { | ||
while (stepper->isRunning()) { | ||
// esp_task_wdt_reset(); | ||
printf("pos=%" PRId32, stepper->getCurrentPosition()); | ||
#ifdef SUPPORT_ESP32_PULSE_COUNTER | ||
int16_t pcnt = stepper->readPulseCounter(); | ||
printf(" pcnt=%d", pcnt); | ||
#endif | ||
printf("\n"); | ||
vTaskDelay(pdMS_TO_TICKS(500)); | ||
} | ||
printf("done\n"); | ||
vTaskDelay(pdMS_TO_TICKS(500)); | ||
printf("move\n"); | ||
target = 1000 - target; | ||
stepper->moveTo(target); | ||
} | ||
// WARNING: if program reaches end of function app_main() the MCU will | ||
// restart. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Required by the android-esp32 component. | ||
CONFIG_FREERTOS_HZ=1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dependencies: | ||
espressif/arduino-esp32: | ||
version: "*" |