Added touch to gdisp Win32 driver
GDISP Win32 driver: Fixed a window sizing bug Added hardware scroll support Added touchscreen integrated driver into this driver
This commit is contained in:
parent
c069817f0c
commit
77e1371b86
4 changed files with 173 additions and 7 deletions
drivers/gdisp/Win32
|
@ -29,6 +29,7 @@
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "gdisp.h"
|
#include "gdisp.h"
|
||||||
|
#include "touchscreen.h"
|
||||||
|
|
||||||
#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/
|
#if GFX_USE_GDISP /*|| defined(__DOXYGEN__)*/
|
||||||
|
|
||||||
|
@ -56,6 +57,8 @@ static HDC dcBuffer = NULL;
|
||||||
static HBITMAP dcBitmap = NULL;
|
static HBITMAP dcBitmap = NULL;
|
||||||
static HBITMAP dcOldBitmap;
|
static HBITMAP dcOldBitmap;
|
||||||
static volatile bool_t isReady = FALSE;
|
static volatile bool_t isReady = FALSE;
|
||||||
|
static coord_t mousex, mousey;
|
||||||
|
static bool_t mousedn;
|
||||||
|
|
||||||
static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
@ -65,9 +68,20 @@ static LRESULT myWindowProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||||
switch (Msg) {
|
switch (Msg) {
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
break;
|
break;
|
||||||
case WM_MOUSEMOVE:
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
|
mousedn = TRUE;
|
||||||
|
mousex = (coord_t)LOWORD(lParam);
|
||||||
|
mousey = (coord_t)HIWORD(lParam);
|
||||||
|
break;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
|
mousedn = FALSE;
|
||||||
|
mousex = (coord_t)LOWORD(lParam);
|
||||||
|
mousey = (coord_t)HIWORD(lParam);
|
||||||
|
break;
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
mousex = (coord_t)LOWORD(lParam);
|
||||||
|
mousey = (coord_t)HIWORD(lParam);
|
||||||
|
break;
|
||||||
case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDBLCLK:
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
case WM_MBUTTONUP:
|
case WM_MBUTTONUP:
|
||||||
|
@ -129,13 +143,18 @@ static DWORD WINAPI WindowThread(LPVOID lpParameter) {
|
||||||
wc.lpszClassName = APP_NAME;
|
wc.lpszClassName = APP_NAME;
|
||||||
RegisterClass(&wc);
|
RegisterClass(&wc);
|
||||||
|
|
||||||
|
rect.top = 0; rect.bottom = GDISP.Height;
|
||||||
|
rect.left = 0; rect.right = GDISP.Width;
|
||||||
|
AdjustWindowRect(&rect, WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU, 0);
|
||||||
winRootWindow = CreateWindow(APP_NAME, "", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU, 0, 0,
|
winRootWindow = CreateWindow(APP_NAME, "", WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU, 0, 0,
|
||||||
GDISP.Width, GDISP.Height, 0, 0, hInstance, NULL);
|
rect.right-rect.left, rect.bottom-rect.top, 0, 0, hInstance, NULL);
|
||||||
assert(winRootWindow != NULL);
|
assert(winRootWindow != NULL);
|
||||||
|
|
||||||
HDC dc = GetDC(winRootWindow);
|
HDC dc = GetDC(winRootWindow);
|
||||||
|
|
||||||
GetClientRect(winRootWindow, &rect);
|
GetClientRect(winRootWindow, &rect);
|
||||||
|
GDISP.Width = rect.right-rect.left;
|
||||||
|
GDISP.Height = rect.bottom - rect.top;
|
||||||
dcBitmap = CreateCompatibleBitmap(dc, GDISP.Width, GDISP.Height);
|
dcBitmap = CreateCompatibleBitmap(dc, GDISP.Width, GDISP.Height);
|
||||||
dcBuffer = CreateCompatibleDC(dc);
|
dcBuffer = CreateCompatibleDC(dc);
|
||||||
dcOldBitmap = SelectObject(dcBuffer, dcBitmap);
|
dcOldBitmap = SelectObject(dcBuffer, dcBitmap);
|
||||||
|
@ -430,6 +449,9 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
* @notapi
|
* @notapi
|
||||||
*/
|
*/
|
||||||
void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
|
void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) {
|
||||||
|
RECT rect, frect;
|
||||||
|
HBRUSH hbr;
|
||||||
|
|
||||||
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
|
#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
|
||||||
if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
|
if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
|
||||||
if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; }
|
if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; }
|
||||||
|
@ -437,10 +459,99 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) {
|
||||||
if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x;
|
if (x+cx > GDISP.clipx1) cx = GDISP.clipx1 - x;
|
||||||
if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y;
|
if (y+cy > GDISP.clipy1) cy = GDISP.clipy1 - y;
|
||||||
#endif
|
#endif
|
||||||
/* NOT IMPLEMENTED YET */
|
|
||||||
|
rect.bottom = y+cy;
|
||||||
|
rect.top = y;
|
||||||
|
rect.left = x;
|
||||||
|
rect.right = x+cx;
|
||||||
|
if (cy > lines && cy > -lines)
|
||||||
|
ScrollDC(dcBuffer, 0, -lines, &rect, 0, 0, 0);
|
||||||
|
bgcolor = COLOR2BGR(bgcolor);
|
||||||
|
hbr = CreateSolidBrush(bgcolor);
|
||||||
|
if (hbr) {
|
||||||
|
if (lines > 0) {
|
||||||
|
if (lines > cy) lines = cy;
|
||||||
|
frect.bottom = y+cy;
|
||||||
|
frect.top = y+cy-lines;
|
||||||
|
} else {
|
||||||
|
if (-lines > cy) lines = -cy;
|
||||||
|
frect.top = y;
|
||||||
|
frect.bottom = y-lines;
|
||||||
|
}
|
||||||
|
frect.left = x;
|
||||||
|
frect.right = x+cx;
|
||||||
|
FillRect(dcBuffer, &frect, hbr);
|
||||||
|
}
|
||||||
|
InvalidateRect(winRootWindow, &rect, FALSE);
|
||||||
|
UpdateWindow(winRootWindow);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if GFX_USE_TOUCHSCREEN /*|| defined(__DOXYGEN__)*/
|
||||||
|
|
||||||
|
void ts_store_calibration_lld(struct cal_t *cal) {
|
||||||
|
(void) cal;
|
||||||
|
// Just ignore the calibration data - we implicitly know the calibration
|
||||||
|
}
|
||||||
|
|
||||||
|
struct cal_t *ts_restore_calibration_lld(void) {
|
||||||
|
static struct cal_t cal = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0 };
|
||||||
|
// Our x,y is always already calibrated.
|
||||||
|
return &cal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Low level touchscreen driver initialization.
|
||||||
|
*
|
||||||
|
* @param[in] ts The touchscreen driver
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
void ts_lld_init(const TouchscreenDriver *ts) {
|
||||||
|
(void) ts;
|
||||||
|
// Just ignore everything
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads out the X direction.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
uint16_t ts_lld_read_x(void) {
|
||||||
|
return mousex;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads out the Y direction.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
uint16_t ts_lld_read_y(void) {
|
||||||
|
return mousey;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads out the Z direction.
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
uint16_t ts_lld_read_z(void) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief for checking if touchpad is pressed or not.
|
||||||
|
*
|
||||||
|
* @return 1 if pressed / 0 if not pressed
|
||||||
|
*
|
||||||
|
* @notapi
|
||||||
|
*/
|
||||||
|
uint8_t ts_lld_irq(void) {
|
||||||
|
return (uint8_t)mousedn;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* GFX_USE_TOUCHSCREEN */
|
||||||
|
|
||||||
#endif /* GFX_USE_GDISP */
|
#endif /* GFX_USE_GDISP */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#define GDISP_HARDWARE_LINES TRUE
|
#define GDISP_HARDWARE_LINES TRUE
|
||||||
#define GDISP_HARDWARE_FILLS TRUE
|
#define GDISP_HARDWARE_FILLS TRUE
|
||||||
#define GDISP_HARDWARE_BITFILLS TRUE
|
#define GDISP_HARDWARE_BITFILLS TRUE
|
||||||
#define GDISP_HARDWARE_SCROLL FALSE
|
#define GDISP_HARDWARE_SCROLL TRUE
|
||||||
#define GDISP_HARDWARE_PIXELREAD TRUE
|
#define GDISP_HARDWARE_PIXELREAD TRUE
|
||||||
|
|
||||||
#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
|
#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
To use this driver:
|
To use this driver:
|
||||||
|
|
||||||
|
This driver is special in that it implements both the gdisp low level driver
|
||||||
|
and a touchscreen driver.
|
||||||
|
|
||||||
1. Add in your halconf.h:
|
1. Add in your halconf.h:
|
||||||
a) #define GFX_USE_GDISP TRUE
|
a) #define GFX_USE_GDISP TRUE
|
||||||
b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
|
b) #define GFX_USE_TOUCHSCREEN TRUE
|
||||||
c) All of the following (with appropriate values):
|
c) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD
|
||||||
|
d) All of the following (with appropriate values):
|
||||||
#define GDISP_SCREEN_WIDTH 640
|
#define GDISP_SCREEN_WIDTH 640
|
||||||
#define GDISP_SCREEN_HEIGHT 480
|
#define GDISP_SCREEN_HEIGHT 480
|
||||||
|
|
||||||
|
|
51
drivers/gdisp/Win32/touchscreen_lld_config.h
Normal file
51
drivers/gdisp/Win32/touchscreen_lld_config.h
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
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_IRQ TRUE
|
||||||
|
#define TOUCHSCREEN_HAS_PRESSURE FALSE
|
||||||
|
#define TOUCHSCREEN_XY_INVERTED FALSE
|
||||||
|
#define TOUCHSCREEN_STORE_CALIBRATION TRUE
|
||||||
|
|
||||||
|
/* Nasty stuff to fix SPI dependancy in driver structure (which doesn't exist in Win32) */
|
||||||
|
typedef struct SPIDriver_t {} SPIDriver;
|
||||||
|
typedef struct SPIConfig_t {} SPIConfig;
|
||||||
|
|
||||||
|
#endif /* GFX_USE_TOUCHSCREEN */
|
||||||
|
|
||||||
|
#endif /* TOUCHSCREEN_LLD_CONFIG_H */
|
||||||
|
/** @} */
|
||||||
|
|
Loading…
Add table
Reference in a new issue