summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-11-21 23:55:39 +0000
committerJens Arnold <amiconn@rockbox.org>2005-11-21 23:55:39 +0000
commitb51f7dfc9b507ab9db12fe90b2ddad708f435e06 (patch)
treeefcef3411689401da21795d700a0741f8ab1072b /uisimulator
parente68680ac310adb8373c9f3a5194466766d64cf37 (diff)
downloadrockbox-b51f7dfc9b507ab9db12fe90b2ddad708f435e06.tar.gz
rockbox-b51f7dfc9b507ab9db12fe90b2ddad708f435e06.tar.bz2
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.c33
-rw-r--r--uisimulator/win32/button.c8
-rw-r--r--uisimulator/win32/kernel.c51
-rw-r--r--uisimulator/win32/uisw32.c11
-rw-r--r--uisimulator/x11/button-x11.c11
-rw-r--r--uisimulator/x11/kernel.c52
-rw-r--r--uisimulator/x11/thread.c6
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)
}
#endif
-/* Generic firmware stubs. */
-void backlight_on(void)
+#ifdef CONFIG_BACKLIGHT
+void sim_backlight(int value)
{
- /* we could do something better here! */
-}
-
-void backlight_off(void)
-{
- /* we could do something better here! */
+ DEBUGF("backlight: %s\n", (value > 0) ? "on" : "off");
}
+#endif
-void backlight_time(int dummy)
+#ifdef HAVE_REMOTE_LCD
+void sim_remote_backlight(int value)
{
- (void)dummy;
+ DEBUGF("remote backlight: %s\n", (value > 0) ? "on" : "off");
}
+#endif
int fat_startsector(void)
{
@@ -167,21 +165,6 @@ bool simulate_usb(void)
return false;
}
-void backlight_set_timeout(int index)
-{
- (void)index;
-}
-
-void backlight_set_on_when_charging(bool beep)
-{
- (void)beep;
-}
-
-void remote_backlight_set_timeout(int index)
-{
- (void)index;
-}
-
int rtc_read(int address)
{
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)
else
queue_post(&button_queue, btn, NULL);
- backlight_on();
+#ifdef HAVE_REMOTE_LCD
+ if(btn & BUTTON_REMOTE)
+ remote_backlight_on();
+ else
+#endif
+ backlight_on();
+
}
}
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 @@
#include "kernel.h"
#include "thread-win32.h"
#include "thread.h"
+#include "debug.h"
/* (Daniel 2002-10-31) Mingw32 requires this errno variable to be present.
I'm not quite sure why and I don't know if this breaks the MSVC compile.
If it does, we should put this within #ifdef __MINGW32__ */
int errno;
+static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
+
int set_irq_level (int level)
{
static int _lv = 0;
@@ -99,6 +102,54 @@ void switch_thread (void)
yield ();
}
+void sim_tick_tasks(void)
+{
+ int i;
+
+ /* Run through the list of tick tasks */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i])
+ {
+ tick_funcs[i]();
+ }
+ }
+}
+
+int tick_add_task(void (*f)(void))
+{
+ int i;
+
+ /* Add a task if there is room */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i] == NULL)
+ {
+ tick_funcs[i] = f;
+ return 0;
+ }
+ }
+ DEBUGF("Error! tick_add_task(): out of tasks");
+ return -1;
+}
+
+int tick_remove_task(void (*f)(void))
+{
+ int i;
+
+ /* Remove a task if it is there */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i] == f)
+ {
+ tick_funcs[i] = NULL;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
/* TODO: Implement mutexes for win32 */
void mutex_init(struct mutex *m)
{
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 @@
// extern functions
extern void app_main (void *); // mod entry point
-extern void new_key(int key);
+extern void new_key(int key);
+extern void sim_tick_tasks(void);
void button_event(int key, bool pressed);
@@ -67,12 +68,18 @@ LRESULT CALLBACK GUIWndProc (
static HDC hMemDc;
static LARGE_INTEGER persec, tick1, ticknow;
+ long new_tick;
switch (uMsg)
{
case WM_TIMER:
QueryPerformanceCounter(&ticknow);
- current_tick = ((ticknow.QuadPart-tick1.QuadPart)*HZ)/persec.QuadPart;
+ new_tick = ((ticknow.QuadPart-tick1.QuadPart)*HZ)/persec.QuadPart;
+ if (new_tick != current_tick)
+ {
+ sim_tick_tasks();
+ current_tick = new_tick;
+ }
return TRUE;
case WM_ACTIVATE:
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 @@
#include "button.h"
#include "kernel.h"
#include "debug.h"
+#include "backlight.h"
#include "misc.h"
#include "X11/keysym.h"
@@ -47,7 +48,7 @@ static long lastbtn; /* Last valid button status */
/* mostly copied from real button.c */
void button_read (void);
-void button_tick(void)
+static void button_tick(void)
{
static int tick = 0;
static int count = 0;
@@ -117,6 +118,13 @@ void button_tick(void)
queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
else
queue_post(&button_queue, btn, NULL);
+#ifdef HAVE_REMOTE_LCD
+ if(btn & BUTTON_REMOTE)
+ remote_backlight_on();
+ else
+#endif
+ backlight_on();
+
}
}
else
@@ -276,6 +284,7 @@ long button_get_w_tmo(int ticks)
void button_init(void)
{
+ tick_add_task(button_tick);
}
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 @@
*
****************************************************************************/
+#include <stddef.h>
#include "kernel.h"
#include "thread.h"
+#include "debug.h"
+
+static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
int set_irq_level (int level)
{
@@ -91,6 +95,54 @@ void switch_thread (void)
yield ();
}
+void sim_tick_tasks(void)
+{
+ int i;
+
+ /* Run through the list of tick tasks */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i])
+ {
+ tick_funcs[i]();
+ }
+ }
+}
+
+int tick_add_task(void (*f)(void))
+{
+ int i;
+
+ /* Add a task if there is room */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i] == NULL)
+ {
+ tick_funcs[i] = f;
+ return 0;
+ }
+ }
+ DEBUGF("Error! tick_add_task(): out of tasks");
+ return -1;
+}
+
+int tick_remove_task(void (*f)(void))
+{
+ int i;
+
+ /* Remove a task if it is there */
+ for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
+ {
+ if(tick_funcs[i] == f)
+ {
+ tick_funcs[i] = NULL;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
void mutex_init(struct mutex *m)
{
(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 @@
#endif
long current_tick = 0;
-extern void button_tick(void);
+extern void sim_tick_tasks(void);
static void msleep(int msec)
{
@@ -59,10 +59,8 @@ static void update_tick_thread()
+ (now.tv_usec - start.tv_usec) / (1000000/HZ);
if (new_tick > current_tick)
{
+ sim_tick_tasks();
current_tick = new_tick;
- button_tick(); /* Dirty call to button.c. This should probably
- * be implemented as a tick task the same way
- * as on the target. */
}
}
}