Store encoder-steps at shutdown, consider at startup

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
This commit is contained in:
jonny
2024-03-14 16:06:20 +01:00
parent 1d0ea6a5aa
commit 1d4e83a2ea
8 changed files with 154 additions and 8 deletions

View File

@@ -164,6 +164,13 @@ esp_err_t rotary_encoder_get_state(const rotary_encoder_info_t * info, rotary_en
*/
esp_err_t rotary_encoder_reset(rotary_encoder_info_t * info);
/**
* @brief Set the current position of the rotary encoder to passed value.
* @param[in] info Pointer to initialised rotary encoder info structure.
* @return ESP_OK if successful, ESP_FAIL or ESP_ERR_* if an error occurred.
*/
esp_err_t rotary_encoder_set_position(rotary_encoder_info_t * info, uint32_t posNew);
#ifdef __cplusplus
}