minor fix for remote button code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14795 a1c6a512-1295-4272-9138-f99709370657
diff --git a/firmware/target/arm/olympus/mrobe-500/button-mr500.c b/firmware/target/arm/olympus/mrobe-500/button-mr500.c
index f85eeca..a25a71e 100644
--- a/firmware/target/arm/olympus/mrobe-500/button-mr500.c
+++ b/firmware/target/arm/olympus/mrobe-500/button-mr500.c
@@ -29,6 +29,11 @@
#include "uart-target.h"
#define BUTTON_TIMEOUT 50
+
+#define BUTTON_START_BYTE 0xF0
+#define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */
+ /* but always the same one for the session? */
+
void button_init_device(void)
{
/* GIO is the power button, set as input */
@@ -43,6 +48,7 @@
int button_read_device(void)
{
char data[5], c;
+ int val;
int i = 0;
int btn = BUTTON_NONE, timeout = BUTTON_TIMEOUT;
@@ -52,14 +58,16 @@
uartHeartbeat();
while (timeout > 0)
{
- c = uartPollch(BUTTON_TIMEOUT*100);
- if (c > -1)
+ val = uartPollch(BUTTON_TIMEOUT*100);
+ if (val > -1)
{
- if (i && data[0] == 0xf4)
+ c = val&0xff;
+ if (i && (data[0] == BUTTON_START_BYTE || data[0] == BUTTON_START_BYTE2))
{
data[i++] = c;
}
- else if (c == 0xf4)
+ else if (c == BUTTON_START_BYTE ||
+ c == BUTTON_START_BYTE2)
{
data[0] = c;
i = 1;