aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2013-04-07 16:02:10 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2013-04-07 16:02:10 +1000
commit9ee7c284e63fc419f70ffc3c53eb23590767ee08 (patch)
tree57a45c0ca6e5222292bebb8445dffaff5757275b /include
parent90f5e851467e5ea14b710ada937409e506820d58 (diff)
downloaduGFX-9ee7c284e63fc419f70ffc3c53eb23590767ee08.tar.gz
uGFX-9ee7c284e63fc419f70ffc3c53eb23590767ee08.tar.bz2
uGFX-9ee7c284e63fc419f70ffc3c53eb23590767ee08.zip
Add GINPUT Dial, simplify GWIN input assignment
Added GINPUT Dial support and a driver that uses GADC to read the dial. Added support for Dial inputs to the GWIN slider. Updated the slider demo for Dial Inputs. Simplified the assigning of inputs to GWIN "widgets" button and slider. Updated the demo's to match the new input to button assignment.
Diffstat (limited to 'include')
-rw-r--r--include/ginput/dial.h245
-rw-r--r--include/ginput/lld/dial.h57
-rw-r--r--include/gwin/button.h22
-rw-r--r--include/gwin/slider.h23
4 files changed, 207 insertions, 140 deletions
diff --git a/include/ginput/dial.h b/include/ginput/dial.h
index c395f1da..358e36cf 100644
--- a/include/ginput/dial.h
+++ b/include/ginput/dial.h
@@ -1,123 +1,122 @@
-/*
- ChibiOS/GFX - Copyright (C) 2012, 2013
- Joel Bodenmann aka Tectu <joel@unormal.org>
-
- This file is part of ChibiOS/GFX.
-
- ChibiOS/GFX is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- ChibiOS/GFX is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-/**
- * @file include/ginput/dial.h
- * @brief GINPUT GFX User Input subsystem header file.
- *
- * @defgroup Dial Dial
- * @ingroup GINPUT
- *
- * @details A dial provides a powerful way to navigate through menus
- * on a display.
- *
- * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
- * @pre GINPUT_NEED_DIAL must be set to TRUE in your gfxconf.h
- *
- * @{
- */
-#ifndef _GINPUT_DIAL_H
-#define _GINPUT_DIAL_H
-
-#if GINPUT_NEED_DIAL || defined(__DOXYGEN__)
-
-/*===========================================================================*/
-/* Type definitions */
-/*===========================================================================*/
-
-// Event types for various ginput sources
-#define GEVENT_DIAL (GEVENT_GINPUT_FIRST+4)
-
-typedef struct GEventDial_t {
- GEventType type; // The type of this event (GEVENT_DIAL)
- uint16_t instance; // The dial instance
- uint16_t value; // The dial value
- } GEventDial;
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
- /**
- * @brief Create a dial input instance
- *
- * @param[in] instance The ID of the dial input instance (from 0 to 9999)
- *
- * @return The soure handle of the created dial instance
- */
- GSourceHandle ginputGetDial(uint16_t instance);
-
- /**
- * @brief Reset the value back to the hardware default
- *
- * @param[in] instance The ID of the dial input instance
- */
- void ginputResetDialRange(uint16_t instance);
-
- /**
- * @brief Get the maximum value
- * @details The readings are scaled to be 0 ... max-1.
- * 0 means over the full uint16_t range.
- *
- * @param[in] instance The ID of the dial input instance
- *
- * @return The maximum value
- */
- uint16_t ginputGetDialRange(uint16_t instance);
-
- /**
- * @brief Set the maximum value
- * @note This shouldn't be set higher that the hardwares possible maximum value
- *
- * @param[in] instance The ID of the dial input instance
- * @param[in] max The maximum value to be set
- */
- void ginputSetDialRange(uint16_t instance, uint16_t max);
-
- /**
- * @brief Set the level change required before a dial even is generated (threshold)
- * @note This is done after range scaling
- *
- * @param[in] instance The ID of the dial input instance
- * @param[in] diff The amount of level changes
- */
- void ginputSetDialSensitivity(uint16_t instance, uint16_t diff);
-
- /**
- * @brief Get the current dial status
- *
- * @param[in] instance The ID of the dial input instance
- * @param[in] pdial The dial event struct
- *
- * @return Returns FALSE on an error (eg invalid instance)
- */
- bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GINPUT_NEED_DIAL */
-
-#endif /* _GINPUT_DIAL_H */
-/** @} */
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/ginput/dial.h
+ * @brief GINPUT GFX User Input subsystem header file.
+ *
+ * @defgroup Dial Dial
+ * @ingroup GINPUT
+ *
+ * @details A dial provides a powerful way to navigate through menus
+ * on a display.
+ *
+ * @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
+ * @pre GINPUT_NEED_DIAL must be set to TRUE in your gfxconf.h
+ *
+ * @{
+ */
+#ifndef _GINPUT_DIAL_H
+#define _GINPUT_DIAL_H
+
+#if GINPUT_NEED_DIAL || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Type definitions */
+/*===========================================================================*/
+
+// Event types for various ginput sources
+#define GEVENT_DIAL (GEVENT_GINPUT_FIRST+4)
+
+typedef struct GEventDial_t {
+ GEventType type; // The type of this event (GEVENT_DIAL)
+ uint16_t instance; // The dial instance
+ uint16_t value; // The dial value
+ } GEventDial;
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /**
+ * @brief Create a dial input instance
+ *
+ * @param[in] instance The ID of the dial input instance (from 0 to 9999)
+ *
+ * @return The soure handle of the created dial instance
+ */
+ GSourceHandle ginputGetDial(uint16_t instance);
+
+ /**
+ * @brief Reset the value back to the hardware default
+ *
+ * @param[in] instance The ID of the dial input instance
+ */
+ void ginputResetDialRange(uint16_t instance);
+
+ /**
+ * @brief Get the maximum value
+ * @details The readings are scaled to be 0 ... max.
+ *
+ * @param[in] instance The ID of the dial input instance
+ *
+ * @return The maximum value
+ */
+ uint16_t ginputGetDialRange(uint16_t instance);
+
+ /**
+ * @brief Set the maximum value
+ * @details The readings are scaled to be 0 ... max.
+ *
+ * @param[in] instance The ID of the dial input instance
+ * @param[in] max The maximum value to be set
+ */
+ void ginputSetDialRange(uint16_t instance, uint16_t max);
+
+ /**
+ * @brief Set the level change required before a dial even is generated (threshold)
+ * @note This is done after range scaling
+ *
+ * @param[in] instance The ID of the dial input instance
+ * @param[in] diff The amount of level changes
+ */
+ void ginputSetDialSensitivity(uint16_t instance, uint16_t diff);
+
+ /**
+ * @brief Get the current dial status
+ *
+ * @param[in] instance The ID of the dial input instance
+ * @param[in] pdial The dial event struct
+ *
+ * @return Returns FALSE on an error (eg invalid instance)
+ */
+ bool_t ginputGetDialStatus(uint16_t instance, GEventDial *pdial);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GINPUT_NEED_DIAL */
+
+#endif /* _GINPUT_DIAL_H */
+/** @} */
diff --git a/include/ginput/lld/dial.h b/include/ginput/lld/dial.h
new file mode 100644
index 00000000..3efae04f
--- /dev/null
+++ b/include/ginput/lld/dial.h
@@ -0,0 +1,57 @@
+/*
+ ChibiOS/GFX - Copyright (C) 2012, 2013
+ Joel Bodenmann aka Tectu <joel@unormal.org>
+
+ This file is part of ChibiOS/GFX.
+
+ ChibiOS/GFX is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/GFX is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/**
+ * @file include/ginput/lld/dial.h
+ * @brief GINPUT header file for dial drivers.
+ *
+ * @defgroup Dial Dial
+ * @ingroup GINPUT
+ * @{
+ */
+
+#ifndef _LLD_GINPUT_DIAL_H
+#define _LLD_GINPUT_DIAL_H
+
+#if GINPUT_NEED_DIAL || defined(__DOXYGEN__)
+
+#include "ginput_lld_dial_config.h"
+
+typedef void (*DialCallbackFn)(uint16_t instance, uint16_t rawvalue);
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ void ginput_lld_dial_init(void);
+ void ginput_lld_dial_poll(DialCallbackFn fn);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
+
+#endif /* _LLD_GINPUT_TOGGLE_H */
+/** @} */
+
diff --git a/include/gwin/button.h b/include/gwin/button.h
index 2df540da..3d54afbb 100644
--- a/include/gwin/button.h
+++ b/include/gwin/button.h
@@ -180,30 +180,28 @@ void gwinSetButtonCustom(GHandle gh, GButtonDrawFunction fn, void *param);
*/
#define gwinGetButtonSource(gh) ((GSourceHandle)(gh))
-#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
/**
- * @brief Attach a mouse source
- * @details Attach a mouse source to a given button
+ * @brief Attach a mouse to a button
*
- * @param[in] gh The button handle
- * @param[in] gsh The source handle
+ * @param[in] gh The button handle
+ * @param[in] instance The mouse instance
*
* @api
*/
- bool_t gwinAttachButtonMouseSource(GHandle gh, GSourceHandle gsh);
+ bool_t gwinAttachButtonMouse(GHandle gh, uint16_t instance);
#endif
-#if defined(GINPUT_NEED_TOGGLE) && GINPUT_NEED_TOGGLE
+#if GFX_USE_GINPUT && GINPUT_NEED_TOGGLE
/**
- * @brief Attach a toggle source
- * @details Attach a toggle source to this button
+ * @brief Attach a toggle to a button
*
- * @param[in] gh The button handle
- * @param[in] gsh The source handle
+ * @param[in] gh The button handle
+ * @param[in] instance The toggle instance
*
* @api
*/
- bool_t gwinAttachButtonToggleSource(GHandle gh, GSourceHandle gsh);
+ bool_t gwinAttachButtonToggle(GHandle gh, uint16_t instance);
#endif
/**
diff --git a/include/gwin/slider.h b/include/gwin/slider.h
index 412900a5..1943729f 100644
--- a/include/gwin/slider.h
+++ b/include/gwin/slider.h
@@ -187,17 +187,30 @@ void gwinSetSliderCustom(GHandle gh, GSliderDrawFunction fn, void *param);
*/
#define gwinGetSliderSource(gh) ((GSourceHandle)(gh))
-#if defined(GINPUT_NEED_MOUSE) && GINPUT_NEED_MOUSE
+#if GFX_USE_GINPUT && GINPUT_NEED_MOUSE
/**
* @brief Attach a mouse source
- * @details Attach a mouse source to a slider
+ * @details Attach a mouse to a slider
*
- * @param[in] gh The slider handle
- * @param[in] gsh The source handle
+ * @param[in] gh The slider handle
+ * @param[in] instance The mouse instance
*
* @api
*/
- bool_t gwinAttachSliderMouseSource(GHandle gh, GSourceHandle gsh);
+ bool_t gwinAttachSliderMouse(GHandle gh, uint16_t instance);
+#endif
+
+#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
+ /**
+ * @brief Attach a dial source
+ * @details Attach a dial to a slider
+ *
+ * @param[in] gh The dial handle
+ * @param[in] instance The dial instance
+ *
+ * @api
+ */
+ bool_t gwinAttachSliderDial(GHandle gh, uint16_t instance);
#endif
/**