version 2.8
ginput_dial.h
Go to the documentation of this file.
1 /*
2  * This file is subject to the terms of the GFX License. If a copy of
3  * the license was not distributed with this file, you can obtain one at:
4  *
5  * http://ugfx.org/license.html
6  */
7 
8 /**
9  * @file src/ginput/ginput_dial.h
10  *
11  * @defgroup Dial Dial
12  * @ingroup GINPUT
13  *
14  * @brief Sub-Module to handle physical controls that provide a range value (eg. potentiometers and rotary encoders).
15  *
16  * @details A dial provides a powerful way to navigate through menus
17  * on a display.
18  *
19  * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
20  * @pre GINPUT_NEED_DIAL must be set to TRUE in your gfxconf.h
21  *
22  * @{
23  */
24 #ifndef _GINPUT_DIAL_H
25 #define _GINPUT_DIAL_H
26 
27 #if GINPUT_NEED_DIAL || defined(__DOXYGEN__)
28 
29 /*===========================================================================*/
30 /* Type definitions */
31 /*===========================================================================*/
32 
33 // Event types for various ginput sources
34 #define GEVENT_DIAL (GEVENT_GINPUT_FIRST+4)
35 
36 typedef struct GEventDial_t {
37  GEventType type; // The type of this event (GEVENT_DIAL)
38  uint16_t instance; // The dial instance
39  uint16_t value; // The dial value
40  uint16_t maxvalue; // The maximum dial value
41  } GEventDial;
42 
43 /*===========================================================================*/
44 /* External declarations. */
45 /*===========================================================================*/
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51  /**
52  * @brief Create a dial input instance
53  *
54  * @param[in] instance The ID of the dial input instance (from 0 to 9999)
55  *
56  * @return The soure handle of the created dial instance
57  */
58  GSourceHandle ginputGetDial(uint16_t instance);
59 
60  /**
61  * @brief Reset the value back to the hardware default
62  *
63  * @param[in] instance The ID of the dial input instance
64  */
65  void ginputResetDialRange(uint16_t instance);
66 
67  /**
68  * @brief Get the maximum value
69  * @details The readings are scaled to be 0 ... max.
70  *
71  * @param[in] instance The ID of the dial input instance
72  *
73  * @return The maximum value
74  */
75  uint16_t ginputGetDialRange(uint16_t instance);
76 
77  /**
78  * @brief Set the maximum value
79  * @details The readings are scaled to be 0 ... max.
80  *
81  * @param[in] instance The ID of the dial input instance
82  * @param[in] max The maximum value to be set
83  */
84  void ginputSetDialRange(uint16_t instance, uint16_t max);
85 
86  /**
87  * @brief Set the level change required before a dial even is generated (threshold)
88  * @note This is done after range scaling
89  *
90  * @param[in] instance The ID of the dial input instance
91  * @param[in] diff The amount of level changes
92  */
93  void ginputSetDialSensitivity(uint16_t instance, uint16_t diff);
94 
95  /**
96  * @brief Get the current dial status
97  *
98  * @param[in] instance The ID of the dial input instance
99  * @param[in] pdial The dial event struct
100  *
101  * @return Returns FALSE on an error (eg invalid instance)
102  */
103  bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial);
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* GINPUT_NEED_DIAL */
110 
111 #endif /* _GINPUT_DIAL_H */
112 /** @} */
uint16_t ginputGetDialRange(uint16_t instance)
Get the maximum value.
void ginputResetDialRange(uint16_t instance)
Reset the value back to the hardware default.
bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial)
Get the current dial status.
void ginputSetDialRange(uint16_t instance, uint16_t max)
Set the maximum value.
void ginputSetDialSensitivity(uint16_t instance, uint16_t diff)
Set the level change required before a dial even is generated (threshold)
GSourceHandle ginputGetDial(uint16_t instance)
Create a dial input instance.