2008-03-12 20:35:42 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 by Jens Arnold
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2008-03-12 20:35:42 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "button.h"
|
|
|
|
#include "backlight.h"
|
|
|
|
#include "adc.h"
|
2012-01-07 19:07:36 +00:00
|
|
|
#include "lcd-remote.h"
|
2008-03-12 20:35:42 +00:00
|
|
|
|
|
|
|
static bool hold_button = false;
|
|
|
|
static bool remote_hold_button = false;
|
|
|
|
|
|
|
|
void button_init_device(void)
|
|
|
|
{
|
|
|
|
/* Remote Play */
|
|
|
|
GPIO_FUNCTION |= 0x80000000;
|
|
|
|
GPIO_ENABLE &= ~0x80000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool button_hold(void)
|
|
|
|
{
|
|
|
|
return (GPIO1_READ & 0x00000200) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool remote_button_hold(void)
|
|
|
|
{
|
|
|
|
return remote_hold_button;
|
|
|
|
}
|
|
|
|
|
|
|
|
int button_read_device(void)
|
|
|
|
{
|
|
|
|
int btn = BUTTON_NONE;
|
2020-10-13 17:06:18 +00:00
|
|
|
#ifndef BOOTLOADER
|
2008-03-12 20:35:42 +00:00
|
|
|
bool remote_hold_button_old;
|
2020-10-13 17:06:18 +00:00
|
|
|
#endif
|
2008-03-15 12:20:59 +00:00
|
|
|
int data;
|
2008-03-12 20:35:42 +00:00
|
|
|
|
|
|
|
/* normal buttons */
|
|
|
|
hold_button = button_hold();
|
|
|
|
|
|
|
|
if (!hold_button)
|
|
|
|
{
|
2008-03-17 00:19:23 +00:00
|
|
|
data = adc_read(ADC_BUTTONS);
|
2008-03-12 20:35:42 +00:00
|
|
|
|
2008-03-15 12:20:59 +00:00
|
|
|
if (data < 0xc0)
|
2008-03-12 20:35:42 +00:00
|
|
|
{
|
2008-03-15 12:20:59 +00:00
|
|
|
if (data < 0x67)
|
|
|
|
if (data < 0x37)
|
|
|
|
btn = BUTTON_VOL_DOWN;
|
|
|
|
else
|
|
|
|
if (data < 0x51)
|
|
|
|
btn = BUTTON_MODE;
|
|
|
|
else
|
|
|
|
btn = BUTTON_VOL_UP;
|
|
|
|
else
|
|
|
|
if (data < 0x7f)
|
|
|
|
btn = BUTTON_REC;
|
|
|
|
else
|
|
|
|
if (data < 0x98)
|
|
|
|
btn = BUTTON_LEFT;
|
|
|
|
else
|
|
|
|
btn = BUTTON_RIGHT;
|
2008-03-12 20:35:42 +00:00
|
|
|
}
|
|
|
|
if (!(GPIO1_READ & 0x00000002))
|
|
|
|
btn |= BUTTON_PLAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* remote buttons */
|
2008-03-17 00:19:23 +00:00
|
|
|
data = remote_detect() ? adc_read(ADC_REMOTE) : 0xff;
|
2008-03-12 20:35:42 +00:00
|
|
|
|
2020-10-13 17:06:18 +00:00
|
|
|
#ifndef BOOTLOADER
|
2008-03-12 20:35:42 +00:00
|
|
|
remote_hold_button_old = remote_hold_button;
|
2020-10-13 17:06:18 +00:00
|
|
|
#endif
|
2008-03-15 12:20:59 +00:00
|
|
|
remote_hold_button = data < 0x14;
|
2008-03-12 20:35:42 +00:00
|
|
|
|
|
|
|
#ifndef BOOTLOADER
|
|
|
|
if (remote_hold_button != remote_hold_button_old)
|
2008-03-14 08:54:54 +00:00
|
|
|
backlight_hold_changed(remote_hold_button);
|
2008-03-12 20:35:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!remote_hold_button)
|
|
|
|
{
|
2008-03-15 12:20:59 +00:00
|
|
|
if (data < 0xd0)
|
2008-03-12 20:35:42 +00:00
|
|
|
{
|
2008-03-15 12:20:59 +00:00
|
|
|
if (data < 0x67)
|
|
|
|
if (data < 0x37)
|
|
|
|
btn |= BUTTON_RC_FF;
|
|
|
|
else
|
|
|
|
if (data < 0x51)
|
|
|
|
btn |= BUTTON_RC_REW;
|
|
|
|
else
|
|
|
|
btn |= BUTTON_RC_MODE;
|
|
|
|
else
|
|
|
|
if (data < 0x98)
|
|
|
|
if (data < 0x7f)
|
|
|
|
btn |= BUTTON_RC_REC;
|
|
|
|
else
|
|
|
|
btn |= BUTTON_RC_MENU;
|
|
|
|
else
|
|
|
|
if (data < 0xb0)
|
|
|
|
btn |= BUTTON_RC_VOL_UP;
|
|
|
|
else
|
|
|
|
btn |= BUTTON_RC_VOL_DOWN;
|
2008-03-12 20:35:42 +00:00
|
|
|
}
|
2008-03-25 19:57:23 +00:00
|
|
|
if ((GPIO_READ & 0x80000000) == 0)
|
2008-03-12 20:35:42 +00:00
|
|
|
btn |= BUTTON_RC_PLAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
return btn;
|
|
|
|
}
|