1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 by Karl Kurbjun
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
25 #include "backlight.h"
28 #include "backlight-target.h"
29 #include "uart-target.h"
31 #define BUTTON_TIMEOUT 50
33 #define BUTTON_START_BYTE 0xF0
34 #define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */
35 /* but always the same one for the session? */
37 void button_init_device(void)
39 /* GIO is the power button, set as input */
43 inline bool button_hold(void)
48 int button_read_device(void)
52 int btn
= BUTTON_NONE
;
54 if ((IO_GIO_BITSET0
&0x01) == 0)
58 while (uartAvailable())
62 if (i
&& (data
[0] == BUTTON_START_BYTE
|| data
[0] == BUTTON_START_BYTE2
))
66 else if (c
== BUTTON_START_BYTE
||
67 c
== BUTTON_START_BYTE2
)
76 btn
|= BUTTON_RC_HEART
;
78 btn
|= BUTTON_RC_MODE
;
80 btn
|= BUTTON_RC_VOL_DOWN
;
82 btn
|= BUTTON_RC_VOL_UP
;
88 btn
|= BUTTON_RC_DOWN
;
90 btn
|= BUTTON_RC_PLAY
;