diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-11-21 23:55:39 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-11-21 23:55:39 +0000 |
commit | b51f7dfc9b507ab9db12fe90b2ddad708f435e06 (patch) | |
tree | efcef3411689401da21795d700a0741f8ab1072b /uisimulator | |
parent | e68680ac310adb8373c9f3a5194466766d64cf37 (diff) | |
download | rockbox-b51f7dfc9b507ab9db12fe90b2ddad708f435e06.tar.gz rockbox-b51f7dfc9b507ab9db12fe90b2ddad708f435e06.zip |
Backlight handling: * Added 'Caption Backlight' and 'Backlight On When Charging' for the iriver remote LCD. * Enabled the backlight code for the simulator, and prepared backlight simulation. It's only a stub atm, writing messages to the console window. * Added tick task handling to the simulators for this to work. * Code cleanup in backlight.c, less dead code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8034 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r-- | uisimulator/common/stubs.c | 33 | ||||
-rw-r--r-- | uisimulator/win32/button.c | 8 | ||||
-rw-r--r-- | uisimulator/win32/kernel.c | 51 | ||||
-rw-r--r-- | uisimulator/win32/uisw32.c | 11 | ||||
-rw-r--r-- | uisimulator/x11/button-x11.c | 11 | ||||
-rw-r--r-- | uisimulator/x11/kernel.c | 52 | ||||
-rw-r--r-- | uisimulator/x11/thread.c | 6 |
7 files changed, 139 insertions, 33 deletions
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 0bbecdae41..ff66c1fab3 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c | |||
@@ -78,21 +78,19 @@ void audio_set_buffer_margin(int seconds) | |||
78 | } | 78 | } |
79 | #endif | 79 | #endif |
80 | 80 | ||
81 | /* Generic firmware stubs. */ | 81 | #ifdef CONFIG_BACKLIGHT |
82 | void backlight_on(void) | 82 | void sim_backlight(int value) |
83 | { | 83 | { |
84 | /* we could do something better here! */ | 84 | DEBUGF("backlight: %s\n", (value > 0) ? "on" : "off"); |
85 | } | ||
86 | |||
87 | void backlight_off(void) | ||
88 | { | ||
89 | /* we could do something better here! */ | ||
90 | } | 85 | } |
86 | #endif | ||
91 | 87 | ||
92 | void backlight_time(int dummy) | 88 | #ifdef HAVE_REMOTE_LCD |
89 | void sim_remote_backlight(int value) | ||
93 | { | 90 | { |
94 | (void)dummy; | 91 | DEBUGF("remote backlight: %s\n", (value > 0) ? "on" : "off"); |
95 | } | 92 | } |
93 | #endif | ||
96 | 94 | ||
97 | int fat_startsector(void) | 95 | int fat_startsector(void) |
98 | { | 96 | { |
@@ -167,21 +165,6 @@ bool simulate_usb(void) | |||
167 | return false; | 165 | return false; |
168 | } | 166 | } |
169 | 167 | ||
170 | void backlight_set_timeout(int index) | ||
171 | { | ||
172 | (void)index; | ||
173 | } | ||
174 | |||
175 | void backlight_set_on_when_charging(bool beep) | ||
176 | { | ||
177 | (void)beep; | ||
178 | } | ||
179 | |||
180 | void remote_backlight_set_timeout(int index) | ||
181 | { | ||
182 | (void)index; | ||
183 | } | ||
184 | |||
185 | int rtc_read(int address) | 168 | int rtc_read(int address) |
186 | { | 169 | { |
187 | time_t now = time(NULL); | 170 | time_t now = time(NULL); |
diff --git a/uisimulator/win32/button.c b/uisimulator/win32/button.c index 08ef5e15d8..47adbb485f 100644 --- a/uisimulator/win32/button.c +++ b/uisimulator/win32/button.c | |||
@@ -202,7 +202,13 @@ void button_event(int key, bool pressed) | |||
202 | else | 202 | else |
203 | queue_post(&button_queue, btn, NULL); | 203 | queue_post(&button_queue, btn, NULL); |
204 | 204 | ||
205 | backlight_on(); | 205 | #ifdef HAVE_REMOTE_LCD |
206 | if(btn & BUTTON_REMOTE) | ||
207 | remote_backlight_on(); | ||
208 | else | ||
209 | #endif | ||
210 | backlight_on(); | ||
211 | |||
206 | } | 212 | } |
207 | } | 213 | } |
208 | else | 214 | else |
diff --git a/uisimulator/win32/kernel.c b/uisimulator/win32/kernel.c index 8e7bb88546..eb55bf7a72 100644 --- a/uisimulator/win32/kernel.c +++ b/uisimulator/win32/kernel.c | |||
@@ -22,12 +22,15 @@ | |||
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "thread-win32.h" | 23 | #include "thread-win32.h" |
24 | #include "thread.h" | 24 | #include "thread.h" |
25 | #include "debug.h" | ||
25 | 26 | ||
26 | /* (Daniel 2002-10-31) Mingw32 requires this errno variable to be present. | 27 | /* (Daniel 2002-10-31) Mingw32 requires this errno variable to be present. |
27 | I'm not quite sure why and I don't know if this breaks the MSVC compile. | 28 | I'm not quite sure why and I don't know if this breaks the MSVC compile. |
28 | If it does, we should put this within #ifdef __MINGW32__ */ | 29 | If it does, we should put this within #ifdef __MINGW32__ */ |
29 | int errno; | 30 | int errno; |
30 | 31 | ||
32 | static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); | ||
33 | |||
31 | int set_irq_level (int level) | 34 | int set_irq_level (int level) |
32 | { | 35 | { |
33 | static int _lv = 0; | 36 | static int _lv = 0; |
@@ -99,6 +102,54 @@ void switch_thread (void) | |||
99 | yield (); | 102 | yield (); |
100 | } | 103 | } |
101 | 104 | ||
105 | void sim_tick_tasks(void) | ||
106 | { | ||
107 | int i; | ||
108 | |||
109 | /* Run through the list of tick tasks */ | ||
110 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
111 | { | ||
112 | if(tick_funcs[i]) | ||
113 | { | ||
114 | tick_funcs[i](); | ||
115 | } | ||
116 | } | ||
117 | } | ||
118 | |||
119 | int tick_add_task(void (*f)(void)) | ||
120 | { | ||
121 | int i; | ||
122 | |||
123 | /* Add a task if there is room */ | ||
124 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
125 | { | ||
126 | if(tick_funcs[i] == NULL) | ||
127 | { | ||
128 | tick_funcs[i] = f; | ||
129 | return 0; | ||
130 | } | ||
131 | } | ||
132 | DEBUGF("Error! tick_add_task(): out of tasks"); | ||
133 | return -1; | ||
134 | } | ||
135 | |||
136 | int tick_remove_task(void (*f)(void)) | ||
137 | { | ||
138 | int i; | ||
139 | |||
140 | /* Remove a task if it is there */ | ||
141 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
142 | { | ||
143 | if(tick_funcs[i] == f) | ||
144 | { | ||
145 | tick_funcs[i] = NULL; | ||
146 | return 0; | ||
147 | } | ||
148 | } | ||
149 | |||
150 | return -1; | ||
151 | } | ||
152 | |||
102 | /* TODO: Implement mutexes for win32 */ | 153 | /* TODO: Implement mutexes for win32 */ |
103 | void mutex_init(struct mutex *m) | 154 | void mutex_init(struct mutex *m) |
104 | { | 155 | { |
diff --git a/uisimulator/win32/uisw32.c b/uisimulator/win32/uisw32.c index d098c6ef24..b31eccf794 100644 --- a/uisimulator/win32/uisw32.c +++ b/uisimulator/win32/uisw32.c | |||
@@ -36,7 +36,8 @@ | |||
36 | 36 | ||
37 | // extern functions | 37 | // extern functions |
38 | extern void app_main (void *); // mod entry point | 38 | extern void app_main (void *); // mod entry point |
39 | extern void new_key(int key); | 39 | extern void new_key(int key); |
40 | extern void sim_tick_tasks(void); | ||
40 | 41 | ||
41 | void button_event(int key, bool pressed); | 42 | void button_event(int key, bool pressed); |
42 | 43 | ||
@@ -67,12 +68,18 @@ LRESULT CALLBACK GUIWndProc ( | |||
67 | static HDC hMemDc; | 68 | static HDC hMemDc; |
68 | 69 | ||
69 | static LARGE_INTEGER persec, tick1, ticknow; | 70 | static LARGE_INTEGER persec, tick1, ticknow; |
71 | long new_tick; | ||
70 | 72 | ||
71 | switch (uMsg) | 73 | switch (uMsg) |
72 | { | 74 | { |
73 | case WM_TIMER: | 75 | case WM_TIMER: |
74 | QueryPerformanceCounter(&ticknow); | 76 | QueryPerformanceCounter(&ticknow); |
75 | current_tick = ((ticknow.QuadPart-tick1.QuadPart)*HZ)/persec.QuadPart; | 77 | new_tick = ((ticknow.QuadPart-tick1.QuadPart)*HZ)/persec.QuadPart; |
78 | if (new_tick != current_tick) | ||
79 | { | ||
80 | sim_tick_tasks(); | ||
81 | current_tick = new_tick; | ||
82 | } | ||
76 | return TRUE; | 83 | return TRUE; |
77 | case WM_ACTIVATE: | 84 | case WM_ACTIVATE: |
78 | if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) | 85 | if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE) |
diff --git a/uisimulator/x11/button-x11.c b/uisimulator/x11/button-x11.c index b2d8ab6c7a..e037867caf 100644 --- a/uisimulator/x11/button-x11.c +++ b/uisimulator/x11/button-x11.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "button.h" | 21 | #include "button.h" |
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "debug.h" | 23 | #include "debug.h" |
24 | #include "backlight.h" | ||
24 | #include "misc.h" | 25 | #include "misc.h" |
25 | 26 | ||
26 | #include "X11/keysym.h" | 27 | #include "X11/keysym.h" |
@@ -47,7 +48,7 @@ static long lastbtn; /* Last valid button status */ | |||
47 | /* mostly copied from real button.c */ | 48 | /* mostly copied from real button.c */ |
48 | void button_read (void); | 49 | void button_read (void); |
49 | 50 | ||
50 | void button_tick(void) | 51 | static void button_tick(void) |
51 | { | 52 | { |
52 | static int tick = 0; | 53 | static int tick = 0; |
53 | static int count = 0; | 54 | static int count = 0; |
@@ -117,6 +118,13 @@ void button_tick(void) | |||
117 | queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); | 118 | queue_post(&button_queue, BUTTON_REPEAT | btn, NULL); |
118 | else | 119 | else |
119 | queue_post(&button_queue, btn, NULL); | 120 | queue_post(&button_queue, btn, NULL); |
121 | #ifdef HAVE_REMOTE_LCD | ||
122 | if(btn & BUTTON_REMOTE) | ||
123 | remote_backlight_on(); | ||
124 | else | ||
125 | #endif | ||
126 | backlight_on(); | ||
127 | |||
120 | } | 128 | } |
121 | } | 129 | } |
122 | else | 130 | else |
@@ -276,6 +284,7 @@ long button_get_w_tmo(int ticks) | |||
276 | 284 | ||
277 | void button_init(void) | 285 | void button_init(void) |
278 | { | 286 | { |
287 | tick_add_task(button_tick); | ||
279 | } | 288 | } |
280 | 289 | ||
281 | int button_status(void) | 290 | int button_status(void) |
diff --git a/uisimulator/x11/kernel.c b/uisimulator/x11/kernel.c index 7405fec52f..25f2df220c 100644 --- a/uisimulator/x11/kernel.c +++ b/uisimulator/x11/kernel.c | |||
@@ -17,8 +17,12 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | 19 | ||
20 | #include <stddef.h> | ||
20 | #include "kernel.h" | 21 | #include "kernel.h" |
21 | #include "thread.h" | 22 | #include "thread.h" |
23 | #include "debug.h" | ||
24 | |||
25 | static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); | ||
22 | 26 | ||
23 | int set_irq_level (int level) | 27 | int set_irq_level (int level) |
24 | { | 28 | { |
@@ -91,6 +95,54 @@ void switch_thread (void) | |||
91 | yield (); | 95 | yield (); |
92 | } | 96 | } |
93 | 97 | ||
98 | void sim_tick_tasks(void) | ||
99 | { | ||
100 | int i; | ||
101 | |||
102 | /* Run through the list of tick tasks */ | ||
103 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
104 | { | ||
105 | if(tick_funcs[i]) | ||
106 | { | ||
107 | tick_funcs[i](); | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | int tick_add_task(void (*f)(void)) | ||
113 | { | ||
114 | int i; | ||
115 | |||
116 | /* Add a task if there is room */ | ||
117 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
118 | { | ||
119 | if(tick_funcs[i] == NULL) | ||
120 | { | ||
121 | tick_funcs[i] = f; | ||
122 | return 0; | ||
123 | } | ||
124 | } | ||
125 | DEBUGF("Error! tick_add_task(): out of tasks"); | ||
126 | return -1; | ||
127 | } | ||
128 | |||
129 | int tick_remove_task(void (*f)(void)) | ||
130 | { | ||
131 | int i; | ||
132 | |||
133 | /* Remove a task if it is there */ | ||
134 | for(i = 0;i < MAX_NUM_TICK_TASKS;i++) | ||
135 | { | ||
136 | if(tick_funcs[i] == f) | ||
137 | { | ||
138 | tick_funcs[i] = NULL; | ||
139 | return 0; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | return -1; | ||
144 | } | ||
145 | |||
94 | void mutex_init(struct mutex *m) | 146 | void mutex_init(struct mutex *m) |
95 | { | 147 | { |
96 | (void)m; | 148 | (void)m; |
diff --git a/uisimulator/x11/thread.c b/uisimulator/x11/thread.c index f3fe868fbc..6d9139c35d 100644 --- a/uisimulator/x11/thread.c +++ b/uisimulator/x11/thread.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | long current_tick = 0; | 32 | long current_tick = 0; |
33 | extern void button_tick(void); | 33 | extern void sim_tick_tasks(void); |
34 | 34 | ||
35 | static void msleep(int msec) | 35 | static void msleep(int msec) |
36 | { | 36 | { |
@@ -59,10 +59,8 @@ static void update_tick_thread() | |||
59 | + (now.tv_usec - start.tv_usec) / (1000000/HZ); | 59 | + (now.tv_usec - start.tv_usec) / (1000000/HZ); |
60 | if (new_tick > current_tick) | 60 | if (new_tick > current_tick) |
61 | { | 61 | { |
62 | sim_tick_tasks(); | ||
62 | current_tick = new_tick; | 63 | current_tick = new_tick; |
63 | button_tick(); /* Dirty call to button.c. This should probably | ||
64 | * be implemented as a tick task the same way | ||
65 | * as on the target. */ | ||
66 | } | 64 | } |
67 | } | 65 | } |
68 | } | 66 | } |