Wed, 04 Oct 2023 11:28:49 +0200
Version 0.3.1. Remove obsolete files from spiffs filesystem. Removed obsolete wifi stations.conf file and functions. Removed obsolete user screens.
0
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1 | /* |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
2 | * Copyright (c) 2019 David Antliff |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
3 | * Copyright 2011 Ben Buxton |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
4 | * |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
5 | * This file is part of the esp32-rotary-encoder component. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
6 | * |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
7 | * esp32-rotary-encoder is free software: you can redistribute it and/or modify |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
8 | * it under the terms of the GNU General Public License as published by |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
9 | * the Free Software Foundation, either version 3 of the License, or |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
10 | * (at your option) any later version. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
11 | * |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
12 | * esp32-rotary-encoder is distributed in the hope that it will be useful, |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
15 | * GNU General Public License for more details. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
16 | * |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
17 | * You should have received a copy of the GNU General Public License |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
18 | * along with esp32-rotary-encoder. If not, see <https://www.gnu.org/licenses/>. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
19 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
20 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
21 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
22 | * @file rotary_encoder.h |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
23 | * @brief Interface definitions for the ESP32-compatible Incremental Rotary Encoder component. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
24 | * |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
25 | * This component provides a means to interface with a typical rotary encoder such as the EC11 or LPD3806. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
26 | * These encoders produce a quadrature signal on two outputs, which can be used to track the position and |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
27 | * direction as movement occurs. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
28 | * |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
29 | * This component provides functions to initialise the GPIOs and install appropriate interrupt handlers to |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
30 | * track a single device's position. An event queue is used to provide a way for a user task to obtain |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
31 | * position information from the component as it is generated. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
32 | * |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
33 | * Note that the queue is of length 1, and old values will be overwritten. Using a longer queue is |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
34 | * possible with some minor modifications however newer values are lost if the queue overruns. A circular |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
35 | * buffer where old values are lost would be better (maybe StreamBuffer in FreeRTOS 10.0.0?). |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
36 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
37 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
38 | #ifndef ROTARY_ENCODER_H |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
39 | #define ROTARY_ENCODER_H |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
40 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
41 | #include <stdbool.h> |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
42 | #include <stdint.h> |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
43 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
44 | #include "freertos/FreeRTOS.h" |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
45 | #include "freertos/queue.h" |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
46 | #include "esp_err.h" |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
47 | #include "driver/gpio.h" |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
48 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
49 | #ifdef __cplusplus |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | extern "C" { |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | #endif |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | typedef int32_t rotary_encoder_position_t; |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | * @brief Enum representing the direction of rotation. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | typedef enum |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
59 | { |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | ROTARY_ENCODER_DIRECTION_NOT_SET = 0, ///< Direction not yet known (stationary since reset) |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
61 | ROTARY_ENCODER_DIRECTION_CLOCKWISE, |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
62 | ROTARY_ENCODER_DIRECTION_COUNTER_CLOCKWISE, |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
63 | } rotary_encoder_direction_t; |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
64 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
65 | // Used internally |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
66 | ///@cond INTERNAL |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
67 | #define TABLE_COLS 4 |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
68 | typedef uint8_t table_row_t[TABLE_COLS]; |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
69 | ///@endcond |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
70 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
71 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
72 | * @brief Struct represents the current state of the device in terms of incremental position and direction of last movement |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
73 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
74 | typedef struct |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
75 | { |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
76 | rotary_encoder_position_t position; ///< Numerical position since reset. This value increments on clockwise rotation, and decrements on counter-clockewise rotation. Counts full or half steps depending on mode. Set to zero on reset. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | rotary_encoder_direction_t direction; ///< Direction of last movement. Set to NOT_SET on reset. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | } rotary_encoder_state_t; |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
79 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
81 | * @brief Struct carries all the information needed by this driver to manage the rotary encoder device. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
82 | * The fields of this structure should not be accessed directly. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
83 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
84 | typedef struct |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
85 | { |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
86 | gpio_num_t pin_a; ///< GPIO for Signal A from the rotary encoder device |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | gpio_num_t pin_b; ///< GPIO for Signal B from the rotary encoder device |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
88 | QueueHandle_t queue; ///< Handle for event queue, created by ::rotary_encoder_create_queue |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
89 | const table_row_t * table; ///< Pointer to active state transition table |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
90 | uint8_t table_state; ///< Internal state |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
91 | volatile rotary_encoder_state_t state; ///< Device state |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
92 | } rotary_encoder_info_t; |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
93 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
94 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
95 | * @brief Struct represents a queued event, used to communicate current position to a waiting task |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
96 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
97 | typedef struct |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
98 | { |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
99 | rotary_encoder_state_t state; ///< The device state corresponding to this event |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
100 | } rotary_encoder_event_t; |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
101 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
102 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
103 | * @brief Initialise the rotary encoder device with the specified GPIO pins and full step increments. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
104 | * This function will set up the GPIOs as needed, |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
105 | * Note: this function assumes that gpio_install_isr_service(0) has already been called. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
106 | * @param[in, out] info Pointer to allocated rotary encoder info structure. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
107 | * @param[in] pin_a GPIO number for rotary encoder output A. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
108 | * @param[in] pin_b GPIO number for rotary encoder output B. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
109 | * @return ESP_OK if successful, ESP_FAIL or ESP_ERR_* if an error occurred. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
110 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
111 | esp_err_t rotary_encoder_init(rotary_encoder_info_t * info, gpio_num_t pin_a, gpio_num_t pin_b); |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
112 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
113 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
114 | * @brief Enable half-stepping mode. This generates twice as many counted steps per rotation. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
115 | * @param[in] info Pointer to initialised rotary encoder info structure. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
116 | * @param[in] enable If true, count half steps. If false, only count full steps. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
117 | * @return ESP_OK if successful, ESP_FAIL or ESP_ERR_* if an error occurred. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
118 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | esp_err_t rotary_encoder_enable_half_steps(rotary_encoder_info_t * info, bool enable); |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
120 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
121 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
122 | * @brief Reverse (flip) the sense of the direction. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
123 | * Use this if clockwise/counterclockwise are not what you expect. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | * @param[in] info Pointer to initialised rotary encoder info structure. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | * @return ESP_OK if successful, ESP_FAIL or ESP_ERR_* if an error occurred. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
127 | esp_err_t rotary_encoder_flip_direction(rotary_encoder_info_t * info); |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
128 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
129 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
130 | * @brief Remove the interrupt handlers installed by ::rotary_encoder_init. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
131 | * Note: GPIOs will be left in the state they were configured by ::rotary_encoder_init. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
132 | * @param[in] info Pointer to initialised rotary encoder info structure. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
133 | * @return ESP_OK if successful, ESP_FAIL or ESP_ERR_* if an error occurred. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
134 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
135 | esp_err_t rotary_encoder_uninit(rotary_encoder_info_t * info); |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
136 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
137 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
138 | * @brief Create a queue handle suitable for use as an event queue. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
139 | * @return A handle to a new queue suitable for use as an event queue. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
140 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
141 | QueueHandle_t rotary_encoder_create_queue(void); |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
142 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
143 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
144 | * @brief Set the driver to use the specified queue as an event queue. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
145 | * It is recommended that a queue constructed by ::rotary_encoder_create_queue is used. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
146 | * @param[in] info Pointer to initialised rotary encoder info structure. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
147 | * @param[in] queue Handle to queue suitable for use as an event queue. See ::rotary_encoder_create_queue. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
148 | * @return ESP_OK if successful, ESP_FAIL or ESP_ERR_* if an error occurred. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
149 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
150 | esp_err_t rotary_encoder_set_queue(rotary_encoder_info_t * info, QueueHandle_t queue); |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
151 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
152 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
153 | * @brief Get the current position of the rotary encoder. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
154 | * @param[in] info Pointer to initialised rotary encoder info structure. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
155 | * @param[in, out] state Pointer to an allocated rotary_encoder_state_t struct that will |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
156 | * @return ESP_OK if successful, ESP_FAIL or ESP_ERR_* if an error occurred. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | esp_err_t rotary_encoder_get_state(const rotary_encoder_info_t * info, rotary_encoder_state_t * state); |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | /** |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | * @brief Reset the current position of the rotary encoder to zero. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | * @param[in] info Pointer to initialised rotary encoder info structure. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | * @return ESP_OK if successful, ESP_FAIL or ESP_ERR_* if an error occurred. |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
164 | */ |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
165 | esp_err_t rotary_encoder_reset(rotary_encoder_info_t * info); |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
166 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
167 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
168 | #ifdef __cplusplus |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | } |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
170 | #endif |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
171 | |
88d965579617
Initial import of the CO2 meter application.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
172 | #endif // ROTARY_ENCODER_H |