aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ginput
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 /drivers/ginput
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 'drivers/ginput')
-rw-r--r--drivers/ginput/dial/GADC/ginput_lld.mk5
-rw-r--r--drivers/ginput/dial/GADC/ginput_lld_dial.c101
-rw-r--r--drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h48
-rw-r--r--drivers/ginput/dial/GADC/ginput_lld_dial_config.h50
-rw-r--r--drivers/ginput/dial/GADC/readme.txt16
5 files changed, 220 insertions, 0 deletions
diff --git a/drivers/ginput/dial/GADC/ginput_lld.mk b/drivers/ginput/dial/GADC/ginput_lld.mk
new file mode 100644
index 00000000..763549b8
--- /dev/null
+++ b/drivers/ginput/dial/GADC/ginput_lld.mk
@@ -0,0 +1,5 @@
+# List the required driver.
+GFXSRC += $(GFXLIB)/drivers/ginput/dial/GADC/ginput_lld_dial.c
+
+# Required include directories
+GFXINC += $(GFXLIB)/drivers/ginput/dial/GADC
diff --git a/drivers/ginput/dial/GADC/ginput_lld_dial.c b/drivers/ginput/dial/GADC/ginput_lld_dial.c
new file mode 100644
index 00000000..ced71a27
--- /dev/null
+++ b/drivers/ginput/dial/GADC/ginput_lld_dial.c
@@ -0,0 +1,101 @@
+/*
+ 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 drivers/ginput/dial/GADC/ginput_lld_dial.c
+ * @brief GINPUT Dial low level driver source for GADC hardware.
+ *
+ * @defgroup Dial Dial
+ * @ingroup GINPUT
+ * @{
+ */
+
+#include "ch.h"
+#include "hal.h"
+#include "gfx.h"
+
+#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
+
+#include "ginput/lld/dial.h"
+
+#if GINPUT_DIAL_NUM_PORTS >= 5
+ #error "GINPUT: Dial - GADC driver currently only supports 4 devices"
+#endif
+
+static adcsample_t samplebuf[GINPUT_DIAL_NUM_PORTS];
+
+#if GINPUT_DIAL_CYCLE_POLL
+ static uint16_t cycle;
+#endif
+
+static void GADCCallback(adcsample_t *buffer, void *param) {
+ ((DialCallbackFn)param)(buffer-samplebuf, buffer[0]);
+}
+
+void ginput_lld_dial_init(void) {
+ #if GINPUT_DIAL_CYCLE_POLL
+ cycle = 0;
+ #endif
+}
+
+void ginput_lld_dial_poll(DialCallbackFn fn) {
+ #if GINPUT_DIAL_CYCLE_POLL
+ switch(cycle++) {
+ #if GINPUT_DIAL_NUM_PORTS >= 1
+ case 0:
+ gadcLowSpeedStart(GINPUT_DIAL_DEVICE0, samplebuf+0, GADCCallback, (void *)fn);
+ break;
+ #endif
+ #if GINPUT_DIAL_NUM_PORTS >= 2
+ case 1:
+ gadcLowSpeedStart(GINPUT_DIAL_DEVICE1, samplebuf+1, GADCCallback, (void *)fn);
+ break;
+ #endif
+ #if GINPUT_DIAL_NUM_PORTS >= 3
+ case 2:
+ gadcLowSpeedStart(GINPUT_DIAL_DEVICE2, samplebuf+2, GADCCallback, (void *)fn);
+ break;
+ #endif
+ #if GINPUT_DIAL_NUM_PORTS >= 4
+ case 3:
+ gadcLowSpeedStart(GINPUT_DIAL_DEVICE3, samplebuf+3, GADCCallback, (void *)fn);
+ break;
+ #endif
+ }
+ if (cycle >= GINPUT_DIAL_NUM_PORTS)
+ cycle = 0;
+ #else
+ #if GINPUT_DIAL_NUM_PORTS >= 1
+ gadcLowSpeedStart(GINPUT_DIAL_DEVICE0, samplebuf+0, GADCCallback, (void *)fn);
+ #endif
+ #if GINPUT_DIAL_NUM_PORTS >= 2
+ gadcLowSpeedStart(GINPUT_DIAL_DEVICE1, samplebuf+1, GADCCallback, (void *)fn);
+ #endif
+ #if GINPUT_DIAL_NUM_PORTS >= 3
+ gadcLowSpeedStart(GINPUT_DIAL_DEVICE2, samplebuf+2, GADCCallback, (void *)fn);
+ #endif
+ #if GINPUT_DIAL_NUM_PORTS >= 4
+ gadcLowSpeedStart(GINPUT_DIAL_DEVICE3, samplebuf+3, GADCCallback, (void *)fn);
+ #endif
+ #endif
+}
+
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */
+/** @} */
diff --git a/drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h b/drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h
new file mode 100644
index 00000000..13788188
--- /dev/null
+++ b/drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h
@@ -0,0 +1,48 @@
+/*
+ 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 drivers/ginput/dial/GADC/ginput_lld_dial_board_olimexsam7ex256.h
+ * @brief GINPUT Dial Driver config file.
+ *
+ * @defgroup Dial Dial
+ * @ingroup GINPUT
+ * @{
+ */
+
+#ifndef _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H
+#define _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H
+
+#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
+
+/*===========================================================================*/
+/* Analogue devices on this board */
+/*===========================================================================*/
+
+#define GINPUT_DIAL_NUM_PORTS 1
+#define GINPUT_DIAL_DEVICE0 GADC_PHYSDEV_DIAL
+#define GINPUT_DIAL_POLL_PERIOD 200
+#define GINPUT_DIAL_CYCLE_POLL FALSE
+
+#endif /* GFX_USE_GINPUT && GINPUT_NEED_DIAL */
+
+#endif /* _GINPUT_LLD_DIAL_BOARD_OLIMEXSAM7EX256_H */
+/** @} */
+
diff --git a/drivers/ginput/dial/GADC/ginput_lld_dial_config.h b/drivers/ginput/dial/GADC/ginput_lld_dial_config.h
new file mode 100644
index 00000000..535b09a6
--- /dev/null
+++ b/drivers/ginput/dial/GADC/ginput_lld_dial_config.h
@@ -0,0 +1,50 @@
+/*
+ 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 drivers/ginput/dial/GADC/ginput_lld_dial_config.h
+ * @brief GINPUT Dial Driver configuration header.
+ *
+ * @defgroup Dial Dial
+ * @ingroup GINPUT
+ * @{
+ */
+
+#ifndef _GINPUT_LLD_DIAL_CONFIG_H
+#define _GINPUT_LLD_DIAL_CONFIG_H
+
+#if GFX_USE_GINPUT && GINPUT_NEED_DIAL
+
+#define GINPUT_DIAL_MAX_VALUE ((1<<GADC_BITS_PER_SAMPLE)-1)
+
+#if GINPUT_TOGGLE_USE_CUSTOM_BOARD
+ /* Include the user supplied board definitions */
+ #include "ginput_lld_dial_board.h"
+#elif defined(BOARD_OLIMEX_SAM7_EX256)
+ #include "ginput_lld_dial_board_olimexsam7ex256.h"
+#else
+ /* Include the user supplied board definitions */
+ #include "ginput_lld_dial_board.h"
+#endif
+
+#endif /* GFX_USE_GDISP && GINPUT_NEED_DIAL */
+
+#endif /* _GINPUT_LLD_DIAL_CONFIG_H */
+/** @} */
diff --git a/drivers/ginput/dial/GADC/readme.txt b/drivers/ginput/dial/GADC/readme.txt
new file mode 100644
index 00000000..5c303870
--- /dev/null
+++ b/drivers/ginput/dial/GADC/readme.txt
@@ -0,0 +1,16 @@
+To use this driver:
+
+1. Add in your halconf.h:
+ a) #define GFX_USE_GINPUT TRUE
+ #define GINPUT_NEED_DIAL TRUE
+ #define GINPUT_NEED_GADC TRUE
+ d) If you are not using a known board then create a ginput_lld_toggle_board.h file
+ and ensure it is on your include path.
+ Use the ginput_lld_dial_board_example.h file as a basis.
+ Currently known boards are:
+ Olimex SAM7-EX256
+
+2. To your makefile add the following lines:
+ include $(GFXLIB)/drivers/ginput/dial/GADC/ginput_lld.mk
+ include $(GFXLIB)/drivers/gadc/yourGADCdriver/gadc_lld.mk
+ \ No newline at end of file