diff options
| author | qiuyiuestc <[email protected]> | 2010-05-15 01:11:18 +0000 |
|---|---|---|
| committer | qiuyiuestc <[email protected]> | 2010-05-15 01:11:18 +0000 |
| commit | 3f33f036ece9d33a35aa41a7b9e09c10a47e9d5a (patch) | |
| tree | f0aff1c25c79e3987c8fdf609714f7446a2b9693 /bsp/mini2440 | |
| parent | ca81f820f36390ce54256adbdcf5f2d9c8675095 (diff) | |
[mini2440]fix bugs in touch driver
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@709 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'bsp/mini2440')
| -rw-r--r-- | bsp/mini2440/lcd_t35.c | 2 | ||||
| -rw-r--r-- | bsp/mini2440/touch.c | 107 |
2 files changed, 59 insertions, 50 deletions
diff --git a/bsp/mini2440/lcd_t35.c b/bsp/mini2440/lcd_t35.c index 752a4684fa..bd36be8b9f 100644 --- a/bsp/mini2440/lcd_t35.c +++ b/bsp/mini2440/lcd_t35.c @@ -177,7 +177,7 @@ void rt_hw_lcd_update(rtgui_rect_t *rect) pitch = 2 * (rect->x2 - rect->x1);
- rt_kprintf("update (%d,%d - %d,%d)\n", rect->x1, rect->y1, rect->x2, rect->y2);
+ /* rt_kprintf("update (%d,%d - %d,%d)\n", rect->x1, rect->y1, rect->x2, rect->y2); */
/* copy from framebuffer to physical framebuffer */
src_ptr = &_rt_framebuffer[rect->x1][rect->y1];
diff --git a/bsp/mini2440/touch.c b/bsp/mini2440/touch.c index c1d30aa442..a8400aea64 100644 --- a/bsp/mini2440/touch.c +++ b/bsp/mini2440/touch.c @@ -3,6 +3,7 @@ #include <s3c24x0.h>
#include <rtgui/rtgui_system.h>
#include <rtgui/rtgui_server.h>
+#include <rtgui/event.h>
#include "touch.h"
@@ -82,13 +83,12 @@ struct rtgui_touch_device static struct rtgui_touch_device *touch = RT_NULL;
static int first_down_report;
-#include <rtgui/event.h>
static void report_touch_input(int updown)
{
struct rtgui_event_mouse emouse;
/* set emouse button */
- emouse.button |= RTGUI_MOUSE_BUTTON_LEFT;
+ emouse.button = RTGUI_MOUSE_BUTTON_LEFT;
emouse.parent.sender = RT_NULL;
if (updown)
@@ -96,15 +96,19 @@ static void report_touch_input(int updown) ts.xp = ts.xp / ts.count;
ts.yp = ts.yp / ts.count;;
- ts.xp = 240 * (ts.xp-touch->min_x)/(touch->max_x-touch->min_x);
- ts.yp = 320 - (320*(ts.yp-touch->min_y)/(touch->max_y-touch->min_y));
-
- touch->x = ts.xp;
- touch->y = ts.yp;
+ if ((touch->calibrating == RT_TRUE) && (touch->calibration_func != RT_NULL))
+ {
+ touch->x = ts.xp;
+ touch->y = ts.yp;
+ }
+ else
+ {
+ touch->x = 240 * (ts.xp-touch->min_x)/(touch->max_x-touch->min_x);
+ touch->y = 320 - (320*(ts.yp-touch->min_y)/(touch->max_y-touch->min_y));
+ }
emouse.x = touch->x;
emouse.y = touch->y;
-
if(first_down_report == 1)
{
emouse.parent.type = RTGUI_EVENT_MOUSE_BUTTON;
@@ -291,59 +295,64 @@ static rt_err_t rtgui_touch_init (rt_device_t dev) static rt_err_t rtgui_touch_control (rt_device_t dev, rt_uint8_t cmd, void *args)
{
- switch (cmd)
- {
- case RT_TOUCH_CALIBRATION:
- touch->calibrating = RT_TRUE;
- touch->calibration_func = (rt_touch_calibration_func_t)args;
- break;
+ switch (cmd)
+ {
+ case RT_TOUCH_CALIBRATION:
+ touch->calibrating = RT_TRUE;
+ touch->calibration_func = (rt_touch_calibration_func_t)args;
+ break;
+
+ case RT_TOUCH_NORMAL:
+ touch->calibrating = RT_FALSE;
+ break;
- case RT_TOUCH_NORMAL:
- touch->calibrating = RT_FALSE;
- break;
+ case RT_TOUCH_CALIBRATION_DATA:
+ {
+ struct calibration_data* data;
- case RT_TOUCH_CALIBRATION_DATA:
- {
- struct calibration_data* data;
+ data = (struct calibration_data*) args;
- data = (struct calibration_data*) args;
+ //update
+ touch->min_x = data->min_x;
+ touch->max_x = data->max_x;
+ touch->min_y = data->max_y;
+ touch->max_y = data->min_y;
- //update
- touch->min_x = data->min_x;
- touch->max_x = data->max_x;
- touch->min_y = data->min_y;
- touch->max_y = data->max_y;
- }
- break;
- }
+ /*
+ rt_kprintf("min_x = %d, max_x = %d, min_y = %d, max_y = %d\n",
+ touch->min_x, touch->max_x, touch->min_y, touch->max_y);
+ */
+ }
+ break;
+ }
- return RT_EOK;
+ return RT_EOK;
}
void rtgui_touch_hw_init(void)
{
- touch = (struct rtgui_touch_device*)rt_malloc (sizeof(struct rtgui_touch_device));
- if (touch == RT_NULL) return; /* no memory yet */
+ touch = (struct rtgui_touch_device*)rt_malloc (sizeof(struct rtgui_touch_device));
+ if (touch == RT_NULL) return; /* no memory yet */
- /* clear device structure */
- rt_memset(&(touch->parent), 0, sizeof(struct rt_device));
- touch->calibrating = RT_FALSE;
- touch->min_x = X_MIN;
- touch->max_x = X_MAX;
- touch->min_y = Y_MIN;
- touch->max_y = X_MAX;
+ /* clear device structure */
+ rt_memset(&(touch->parent), 0, sizeof(struct rt_device));
+ touch->calibrating = RT_FALSE;
+ touch->min_x = X_MIN;
+ touch->max_x = X_MAX;
+ touch->min_y = Y_MIN;
+ touch->max_y = X_MAX;
- /* init device structure */
- touch->parent.type = RT_Device_Class_Unknown;
- touch->parent.init = rtgui_touch_init;
- touch->parent.control = rtgui_touch_control;
- touch->parent.private = RT_NULL;
+ /* init device structure */
+ touch->parent.type = RT_Device_Class_Unknown;
+ touch->parent.init = rtgui_touch_init;
+ touch->parent.control = rtgui_touch_control;
+ touch->parent.private = RT_NULL;
- /* create 1/8 second timer */
- touch->poll_timer = rt_timer_create("touch", touch_timer_fire, RT_NULL,
- RT_TICK_PER_SECOND/8, RT_TIMER_FLAG_PERIODIC);
+ /* create 1/8 second timer */
+ touch->poll_timer = rt_timer_create("touch", touch_timer_fire, RT_NULL,
+ RT_TICK_PER_SECOND/8, RT_TIMER_FLAG_PERIODIC);
- /* register touch device to RT-Thread */
- rt_device_register(&(touch->parent), "touch", RT_DEVICE_FLAG_RDWR);
+ /* register touch device to RT-Thread */
+ rt_device_register(&(touch->parent), "touch", RT_DEVICE_FLAG_RDWR);
}
|
