µGFX  2.9
version 2.9
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.io/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 GFXON in your gfxconf.h
20  * @pre GINPUT_NEED_DIAL must be set to GFXON 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  gU16 instance; // The dial instance
39  gU16 value; // The dial value
40  gU16 maxvalue; // The maximum dial value
41  } GEventDial;
42 
43 /*===========================================================================*/
44 /* External declarations. */
45 /*===========================================================================*/
46 
47 /**
48  * @brief Create a dial input instance
49  *
50  * @param[in] instance The ID of the dial input instance (from 0 to 9999)
51  *
52  * @return The soure handle of the created dial instance
53  */
54 GSourceHandle ginputGetDial(gU16 instance);
55 
56 /**
57  * @brief Reset the value back to the hardware default
58  *
59  * @param[in] instance The ID of the dial input instance
60  */
61 void ginputResetDialRange(gU16 instance);
62 
63 /**
64  * @brief Get the maximum value
65  * @details The readings are scaled to be 0 ... max.
66  *
67  * @param[in] instance The ID of the dial input instance
68  *
69  * @return The maximum value
70  */
71 gU16 ginputGetDialRange(gU16 instance);
72 
73 /**
74  * @brief Set the maximum value
75  * @details The readings are scaled to be 0 ... max.
76  *
77  * @param[in] instance The ID of the dial input instance
78  * @param[in] max The maximum value to be set
79  */
80 void ginputSetDialRange(gU16 instance, gU16 max);
81 
82 /**
83  * @brief Set the level change required before a dial even is generated (threshold)
84  * @note This is done after range scaling
85  *
86  * @param[in] instance The ID of the dial input instance
87  * @param[in] diff The amount of level changes
88  */
89 void ginputSetDialSensitivity(gU16 instance, gU16 diff);
90 
91 /**
92  * @brief Get the current dial status
93  *
94  * @param[in] instance The ID of the dial input instance
95  * @param[in] pdial The dial event struct
96  *
97  * @return Returns gFalse on an error (eg invalid instance)
98  */
99 gBool ginputGetDialStatus(gU16 instance, GEventDial *pdial);
100 
101 #endif /* GINPUT_NEED_DIAL */
102 
103 #endif /* _GINPUT_DIAL_H */
104 /** @} */
void ginputSetDialRange(gU16 instance, gU16 max)
Set the maximum value.
void ginputResetDialRange(gU16 instance)
Reset the value back to the hardware default.
GSourceHandle ginputGetDial(gU16 instance)
Create a dial input instance.
gU16 ginputGetDialRange(gU16 instance)
Get the maximum value.
void ginputSetDialSensitivity(gU16 instance, gU16 diff)
Set the level change required before a dial even is generated (threshold)
gBool ginputGetDialStatus(gU16 instance, GEventDial *pdial)
Get the current dial status.