diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/drivers/button.c | 48 | ||||
-rw-r--r-- | firmware/export/config-mrobe500.h | 2 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c | 71 | ||||
-rw-r--r-- | firmware/target/arm/tms320dm320/mrobe-500/button-target.h | 3 |
4 files changed, 80 insertions, 44 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 3967dfcc1a..000c4789a5 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -73,7 +73,11 @@ bool phones_present = false; /* speed repeat finishes at, in ticks */ #define REPEAT_INTERVAL_FINISH 5 +#ifdef HAVE_BUTTON_DATA +static int button_read(int *data); +#else static int button_read(void); +#endif static void button_tick(void) { @@ -90,6 +94,11 @@ static void button_tick(void) #endif int diff; int btn; +#ifdef HAVE_BUTTON_DATA + int data = 0; +#else + const int data = 0; +#endif #ifdef HAS_SERIAL_REMOTE /* Post events for the remote control */ @@ -117,7 +126,11 @@ static void button_tick(void) } #endif +#ifdef HAVE_BUTTON_DATA + btn = button_read(&data); +#else btn = button_read(); +#endif /* Find out if a key has been released */ diff = btn ^ lastbtn; @@ -127,17 +140,17 @@ static void button_tick(void) #ifdef HAVE_REMOTE_LCD if(diff & BUTTON_REMOTE) if(!skip_remote_release) - queue_post(&button_queue, BUTTON_REL | diff, 0); + queue_post(&button_queue, BUTTON_REL | diff, data); else skip_remote_release = false; else #endif if(!skip_release) - queue_post(&button_queue, BUTTON_REL | diff, 0); + queue_post(&button_queue, BUTTON_REL | diff, data); else skip_release = false; #else - queue_post(&button_queue, BUTTON_REL | diff, 0); + queue_post(&button_queue, BUTTON_REL | diff, data); #endif } else @@ -212,7 +225,7 @@ static void button_tick(void) * to avoid afterscroll effects. */ if (queue_empty(&button_queue)) { - queue_post(&button_queue, BUTTON_REPEAT | btn, 0); + queue_post(&button_queue, BUTTON_REPEAT | btn, data); #ifdef HAVE_BACKLIGHT #ifdef HAVE_REMOTE_LCD skip_remote_release = false; @@ -232,7 +245,7 @@ static void button_tick(void) || (remote_type()==REMOTETYPE_H300_NONLCD) #endif ) - queue_post(&button_queue, btn, 0); + queue_post(&button_queue, btn, data); else skip_remote_release = true; } @@ -243,11 +256,11 @@ static void button_tick(void) || (btn&BUTTON_REMOTE) #endif ) - queue_post(&button_queue, btn, 0); + queue_post(&button_queue, btn, data); else skip_release = true; #else /* no backlight, nothing to skip */ - queue_post(&button_queue, btn, 0); + queue_post(&button_queue, btn, data); #endif post = false; } @@ -356,13 +369,22 @@ intptr_t button_get_data(void) void button_init(void) { +#ifdef HAVE_BUTTON_DATA + int temp; +#endif /* hardware inits */ button_init_device(); queue_init(&button_queue, true); - + +#ifdef HAVE_BUTTON_DATA + button_read(&temp); + lastbtn = button_read(&temp); +#else button_read(); lastbtn = button_read(); +#endif + tick_add_task(button_tick); reset_poweroff_timer(); @@ -457,9 +479,15 @@ void set_remote_backlight_filter_keypress(bool value) /* * Get button pressed from hardware */ +#ifdef HAVE_BUTTON_DATA +static int button_read(int *data) +{ + int btn = button_read_device(data); +#else static int button_read(void) { int btn = button_read_device(); +#endif int retval; #ifdef HAVE_LCD_BITMAP @@ -469,9 +497,11 @@ static int button_read(void) /* Filter the button status. It is only accepted if we get the same status twice in a row. */ +#ifndef HAVE_TOUCHPAD if (btn != last_read) - retval = lastbtn; + retval = lastbtn; else +#endif retval = btn; last_read = btn; diff --git a/firmware/export/config-mrobe500.h b/firmware/export/config-mrobe500.h index bd0176452f..9cd7a7c478 100644 --- a/firmware/export/config-mrobe500.h +++ b/firmware/export/config-mrobe500.h @@ -77,6 +77,8 @@ #define DEFAULT_REMOTE_CONTRAST_SETTING 7 #define CONFIG_KEYPAD MROBE500_PAD +#define HAVE_TOUCHPAD +#define HAVE_BUTTON_DATA /* Define this if you do software codec */ #define CONFIG_CODEC SWCODEC diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index ea97f6d0db..f31c6ecb9f 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c @@ -38,7 +38,7 @@ #define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */ /* but always the same one for the session? */ static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ -static int last_touch; +static bool touch_available = false; static struct touch_calibration_point topleft, bottomright; static bool using_calibration = false; @@ -76,7 +76,7 @@ static int touch_to_pixels(short val_x, short val_y) void button_init_device(void) { - last_touch = 0; + touch_available = false; /* GIO is the power button, set as input */ IO_GIO_DIR0 |= 0x01; topleft.px_x = 0; topleft.px_y = 0; @@ -104,28 +104,50 @@ inline bool button_hold(void) return false; } -int button_get_last_touch(void) -{ - int ret_val = last_touch; - last_touch = 0; - return ret_val; -} - static void remote_heartbeat(void) { char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'}; uart1_puts(data); } -int button_read_device(void) +#define TOUCH_MARGIN 8 +int button_read_device(int *data) { char c; int i = 0; int btn = BUTTON_NONE; - + *data = 0; + if ((IO_GIO_BITSET0&0x01) == 0) btn |= BUTTON_POWER; - + if (touch_available) + { + short x,y; + static long last_touch = 0; + bool send_touch = false; + tsc2100_read_values(&x, &y, &last_z1, &last_z2); + if (TIME_BEFORE(last_touch + HZ/5, current_tick)) + { + if ((x > last_x + TOUCH_MARGIN) || + (x < last_x - TOUCH_MARGIN) || + (y > last_y + TOUCH_MARGIN) || + (y < last_y - TOUCH_MARGIN)) + { + send_touch = true; + } + } + else + send_touch = true; + if (send_touch) + { + last_x = x; + last_y = y; + *data = touch_to_pixels(x, y); + btn |= BUTTON_TOUCHPAD; + } + last_touch = current_tick; + touch_available = false; + } remote_heartbeat(); while (uart1_getch(&c)) { @@ -163,27 +185,10 @@ int button_read_device(void) } return btn; } -#define TOUCH_MARGIN 8 + +/* Touchpad data available interupt */ void GIO14(void) { - short x,y; - static int last_tick = 0; - tsc2100_read_values(&x, &y, - &last_z1, &last_z2); - if (TIME_BEFORE(last_tick+HZ/5, current_tick)) - { - if ((x > last_x + TOUCH_MARGIN) || - (x < last_x - TOUCH_MARGIN) || - (y > last_y + TOUCH_MARGIN) || - (y < last_y - TOUCH_MARGIN)) - { - last_x = x; - last_y = y; - queue_clear(&button_queue); - queue_post(&button_queue, BUTTON_TOUCHPAD, - touch_to_pixels(x, y)); - } - last_tick = current_tick; - } - IO_INTC_IRQ2 = (1<<3); + touch_available = true; + IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */ } diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h index 238a3f6143..aa4768c05b 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h @@ -27,8 +27,7 @@ bool button_hold(void); void button_init_device(void); -int button_read_device(void); -int button_get_last_touch(void); +int button_read_device(int *data); struct touch_calibration_point { short px_x; /* known pixel value */ |