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)
downloadrockbox-a567d8228cdf69ba18d447004468a3f63cdca62f.tar.gz
rockbox-a567d8228cdf69ba18d447004468a3f63cdca62f.zip
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 @@
26#include "scroll_engine.h" 26#include "scroll_engine.h"
27#include "uart-target.h" 27#include "uart-target.h"
28#include "button.h" 28#include "button.h"
29#include "powermgmt.h"
29 30
30static enum remote_control_states 31static enum remote_control_states
31{ 32{
@@ -35,7 +36,7 @@ static enum remote_control_states
35 REMOTE_CONTROL_MASK, 36 REMOTE_CONTROL_MASK,
36 REMOTE_CONTROL_DRAW, 37 REMOTE_CONTROL_DRAW,
37 REMOTE_CONTROL_SLEEP 38 REMOTE_CONTROL_SLEEP
38} remote_state_control = REMOTE_CONTROL_NOP, remote_state_control_next; 39} remote_state_control = REMOTE_CONTROL_MASK, remote_state_control_next;
39 40
40static enum remote_draw_states 41static enum remote_draw_states
41{ 42{
@@ -50,7 +51,6 @@ bool remote_initialized=true;
50 51
51static unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING; 52static unsigned char remote_contrast=DEFAULT_REMOTE_CONTRAST_SETTING;
52static unsigned char remote_power=0x00; 53static unsigned char remote_power=0x00;
53static unsigned char remote_mask=0x00;
54 54
55/*** hardware configuration ***/ 55/*** hardware configuration ***/
56 56
@@ -120,10 +120,13 @@ unsigned char remote_draw_x, remote_draw_y,
120static void remote_tick(void) 120static void remote_tick(void)
121{ 121{
122 unsigned char i; 122 unsigned char i;
123 int bat_level;
123 static unsigned char pause_length=0; 124 static unsigned char pause_length=0;
124 125
125 if(remote_state_control!=REMOTE_CONTROL_DRAW) 126 if(remote_state_control!=REMOTE_CONTROL_DRAW) {
126 remote_state_control=remote_state_control_next; 127 remote_state_control=remote_state_control_next;
128 remote_state_control_next=REMOTE_CONTROL_MASK;
129 }
127 130
128 switch (remote_state_control) 131 switch (remote_state_control)
129 { 132 {
@@ -137,7 +140,7 @@ static void remote_tick(void)
137 remote_payload[1]=0x30; 140 remote_payload[1]=0x30;
138 141
139 remote_payload_size=2; 142 remote_payload_size=2;
140 remote_state_control=REMOTE_CONTROL_NOP; 143 remote_state_control=REMOTE_CONTROL_MASK;
141 break; 144 break;
142 145
143 case REMOTE_CONTROL_POWER: 146 case REMOTE_CONTROL_POWER:
@@ -146,15 +149,26 @@ static void remote_tick(void)
146 remote_payload[2]=remote_contrast; 149 remote_payload[2]=remote_contrast;
147 150
148 remote_payload_size=3; 151 remote_payload_size=3;
149 remote_state_control=REMOTE_CONTROL_NOP; 152 remote_state_control=REMOTE_CONTROL_MASK;
150 break; 153 break;
151 154
152 case REMOTE_CONTROL_MASK: 155 case REMOTE_CONTROL_MASK:
156 bat_level=battery_level()>>5;
157 remote_payload[1]=0;
158
159 if(bat_level&0x02) {
160 remote_payload[1] |= 0x07 << 5;
161 } else if(bat_level&0x01) {
162 remote_payload[1] |= 0x03 << 5;
163 } else {
164 remote_payload[1] |= 0x01 << 5;
165 }
166 remote_payload[1]|=1<<4;
167
153 remote_payload[0]=0x41; 168 remote_payload[0]=0x41;
154 remote_payload[1]=remote_mask;
155 169
156 remote_payload_size=2; 170 remote_payload_size=2;
157 remote_state_control=REMOTE_CONTROL_NOP; 171 remote_state_control=REMOTE_CONTROL_MASK;
158 break; 172 break;
159 173
160 case REMOTE_CONTROL_DRAW: 174 case REMOTE_CONTROL_DRAW:
@@ -192,7 +206,7 @@ static void remote_tick(void)
192 if(--pause_length==0) 206 if(--pause_length==0)
193 { 207 {
194 if(remote_state_draw_next==DRAW_TOP) 208 if(remote_state_draw_next==DRAW_TOP)
195 remote_state_control=REMOTE_CONTROL_NOP; 209 remote_state_control=REMOTE_CONTROL_MASK;
196 210
197 remote_state_draw=remote_state_draw_next; 211 remote_state_draw=remote_state_draw_next;
198 } 212 }