aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/Source/d_button.r
diff options
context:
space:
mode:
Diffstat (limited to 'AT91SAM7S256/Source/d_button.r')
-rw-r--r--AT91SAM7S256/Source/d_button.r31
1 files changed, 16 insertions, 15 deletions
diff --git a/AT91SAM7S256/Source/d_button.r b/AT91SAM7S256/Source/d_button.r
index c478394..1e24b36 100644
--- a/AT91SAM7S256/Source/d_button.r
+++ b/AT91SAM7S256/Source/d_button.r
@@ -40,10 +40,7 @@ static UBYTE RisingTime;
/* And because it's an AD value returned from the AVR */
/* then a peak detector is needed */
#define BUTTONRead(pB) {\
- UBYTE Tmp, BtnPtr;\
- UWORD TmpBtn;\
*pB = OldState;\
- BtnPtr = 0x01;\
if (OldVal < IoFromAvr.Buttons)\
{\
OldVal = IoFromAvr.Buttons;\
@@ -60,27 +57,31 @@ static UBYTE RisingTime;
{\
if (RisingTime > RISING_THRESHOLD)\
{\
- TmpBtn = IoFromAvr.Buttons;\
- if (0x40 > TmpBtn)\
- {\
- TmpBtn = 0x00;\
+ UBYTE Tmp, BtnPtr, TmpBtn;\
+ UWORD buttonsVal;\
+ buttonsVal = IoFromAvr.Buttons;\
+ TmpBtn = 0;\
+ if (buttonsVal > 0x5FF) {\
+ TmpBtn = 0x08;\
+ buttonsVal -= 0x7ff;\
}\
- else if (0x100 > TmpBtn)\
+ if (0x40 > buttonsVal)\
{\
- TmpBtn = 0x04;\
+ TmpBtn |= 0x00;\
}\
- else if (0x1FF > TmpBtn)\
+ else if (0x100 > buttonsVal)\
{\
- TmpBtn = 0x02;\
+ TmpBtn |= 0x04;\
}\
- else if (0x5FF > TmpBtn)\
+ else if (0x1FF > buttonsVal)\
{\
- TmpBtn = 0x01;\
+ TmpBtn |= 0x02;\
}\
- else\
+ else if (0x5FF > buttonsVal)\
{\
- TmpBtn = 0x08;\
+ TmpBtn |= 0x01;\
}\
+ BtnPtr = 0x01;\
for (Tmp = 0; Tmp < NOS_OF_AVR_BTNS; Tmp++)\
{\
if ((TmpBtn) & BtnPtr)\