2008-12-24 04:10:18 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id: button-e200v2.c 19035 2008-11-07 05:31:05Z jdgordon $
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Barry Wardell
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "system.h"
|
2009-06-17 19:55:27 +00:00
|
|
|
#include "button-target.h"
|
2008-12-24 04:10:18 +00:00
|
|
|
#include "button.h"
|
|
|
|
#include "backlight.h"
|
|
|
|
#include "powermgmt.h"
|
|
|
|
|
|
|
|
|
2009-09-05 18:56:59 +00:00
|
|
|
static unsigned short _dbop_din = 0xFFFF;
|
2009-06-17 19:55:27 +00:00
|
|
|
|
|
|
|
/* in the lcd driver */
|
2009-09-05 18:56:59 +00:00
|
|
|
extern unsigned short int lcd_dbop_input(void);
|
2009-06-17 19:55:27 +00:00
|
|
|
|
2008-12-24 04:10:18 +00:00
|
|
|
static bool hold_button = false;
|
2009-06-17 19:55:27 +00:00
|
|
|
#ifndef BOOTLOADER
|
2008-12-24 04:10:18 +00:00
|
|
|
static bool hold_button_old = false;
|
2009-06-17 19:55:27 +00:00
|
|
|
#endif
|
2008-12-24 04:10:18 +00:00
|
|
|
|
2009-06-18 15:05:59 +00:00
|
|
|
/* for the debug menu */
|
|
|
|
unsigned short button_dbop_data(void)
|
|
|
|
{
|
|
|
|
return _dbop_din;
|
|
|
|
}
|
|
|
|
|
2008-12-24 04:10:18 +00:00
|
|
|
void button_init_device(void)
|
|
|
|
{
|
2009-06-17 19:55:27 +00:00
|
|
|
GPIOA_DIR &= ~(1<<3);
|
2008-12-24 04:10:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool button_hold(void)
|
|
|
|
{
|
2009-06-17 19:55:27 +00:00
|
|
|
return hold_button;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get button pressed from hardware
|
|
|
|
*/
|
|
|
|
int button_read_device(void)
|
2008-12-24 04:10:18 +00:00
|
|
|
{
|
2009-06-17 19:55:27 +00:00
|
|
|
int btn = BUTTON_NONE;
|
2008-12-24 04:10:18 +00:00
|
|
|
|
2009-09-05 18:56:59 +00:00
|
|
|
_dbop_din = lcd_dbop_input();
|
|
|
|
|
|
|
|
/* hold button handling */
|
|
|
|
hold_button = ((_dbop_din & (1<<12)) == 0);
|
|
|
|
#ifndef BOOTLOADER
|
|
|
|
/* light handling */
|
|
|
|
if (hold_button != hold_button_old)
|
|
|
|
{
|
|
|
|
hold_button_old = hold_button;
|
|
|
|
backlight_hold_changed(hold_button);
|
|
|
|
}
|
|
|
|
#endif /* BOOTLOADER */
|
|
|
|
if (hold_button) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-24 04:10:18 +00:00
|
|
|
/* direct GPIO connections */
|
|
|
|
if (GPIOA_PIN(3))
|
2009-06-17 19:55:27 +00:00
|
|
|
btn |= BUTTON_POWER;
|
2008-12-24 04:10:18 +00:00
|
|
|
|
2009-09-05 18:56:59 +00:00
|
|
|
/* DBOP buttons */
|
2009-06-18 15:05:59 +00:00
|
|
|
if(!(_dbop_din & (1<<2)))
|
2009-06-17 19:55:27 +00:00
|
|
|
btn |= BUTTON_LEFT;
|
2009-06-18 15:05:59 +00:00
|
|
|
if(!(_dbop_din & (1<<3)))
|
|
|
|
btn |= BUTTON_DOWN;
|
|
|
|
if(!(_dbop_din & (1<<4)))
|
|
|
|
btn |= BUTTON_SELECT;
|
|
|
|
if(!(_dbop_din & (1<<5)))
|
|
|
|
btn |= BUTTON_UP;
|
|
|
|
if(!(_dbop_din & (1<<6)))
|
|
|
|
btn |= BUTTON_RIGHT;
|
2009-09-05 18:56:59 +00:00
|
|
|
if(!(_dbop_din & (1<<13)))
|
|
|
|
btn |= BUTTON_VOL_UP;
|
|
|
|
if(!(_dbop_din & (1<<14)))
|
|
|
|
btn |= BUTTON_VOL_DOWN;
|
|
|
|
if(!(_dbop_din & (1<<15)))
|
|
|
|
btn |= BUTTON_REC;
|
2008-12-24 04:10:18 +00:00
|
|
|
|
2009-06-17 19:55:27 +00:00
|
|
|
return btn;
|
2008-12-24 04:10:18 +00:00
|
|
|
}
|