diff options
Diffstat (limited to 'uisimulator/battery.c')
-rw-r--r-- | uisimulator/battery.c | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/uisimulator/battery.c b/uisimulator/battery.c deleted file mode 100644 index b92f4d4bdb..0000000000 --- a/uisimulator/battery.c +++ /dev/null | |||
@@ -1,102 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 1999 Robert Hak (rhak@ramapo.edu) | ||
11 | * | ||
12 | * Heavily modified for embedded use by Björn Stenberg (bjorn@haxx.se) | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License | ||
16 | * as published by the Free Software Foundation; either version 2 | ||
17 | * of the License, or (at your option) any later version. | ||
18 | * | ||
19 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
20 | * KIND, either express or implied. | ||
21 | * | ||
22 | ****************************************************************************/ | ||
23 | |||
24 | #include "types.h" | ||
25 | #include "lcd.h" | ||
26 | #include "debug.h" | ||
27 | #define CONFIG_KEYPAD RECORDER_PAD | ||
28 | #include "button.h" | ||
29 | |||
30 | #ifdef SIMULATOR | ||
31 | #include <stdio.h> | ||
32 | #include <unistd.h> | ||
33 | #endif | ||
34 | |||
35 | /* I hacked this function to be placed inside because I figure we will need | ||
36 | something like it eventually. | ||
37 | |||
38 | Args are fairly straight forward. | ||
39 | int xbase: location of "bottom" of battery on screen | ||
40 | int ybase: location of "left" edge of battery on screen | ||
41 | int len: how long is the battery to be (in pixels) | ||
42 | int wid: how tall is the battery to be (in pixels) | ||
43 | int percent: what percentage of the charge has been used | ||
44 | |||
45 | Note: I am making use of the Logf() function until logging is | ||
46 | straightened out. | ||
47 | */ | ||
48 | |||
49 | void draw_battery(int xbase, int ybase, int len, int wid, int percent) | ||
50 | { | ||
51 | float capacity = 0; | ||
52 | int bar_xoffset = 2; | ||
53 | int bar_yoffset = 2; | ||
54 | int bar_len = 0; | ||
55 | int bar_wid = wid - (bar_xoffset*2); | ||
56 | int i = 0; | ||
57 | |||
58 | /* We only worry about length and width because if you place | ||
59 | the battery off the screen, its your own damn fault. We log | ||
60 | and then just draw an empty battery */ | ||
61 | if((percent > 100) || (percent < 0) || (len < 0) || (wid < 0)) { | ||
62 | /* debug("Error: Battery data invalid"); */ | ||
63 | percent = 0; | ||
64 | } | ||
65 | |||
66 | /* top batt. edge */ | ||
67 | lcd_hline(xbase, xbase+len-2, ybase); | ||
68 | |||
69 | /* bot batt. edge */ | ||
70 | lcd_hine(xbase, xbase+len-2, ybase+wid); | ||
71 | |||
72 | /* left batt. edge */ | ||
73 | lcd_vline(xbase, ybase, ybase+wid); | ||
74 | |||
75 | /* right batt. edge */ | ||
76 | lcd_vline(xbase+len, ybase+1, ybase+wid-1); | ||
77 | |||
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); | ||
81 | |||
82 | if(percent > 0) { | ||
83 | /* % battery is full, 100% is length-bar_xoffset-1 pixels */ | ||
84 | capacity = ((float)percent / 100.0) * (len-(bar_xoffset*2)-1); | ||
85 | bar_len = capacity; | ||
86 | |||
87 | for(i = 0; i < bar_wid+1; i++) { | ||
88 | lcd_hline(xbase+bar_xoffset, | ||
89 | xbase+bar_xoffset+bar_len, ybase+bar_yoffset+i); | ||
90 | } | ||
91 | } | ||
92 | lcd_update(); | ||
93 | } | ||
94 | |||
95 | |||
96 | |||
97 | |||
98 | |||
99 | |||
100 | |||
101 | |||
102 | |||