shutdown: - add functions to read/write last encoder steps from nvs - store encoder steps at shutdown guide: - add function to calculate layer count from cable length - read last encoder-steps at startup - if length >2m calculate layers, dont home - home at move-to-zero when not done at startup encoder library: - add function to set encoder steps control: - read last encoder-steps at startup - apply last steps if >2m
43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
/* in this file all used functions from original rotary_encoder.h library are wrapped with custom functions to reduce global variables and duplicate code
|
|
*/
|
|
//TODO create a cpp class for an encoder?
|
|
#pragma once
|
|
extern "C" {
|
|
#include <freertos/task.h>
|
|
#include "freertos/queue.h"
|
|
}
|
|
|
|
|
|
|
|
//----------------------------
|
|
//----- global variables -----
|
|
//----------------------------
|
|
//TODO ignore global encoder queue, since it is not used?
|
|
extern QueueHandle_t encoder_queue; //encoder event queue
|
|
|
|
|
|
//-------------------------
|
|
//------- functions -------
|
|
//-------------------------
|
|
|
|
//--- encoder_init ---
|
|
//init encoder
|
|
QueueHandle_t encoder_init();
|
|
|
|
//--- encoder_getSteps ---
|
|
//get steps counted since last reset
|
|
int encoder_getSteps();
|
|
|
|
|
|
//--- encoder_getLenMm ---
|
|
//get current length in Mm since last reset
|
|
int encoder_getLenMm();
|
|
|
|
|
|
//--- encoder_reset ---
|
|
//reset counted steps / length to 0
|
|
void encoder_reset();
|
|
|
|
//--- encoder_setPos ---
|
|
//set encoder position to certain Steps
|
|
void encoder_setPos(uint32_t posNew); |