1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 1999 Robert Hak (rhak@ramapo.edu)
12 * Heavily modified for embedded use by Björn Stenberg (bjorn@haxx.se)
14 * All files in this archive are subject to the GNU General Public License.
15 * See the file COPYING in the source tree root for full license agreement.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 #define HAVE_RECORDER_KEYPAD
33 /* I hacked this function to be placed inside because I figure we will need
34 something like it eventually.
36 Args are fairly straight forward.
37 int xbase: location of "bottom" of battery on screen
38 int ybase: location of "left" edge of battery on screen
39 int len: how long is the battery to be (in pixels)
40 int wid: how tall is the battery to be (in pixels)
41 int percent: what percentage of the charge has been used
43 Note: I am making use of the Logf() function until logging is
47 void draw_battery(int xbase
, int ybase
, int len
, int wid
, int percent
)
53 int bar_wid
= wid
- (bar_xoffset
*2);
56 /* We only worry about length and width because if you place
57 the battery off the screen, its your own damn fault. We log
58 and then just draw an empty battery */
59 if((percent
> 100) || (percent
< 0) || (len
< 0) || (wid
< 0)) {
60 /* debug("Error: Battery data invalid"); */
65 lcd_drawline(xbase
, ybase
, xbase
+len
-2, ybase
);
68 lcd_drawline(xbase
, ybase
+wid
,
69 xbase
+len
-2, ybase
+wid
);
72 lcd_drawline(xbase
, ybase
, xbase
, ybase
+wid
);
74 /* right batt. edge */
75 lcd_drawline(xbase
+len
, ybase
+1,
76 xbase
+len
, ybase
+wid
-1);
78 /* 2 dots that account for the nub on the right side of the battery */
79 lcd_drawpixel(xbase
+len
-1, ybase
+1);
80 lcd_drawpixel(xbase
+len
-1, ybase
+wid
-1);
83 /* % battery is full, 100% is length-bar_xoffset-1 pixels */
84 capacity
= ((float)percent
/ 100.0) * (len
-(bar_xoffset
*2)-1);
87 for(i
= 0; i
< bar_wid
+1; i
++) {
88 lcd_drawline(xbase
+bar_xoffset
, ybase
+bar_yoffset
+i
,
89 xbase
+bar_xoffset
+bar_len
, ybase
+bar_yoffset
+i
);