mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 12:45:26 -05:00
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
This commit is contained in:
parent
e68680ac31
commit
b51f7dfc9b
29 changed files with 416 additions and 231 deletions
|
|
@ -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! */
|
||||
DEBUGF("backlight: %s\n", (value > 0) ? "on" : "off");
|
||||
}
|
||||
#endif
|
||||
|
||||
void backlight_off(void)
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
void sim_remote_backlight(int value)
|
||||
{
|
||||
/* we could do something better here! */
|
||||
}
|
||||
|
||||
void backlight_time(int dummy)
|
||||
{
|
||||
(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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue