2006-08-12 08:01:54 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Linus Nielsen Feltzing
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "config.h"
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "system.h"
|
2006-12-29 02:49:12 +00:00
|
|
|
#include "backlight-target.h"
|
2006-08-12 08:01:54 +00:00
|
|
|
#include "backlight.h"
|
|
|
|
#include "lcd.h"
|
2006-11-05 07:54:08 +00:00
|
|
|
#include "sc606-meg-fx.h"
|
2007-01-08 08:53:36 +00:00
|
|
|
#include "power.h"
|
|
|
|
|
2007-01-07 06:38:57 +00:00
|
|
|
#define BUTTONLIGHT_MENU (SC606_LED_B1)
|
|
|
|
#define BUTTONLIGHT_ALL (SC606_LED_B1 | SC606_LED_B2 | SC606_LED_C1 | SC606_LED_C2)
|
2007-01-04 09:32:49 +00:00
|
|
|
|
2007-01-07 06:38:57 +00:00
|
|
|
static void led_control_service(void);
|
2007-05-14 05:04:21 +00:00
|
|
|
static unsigned char backlight_brightness;
|
|
|
|
static unsigned char buttonlight_brightness;
|
|
|
|
static unsigned char backlight_target;
|
|
|
|
static unsigned char buttonlight_target;
|
2007-01-07 06:38:57 +00:00
|
|
|
|
|
|
|
static enum backlight_states
|
|
|
|
{
|
|
|
|
BACKLIGHT_CONTROL_IDLE,
|
|
|
|
BACKLIGHT_CONTROL_OFF,
|
|
|
|
BACKLIGHT_CONTROL_ON,
|
|
|
|
BACKLIGHT_CONTROL_SET,
|
2007-05-07 19:34:34 +00:00
|
|
|
BACKLIGHT_CONTROL_FADE
|
2007-01-07 06:38:57 +00:00
|
|
|
} backlight_control;
|
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
static enum sc606_states
|
|
|
|
{
|
|
|
|
SC606_CONTROL_IDLE,
|
|
|
|
SC606_CONTROL_A12,
|
|
|
|
SC606_CONTROL_B12,
|
|
|
|
SC606_CONTROL_C12,
|
|
|
|
SC606_CONTROL_CONF
|
|
|
|
} sc606_control;
|
2007-01-07 06:38:57 +00:00
|
|
|
|
|
|
|
enum buttonlight_states
|
|
|
|
{
|
2007-05-07 19:34:34 +00:00
|
|
|
BUTTONLIGHT_CONTROL_IDLE,
|
|
|
|
BUTTONLIGHT_CONTROL_OFF,
|
|
|
|
BUTTONLIGHT_CONTROL_ON,
|
2007-05-08 06:45:38 +00:00
|
|
|
BUTTONLIGHT_CONTROL_SET,
|
2007-05-07 19:34:34 +00:00
|
|
|
BUTTONLIGHT_CONTROL_FADE,
|
|
|
|
} buttonlight_control;
|
2007-01-08 08:53:36 +00:00
|
|
|
|
|
|
|
static unsigned short buttonlight_trigger_now;
|
|
|
|
|
2007-01-12 20:26:23 +00:00
|
|
|
bool __backlight_init(void)
|
2006-12-29 02:49:12 +00:00
|
|
|
{
|
2007-05-14 05:04:21 +00:00
|
|
|
buttonlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
|
|
|
|
backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
|
2007-01-07 06:38:57 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
2007-05-14 05:04:21 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_ON;
|
|
|
|
|
|
|
|
/* Set the backlight up in a known state */
|
|
|
|
sc606_init();
|
|
|
|
sc606_write(SC606_REG_A , DEFAULT_BRIGHTNESS_SETTING);
|
|
|
|
sc606_write(SC606_REG_B , 0);
|
|
|
|
sc606_write(SC606_REG_C , 0);
|
|
|
|
sc606_write(SC606_REG_CONF , 0x03);
|
2007-01-07 06:38:57 +00:00
|
|
|
|
|
|
|
/* put the led control on the tick list */
|
|
|
|
tick_add_task(led_control_service);
|
2007-01-14 03:28:31 +00:00
|
|
|
|
2007-01-12 20:26:23 +00:00
|
|
|
return true;
|
2006-12-29 02:49:12 +00:00
|
|
|
}
|
2006-08-12 08:01:54 +00:00
|
|
|
|
|
|
|
void __backlight_on(void)
|
|
|
|
{
|
2007-01-07 06:38:57 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_ON;
|
2006-08-12 08:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void __backlight_off(void)
|
|
|
|
{
|
2007-01-07 06:38:57 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_OFF;
|
2006-08-12 08:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-01-04 09:32:49 +00:00
|
|
|
/* Assumes that the backlight has been initialized */
|
2006-11-05 07:54:08 +00:00
|
|
|
void __backlight_set_brightness(int brightness)
|
2006-08-12 08:01:54 +00:00
|
|
|
{
|
2007-01-04 09:32:49 +00:00
|
|
|
/* stop the interrupt from messing us up */
|
2007-01-07 06:38:57 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
2007-05-07 19:34:34 +00:00
|
|
|
backlight_brightness = brightness;
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_SET;
|
2007-01-04 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 08:53:36 +00:00
|
|
|
/* only works if the buttonlight mode is set to triggered mode */
|
|
|
|
void __buttonlight_trigger(void)
|
2007-01-04 09:32:49 +00:00
|
|
|
{
|
2007-01-08 08:53:36 +00:00
|
|
|
buttonlight_trigger_now = 1;
|
2007-01-07 06:38:57 +00:00
|
|
|
}
|
|
|
|
|
2007-01-08 08:53:36 +00:00
|
|
|
/* map the mode from the command into the state machine entries */
|
2007-05-07 19:34:34 +00:00
|
|
|
void __buttonlight_mode(enum buttonlight_mode mode)
|
2007-01-07 06:38:57 +00:00
|
|
|
{
|
2007-01-08 08:53:36 +00:00
|
|
|
/* choose stop to setup mode */
|
2007-05-07 19:34:34 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
2007-01-04 09:32:49 +00:00
|
|
|
|
2007-01-08 08:53:36 +00:00
|
|
|
/* which mode to use */
|
2007-01-07 06:38:57 +00:00
|
|
|
switch (mode)
|
2007-01-04 09:32:49 +00:00
|
|
|
{
|
2007-01-07 06:38:57 +00:00
|
|
|
case BUTTONLIGHT_OFF:
|
2007-05-07 19:34:34 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_OFF;
|
2007-01-07 06:38:57 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BUTTONLIGHT_ON:
|
2007-05-07 19:34:34 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_ON;
|
2007-01-07 06:38:57 +00:00
|
|
|
break;
|
2007-05-07 19:34:34 +00:00
|
|
|
|
2007-01-08 08:53:36 +00:00
|
|
|
case BUTTONLIGHT_FOLLOW:
|
2007-05-07 19:34:34 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
|
2007-01-08 08:53:36 +00:00
|
|
|
break;
|
|
|
|
|
2007-01-07 06:38:57 +00:00
|
|
|
default:
|
|
|
|
return; /* unknown mode */
|
2007-01-04 09:32:49 +00:00
|
|
|
}
|
2007-01-07 06:38:57 +00:00
|
|
|
}
|
|
|
|
|
2007-01-11 10:24:21 +00:00
|
|
|
/* led_control_service runs in interrupt context - be brief!
|
|
|
|
* This service is called once per interrupt timer tick - 100 times a second.
|
2007-01-07 06:38:57 +00:00
|
|
|
*
|
|
|
|
* There should be at most only one i2c operation per call - if more are need
|
|
|
|
* the calls should be spread across calls.
|
|
|
|
*
|
|
|
|
* Putting all led servicing in one thread means that we wont step on any
|
|
|
|
* i2c operations - they are all serialized here in the ISR tick. It also
|
|
|
|
* insures that we get called at equal timing for good visual effect.
|
|
|
|
*/
|
|
|
|
static void led_control_service(void)
|
|
|
|
{
|
2007-05-07 19:34:34 +00:00
|
|
|
static unsigned char
|
|
|
|
sc606regAval=DEFAULT_BRIGHTNESS_SETTING,
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606regBval=0,
|
|
|
|
sc606regCval=0,
|
2007-05-10 03:08:47 +00:00
|
|
|
sc606regCONFval=0x03;
|
2007-05-07 19:34:34 +00:00
|
|
|
|
2007-05-14 05:04:21 +00:00
|
|
|
static bool sc606_changed=false, sc606_CONF_changed=false;
|
2007-05-08 05:47:36 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
if(sc606_changed==false)
|
2007-01-04 09:32:49 +00:00
|
|
|
{
|
2007-05-07 19:34:34 +00:00
|
|
|
switch (backlight_control)
|
2007-01-07 06:38:57 +00:00
|
|
|
{
|
2007-05-07 19:34:34 +00:00
|
|
|
case BACKLIGHT_CONTROL_IDLE:
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
|
|
|
break;
|
|
|
|
case BACKLIGHT_CONTROL_OFF:
|
|
|
|
sc606_changed=true;
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606_CONF_changed=true;
|
2007-05-07 19:34:34 +00:00
|
|
|
sc606regCONFval &= ~0x03;
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606regAval=0;
|
2007-05-07 19:34:34 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
|
|
|
break;
|
|
|
|
case BACKLIGHT_CONTROL_ON:
|
|
|
|
sc606_changed=true;
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606_CONF_changed=true;
|
2007-05-07 19:34:34 +00:00
|
|
|
sc606regCONFval |= 0x03;
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606regAval=backlight_brightness;
|
2007-05-07 19:34:34 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
|
|
|
break;
|
|
|
|
case BACKLIGHT_CONTROL_SET:
|
2007-05-14 05:04:21 +00:00
|
|
|
if(!(sc606regCONFval&0x03))
|
|
|
|
break;
|
2007-05-07 19:34:34 +00:00
|
|
|
sc606_changed=true;
|
2007-05-10 03:08:47 +00:00
|
|
|
sc606regAval=backlight_brightness;
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
2007-05-07 19:34:34 +00:00
|
|
|
break;
|
|
|
|
case BACKLIGHT_CONTROL_FADE:
|
2007-05-08 05:47:36 +00:00
|
|
|
/* Was this mode set while the backlight is already on/off? */
|
|
|
|
if(backlight_target==sc606regAval)
|
|
|
|
{
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
|
|
|
break;
|
|
|
|
}
|
2007-05-07 19:34:34 +00:00
|
|
|
sc606_changed=true;
|
2007-05-14 05:04:21 +00:00
|
|
|
if(!(sc606regCONFval&0x03))
|
|
|
|
{
|
|
|
|
sc606_CONF_changed=true;
|
|
|
|
sc606regCONFval |= 0x03;
|
|
|
|
}
|
2007-05-08 03:57:42 +00:00
|
|
|
if(backlight_target>sc606regAval)
|
|
|
|
{
|
|
|
|
sc606regAval++;
|
|
|
|
if(backlight_target==sc606regAval)
|
2007-05-14 05:04:21 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
2007-05-08 03:57:42 +00:00
|
|
|
}
|
2007-01-11 10:24:21 +00:00
|
|
|
else
|
2007-05-08 03:57:42 +00:00
|
|
|
{
|
|
|
|
sc606regAval--;
|
2007-05-14 05:04:21 +00:00
|
|
|
if(sc606regAval==0)
|
2007-05-08 03:57:42 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_OFF;
|
2007-05-14 05:04:21 +00:00
|
|
|
else if (backlight_target==sc606regAval)
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
2007-05-08 03:57:42 +00:00
|
|
|
}
|
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-05-14 05:04:21 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
2007-05-07 19:34:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (buttonlight_control)
|
|
|
|
{
|
|
|
|
case BUTTONLIGHT_CONTROL_IDLE:
|
|
|
|
buttonlight_control=BUTTONLIGHT_CONTROL_IDLE;
|
|
|
|
break;
|
|
|
|
case BUTTONLIGHT_CONTROL_OFF:
|
|
|
|
sc606_changed=true;
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606_CONF_changed=true;
|
|
|
|
sc606regCONFval &= ~BUTTONLIGHT_ALL;
|
2007-05-10 03:08:47 +00:00
|
|
|
sc606regBval=sc606regCval=0;
|
2007-05-07 19:34:34 +00:00
|
|
|
buttonlight_control=BUTTONLIGHT_CONTROL_IDLE;
|
|
|
|
break;
|
|
|
|
case BUTTONLIGHT_CONTROL_ON:
|
|
|
|
sc606_changed=true;
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606_CONF_changed=true;
|
|
|
|
sc606regCONFval |= BUTTONLIGHT_ALL;
|
2007-05-10 03:08:47 +00:00
|
|
|
sc606regBval=sc606regCval=buttonlight_brightness;
|
2007-05-07 19:34:34 +00:00
|
|
|
buttonlight_control=BUTTONLIGHT_CONTROL_IDLE;
|
|
|
|
break;
|
2007-05-08 06:45:38 +00:00
|
|
|
case BUTTONLIGHT_CONTROL_SET:
|
2007-05-14 05:04:21 +00:00
|
|
|
if(!(sc606regCONFval&BUTTONLIGHT_ALL))
|
|
|
|
break;
|
2007-05-08 06:45:38 +00:00
|
|
|
sc606_changed=true;
|
2007-05-10 03:08:47 +00:00
|
|
|
sc606regBval=sc606regCval=buttonlight_brightness;
|
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
2007-05-08 06:45:38 +00:00
|
|
|
break;
|
2007-05-07 19:34:34 +00:00
|
|
|
case BUTTONLIGHT_CONTROL_FADE:
|
2007-05-14 05:04:21 +00:00
|
|
|
/* Was this mode set while the button light is already on? */
|
2007-05-08 05:47:36 +00:00
|
|
|
if(buttonlight_target==sc606regBval)
|
|
|
|
{
|
2007-05-10 03:08:47 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
2007-05-08 05:47:36 +00:00
|
|
|
break;
|
|
|
|
}
|
2007-05-07 19:34:34 +00:00
|
|
|
sc606_changed=true;
|
2007-05-14 05:04:21 +00:00
|
|
|
if(!(sc606regCONFval&BUTTONLIGHT_ALL))
|
|
|
|
{
|
|
|
|
sc606_CONF_changed=true;
|
|
|
|
sc606regCONFval |= BUTTONLIGHT_ALL;
|
|
|
|
}
|
2007-05-08 03:57:42 +00:00
|
|
|
if(buttonlight_target>sc606regBval)
|
|
|
|
{
|
|
|
|
sc606regCval=++sc606regBval;
|
|
|
|
if(buttonlight_target==sc606regBval)
|
2007-05-14 05:04:21 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
2007-05-08 03:57:42 +00:00
|
|
|
}
|
2007-01-11 10:24:21 +00:00
|
|
|
else
|
2007-05-08 03:57:42 +00:00
|
|
|
{
|
|
|
|
sc606regCval=--sc606regBval;
|
2007-05-10 03:08:47 +00:00
|
|
|
if(sc606regBval==0)
|
2007-05-08 03:57:42 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_OFF;
|
2007-05-14 05:04:21 +00:00
|
|
|
else if (buttonlight_target==sc606regBval)
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
2007-05-08 03:57:42 +00:00
|
|
|
}
|
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-05-14 05:04:21 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
2007-05-07 19:34:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-01-07 06:38:57 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
switch (sc606_control)
|
|
|
|
{
|
|
|
|
case SC606_CONTROL_IDLE:
|
|
|
|
if(sc606_changed)
|
|
|
|
sc606_control=SC606_CONTROL_A12;
|
2007-01-07 06:38:57 +00:00
|
|
|
else
|
2007-05-07 19:34:34 +00:00
|
|
|
sc606_control=SC606_CONTROL_IDLE;
|
2007-01-07 06:38:57 +00:00
|
|
|
break;
|
2007-05-14 05:04:21 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
case SC606_CONTROL_A12:
|
|
|
|
sc606_write(SC606_REG_A , sc606regAval);
|
|
|
|
sc606_control=SC606_CONTROL_B12;
|
2007-01-08 08:53:36 +00:00
|
|
|
break;
|
2007-05-14 05:04:21 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
case SC606_CONTROL_B12:
|
|
|
|
sc606_write(SC606_REG_B , sc606regBval);
|
|
|
|
sc606_control=SC606_CONTROL_C12;
|
2007-01-08 08:53:36 +00:00
|
|
|
break;
|
2007-05-14 05:04:21 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
case SC606_CONTROL_C12:
|
|
|
|
sc606_write(SC606_REG_C , sc606regCval);
|
2007-05-14 05:04:21 +00:00
|
|
|
if(sc606_CONF_changed!=true)
|
|
|
|
{
|
|
|
|
sc606_changed=false;
|
|
|
|
if(backlight_control != BACKLIGHT_CONTROL_IDLE ||
|
|
|
|
buttonlight_control != BUTTONLIGHT_CONTROL_IDLE)
|
|
|
|
{
|
|
|
|
sc606_control=SC606_CONTROL_A12;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sc606_control=SC606_CONTROL_IDLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sc606_control=SC606_CONTROL_CONF;
|
|
|
|
}
|
2007-01-07 06:38:57 +00:00
|
|
|
break;
|
2007-05-14 05:04:21 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
case SC606_CONTROL_CONF:
|
|
|
|
sc606_write(SC606_REG_CONF , sc606regCONFval);
|
|
|
|
sc606_changed=false;
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606_CONF_changed=false;
|
|
|
|
if(backlight_control != BACKLIGHT_CONTROL_IDLE ||
|
|
|
|
buttonlight_control != BUTTONLIGHT_CONTROL_IDLE)
|
|
|
|
{
|
2007-05-08 03:57:42 +00:00
|
|
|
sc606_control=SC606_CONTROL_A12;
|
2007-05-14 05:04:21 +00:00
|
|
|
}
|
2007-05-08 03:57:42 +00:00
|
|
|
else
|
2007-05-14 05:04:21 +00:00
|
|
|
{
|
2007-05-08 03:57:42 +00:00
|
|
|
sc606_control=SC606_CONTROL_IDLE;
|
2007-05-14 05:04:21 +00:00
|
|
|
}
|
2007-01-07 06:38:57 +00:00
|
|
|
break;
|
2007-05-14 05:04:21 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
default:
|
2007-05-14 05:04:21 +00:00
|
|
|
sc606_control=SC606_CONTROL_IDLE;
|
2007-01-07 06:38:57 +00:00
|
|
|
break;
|
2007-01-04 09:32:49 +00:00
|
|
|
}
|
2007-05-08 05:47:36 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
if(sc606regCONFval&0x03)
|
2007-01-11 10:24:21 +00:00
|
|
|
lcd_enable(true);
|
|
|
|
else
|
|
|
|
lcd_enable(false);
|
2007-01-04 09:32:49 +00:00
|
|
|
}
|
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
void __button_backlight_on(void)
|
|
|
|
{
|
2007-05-10 03:08:47 +00:00
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_ON;
|
2007-05-07 19:34:34 +00:00
|
|
|
}
|
2007-01-04 09:32:49 +00:00
|
|
|
|
2007-05-07 19:34:34 +00:00
|
|
|
void __button_backlight_off(void)
|
2007-05-10 03:08:47 +00:00
|
|
|
{
|
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_OFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __button_backlight_dim(bool dim_now)
|
2007-05-07 19:34:34 +00:00
|
|
|
{
|
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
2007-05-10 03:08:47 +00:00
|
|
|
buttonlight_target = (dim_now == true) ? 0 : buttonlight_brightness;
|
|
|
|
if(buttonlight_target==0 && buttonlight_brightness==0)
|
|
|
|
{
|
|
|
|
if(dim_now == false)
|
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_ON;
|
|
|
|
else
|
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_OFF;
|
|
|
|
}
|
2007-05-08 06:45:38 +00:00
|
|
|
else
|
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
|
2007-05-07 19:34:34 +00:00
|
|
|
}
|
2007-01-04 09:32:49 +00:00
|
|
|
|
|
|
|
void __backlight_dim(bool dim_now)
|
|
|
|
{
|
|
|
|
/* dont let the interrupt tick happen */
|
2007-01-07 06:38:57 +00:00
|
|
|
backlight_control = BACKLIGHT_CONTROL_IDLE;
|
2007-05-07 19:34:34 +00:00
|
|
|
backlight_target = (dim_now == true) ? 0 : backlight_brightness;
|
2007-05-08 06:45:38 +00:00
|
|
|
if(backlight_target==0 && backlight_brightness==0)
|
|
|
|
{
|
|
|
|
if(dim_now == false)
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_ON;
|
|
|
|
else
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_OFF;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
backlight_control = BACKLIGHT_CONTROL_FADE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __buttonlight_set_brightness(int brightness)
|
|
|
|
{
|
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
|
|
|
|
buttonlight_brightness = brightness;
|
|
|
|
buttonlight_control = BUTTONLIGHT_CONTROL_SET;
|
2006-08-12 08:01:54 +00:00
|
|
|
}
|