Merge pull request #12 from Tectu/master

Merge Tectu Changes
ugfx_release_2.6
Andrew Hannam 2012-12-20 00:03:33 -08:00
commit b669bf98f1
71 changed files with 557 additions and 1697 deletions

View File

@ -32,7 +32,7 @@ PROJECT_NAME = ChibiOS/GFX
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 1.4
PROJECT_NUMBER = 1.5
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer

View File

@ -25,7 +25,7 @@
#define GDISP_NEED_ARC FALSE
#define GDISP_NEED_SCROLL FALSE
#define GDISP_NEED_PIXELREAD FALSE
#define GDISP_NEED_CONTROL FALSE
#define GDISP_NEED_CONTROL TRUE
#define GDISP_NEED_MULTITHREAD TRUE
#define GDISP_NEED_ASYNC FALSE
#define GDISP_NEED_MSGAPI FALSE

View File

@ -75,6 +75,7 @@ int main(void) {
gdispInit();
ginputGetMouse(0);
gdispSetOrientation(GDISP_ROTATE_90);
drawScreen();

View File

@ -1,26 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/>.
*/
/**
* @addtogroup GDISP
* @details The GDISP module provides high level abstraction to interface
* pixel oriented graphic displays.
*/

View File

@ -1,28 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/>.
*/
/**
* @addtogroup GRAPH
* @details The GRAPH module provides high level HAL independed routines
* to draw graphs on a graphic display. The graph is highly
* configurable. There are many options to controll the look
* of the graph.
*/

View File

@ -1,36 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/>.
*/
/**
* @addtogroup GTIMER
* @details The GTIMER module provides high level, simple and hardware
* independend timers. The timers are meant to be used in different
* ChibiOS/GFX modules and are not very accurate.
*
* @details The reason why ChibiOS/GFX has it's own timer abstraction is because
* virtual timers provided by ChibiOS/RT are interrupt context only.
* While great for what they are designed for, they make coding of the input
* drivers much more complex.
* For non-performance critical drivers like these input drivers, it would also
* hog an in-ordinate amount of critical (interrupt locked) system time.
* This contrary to the goals of a real-time operating system. So a user-land
* (thread based) timer mechanism is also required.
*/

View File

@ -1,27 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/>.
*/
/**
* @addtogroup GWIN
* @details The GWIN module provides simple window management.
* @details Please note that GWIN is a module ontop of GDISP. Therefore, GDISP
* has to be set up correctly.
*/

View File

@ -1,26 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/>.
*/
/**
* @addtogroup TOUCHSCREEN
* @details The TOUCHSCREEN module provides high level abstraction to interface
* touchscreens.
*/

View File

@ -95,7 +95,7 @@ static __inline void set_cursor(coord_t x, coord_t y) {
}
}
static __inline void set_viewport(coord_t x, coord_t y, coord_t cx, coord_t cy) {
void set_viewport(coord_t x, coord_t y, coord_t cx, coord_t cy) {
set_cursor(x, y);
@ -134,6 +134,19 @@ static __inline void set_viewport(coord_t x, coord_t y, coord_t cx, coord_t cy)
set_cursor(x, y);
}
void reset_viewport(void) {
switch(GDISP.Orientation) {
case GDISP_ROTATE_0:
case GDISP_ROTATE_180:
set_viewport(0, 0, GDISP_SCREEN_WIDTH, GDISP_SCREEN_HEIGHT);
break;
case GDISP_ROTATE_90:
case GDISP_ROTATE_270:
set_viewport(0, 0, GDISP_SCREEN_HEIGHT, GDISP_SCREEN_WIDTH);
break;
}
}
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
@ -167,9 +180,9 @@ bool_t GDISP_LLD(init)(void) {
acquire_bus();
write_reg(0x0000,0x0001); delay(5);
write_reg(0x0003,0xA8A4); delay(5);
write_reg(0x000C,0x0000); delay(5);
write_reg(0x000D,0x080C); delay(5);
write_reg(0x0003,0xA8A4); delay(5);
write_reg(0x000C,0x0000); delay(5);
write_reg(0x000D,0x080C); delay(5);
write_reg(0x000E,0x2B00); delay(5);
write_reg(0x001E,0x00B0); delay(5);
write_reg(0x0001,0x2B3F); delay(5);
@ -277,14 +290,15 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
* @notapi
*/
void GDISP_LLD(clear)(color_t color) {
unsigned i;
unsigned i;
acquire_bus();
set_cursor(0, 0);
stream_start();
for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++)
write_data(color);
stream_stop();
reset_viewport();
set_cursor(0, 0);
stream_start();
for(i = 0; i < GDISP_SCREEN_WIDTH * GDISP_SCREEN_HEIGHT; i++)
write_data(color);
stream_stop();
release_bus();
}
#endif
@ -485,6 +499,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
* @notapi
*/
void GDISP_LLD(control)(unsigned what, void *value) {
acquire_bus();
switch(what) {
case GDISP_CONTROL_POWER:
if (GDISP.Powermode == (gdisp_powermode_t)value)
@ -557,6 +572,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
case GDISP_CONTROL_CONTRAST:
*/
}
release_bus();
}
#endif

View File

@ -22,7 +22,8 @@
* @file drivers/ginput/toggle/Pal/ginput_lld_toggle.c
* @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware.
*
* @addtogroup GINPUT_TOGGLE
* @defgroup Toggle Toggle
* @ingroup GINPUT
* @{
*/

View File

@ -22,7 +22,8 @@
* @file drivers/ginput/toggle/Pal/ginput_lld_toggle_board_example.h
* @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware on the example board.
*
* @addtogroup GINPUT_TOGGLE
* @defgroup Toggle Toggle
* @ingroup GINPUT
* @{
*/

View File

@ -22,7 +22,8 @@
* @file drivers/ginput/toggle/Pal/ginput_lld_toggle_board_olimexsam7ex256.h
* @brief GINPUT Toggle low level driver source for the ChibiOS PAL hardware on the Olimex SAM7EX256 board.
*
* @addtogroup GINPUT_TOGGLE
* @defgroup Toggle Toggle
* @ingroup GINPUT
* @{
*/

View File

@ -22,7 +22,8 @@
* @file drivers/ginput/toggle/Pal/ginput_lld_toggle_config.h
* @brief GINPUT Toggle Driver configuration header.
*
* @addtogroup GDISP
* @defgroup Toggle Toggle
* @ingroup GINPUT
* @{
*/

View File

@ -22,7 +22,8 @@
* @file drivers/ginput/touch/ADS7843/ginput_lld_mouse.c
* @brief GINPUT Touch low level driver source for the ADS7843.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
* @{
*/
@ -38,6 +39,8 @@
#include "ginput_lld_mouse_board.h"
#elif defined(BOARD_FIREBULL_STM32_F103)
#include "ginput_lld_mouse_board_firebull_stm32f103.h"
#elif defined(BOARD_OLIMEX_STM32_E407)
#include "ginput_lld_mouse_board_olimex_stm32_e407.h"
#else
#include "ginput_lld_mouse_board_example.h"
#endif

View File

@ -22,7 +22,8 @@
* @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h
* @brief GINPUT Touch low level driver source for the ADS7843 on the example board.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
* @{
*/

View File

@ -22,7 +22,8 @@
* @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_example.h
* @brief GINPUT Touch low level driver source for the ADS7843 on the example board.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
* @{
*/

View File

@ -19,10 +19,11 @@
*/
/**
* @file drivers/ginput/touch/XPT2046/ginput_lld_mouse_board_example.h
* @brief GINPUT Touch low level driver source for the XPT2046 on the example board.
* @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_board_olimex_stm32_e407.h
* @brief GINPUT Touch low level driver source for the ADS7843 on an Olimex STM32E407.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
* @{
*/
@ -31,8 +32,8 @@
static const SPIConfig spicfg = {
NULL,
GPIOC,
6,
GPIOG,
10,
/* SPI_CR1_BR_2 |*/ SPI_CR1_BR_1 | SPI_CR1_BR_0,
};
@ -42,7 +43,7 @@ static const SPIConfig spicfg = {
* @notapi
*/
static __inline void init_board(void) {
spiStart(&SPID1, &spicfg);
spiStart(&SPID2, &spicfg);
}
/**
@ -52,7 +53,7 @@ static __inline void init_board(void) {
* @notapi
*/
static __inline bool_t getpin_pressed(void) {
return (!palReadPad(GPIOC, 4));
return (!palReadPad(GPIOG, 0));
}
/**
* @brief Aquire the bus ready for readings
@ -60,9 +61,9 @@ static __inline bool_t getpin_pressed(void) {
* @notapi
*/
static __inline void aquire_bus(void) {
spiAcquireBus(&SPID1);
spiAcquireBus(&SPID2);
//TOUCHSCREEN_SPI_PROLOGUE();
palClearPad(GPIOC, 6);
palClearPad(GPIOG, 10);
}
/**
@ -71,8 +72,8 @@ static __inline void aquire_bus(void) {
* @notapi
*/
static __inline void release_bus(void) {
palSetPad(GPIOC, 6);
spiReleaseBus(&SPID1);
palSetPad(GPIOG, 10);
spiReleaseBus(&SPID2);
//TOUCHSCREEN_SPI_EPILOGUE();
}
@ -91,7 +92,7 @@ static __inline uint16_t read_value(uint16_t port) {
txbuf[0] = port;
spiExchange(&SPID1, 3, txbuf, rxbuf);
spiExchange(&SPID2, 3, txbuf, rxbuf);
ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3);

View File

@ -21,9 +21,12 @@
* @file drivers/ginput/touch/ADS7843/ginput_lld_mouse_config.h
* @brief GINPUT LLD header file for mouse/touch driver.
*
* @addtogroup GINPUT_LLD_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H

View File

@ -22,7 +22,9 @@
* @file drivers/ginput/touch/MCU/ginput_lld_mouse.c
* @brief GINPUT Touch low level driver source for the MCU.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/

View File

@ -22,7 +22,9 @@
* @file drivers/ginput/touch/MCU/ginput_lld_mouse_board_example.h
* @brief GINPUT Touch low level driver source for the MCU on the example board.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/

View File

@ -22,7 +22,9 @@
* @file drivers/ginput/touch/MCU/ginput_lld_mouse_board_olimex_stm32_lcd.h
* @brief GINPUT Touch low level driver source for the MCU on the example board.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/

View File

@ -21,21 +21,24 @@
* @file drivers/ginput/touch/MCU/ginput_lld_mouse_config.h
* @brief GINPUT LLD header file for touch driver.
*
* @addtogroup GINPUT_LLD_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 10
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 12
#define GINPUT_MOUSE_READ_CYCLES 4
#define GINPUT_MOUSE_POLL_PERIOD 100
#define GINPUT_MOUSE_MAX_CLICK_JITTER 4
#define GINPUT_MOUSE_MAX_MOVE_JITTER 4
#define GINPUT_MOUSE_CLICK_TIME 700
#define GINPUT_MOUSE_POLL_PERIOD 25
#define GINPUT_MOUSE_MAX_CLICK_JITTER 2
#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
#define GINPUT_MOUSE_CLICK_TIME 500
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */

View File

@ -1,5 +0,0 @@
# List the required driver.
GFXSRC += $(GFXLIB)/drivers/ginput/touch/XPT2046/ginput_lld_mouse.c
# Required include directories
GFXINC += $(GFXLIB)/drivers/ginput/touchXPT20466

View File

@ -1,141 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touch/XPT2046/ginput_lld_mouse.c
* @brief GINPUT Touch low level driver source for the XPT2046.
*
* @addtogroup GINPUT_MOUSE
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"
#if (GFX_USE_GINPUT && GINPUT_NEED_MOUSE) /*|| defined(__DOXYGEN__)*/
#include "ginput/lld/mouse.h"
#if defined(GINPUT_MOUSE_USE_CUSTOM_BOARD) && GINPUT_MOUSE_USE_CUSTOM_BOARD
#include "ginput_lld_mouse_board.h"
#elif defined(BOARD_FIREBULL_STM32_F103)
#include "ginput_lld_mouse_board_firebull_stm32f103.h"
#else
#include "ginput_lld_mouse_board_example.h"
#endif
static uint16_t sampleBuf[7];
static coord_t lastx, lasty;
/**
* @brief 7-point median filtering code for touch samples
*
* @note This is an internally used routine only.
*
* @notapi
*/
static void filter(void) {
uint16_t temp;
int i,j;
for(i = 0; i < 4; i++) {
for(j = i; j < 7; j++) {
if(sampleBuf[i] > sampleBuf[j]) {
/* Swap the values */
temp = sampleBuf[i];
sampleBuf[i] = sampleBuf[j];
sampleBuf[j] = temp;
}
}
}
}
/**
* @brief Initialise the mouse/touch.
*
* @notapi
*/
void ginput_lld_mouse_init(void) {
init_board();
}
/**
* @brief Read the mouse/touch position.
*
* @param[in] pt A pointer to the structure to fill
*
* @note For drivers that don't support returning a position
* when the touch is up (most touch devices), it should
* return the previous position with the new Z value.
* The z value is the pressure for those touch devices
* that support it (-100 to 100 where > 0 is touched)
* or, 0 or 100 for those drivers that don't.
*
* @notapi
*/
void ginput_lld_mouse_get_reading(MouseReading *pt) {
uint16_t i;
// If touch-off return the previous results
if (!getpin_pressed()) {
pt->x = lastx;
pt->y = lasty;
pt->z = 0;
pt->buttons = 0;
return;
}
// Read the port to get the touch settings
aquire_bus();
/* Get the X value
* Discard the first conversion - very noisy and keep the ADC on hereafter
* till we are done with the sampling. Note that PENIRQ is disabled while reading.
* Finally switch on PENIRQ once again - perform a dummy read.
* Once we have the readings, find the medium using our filter function
*/
read_value(0xD1);
for(i = 0; i < 7; i++)
sampleBuf[i] = read_value(0xD1);
read_value(0xD0);
filter();
lastx = (coord_t)sampleBuf[3];
/* Get the Y value using the same process as above */
read_value(0x91);
for(i = 0; i < 7; i++)
sampleBuf[i] = read_value(0x91);
read_value(0x90);
filter();
lasty = (coord_t)sampleBuf[3];
// Release the bus
release_bus();
// Return the results
pt->x = lastx;
pt->y = lasty;
pt->z = 100;
pt->buttons = GINPUT_TOUCH_PRESSED;
}
#endif /* GFX_USE_GINPUT && GINPUT_NEED_MOUSE */
/** @} */

View File

@ -1,87 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touch/XPT2046/ginput_lld_mouse_board_example.h
* @brief GINPUT Touch low level driver source for the XPT2046 on the example board.
*
* @addtogroup GINPUT_MOUSE
* @{
*/
#ifndef _GINPUT_LLD_MOUSE_BOARD_H
#define _GINPUT_LLD_MOUSE_BOARD_H
/**
* @brief Initialise the board for the touch.
*
* @notapi
*/
static __inline void init_board(void) {
/* Code here */
#error "ginputXPT2046: You must supply a definition for init_board for your board"
}
/**
* @brief Check whether the surface is currently touched
* @return TRUE if the surface is currently touched
*
* @notapi
*/
static __inline bool_t getpin_pressed(void) {
/* Code here */
#error "ginputXPT2046: You must supply a definition for getpin_pressed for your board"
}
/**
* @brief Aquire the bus ready for readings
*
* @notapi
*/
static __inline void aquire_bus(void) {
/* Code here */
#error "ginputXPT2046: You must supply a definition for aquire_bus for your board"
}
/**
* @brief Release the bus after readings
*
* @notapi
*/
static __inline void release_bus(void) {
/* Code here */
#error "ginputXPT2046: You must supply a definition for release_bus for your board"
}
/**
* @brief Read a value from touch controller
* @return The value read from the controller
*
* params[in] port The controller port to read.
*
* @notapi
*/
static __inline uint16_t read_value(uint16_t port) {
/* Code here */
#error "ginputXPT2046: You must supply a definition for read_value for your board"
}
#endif /* _GINPUT_LLD_MOUSE_BOARD_H */
/** @} */

View File

@ -1,41 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touch/XPT2046/ginput_lld_mouse_config.h
* @brief GINPUT LLD header file for mouse/touch driver.
*
* @addtogroup GINPUT_LLD_MOUSE
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
#define GINPUT_MOUSE_EVENT_TYPE GEVENT_TOUCH
#define GINPUT_MOUSE_NEED_CALIBRATION TRUE
#define GINPUT_MOUSE_LLD_CALIBRATION_LOADSAVE FALSE
#define GINPUT_MOUSE_MAX_CALIBRATION_ERROR 5
#define GINPUT_MOUSE_READ_CYCLES 4
#define GINPUT_MOUSE_POLL_PERIOD 25
#define GINPUT_MOUSE_MAX_CLICK_JITTER 10
#define GINPUT_MOUSE_MAX_MOVE_JITTER 2
#define GINPUT_MOUSE_CLICK_TIME 500
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */

View File

@ -1,9 +0,0 @@
To use this driver:
1. Add in your halconf.h:
a) #define GFX_USE_GINPUT TRUE
b) #define GINPUT_NEED_MOUSE TRUE
2. To your makefile add the following lines:
include $(GFXLIB)/drivers/ginput/touch/XPT2046/ginput_lld.mk

View File

@ -21,9 +21,12 @@
* @file drivers/multiple/Win32/ginput_lld_mouse_config.h
* @brief GINPUT LLD header file for mouse/touch driver.
*
* @addtogroup GINPUT_LLD_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_CONFIG_H
#define _LLD_GINPUT_MOUSE_CONFIG_H
@ -56,3 +59,4 @@
#endif /* _LLD_GINPUT_MOUSE_CONFIG_H */
/** @} */

View File

@ -22,7 +22,9 @@
* @file drivers/multiple/Win32/ginput_lld_toggle_config.h
* @brief GINPUT Toggle Driver configuration header.
*
* @addtogroup GINPUT_TOGGLE
* @defgroup Toggle Toggle
* @ingroup GINPUT
*
* @{
*/
@ -49,3 +51,4 @@
#endif /* _GINPUT_LLD_TOGGLE_CONFIG_H */
/** @} */

View File

@ -1,8 +0,0 @@
To use this driver:
1. Add in your halconf.h:
a) #define GFX_USE_TOUCHSCREEN TRUE
2. To your makefile add the following lines:
include $(GFXLIB)/drivers/touchscreen/ADS7843/touchscreen_lld.mk

View File

@ -1,241 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touchscreen/ADS7843/touchscreen_lld.c
* @brief Touchscreen Driver subsystem low level driver source.
*
* @addtogroup TOUCHSCREEN
* @{
*/
#include "ch.h"
#include "hal.h"
#include "touchscreen.h"
#if GFX_USE_TOUCHSCREEN /*|| defined(__DOXYGEN__)*/
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
#if !defined(__DOXYGEN__)
/* Local copy of the current touchscreen driver */
static const TouchscreenDriver *tsDriver;
static uint16_t sampleBuf[7];
#endif
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/* ---- Required Routines ---- */
/**
* @brief Low level touchscreen driver initialization.
*
* @param[in] ts The touchscreen driver
*
* @notapi
*/
void ts_lld_init(const TouchscreenDriver *ts) {
tsDriver = ts;
if(tsDriver->direct_init)
spiStart(tsDriver->spip, tsDriver->spicfg);
}
/**
* @brief Reads a conversion from the touchscreen
*
* @param[in] cmd The command bits to send to the touchscreen
*
* @return The read value 12-bit right-justified
*
* @note This function only reads data, it is assumed that the pins are
* configured properly and the bus has been acquired beforehand
*
* @notapi
*/
uint16_t ts_lld_read_value(uint8_t cmd) {
static uint8_t txbuf[3] = {0};
static uint8_t rxbuf[3] = {0};
uint16_t ret;
txbuf[0] = cmd;
spiExchange(tsDriver->spip, 3, txbuf, rxbuf);
ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3);
return ret;
}
/**
* @brief 7-point median filtering code for touchscreen samples
*
* @note This is an internally used routine only.
*
* @notapi
*/
static void ts_lld_filter(void) {
uint16_t temp;
int i,j;
for(i = 0; i < 4; i++) {
for(j = i; j < 7; j++) {
if(sampleBuf[i] > sampleBuf[j]) {
/* Swap the values */
temp = sampleBuf[i];
sampleBuf[i] = sampleBuf[j];
sampleBuf[j] = temp;
}
}
}
}
/**
* @brief Reads out the X direction.
*
* @note The samples are median filtered for greater noise reduction
*
* @notapi
*/
uint16_t ts_lld_read_x(void) {
int i;
#if defined(SPI_USE_MUTUAL_EXCLUSION)
spiAcquireBus(tsDriver->spip);
#endif
TOUCHSCREEN_SPI_PROLOGUE();
palClearPad(tsDriver->spicfg->ssport, tsDriver->spicfg->sspad);
/* Discard the first conversion - very noisy and keep the ADC on hereafter
* till we are done with the sampling. Note that PENIRQ is disabled.
*/
ts_lld_read_value(0xD1);
for(i = 0; i < 7; i++) {
sampleBuf[i] = ts_lld_read_value(0xD1);
}
/* Switch on PENIRQ once again - perform a dummy read */
ts_lld_read_value(0xD0);
palSetPad(tsDriver->spicfg->ssport, tsDriver->spicfg->sspad);
TOUCHSCREEN_SPI_EPILOGUE();
#if defined(SPI_USE_MUTUAL_EXCLUSION)
spiReleaseBus(tsDriver->spip);
#endif
/* Find the median - use selection sort */
ts_lld_filter();
return sampleBuf[3];
}
/*
* @brief Reads out the Y direction.
*
* @notapi
*/
uint16_t ts_lld_read_y(void) {
int i;
#if defined(SPI_USE_MUTUAL_EXCLUSION)
spiAcquireBus(tsDriver->spip);
#endif
TOUCHSCREEN_SPI_PROLOGUE();
palClearPad(tsDriver->spicfg->ssport, tsDriver->spicfg->sspad);
/* Discard the first conversion - very noisy and keep the ADC on hereafter
* till we are done with the sampling. Note that PENIRQ is disabled.
*/
ts_lld_read_value(0x91);
for(i = 0; i < 7; i++) {
sampleBuf[i] = ts_lld_read_value(0x91);
}
/* Switch on PENIRQ once again - perform a dummy read */
ts_lld_read_value(0x90);
palSetPad(tsDriver->spicfg->ssport, tsDriver->spicfg->sspad);
TOUCHSCREEN_SPI_EPILOGUE();
#ifdef SPI_USE_MUTUAL_EXCLUSION
spiReleaseBus(tsDriver->spip);
#endif
/* Find the median - use selection sort */
ts_lld_filter();
return sampleBuf[3];
}
/* ---- Optional Routines ---- */
#if TOUCHSCREEN_HAS_PRESSED || defined(__DOXYGEN__)
/*
* @brief for checking if touchscreen is pressed or not.
*
* @return 1 if pressed / 0 if not pressed
*
* @notapi
*/
uint8_t ts_lld_pressed(void) {
return (!palReadPad(tsDriver->tsIRQPort, tsDriver->tsIRQPin));
}
#endif
#if TOUCHSCREEN_HAS_PRESSURE || defined(__DOXYGEN__)
/*
* @brief Reads out the Z direction / pressure.
*
* @notapi
*/
uint16_t ts_lld_read_z(void) {
/* ToDo */
return 42;
}
#endif
#endif /* GFX_USE_TOUCHSCREEN */
/** @} */

View File

@ -1,6 +0,0 @@
# List the required driver.
GFXSRC += $(GFXLIB)/drivers/touchscreen/ADS7843/touchscreen_lld.c
# Required include directories
GFXINC += $(GFXLIB)/drivers/touchscreen/ADS7843

View File

@ -1,84 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touchscreen/ADS7843/touchscreen_lld_config.h
* @brief Touchscreen Driver subsystem low level driver.
*
* @addtogroup TOUCHSCREEN
* @{
*/
#ifndef TOUCHSCREEN_LLD_CONFIG_H
#define TOUCHSCREEN_LLD_CONFIG_H
#if GFX_USE_TOUCHSCREEN /*|| defined(__DOXYGEN__)*/
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
#define TOUCHSCREEN_HAS_PRESSED TRUE
#define TOUCHSCREEN_HAS_PRESSURE FALSE
struct TouchscreenDriver {
/*
* @brief Pointer to SPI driver.
* @note SPI driver must be enabled in mcuconf.h and halconf.h
*/
SPIDriver *spip;
/*
* @brief Pointer to the SPI configuration structure.
* @note The lowest possible speed ~ 1-2MHz is to be used, otherwise
* will result in a lot of noise
*/
const SPIConfig *spicfg;
/*
* @brief Touchscreen controller TPIRQ pin GPIO port
*/
ioportid_t tsIRQPort;
/*
* @brief Touchscreen controller TPIRQ GPIO pin
* @note The interface is polled as of now, interrupt support is
* to be implemented in the future.
*/
ioportmask_t tsIRQPin;
/*
* @brief Initialize the SPI with the configuration struct given or not
* If TRUE, spiStart is called by the init, otherwise not
* @note This is provided in such a case when SPI port is being shared
* across multiple peripherals, so not to disturb the SPI bus.
* You can use TOUCHSCREEN_SPI_PROLOGUE() and TOUCHSCREEN_SPI_EPILOGUE()
* macros to change the SPI configuration or speed before and
* after using the touchpad. An example case would be sharing the
* bus with a fast flash memory chip.
*/
bool_t direct_init;
};
#endif /* GFX_USE_TOUCHSCREEN */
#endif /* TOUCHSCREEN_LLD_CONFIG_H */
/** @} */

View File

@ -1,8 +0,0 @@
To use this driver:
1. Add in your halconf.h:
a) #define GFX_USE_TOUCHSCREEN TRUE
2. To your makefile add the following lines:
include $(GFXLIB)/drivers/touchscreen/MCU/touchscreen_lld.mk

View File

@ -1,172 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touchscreen/MCU/touchscreen_lld.c
* @brief Touchscreen Driver subsystem low level driver source.
*
* @addtogroup TOUCHSCREEN
* @{
*/
#include "ch.h"
#include "hal.h"
#include "touchscreen.h"
#if GFX_USE_TOUCHSCREEN /*|| defined(__DOXYGEN__)*/
#define ADC_NUM_CHANNELS 2
#define ADC_BUF_DEPTH 1
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
static const TouchscreenDriver *ts;
static const ADCConversionGroup adc_y_config = {
FALSE,
ADC_NUM_CHANNELS,
NULL,
NULL,
0, 0,
0, 0,
ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS),
0,
ADC_SQR3_SQ2_N(ADC_CHANNEL_IN12) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN13)
};
static const ADCConversionGroup adc_x_config = {
FALSE,
ADC_NUM_CHANNELS,
NULL,
NULL,
0, 0,
0, 0,
ADC_SQR1_NUM_CH(ADC_NUM_CHANNELS),
0,
ADC_SQR3_SQ2_N(ADC_CHANNEL_IN10) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN11)
};
/**
* @brief Low level Touchscreen driver initialization.
*
* @param[in] ts The touchscreen driver struct
*
* @notapi
*/
void ts_lld_init(const TouchscreenDriver *ts_init) {
ts = ts_init;
adcStart(ts->adc_driver, NULL);
}
/**
* @brief 7-point median filtering code for touchscreen samples
*
* @note This is an internally used routine only.
*
* @notapi
*/
static void ts_lld_filter(void) {
return 0;
}
/**
* @brief Reads out the X direction.
*
* @note The samples are median filtered for greater noise reduction
*
* @notapi
*/
uint16_t ts_lld_read_x(void) {
uint16_t val1, val2;
adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH];
palSetPadMode(ts->yd_port, ts->yd_pin, PAL_MODE_INPUT_ANALOG);
palSetPadMode(ts->yu_port, ts->yu_pin, PAL_MODE_INPUT_ANALOG);
palSetPadMode(ts->xl_port, ts->xl_pin, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(ts->xr_port, ts->xr_pin, PAL_MODE_OUTPUT_PUSHPULL);
palSetPad(ts->xl_port, ts->xl_pin);
palClearPad(ts->xr_port, ts->xr_pin);
chThdSleepMilliseconds(1);
adcConvert(ts->adc_driver, &adc_x_config, samples, ADC_BUF_DEPTH);
val1 = ((samples[0] + samples[1])/2);
palClearPad(ts->xl_port, ts->xl_pin);
palSetPad(ts->xr_port, ts->xr_pin);
chThdSleepMilliseconds(1);
adcConvert(ts->adc_driver, &adc_x_config, samples, ADC_BUF_DEPTH);
val2 = ((samples[0] + samples[1])/2);
return ((val1+((1<<12)-val2))/4);
}
/**
* @brief Reads out the Y direction.
*
* @notapi
*/
uint16_t ts_lld_read_y(void) {
uint16_t val1, val2;
adcsample_t samples[ADC_NUM_CHANNELS * ADC_BUF_DEPTH];
palSetPadMode(ts->xl_port, ts->xl_pin, PAL_MODE_INPUT_ANALOG);
palSetPadMode(ts->xr_port, ts->xr_pin, PAL_MODE_INPUT_ANALOG);
palSetPadMode(ts->yd_port, ts->yd_pin, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(ts->yu_port, ts->yu_pin, PAL_MODE_OUTPUT_PUSHPULL);
palSetPad(ts->yu_port, ts->yu_pin);
palClearPad(ts->yd_port, ts->yd_pin);
chThdSleepMilliseconds(1);
adcConvert(ts->adc_driver, &adc_y_config, samples, ADC_BUF_DEPTH);
val1 = ((samples[0] + samples[1])/2);
palClearPad(ts->yu_port, ts->yu_pin);
palSetPad(ts->yd_port, ts->yd_pin);
chThdSleepMilliseconds(1);
adcConvert(ts->adc_driver, &adc_y_config, samples, ADC_BUF_DEPTH);
val2 = ((samples[0] + samples[1])/2);
return ((val1+((1<<12)-val2))/4);
}
/*
* @brief Checks if touchscreen is pressed or not.
*
* @return 1 if pressed, 0 otherwise
*
* @notapi
*/
uint8_t ts_lld_pressed(void) {
palSetPadMode(ts->yd_port, ts->yd_pin, PAL_MODE_INPUT_PULLDOWN);
palSetPadMode(ts->yu_port, ts->yu_pin, PAL_MODE_INPUT);
palSetPadMode(ts->xl_port, ts->xl_pin, PAL_MODE_INPUT);
palSetPadMode(ts->xr_port, ts->xr_pin, PAL_MODE_OUTPUT_PUSHPULL);
palSetPad(ts->xr_port, ts->xr_pin);
return palReadPad(ts->yd_port, ts->yd_pin);
}
#endif /* GFX_USE_TOUCHSCREEN */
/** @} */

View File

@ -1,6 +0,0 @@
# List the required driver.
GFXSRC += $(GFXLIB)/drivers/touchscreen/MCU/touchscreen_lld.c
# Required include directories
GFXINC += $(GFXLIB)/drivers/touchscreen/MCU

View File

@ -1,61 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touchscreen/MCU/touchscreen_lld_config.h
* @brief Touchscreen Driver subsystem low level driver.
*
* @addtogroup TOUCHSCREEN
* @{
*/
#ifndef TOUCHSCREEN_LLD_CONFIG_H
#define TOUCHSCREEN_LLD_CONFIG_H
#if GFX_USE_TOUCHSCREEN /*|| defined(__DOXYGEN__)*/
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
#define TOUCHSCREEN_HAS_PRESSED TRUE
#define TOUCHSCREEN_HAS_PRESSURE FALSE
/**
* @brief The touchscreen driver struct
* @details Pointer to this will be passed to tsInit()
*/
struct TouchscreenDriver {
ADCDriver *adc_driver;
ioportid_t yd_port;
ioportmask_t yd_pin;
ioportid_t yu_port;
ioportmask_t yu_pin;
ioportid_t xl_port;
ioportmask_t xl_pin;
ioportid_t xr_port;
ioportmask_t xr_pin;
};
#endif /* GFX_USE_TOUCHSCREEN */
#endif /* TOUCHSCREEN_LLD_CONFIG_H */
/** @} */

View File

@ -1,8 +0,0 @@
To use this driver:
1. Add in your halconf.h:
a) #define GFX_USE_TOUCHSCREEN TRUE
2. To your makefile add the following lines:
include $(GFXLIB)/drivers/touchscreen/XPT2046/touchscreen_lld.mk

View File

@ -1,241 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touchscreen/XPT2046/touchscreen_lld.c
* @brief Touchscreen Driver subsystem low level driver source.
*
* @addtogroup TOUCHSCREEN
* @{
*/
#include "ch.h"
#include "hal.h"
#include "touchscreen.h"
#if GFX_USE_TOUCHSCREEN /*|| defined(__DOXYGEN__)*/
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
#if !defined(__DOXYGEN__)
/* Local copy of the current touchpad driver */
static const TouchscreenDriver *tsDriver;
static uint16_t sampleBuf[7];
#endif
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/* ---- Required Routines ---- */
/**
* @brief Low level Touchscreen driver initialization.
*
* @param[in] ts The touchscreen driver struct
*
* @notapi
*/
void ts_lld_init(const TouchscreenDriver *ts) {
tsDriver = ts;
if(tsDriver->direct_init)
spiStart(tsDriver->spip, tsDriver->spicfg);
}
/**
* @brief Reads a conversion from the touchscreen
*
* @param[in] cmd The command bits to send to the touchscreen
*
* @return The read value 12-bit right-justified
*
* @note This function only reads data, it is assumed that the pins are
* configured properly and the bus has been acquired beforehand
*
* @notapi
*/
uint16_t ts_lld_read_value(uint8_t cmd) {
static uint8_t txbuf[3] = {0};
static uint8_t rxbuf[3] = {0};
uint16_t ret;
txbuf[0] = cmd;
spiExchange(tsDriver->spip, 3, txbuf, rxbuf);
ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3);
return ret;
}
/**
* @brief 7-point median filtering code for touchscreen samples
*
* @note This is an internally used routine only.
*
* @notapi
*/
static void ts_lld_filter(void) {
uint16_t temp;
int i,j;
for(i = 0; i < 4; i++) {
for(j = i; j < 7; j++) {
if(sampleBuf[i] > sampleBuf[j]) {
/* Swap the values */
temp = sampleBuf[i];
sampleBuf[i] = sampleBuf[j];
sampleBuf[j] = temp;
}
}
}
}
/**
* @brief Reads out the X direction.
*
* @note The samples are median filtered for greater noise reduction
*
* @notapi
*/
uint16_t ts_lld_read_x(void) {
int i;
#if defined(SPI_USE_MUTUAL_EXCLUSION)
spiAcquireBus(tsDriver->spip);
#endif
TOUCHSCREEN_SPI_PROLOGUE();
palClearPad(tsDriver->spicfg->ssport, tsDriver->spicfg->sspad);
/* Discard the first conversion - very noisy and keep the ADC on hereafter
* till we are done with the sampling. Note that PENIRQ is disabled.
*/
ts_lld_read_value(0xD1);
for(i = 0; i < 7; i++) {
sampleBuf[i] = ts_lld_read_value(0xD1);
}
/* Switch on PENIRQ once again - perform a dummy read */
ts_lld_read_value(0xD0);
palSetPad(tsDriver->spicfg->ssport, tsDriver->spicfg->sspad);
TOUCHSCREEN_SPI_EPILOGUE();
#if defined(SPI_USE_MUTUAL_EXCLUSION)
spiReleaseBus(tsDriver->spip);
#endif
/* Find the median - use selection sort */
ts_lld_filter();
return sampleBuf[3];
}
/*
* @brief Reads out the Y direction.
*
* @notapi
*/
uint16_t ts_lld_read_y(void) {
int i;
#if defined(SPI_USE_MUTUAL_EXCLUSION)
spiAcquireBus(tsDriver->spip);
#endif
TOUCHSCREEN_SPI_PROLOGUE();
palClearPad(tsDriver->spicfg->ssport, tsDriver->spicfg->sspad);
/* Discard the first conversion - very noisy and keep the ADC on hereafter
* till we are done with the sampling. Note that PENIRQ is disabled.
*/
ts_lld_read_value(0x91);
for(i = 0; i < 7; i++) {
sampleBuf[i] = ts_lld_read_value(0x91);
}
/* Switch on PENIRQ once again - perform a dummy read */
ts_lld_read_value(0x90);
palSetPad(tsDriver->spicfg->ssport, tsDriver->spicfg->sspad);
TOUCHSCREEN_SPI_EPILOGUE();
#ifdef SPI_USE_MUTUAL_EXCLUSION
spiReleaseBus(tsDriver->spip);
#endif
/* Find the median - use selection sort */
ts_lld_filter();
return sampleBuf[3];
}
/* ---- Optional Routines ---- */
#if TOUCHSCREEN_HAS_PRESSED || defined(__DOXYGEN__)
/*
* @brief for checking if touchscreen is pressed or not.
*
* @return 1 if pressed / 0 if not pressed
*
* @notapi
*/
uint8_t ts_lld_pressed(void) {
return (!palReadPad(tsDriver->tsIRQPort, tsDriver->tsIRQPin));
}
#endif
#if TOUCHSCREEN_HAS_PRESSURE || defined(__DOXYGEN__)
/*
* @brief Reads out the Z direction / pressure.
*
* @notapi
*/
uint16_t ts_lld_read_z(void) {
/* ToDo */
return 42;
}
#endif
#endif /* GFX_USE_TOUCHSCREEN */
/** @} */

View File

@ -1,6 +0,0 @@
# List the required driver.
GFXSRC += $(GFXLIB)/drivers/touchscreen/XPT2046/touchscreen_lld.c
# Required include directories
GFXINC += $(GFXLIB)/drivers/touchscreen/XPT2046

View File

@ -1,84 +0,0 @@
/*
ChibiOS/GFX - Copyright (C) 2012
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/touchscreen/XPT2046/touchscreen_lld_config.h
* @brief Touchscreen Driver subsystem low level driver.
*
* @addtogroup TOUCHSCREEN
* @{
*/
#ifndef TOUCHSCREEN_LLD_CONFIG_H
#define TOUCHSCREEN_LLD_CONFIG_H
#if GFX_USE_TOUCHSCREEN /*|| defined(__DOXYGEN__)*/
/*===========================================================================*/
/* Driver hardware support. */
/*===========================================================================*/
#define TOUCHSCREEN_HAS_PRESSED TRUE
#define TOUCHSCREEN_HAS_PRESSURE TRUE
struct TouchscreenDriver {
/*
* @brief Pointer to SPI driver.
* @note SPI driver must be enabled in mcuconf.h and halconf.h
*/
SPIDriver *spip;
/*
* @brief Pointer to the SPI configuration structure.
* @note The lowest possible speed ~ 1-2MHz is to be used, otherwise
* will result in a lot of noise
*/
const SPIConfig *spicfg;
/*
* @brief Touchscreen controller TPIRQ pin GPIO port
*/
ioportid_t tsIRQPort;
/*
* @brief Touchscreen controller TPIRQ GPIO pin
* @note The interface is polled as of now, interrupt support is
* to be implemented in the future.
*/
ioportmask_t tsIRQPin;
/*
* @brief Initialize the SPI with the configuration struct given or not
* If TRUE, spiStart is called by the init, otherwise not
* @note This is provided in such a case when SPI port is being shared
* across multiple peripherals, so not to disturb the SPI bus.
* You can use TOUCHSCREEN_SPI_PROLOGUE() and TOUCHSCREEN_SPI_EPILOGUE()
* macros to change the SPI configuration or speed before and
* after using the touchpad. An example case would be sharing the
* bus with a fast flash memory chip.
*/
bool_t direct_init;
};
#endif /* GFX_USE_TOUCHSCREEN */
#endif /* TOUCHSCREEN_LLD_CONFIG_H */
/** @} */

View File

@ -80,3 +80,4 @@
*/
#endif /* _GFXCONF_H */

View File

@ -23,6 +23,11 @@
* @brief GDISP Graphic Driver subsystem header file.
*
* @addtogroup GDISP
*
* @details The GDISP module provides high level abstraction to interface pixel oriented graphic displays.
*
* @pre GFX_USE_GDISP must be set to TRUE in gfxconf.h
*
* @{
*/

View File

@ -19,7 +19,7 @@
*/
/**
* @file include/lld/gdisp/gdisp_lld_msgs.h
* @file include/gdisp/lld/gdisp_lld_msgs.h
* @brief GDISP Graphic Driver subsystem low level driver message structures.
*
* @addtogroup GDISP

View File

@ -22,6 +22,12 @@
* @brief GEVENT GFX User Event subsystem header file.
*
* @addtogroup GEVENT
*
* @details GEVENT provides a simple to use but yet powerful event
* system.
*
* @pre GFX_USE_GEVENT must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GEVENT_H
@ -31,13 +37,9 @@
#if GFX_USE_GEVENT || defined(__DOXYGEN__)
/**
* @brief Data part of a static GListener initializer.
*/
/* Data part of a static GListener initializer */
#define _GLISTENER_DATA(name) { _SEMAPHORE_DATA(name.waitqueue, 0), _BSEMAPHORE_DATA(name.eventlock, FALSE), 0, 0, {0} }
/**
* @brief Static GListener initializer.
*/
/* Static GListener initializer */
#define GLISTENER_DECL(name) GListener name = _GLISTENER_DATA(name)
/*===========================================================================*/
@ -120,79 +122,118 @@ extern "C" {
/*---------- Listener Functions --------------------------------------------*/
/* Initialise a Listener.
/**
* @brief Create a Listener
* @details If insufficient resources are available it will either assert or return NULL
* depending on the value of GEVENT_ASSERT_NO_RESOURCE.
*
* @param[in] pl A listener
*/
void geventListenerInit(GListener *pl);
/* Attach a source to a listener.
* Flags are interpreted by the source when generating events for each listener.
* If this source is already assigned to the listener it will update the flags.
* If insufficient resources are available it will either assert or return FALSE
* depending on the value of GEVENT_ASSERT_NO_RESOURCE.
/**
* @brief Attach a source to a listener
* @details Flags are interpreted by the source when generating events for each listener.
* If this source is already assigned to the listener it will update the flags.
* If insufficient resources are available it will either assert or return FALSE
* depending on the value of GEVENT_ASSERT_NO_RESOURCE.
*
* @param[in] pl The listener
* @param[in] gsh The source which has to be attached to the listener
* @param[in] flags The flags
*
* @return TRUE if succeeded, FALSE otherwise
*/
bool_t geventAttachSource(GListener *pl, GSourceHandle gsh, unsigned flags);
/* Detach a source from a listener
* If gsh is NULL detach all sources from this listener and if there is still
* a thread waiting for events on this listener, it is sent the exit event.
/**
* @brief Detach a source from a listener
* @details If gsh is NULL detach all sources from this listener and if there is still
* a thread waiting for events on this listener, it is sent the exit event.
*
* @param[in] pl The listener
* @param[in] gsh The source
*/
void geventDetachSource(GListener *pl, GSourceHandle gsh);
/* Wait for an event on a listener from an assigned source.
* The type of the event should be checked (pevent->type) and then pevent should be typecast to the
* actual event type if it needs to be processed.
* timeout specifies the time to wait in system ticks.
* TIME_INFINITE means no timeout - wait forever for an event.
* TIME_IMMEDIATE means return immediately
* Returns NULL on timeout or if a callback function is already registered.
* Note: The GEvent buffer is staticly allocated within the GListener so the event does not
/**
* @brief Wait for an event on a listener from an assigned source.
* @details The type of the event should be checked (pevent->type) and then pevent should
* be typecast to the actual event type if it needs to be processed.
* timeout specifies the time to wait in system ticks.
* TIME_INFINITE means no timeout - wait forever for an event.
* TIME_IMMEDIATE means return immediately
* @note The GEvent buffer is staticly allocated within the GListener so the event does not
* need to be dynamicly freed however it will get overwritten by the next call to
* this routine.
*
* @param[in] pl The listener
* @param[in] timeout The timeout
*
* @return NULL on timeout
*/
GEvent *geventEventWait(GListener *pl, systime_t timeout);
/* Register a callback for an event on a listener from an assigned source.
* The type of the event should be checked (pevent->type) and then pevent should be typecast to the
* actual event type if it needs to be processed.
* Note: The GEvent buffer is valid only during the time of the callback. The callback MUST NOT save
* a pointer to the buffer for use outside the callback.
* Note: An existing callback function is de-registered by passing a NULL for 'fn'. Any existing
* callback function is replaced. Any thread currently waiting using geventEventWait will be sent the exit event.
* Note: Callbacks occur in a thread context but stack space must be kept to a minumum and
* the callback must process quickly as all other events are performed on a single thread.
* Note: In the callback function you should never call ANY event functions using your own GListener handle
* as it WILL create a deadlock and lock the system up.
* Note: Applications should not use this call - geventEventWait() is the preferred mechanism for an
* application. This call is provided for GUI objects that may not have their own thread.
/* @brief Register a callback for an event on a listener from an assigned source.
* @details The type of the event should be checked (pevent->type) and then pevent should be typecast to the
* actual event type if it needs to be processed.
*
* @params[in] pl The Listener
* @params[in] fn The function to call back
* @params[in] param A parameter to pass the callback function
*
* @note The GEvent buffer is valid only during the time of the callback. The callback MUST NOT save
* a pointer to the buffer for use outside the callback.
* @note An existing callback function is de-registered by passing a NULL for 'fn'. Any existing
* callback function is replaced. Any thread currently waiting using geventEventWait will be sent the exit event.
* @note Callbacks occur in a thread context but stack space must be kept to a minumum and
* the callback must process quickly as all other events are performed on a single thread.
* @note In the callback function you should never call ANY event functions using your own GListener handle
* as it WILL create a deadlock and lock the system up.
* @note Applications should not use this call - geventEventWait() is the preferred mechanism for an
* application. This call is provided for GUI objects that may not have their own thread.
*/
void geventRegisterCallback(GListener *pl, GEventCallbackFn fn, void *param);
/*---------- Source Functions --------------------------------------------*/
/* Sources create their own GSourceHandles which are pointers to any arbitrary structure
typecast to a GSourceHandle.
*/
/* Called by a source with a possible event to get a listener record.
* 'lastlr' should be NULL on the first call and thereafter the result of the previous call.
* It will return NULL when there are no more listeners for this source.
/**
* @brief Called by a source with a possible event to get a listener record.
* @details @p lastlr should be NULL on the first call and thereafter the result of the previous call.
*
* @param[in] gsh The source handler
* @param[in] lastlr The source listener
*
* @return NULL when there are no more listeners for this source
*/
GSourceListener *geventGetSourceListener(GSourceHandle gsh, GSourceListener *lastlr);
/* Get the event buffer from the GSourceListener.
* Returns NULL if the listener is not currently listening.
* A NULL return allows the source to record (perhaps in glr->scrflags) that the listener has missed events.
* This can then be notified as part of the next event for the listener.
* The buffer can only be accessed untill the next call to geventGetSourceListener or geventSendEvent
/**
* @brief Get the event buffer from the GSourceListener.
* @details A NULL return allows the source to record (perhaps in glr->scrflags) that the listener
* has missed events. This can then be notified as part of the next event for the listener.
* The buffer can only be accessed untill the next call to geventGetSourceListener
* or geventSendEvent
*
* @param[in] psl The source listener
*
* @return NULL if the listener is not currently listening.
*/
GEvent *geventGetEventBuffer(GSourceListener *psl);
/* Called by a source to indicate the listener's event buffer has been filled.
* After calling this function the source must not reference in fields in the GSourceListener or the event buffer.
/**
* @brief Called by a source to indicate the listener's event buffer has been filled.
* @details After calling this function the source must not reference in fields in the GSourceListener or the event buffer.
*
* @param[in] psl The source listener
*/
void geventSendEvent(GSourceListener *psl);
/* Detach any listener that has this source attached */
/**
* @brief Detach any listener that has this source attached
*
* @param[in] gsh The source handle
*/
void geventDetachSourceListeners(GSourceHandle gsh);
#ifdef __cplusplus
@ -203,3 +244,4 @@ void geventDetachSourceListeners(GSourceHandle gsh);
#endif /* _GEVENT_H */
/** @} */

View File

@ -21,7 +21,15 @@
* @file include/ginput/dial.h
* @brief GINPUT GFX User Input subsystem header file.
*
* @addtogroup GINPUT
* @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
@ -50,15 +58,58 @@ typedef struct GEventDial_t {
extern "C" {
#endif
/* Dial Functions */
GSourceHandle ginputGetDial(uint16_t instance); // Instance = 0 to n-1
void ginputResetDialRange(uint16_t instance); // Reset the maximum value back to the hardware default.
uint16_t ginputGetDialRange(uint16_t instance); // Get the maximum value. The readings are scaled to be 0...max-1. 0 means over the full uint16_t range.
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 event is generated.
// - This is done after range scaling
/* Get the current keyboard button status.
* Returns FALSE on error (eg invalid instance)
/**
* @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);

View File

@ -22,6 +22,12 @@
* @brief GINPUT GFX User Input subsystem header file.
*
* @addtogroup GINPUT
*
* @details GINPUT provides an easy and common interface to use different input devices
* such as touchscreens and mices.
*
* @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GINPUT_H

View File

@ -21,9 +21,11 @@
* @file include/ginput/keyboard.h
* @brief GINPUT GFX User Input subsystem header file.
*
* @addtogroup GINPUT
* @defgroup Keyboard Keyboard
* @ingroup GINPUT
* @{
*/
#ifndef _GINPUT_KEYBOARD_H
#define _GINPUT_KEYBOARD_H
@ -108,11 +110,22 @@ typedef struct GEventKeyboard_t {
extern "C" {
#endif
/* Keyboard Functions */
GSourceHandle ginputGetKeyboard(uint16_t instance); // Instance = 0 to n-1
/**
* @brief Create a keyboard input instance
*
* @param[in] instance The ID of the keyboard input instance (from 0 to 9999)
*
* @return The source handle of the created input instance
*/
GSourceHandle ginputGetKeyboard(uint16_t instance);
/* Get the current keyboard button status.
* Returns FALSE on error (eg invalid instance)
/**
* @brief Get the current keyboard status
*
* @param[in] instance The ID of the keyboard input instance
* @param[in] pkeyboard The keyboard event struct
*
* @return Returns FALSE on an error (eg invalid instance)
*/
bool_t ginputGetKeyboardStatus(uint16_t instance, GEventKeyboard *pkeyboard);
@ -124,3 +137,4 @@ extern "C" {
#endif /* _GINPUT_KEYBOARD_H */
/** @} */

View File

@ -21,9 +21,11 @@
* @file include/ginput/lld/mouse.h
* @brief GINPUT LLD header file for mouse/touch drivers.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
* @{
*/
#ifndef _LLD_GINPUT_MOUSE_H
#define _LLD_GINPUT_MOUSE_H
@ -116,3 +118,4 @@ extern "C" {
#endif /* _LLD_GINPUT_MOUSE_H */
/** @} */

View File

@ -21,9 +21,11 @@
* @file include/ginput/lld/toggle.h
* @brief GINPUT header file for toggle drivers.
*
* @addtogroup GINPUT_TOGGLE
* @defgroup Toggle Toggle
* @ingroup GINPUT
* @{
*/
#ifndef _LLD_GINPUT_TOGGLE_H
#define _LLD_GINPUT_TOGGLE_H
@ -68,3 +70,4 @@ extern "C" {
#endif /* _LLD_GINPUT_TOGGLE_H */
/** @} */

View File

@ -21,9 +21,18 @@
* @file include/ginput/mouse.h
* @brief GINPUT GFX User Input subsystem header file for mouse and touch.
*
* @addtogroup GINPUT
* @defgroup Mouse Mouse
* @ingroup GINPUT
*
* @details GINPUT allows it to easily interface touchscreens and mices to
* your application.
*
* @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
* @pre GINPUT_NEED_MOUSE must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GINPUT_MOUSE_H
#define _GINPUT_MOUSE_H
@ -85,17 +94,34 @@ typedef struct GEventMouse_t {
extern "C" {
#endif
/* Mouse Functions */
GSourceHandle ginputGetMouse(uint16_t instance); // Instance = 0 to n-1
/**
* @brief Creates an instance of a mouse and returns the Source handler
* @note hack: if the instance is 9999, no calibration will be performed!
*
* @param[in] instance The ID of the mouse input instance (from 0 to 9999)
*
* @return The source handle of the created instance
*/
GSourceHandle ginputGetMouse(uint16_t instance);
/* Get the current mouse position and button status.
* Unlike a listener event, this status cannot record meta events such as "CLICK"
* Returns FALSE on error (eg invalid instance)
/**
* @brief Get the current mouse position and button status
* @note Unlinke a listener event, this status cannot record meta events such as
* "CLICK".
*
* @param[in] instance The ID of the mouse input instance
* @param[in] pmouse The mouse event
*
* @return FALSE on an error (eg. invalid instance)
*/
bool_t ginputGetMouseStatus(uint16_t instance, GEventMouse *pmouse);
/* Run a calibration.
* Returns FALSE if the driver doesn't support it or if the handle is invalid.
/**
* @brief Performs a calibration
*
* @param[in] instance The ID of the mouse input instance
*
* @return FALSE if the driver dosen't support a calibration of if the handle is invalid
*/
bool_t ginputCalibrateMouse(uint16_t instance);
@ -107,9 +133,31 @@ extern "C" {
*/
typedef void (*GMouseCalibrationSaveRoutine)(uint16_t instance, const uint8_t *calbuf, size_t sz); // Save calibration data
typedef const char * (*GMouseCalibrationLoadRoutine)(uint16_t instance); // Load calibration data (returns NULL if not data saved)
/**
* @brief Set the routines to store and restore calibration data
*
* @details This function should be called before first calling ginputGetMouse() for a particular instance
* as the gdispGetMouse() routine may attempt to fetch calibration data and perform a startup calibration if there is no way to get it.
* If this is called after gdispGetMouse() has been called and the driver requires calibration storage, it will immediately save the
* data is has already obtained.
* The 'requireFree' parameter indicates if the fetch buffer must be free()'d to deallocate the buffer provided by the Fetch routine.
*
* @param[in] instance The ID of the mouse input instance
* @param[in] fnsave The routine to save the data
* @param[in] fnload The routine to restore the data
* @param[in] requireFree ToDo
*/
void ginputSetMouseCalibrationRoutines(uint16_t instance, GMouseCalibrationSaveRoutine fnsave, GMouseCalibrationLoadRoutine fnload, bool_t requireFree);
/* Test if a particular mouse/touch instance requires routines to save its calibration data. */
/**
* @brief Test if a particular mouse/touch instance requires routines to save it's alibration data
* @note Not implemented yet
*
* @param[in] instance The ID of the mouse input instance
*
* @return TRUE if needed
*/
bool_t ginputRequireMouseCalibrationStorage(uint16_t instance);
#ifdef __cplusplus
@ -120,3 +168,4 @@ extern "C" {
#endif /* _GINPUT_MOUSE_H */
/** @} */

View File

@ -21,9 +21,18 @@
* @file include/ginput/toggle.h
* @brief GINPUT GFX User Input subsystem header file.
*
* @addtogroup GINPUT
* @defgroup Toggle Toggle
* @ingroup GINPUT
*
* @details GINPUT allows it to interface toggle buttons easily to your
* application.
*
* @pre GFX_USE_GINPUT must be set to TRUE in your gfxconf.h
* @pre GINPUT_NEED_TOGGLE must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GINPUT_TOGGLE_H
#define _GINPUT_TOGGLE_H
@ -65,12 +74,30 @@ typedef struct GEventToggle_t {
extern "C" {
#endif
/* Hardware Toggle/Switch/Button Functions */
GSourceHandle ginputGetToggle(uint16_t instance); // Instance = 0 to n-1
void ginputInvertToggle(uint16_t instance, bool_t invert); // If invert is true, invert the on/off sense for the toggle
/**
* @brief Create a toggle input instance
*
* @param[in] instance The ID of the toggle input instance (from 0 to 9999)
*
* @return The source handle of the created instance
*/
GSourceHandle ginputGetToggle(uint16_t instance);
/* Get the current toggle status.
* Returns FALSE on error (eg invalid instance)
/**
* @brief Can be used to invert the sense of a toggle
*
* @param[in] instance The ID of the toggle input instance
* @param[in] invert If TRUE, will be inverted
*/
void ginputInvertToggle(uint16_t instance, bool_t invert);
/**
* @brief Get the current toggle status
*
* @param[in] instance The ID of the toggle input instance
* @param[in] ptoggle The toggle event struct
*
* @return Returns FALSE on an error (eg invalid instance)
*/
bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle);
@ -82,3 +109,4 @@ extern "C" {
#endif /* _GINPUT_TOGGLE_H */
/** @} */

View File

@ -22,8 +22,21 @@
* @brief GTIMER GFX User Timer subsystem header file.
*
* @addtogroup GTIMER
*
* @details The reason why ChibiOS/GFX has it's own timer abstraction is because
* virtual timers provided by ChibiOS/RT are interrupt context only.
* While great for what they are designed for, they make coding of the input
* drivers much more complex.
* For non-performance critical drivers like these input drivers, it would also
* hog an in-ordinate amount of critical (interrupt locked) system time.
* This contrary to the goals of a real-time operating system. So a user-land
* (thread based) timer mechanism is also required.
*
* @pre GFX_USE_GTIMER must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GTIMER_H
#define _GTIMER_H
@ -35,19 +48,13 @@
/* Type definitions */
/*===========================================================================*/
/**
* @brief Data part of a static GTimer initializer.
*/
/* Data part of a static GTimer initialiser */
#define _GTIMER_DATA() {0,0,0,0,0,0,0}
/**
* @brief Static GTimer initializer.
*/
/* Static GTimer initialiser */
#define GTIMER_DECL(name) GTimer name = _GTIMER_DATA()
/**
* @brief A callback function (executed in a thread context).
*/
/* A callback function (executed in a thread context) */
typedef void (*GTimerFunction)(void *param);
/**
@ -61,7 +68,7 @@ typedef struct GTimer_t {
uint16_t flags;
struct GTimer_t *next;
struct GTimer_t *prev;
} GTimer;
} GTimer;
/*===========================================================================*/
/* External declarations. */
@ -71,11 +78,97 @@ typedef struct GTimer_t {
extern "C" {
#endif
/**
* @brief Initialise a timer.
*
* @param[in] pt pointer to a GTimer structure
*
* @api
*/
void gtimerInit(GTimer *pt);
/**
* @brief Set a timer going or alter its properties if it is already going.
*
* @param[in] pt Pointer to a GTimer structure
* @param[in] fn The callback function
* @param[in] param The parameter to pass to the callback function
* @param[in] periodic Is the timer a periodic timer? FALSE is a once-only timer.
* @param[in] millisec The timer period. The following special values are allowed:
* TIME_IMMEDIATE causes the callback function to be called asap.
* A periodic timer with this value will fire once only.
* TIME_INFINITE never timeout (unless triggered by gtimerJab or gtimerJabI)
*
* @note If the timer is already active its properties are updated with the new parameters.
* The current period will be immediately canceled (without the callback function being
* called) and the timer will be restart with the new timer properties.
* @note The callback function should be careful not to over-run the thread stack.
* Define a new value for the macro GTIME_THREAD_STACK_SIZE if you want to
* change the default size.
* @note The callback function should return as quickly as possible as all
* timer callbacks are performed by a single thread. If a callback function
* takes too long it could affect the timer response for other timers.
* @note A timer callback function is not a replacement for a dedicated thread if the
* function wants to perform computationally expensive stuff.
* @note As the callback function is called on GTIMER's thread, the function must make sure it uses
* appropriate synchronisation controls such as semaphores or mutexes around any data
* structures it shares with other threads such as the main application thread.
*
* @api
*/
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, systime_t millisec);
/**
* @brief Stop a timer (periodic or otherwise)
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
*
* @api
*/
void gtimerStop(GTimer *pt);
/**
* @brief Test if a timer is currently active
*
* @param[in] pt Pointer to a GTimer structure
*
* @return TRUE if active, FALSE otherwise
*
* @api
*/
bool_t gtimerIsActive(GTimer *pt);
/**
* @brief Jab a timer causing the current period to immediate expire
* @details The callback function will be called as soon as possible.
*
* @pre Use from a normal thread context.
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
* @note Repeated Jabs before the callback function actually happens are ignored.
*
* @api
*/
void gtimerJab(GTimer *pt);
/**
* @brief Jab a timer causing the current period to immediate expire
* @details The callback function will be called as soon as possible.
*
* @pre Use from an interrupt routine context.
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
* @note Repeated Jabs before the callback function actually happens are ignored.
*
* @iclass
* @api
*/
void gtimerJabI(GTimer *pt);
#ifdef __cplusplus

View File

@ -21,9 +21,18 @@
* @file include/gwin/button.h
* @brief GWIN Graphic window subsystem header file.
*
* @addtogroup GWIN
* @defgroup Button Button
* @ingroup GWIN
*
* @details GWIN allows it to easily create buttons with different styles
* and check for different meta states such as: PRESSED, CLICKED,
* RELEASED etc.
*
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
* @pre GWIN_NEED_BUTTON must be set to TRUE in your gfxconf.h
* @{
*/
#ifndef _GWIN_BUTTON_H
#define _GWIN_BUTTON_H

View File

@ -21,9 +21,18 @@
* @file include/gwin/console.h
* @brief GWIN Graphic window subsystem header file.
*
* @addtogroup GWIN
* @defgroup Console Console
* @ingroup GWIN
*
* @details GWIN allows it to create a console/terminal like window.
* You can simply use chprintf() to print to the terminal.
*
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
* @pre GWIN_NEED_CONSOLE must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GWIN_CONSOLE_H
#define _GWIN_CONSOLE_H

View File

@ -22,7 +22,13 @@
* @file include/gwin/graph.h
* @brief GWIN GRAPH module header file.
*
* @addtogroup GWIN_GRAPH
* @defgroup Graph Graph
* @ingroup GWIN
*
* @details GWIN allows it to easily draw graphs.
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
* @pre GWIN_NEED_GRAPH must be set to TRUE in your gfxconf.h
*
* @{
*/

View File

@ -21,9 +21,20 @@
* @file include/gwin/gwin.h
* @brief GWIN Graphic window subsystem header file.
*
* @addtogroup GWIN
* @defgroup Window Window
* @ingroup GWIN
*
* @details GWIN provides a basic window manager which allows it to easily
* create and destroy different windows on runtime. Each window
* will have it's own properties such as colors, brushes as well as
* it's own drawing origin.
* Moving the windows around is not supported yet.
*
* @pre GFX_USE_GWIN must be set to TRUE in your gfxconf.h
*
* @{
*/
#ifndef _GWIN_H
#define _GWIN_H

View File

@ -19,7 +19,7 @@
*/
/**
* @file include/gwin_options.h
* @file include/gwin/options.h
* @brief GWIN sub-system options header file.
*
* @addtogroup GWIN
@ -45,9 +45,9 @@
* @details Defaults to FALSE
* @note To use chprintf() for printing in a console window you need to
* include in your application source file...
* #include "chprintf.h"
* #include "chprintf.h"
* Also in your makefile, as part of your list of C source files, include
* ${CHIBIOS}/os/various/chprintf.c
* ${CHIBIOS}/os/various/chprintf.c
*/
#ifndef GWIN_NEED_CONSOLE
#define GWIN_NEED_CONSOLE FALSE

View File

@ -2,7 +2,7 @@
*** Releases ***
*****************************************************************************
current stable: 1.4
current release: 1.5
*** changes after 1.4 ***
@ -22,6 +22,8 @@ DEPRECATE: graph deprecated - replaced with gwin functionality
DEPRECATE: touchscreen deprecated - replaced with ginput functionality
FEATURE: Numerous documentation improvements
FEATURE: Added a number of module demo and test programs
DEPRECATE: Remove of XPT2046 since full compatibility with ADS7843
*** changes after 1.3 ***
FIX: Nokia 6610 fix

View File

@ -737,7 +737,7 @@ static bool_t matchfont(const char *pattern, const char *name) {
* @details The supplied name is matched against the font name. A '*' will replace 0 or more characters.
* @return Returns a font or NULL if no matching font could be found.
*
* @params[in] name The font name to find.
* @param[in] name The font name to find.
*
* @note Wildcard matching will match the shortest possible match.
*
@ -756,7 +756,7 @@ font_t gdispOpenFont(const char *name) {
/**
* @brief Release a font after use.
*
* @params[in] font The font to release.
* @param[in] font The font to release.
*
* @api
*/
@ -768,7 +768,7 @@ void gdispCloseFont(font_t font) {
* @brief Get the name of the specified font.
* @returns The name of the font.
*
* @params[in] font The font to get the name for.
* @param[in] font The font to get the name for.
*
* @api
*/

View File

@ -19,7 +19,7 @@
*/
/**
* @file src/gdisp.c
* @file src/gdisp/gdisp.c
* @brief GDISP Driver code.
*
* @addtogroup GDISP

View File

@ -19,7 +19,7 @@
*/
/**
* @file src/gevent.c
* @file src/gevent/gevent.c
* @brief GEVENT Driver code.
*
* @addtogroup GEVENT
@ -61,13 +61,6 @@ static void deleteAssignments(GListener *pl, GSourceHandle gsh) {
}
}
/**
* @brief Create a Listener
* @details If insufficient resources are available it will either assert or return NULL
* depending on the value of GEVENT_ASSERT_NO_RESOURCE.
*
* @param[in] pl A listener
*/
void geventListenerInit(GListener *pl) {
chSemInit(&pl->waitqueue, 0); // Next wait'er will block
chBSemInit(&pl->eventlock, FALSE); // Only one thread at a time looking at the event buffer
@ -75,19 +68,6 @@ void geventListenerInit(GListener *pl) {
pl->event.type = GEVENT_NULL; // Always safety
}
/**
* @brief Attach a source to a listener
* @details Flags are interpreted by the source when generating events for each listener.
* If this source is already assigned to the listener it will update the flags.
* If insufficient resources are available it will either assert or return FALSE
* depending on the value of GEVENT_ASSERT_NO_RESOURCE.
*
* @param[in] pl The listener
* @param[in] gsh The source which has to be attached to the listener
* @param[in] flags The flags
*
* @return TRUE if succeeded, FALSE otherwise
*/
bool_t geventAttachSource(GListener *pl, GSourceHandle gsh, unsigned flags) {
GSourceListener *psl, *pslfree;
@ -127,14 +107,6 @@ bool_t geventAttachSource(GListener *pl, GSourceHandle gsh, unsigned flags) {
return pslfree != 0;
}
/**
* @brief Detach a source from a listener
* @details If gsh is NULL detach all sources from this listener and if there is still
* a thread waiting for events on this listener, it is sent the exit event.
*
* @param[in] pl The listener
* @param[in] gsh The source
*/
void geventDetachSource(GListener *pl, GSourceHandle gsh) {
if (pl && gsh) {
chMtxLock(&geventMutex);
@ -149,47 +121,12 @@ void geventDetachSource(GListener *pl, GSourceHandle gsh) {
}
}
/**
* @brief Wait for an event on a listener from an assigned source.
* @details The type of the event should be checked (pevent->type) and then pevent should
* be typecast to the actual event type if it needs to be processed.
* timeout specifies the time to wait in system ticks.
* TIME_INFINITE means no timeout - wait forever for an event.
* TIME_IMMEDIATE means return immediately
* @note The GEvent buffer is staticly allocated within the GListener so the event does not
* need to be dynamicly freed however it will get overwritten by the next call to
* this routine.
*
* @param[in] pl The listener
* @param[in] timeout The timeout
*
* @return NULL on timeout
*/
GEvent *geventEventWait(GListener *pl, systime_t timeout) {
if (pl->callback || chSemGetCounterI(&pl->waitqueue) < 0)
return 0;
return chSemWaitTimeout(&pl->waitqueue, timeout) == RDY_OK ? &pl->event : 0;
}
/* @brief Register a callback for an event on a listener from an assigned source.
* @details The type of the event should be checked (pevent->type) and then pevent should be typecast to the
* actual event type if it needs to be processed.
*
* @params[in] pl The Listener
* @params[in] fn The function to call back
* @params[in] param A parameter to pass the callback function
*
* @note The GEvent buffer is valid only during the time of the callback. The callback MUST NOT save
* a pointer to the buffer for use outside the callback.
* @note An existing callback function is de-registered by passing a NULL for 'fn'. Any existing
* callback function is replaced. Any thread currently waiting using geventEventWait will be sent the exit event.
* @note Callbacks occur in a thread context but stack space must be kept to a minumum and
* the callback must process quickly as all other events are performed on a single thread.
* @note In the callback function you should never call ANY event functions using your own GListener handle
* as it WILL create a deadlock and lock the system up.
* @note Applications should not use this call - geventEventWait() is the preferred mechanism for an
* application. This call is provided for GUI objects that may not have their own thread.
*/
void geventRegisterCallback(GListener *pl, GEventCallbackFn fn, void *param) {
if (pl) {
chMtxLock(&geventMutex);
@ -205,15 +142,6 @@ void geventRegisterCallback(GListener *pl, GEventCallbackFn fn, void *param) {
}
}
/**
* @brief Called by a source with a possible event to get a listener record.
* @details @p lastlr should be NULL on the first call and thereafter the result of the previous call.
*
* @param[in] gsh The source handler
* @param[in] lastlr The source listener
*
* @return NULL when there are no more listeners for this source
*/
GSourceListener *geventGetSourceListener(GSourceHandle gsh, GSourceListener *lastlr) {
GSourceListener *psl;
@ -239,28 +167,11 @@ GSourceListener *geventGetSourceListener(GSourceHandle gsh, GSourceListener *las
return 0;
}
/**
* @brief Get the event buffer from the GSourceListener.
* @details A NULL return allows the source to record (perhaps in glr->scrflags) that the listener
* has missed events. This can then be notified as part of the next event for the listener.
* The buffer can only be accessed untill the next call to geventGetSourceListener
* or geventSendEvent
*
* @param[in] psl The source listener
*
* @return NULL if the listener is not currently listening.
*/
GEvent *geventGetEventBuffer(GSourceListener *psl) {
// We already know we have the event lock
return &psl->pListener->callback || chSemGetCounterI(&psl->pListener->waitqueue) < 0 ? &psl->pListener->event : 0;
}
/**
* @brief Called by a source to indicate the listener's event buffer has been filled.
* @details After calling this function the source must not reference in fields in the GSourceListener or the event buffer.
*
* @param[in] psl The source listener
*/
void geventSendEvent(GSourceListener *psl) {
chMtxLock(&geventMutex);
if (psl->pListener->callback) { // This test needs to be taken inside the mutex
@ -276,11 +187,6 @@ void geventSendEvent(GSourceListener *psl) {
}
}
/**
* @brief Detach any listener that has this source attached
*
* @param[in] gsh The source handle
*/
void geventDetachSourceListeners(GSourceHandle gsh) {
chMtxLock(&geventMutex);
deleteAssignments(0, gsh);

View File

@ -22,7 +22,8 @@
* @file src/ginput/dial.c
* @brief GINPUT dial code.
*
* @addtogroup GINPUT
* @defgroup Dial Dial
* @ingroup GINPUT
* @{
*/
#include "ch.h"

View File

@ -22,9 +22,12 @@
* @file src/ginput/keyboard.c
* @brief GINPUT keyboard code.
*
* @addtogroup GINPUT
* @defgroup Keyboard Keyboard
* @ingroup GINPUT
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"

View File

@ -22,7 +22,8 @@
* @file src/ginput/mouse.c
* @brief GINPUT mouse/touch code.
*
* @addtogroup GINPUT_MOUSE
* @defgroup Mouse Mouse
* @ingroup GINPUT
* @{
*/
#include "ch.h"
@ -322,7 +323,6 @@ static void MousePoll(void *param) {
}
}
/* Mouse Functions */
GSourceHandle ginputGetMouse(uint16_t instance) {
#if GINPUT_MOUSE_NEED_CALIBRATION
Calibration *pc;
@ -377,10 +377,6 @@ GSourceHandle ginputGetMouse(uint16_t instance) {
return (GSourceHandle)&MouseConfig;
}
/* Get the current mouse position and button status.
* Unlike a listener event, this status cannot record meta events such as "CLICK"
* Returns FALSE on error (eg invalid instance)
*/
bool_t ginputGetMouseStatus(uint16_t instance, GEventMouse *pe) {
if (instance || (MouseConfig.flags & (FLG_INIT_DONE|FLG_IN_CAL)) != FLG_INIT_DONE)
return FALSE;
@ -401,9 +397,6 @@ bool_t ginputGetMouseStatus(uint16_t instance, GEventMouse *pe) {
return TRUE;
}
/* Run a mouse calibration.
* Returns FALSE if the driver doesn't support it or if the handle is invalid.
*/
bool_t ginputCalibrateMouse(uint16_t instance) {
#if !GINPUT_MOUSE_NEED_CALIBRATION
(void) instance;
@ -527,6 +520,7 @@ bool_t ginputCalibrateMouse(uint16_t instance) {
MouseConfig.fnsavecal(instance, (const uint8_t *)&MouseConfig.caldata, sizeof(MouseConfig.caldata));
MouseConfig.flags |= FLG_CAL_SAVED;
}
return TRUE;
#endif
}

View File

@ -22,7 +22,8 @@
* @file src/ginput/toggle.c
* @brief GINPUT toggle code.
*
* @addtogroup GINPUT_TOGGLE
* @defgroup Toggle Toggle
* @ingroup GINPUT
* @{
*/
#include "ch.h"

View File

@ -43,7 +43,7 @@
/* Don't rework this macro to use a ternary operator - the gcc compiler stuffs it up */
#define TimeIsWithin(x, start, end) ((end >= start && x >= start && x <= end) || (end < start && (x >= start || x <= end)))
// This mutex protects access to our tables
/* This mutex protects access to our tables */
static MUTEX_DECL(mutex);
static Thread *pThread = 0;
static GTimer *pTimerHead = 0;
@ -141,46 +141,10 @@ static msg_t GTimerThreadHandler(void *arg) {
return 0;
}
/**
* @brief Initialise a timer.
*
* @param[in] pt pointer to a GTimer structure
*
* @api
*/
void gtimerInit(GTimer *pt) {
pt->flags = 0;
}
/**
* @brief Set a timer going or alter its properties if it is already going.
*
* @param[in] pt Pointer to a GTimer structure
* @param[in] fn The callback function
* @param[in] param The parameter to pass to the callback function
* @param[in] periodic Is the timer a periodic timer? FALSE is a once-only timer.
* @param[in] millisec The timer period. The following special values are allowed:
* TIME_IMMEDIATE causes the callback function to be called asap.
* A periodic timer with this value will fire once only.
* TIME_INFINITE never timeout (unless triggered by gtimerJab or gtimerJabI)
*
* @note If the timer is already active its properties are updated with the new parameters.
* The current period will be immediately canceled (without the callback function being
* called) and the timer will be restart with the new timer properties.
* @note The callback function should be careful not to over-run the thread stack.
* Define a new value for the macro GTIME_THREAD_STACK_SIZE if you want to
* change the default size.
* @note The callback function should return as quickly as possible as all
* timer callbacks are performed by a single thread. If a callback function
* takes too long it could affect the timer response for other timers.
* @note A timer callback function is not a replacement for a dedicated thread if the
* function wants to perform computationally expensive stuff.
* @note As the callback function is called on GTIMER's thread, the function must make sure it uses
* appropriate synchronisation controls such as semaphores or mutexes around any data
* structures it shares with other threads such as the main application thread.
*
* @api
*/
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, systime_t millisec) {
chMtxLock(&mutex);
@ -230,15 +194,6 @@ void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, sy
chMtxUnlock();
}
/**
* @brief Stop a timer (periodic or otherwise)
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
*
* @api
*/
void gtimerStop(GTimer *pt) {
chMtxLock(&mutex);
if (pt->flags & GTIMER_FLG_SCHEDULED) {
@ -257,32 +212,10 @@ void gtimerStop(GTimer *pt) {
chMtxUnlock();
}
/**
* @brief Test if a timer is currently active
*
* @param[in] pt Pointer to a GTimer structure
*
* @return TRUE if active, FALSE otherwise
*
* @api
*/
bool_t gtimerIsActive(GTimer *pt) {
return (pt->flags & GTIMER_FLG_SCHEDULED) ? TRUE : FALSE;
}
/**
* @brief Jab a timer causing the current period to immediate expire
* @details The callback function will be called as soon as possible.
*
* @pre Use from a normal thread context.
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
* @note Repeated Jabs before the callback function actually happens are ignored.
*
* @api
*/
void gtimerJab(GTimer *pt) {
chMtxLock(&mutex);
@ -294,20 +227,6 @@ void gtimerJab(GTimer *pt) {
chMtxUnlock();
}
/**
* @brief Jab a timer causing the current period to immediate expire
* @details The callback function will be called as soon as possible.
*
* @pre Use from an interrupt routine context.
*
* @param[in] pt Pointer to a GTimer structure
*
* @note If the timer is not active this does nothing.
* @note Repeated Jabs before the callback function actually happens are ignored.
*
* @iclass
* @api
*/
void gtimerJabI(GTimer *pt) {
// Jab it!
pt->flags |= GTIMER_FLG_JABBED;
@ -318,3 +237,4 @@ void gtimerJabI(GTimer *pt) {
#endif /* GFX_USE_GTIMER */
/** @} */

View File

@ -17,14 +17,16 @@
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 src/gwin/button.c
* @brief GWIN sub-system button code.
*
* @addtogroup GWIN_BUTTON
* @defgroup Button Button
* @ingroup GWIN
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"

View File

@ -17,14 +17,16 @@
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 src/gwin/console.c
* @brief GWIN sub-system console code.
*
* @addtogroup GWIN_CONSOLE
* @defgroup Console Console
* @ingroup GWIN
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"

View File

@ -17,14 +17,16 @@
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 src/gwin/button.c
* @brief GWIN sub-system button code.
*
* @addtogroup GWIN_BUTTON
* @defgroup Button Button
* @ingroup GWIN
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"

View File

@ -17,14 +17,16 @@
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 src/gwin/gwin.c
* @brief GWIN sub-system code.
*
* @addtogroup GWIN
* @defgroup Window Window
* @ingroup GWIN
*
* @{
*/
#include "ch.h"
#include "hal.h"
#include "gfx.h"