Add stepper library for esp-idf

This commit is contained in:
jonny_ji7
2023-02-21 21:14:16 +01:00
parent ef0ac39c9b
commit 2651a83ce7
12 changed files with 1536 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
build/
sdkconfig
sdkconfig.old

View File

@@ -0,0 +1,9 @@
# 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.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(EXTRA_COMPONENT_DIRS "../")
project(example)

View File

@@ -0,0 +1,32 @@
# _Sample project_
(See the README.md file in the upper level 'examples' directory for more information about examples.)
This is the simplest buildable example. The example is used by command `idf.py create-project`
that copies the project to user specified path and set it's name. For more information follow the [docs page](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#start-a-new-project)
## How to use example
We encourage the users to use the example as a template for the new projects.
A recommended way is to follow the instructions on a [docs page](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html#start-a-new-project).
## Example folder contents
The project **sample_project** contains one source file in C language [main.c](main/main.c). The file is located in folder [main](main).
ESP-IDF projects are built using CMake. The project build configuration is contained in `CMakeLists.txt`
files that provide set of directives and instructions describing the project's source files and targets
(executable, library, or both).
Below is short explanation of remaining files in the project folder.
```
├── CMakeLists.txt
├── main
│   ├── CMakeLists.txt
│   └── main.c
└── README.md This is the file you are currently reading
```
Additionally, the sample project contains Makefile and component.mk files, used for the legacy Make based build system.
They are not used or needed when building with CMake and idf.py.

View File

@@ -0,0 +1,3 @@
idf_component_register(SRCS "main.cpp"
INCLUDE_DIRS "."
REQUIRES DendoStepper freertos)

View File

@@ -0,0 +1,49 @@
#include <stdio.h>
#include "DendoStepper.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
DendoStepper step;
DendoStepper step1;
extern "C" void app_main(void)
{
DendoStepper_config_t step_cfg = {
.stepPin = 16,
.dirPin = 17,
.enPin = 15,
.timer_group = TIMER_GROUP_0,
.timer_idx = TIMER_0,
.miStep = MICROSTEP_32,
.stepAngle = 1.8};
DendoStepper_config_t step1_cfg = {
.stepPin = 18,
.dirPin = 19,
.enPin = 20,
.timer_group = TIMER_GROUP_0,
.timer_idx = TIMER_1,
.miStep = MICROSTEP_32,
.stepAngle = 1.8};
step.config(&step_cfg);
step1.config(&step1_cfg);
step.init();
step1.init();
step.setSpeed(10000, 1000, 1000);
step1.setSpeed(20000, 1000, 1000);
// step.runInf(true);
step.setStepsPerMm(10);
while (1)
{
step.runPosMm(500);
step1.runPos(10000);
vTaskDelay(1000);
// step.runAbs(5000);
}
}