summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2009-07-08 04:00:50 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2009-07-08 04:00:50 +0000
commita567d8228cdf69ba18d447004468a3f63cdca62f (patch)
tree64df3386864f7761d2e658be784fc6e99520ef25
parenta06f6eedae542afc48cf0aa5e30b4647e18547a2 (diff)
M:robe 500 - Set the mask on the remote so that it indicates the battery status
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21710 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c
index a1faebbf16..742cab3b27 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-remote-mr500.c
@@ -26,6 +26,7 @@
#include "scroll_engine.h"
#include "uart-target.h"
#include "button.h"
+#include "powermgmt.h"
static enum remote_control_states
{
@@ -35,7 +36,7 @@ static enum remote_control_states
REMOTE_CONTROL_MASK,
REMOTE_CONTROL_DRAW,
REMOTE_CONTROL_SLEEP
-} remote_state_control = REMOTE_CONTROL_NOP, remote_state_control_next;
+} remote_state_control = REMOTE_CONTROL_MASK, remote_state_control_next;
static enum remote_draw_states
{
@@ -50,7 +51,6 @@ bool remote_initialized=true;
static unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
static unsigned char remote_power=0x00;
-static unsigned char remote_mask=0x00;
/*** hardware configuration ***/
@@ -120,10 +120,13 @@ unsigned char remote_draw_x, remote_draw_y,
static void remote_tick(void)
{
unsigned char i;
+ int bat_level;
static unsigned char pause_length=0;
- if(remote_state_control!=REMOTE_CONTROL_DRAW)
+ if(remote_state_control!=REMOTE_CONTROL_DRAW) {
remote_state_control=remote_state_control_next;
+ remote_state_control_next=REMOTE_CONTROL_MASK;
+ }
switch (remote_state_control)
{
@@ -137,7 +140,7 @@ static void remote_tick(void)
remote_payload[1]=0x30;
remote_payload_size=2;
- remote_state_control=REMOTE_CONTROL_NOP;
+ remote_state_control=REMOTE_CONTROL_MASK;
break;
case REMOTE_CONTROL_POWER:
@@ -146,15 +149,26 @@ static void remote_tick(void)
remote_payload[2]=remote_contrast;
remote_payload_size=3;
- remote_state_control=REMOTE_CONTROL_NOP;
+ remote_state_control=REMOTE_CONTROL_MASK;
break;
case REMOTE_CONTROL_MASK:
+ bat_level=battery_level()>>5;
+ remote_payload[1]=0;
+
+ if(bat_level&0x02) {
+ remote_payload[1] |= 0x07 << 5;
+ } else if(bat_level&0x01) {
+ remote_payload[1] |= 0x03 << 5;
+ } else {
+ remote_payload[1] |= 0x01 << 5;
+ }
+ remote_payload[1]|=1<<4;
+
remote_payload[0]=0x41;
- remote_payload[1]=remote_mask;
remote_payload_size=2;
- remote_state_control=REMOTE_CONTROL_NOP;
+ remote_state_control=REMOTE_CONTROL_MASK;
break;
case REMOTE_CONTROL_DRAW:
@@ -192,7 +206,7 @@ static void remote_tick(void)
if(--pause_length==0)
{
if(remote_state_draw_next==DRAW_TOP)
- remote_state_control=REMOTE_CONTROL_NOP;
+ remote_state_control=REMOTE_CONTROL_MASK;
remote_state_draw=remote_state_draw_next;
}