clean up render.c a little
This commit is contained in:
+1
-1
@@ -140,7 +140,7 @@ static char **stored_argv;
|
|||||||
static volatile short got_reload_signal = 0;
|
static volatile short got_reload_signal = 0;
|
||||||
|
|
||||||
/* Local exported variables */
|
/* Local exported variables */
|
||||||
long int timer = 0;
|
long timer = 0;
|
||||||
|
|
||||||
/**** Local functions ****/
|
/**** Local functions ****/
|
||||||
static void clear_settings(void);
|
static void clear_settings(void);
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ extern char *build_date;
|
|||||||
#define TIME_UNIT (1e6/RENDER_FREQ)
|
#define TIME_UNIT (1e6/RENDER_FREQ)
|
||||||
/* Variable from stone age, still used a lot. */
|
/* Variable from stone age, still used a lot. */
|
||||||
|
|
||||||
extern long int timer;
|
extern long timer;
|
||||||
/* 32 bits at 8Hz will overflow in 2 ^ 29 = 5e8 seconds = 17 years.
|
/* 32 bits at 8Hz will overflow in 2 ^ 29 = 5e8 seconds = 17 years.
|
||||||
* If you get an overflow, please mail us and we will fix this personally
|
* If you get an overflow, please mail us and we will fix this personally
|
||||||
* for you ! */
|
* for you ! */
|
||||||
|
|||||||
+179
-176
@@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1999, William Ferrell, Scott Scriven
|
* Copyright (c) 1999, William Ferrell, Scott Scriven
|
||||||
* 2001, Joris Robijn
|
* 2001, Joris Robijn
|
||||||
*
|
* 2007, Peter Marschall
|
||||||
*
|
*
|
||||||
* Draws screens on the LCD.
|
* Draws screens on the LCD.
|
||||||
*
|
*
|
||||||
@@ -47,29 +47,22 @@ int output_state = 0;
|
|||||||
char *server_msg_text;
|
char *server_msg_text;
|
||||||
int server_msg_expire = 0;
|
int server_msg_expire = 0;
|
||||||
|
|
||||||
static int reset;
|
|
||||||
|
|
||||||
#define BUFSIZE 1024
|
#define BUFSIZE 1024 /* larger than display width => large enough */
|
||||||
|
|
||||||
static int render_frame(LinkedList *list, char fscroll, int left, int top, int right, int bottom, int fwid, int fhgt, int fspeed, long int timer);
|
|
||||||
|
static int render_frame(LinkedList *list, char fscroll, int left, int top, int right, int bottom, int fwid, int fhgt, int fspeed, long timer);
|
||||||
|
|
||||||
int
|
int
|
||||||
render_screen(Screen *s, long int timer)
|
render_screen(Screen *s, long timer)
|
||||||
{
|
{
|
||||||
static Screen *old_s = NULL;
|
|
||||||
int tmp_state = 0;
|
int tmp_state = 0;
|
||||||
|
|
||||||
debug(RPT_DEBUG, "%s(screen=[%.40s], timer=%d) ==== START RENDERING ====", __FUNCTION__, s->id, timer);
|
debug(RPT_DEBUG, "%s(screen=[%.40s], timer=%ld) ==== START RENDERING ====", __FUNCTION__, s->id, timer);
|
||||||
|
|
||||||
reset = 1;
|
if (s == NULL)
|
||||||
|
|
||||||
if (!s)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (s == old_s)
|
|
||||||
reset = 0;
|
|
||||||
old_s = s;
|
|
||||||
|
|
||||||
/* Clear the LCD screen... */
|
/* Clear the LCD screen... */
|
||||||
drivers_clear();
|
drivers_clear();
|
||||||
|
|
||||||
@@ -82,11 +75,14 @@ render_screen(Screen *s, long int timer)
|
|||||||
*/
|
*/
|
||||||
if (backlight != BACKLIGHT_OPEN) {
|
if (backlight != BACKLIGHT_OPEN) {
|
||||||
tmp_state = backlight;
|
tmp_state = backlight;
|
||||||
} else if (s->client && s->client->backlight != BACKLIGHT_OPEN) {
|
}
|
||||||
|
else if ((s->client != NULL) && (s->client->backlight != BACKLIGHT_OPEN)) {
|
||||||
tmp_state = s->client->backlight;
|
tmp_state = s->client->backlight;
|
||||||
} else if (s->backlight != BACKLIGHT_OPEN) {
|
}
|
||||||
|
else if (s->backlight != BACKLIGHT_OPEN) {
|
||||||
tmp_state = s->backlight;
|
tmp_state = s->backlight;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
tmp_state = backlight_fallback;
|
tmp_state = backlight_fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,16 +95,17 @@ render_screen(Screen *s, long int timer)
|
|||||||
(tmp_state & BACKLIGHT_ON)
|
(tmp_state & BACKLIGHT_ON)
|
||||||
^ ((timer & 7) == 7)
|
^ ((timer & 7) == 7)
|
||||||
) ? BACKLIGHT_ON : BACKLIGHT_OFF);
|
) ? BACKLIGHT_ON : BACKLIGHT_OFF);
|
||||||
/* Backlight blink: check timer and flip backlight as appropriate */
|
|
||||||
}
|
}
|
||||||
|
/* Backlight blink: check timer and flip backlight as appropriate */
|
||||||
else if (tmp_state & BACKLIGHT_BLINK) {
|
else if (tmp_state & BACKLIGHT_BLINK) {
|
||||||
drivers_backlight(
|
drivers_backlight(
|
||||||
(
|
(
|
||||||
(tmp_state & BACKLIGHT_ON)
|
(tmp_state & BACKLIGHT_ON)
|
||||||
^ ((timer & 14) == 14)
|
^ ((timer & 14) == 14)
|
||||||
) ? BACKLIGHT_ON : BACKLIGHT_OFF);
|
) ? BACKLIGHT_ON : BACKLIGHT_OFF);
|
||||||
} else {
|
}
|
||||||
/* Simple: Only send lowest bit then...*/
|
else {
|
||||||
|
/* Simple: Only send lowest bit then... */
|
||||||
drivers_backlight(tmp_state & BACKLIGHT_ON);
|
drivers_backlight(tmp_state & BACKLIGHT_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,18 +113,23 @@ render_screen(Screen *s, long int timer)
|
|||||||
drivers_output(output_state);
|
drivers_output(output_state);
|
||||||
|
|
||||||
/* Draw a frame... */
|
/* Draw a frame... */
|
||||||
render_frame(s->widgetlist, 'v', 0, 0, display_props->width, display_props->height, s->width, s->height, (((s->duration / s->height) < 1) ? 1 : (s->duration / s->height)), timer);
|
render_frame(s->widgetlist, 'v', 0, 0,
|
||||||
|
display_props->width, display_props->height,
|
||||||
|
s->width, s->height, max(s->duration / s->height, 1), timer);
|
||||||
|
|
||||||
/* Set the cursor */
|
/* Set the cursor */
|
||||||
drivers_cursor(s->cursor_x, s->cursor_y, s->cursor);
|
drivers_cursor(s->cursor_x, s->cursor_y, s->cursor);
|
||||||
|
|
||||||
if (heartbeat != HEARTBEAT_OPEN) {
|
if (heartbeat != HEARTBEAT_OPEN) {
|
||||||
tmp_state = heartbeat;
|
tmp_state = heartbeat;
|
||||||
} else if (s->client && s->client->heartbeat != HEARTBEAT_OPEN) {
|
}
|
||||||
|
else if ((s->client != NULL) && (s->client->heartbeat != HEARTBEAT_OPEN)) {
|
||||||
tmp_state = s->client->heartbeat;
|
tmp_state = s->client->heartbeat;
|
||||||
} else if (s->heartbeat != HEARTBEAT_OPEN) {
|
}
|
||||||
|
else if (s->heartbeat != HEARTBEAT_OPEN) {
|
||||||
tmp_state = s->heartbeat;
|
tmp_state = s->heartbeat;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
tmp_state = heartbeat_fallback;
|
tmp_state = heartbeat_fallback;
|
||||||
}
|
}
|
||||||
drivers_heartbeat(tmp_state);
|
drivers_heartbeat(tmp_state);
|
||||||
@@ -136,7 +138,7 @@ render_screen(Screen *s, long int timer)
|
|||||||
if (server_msg_expire > 0) {
|
if (server_msg_expire > 0) {
|
||||||
drivers_string(display_props->width - strlen(server_msg_text) + 1,
|
drivers_string(display_props->width - strlen(server_msg_text) + 1,
|
||||||
display_props->height, server_msg_text);
|
display_props->height, server_msg_text);
|
||||||
server_msg_expire --;
|
server_msg_expire--;
|
||||||
if (server_msg_expire == 0) {
|
if (server_msg_expire == 0) {
|
||||||
free(server_msg_text);
|
free(server_msg_text);
|
||||||
}
|
}
|
||||||
@@ -163,31 +165,22 @@ render_frame(LinkedList *list,
|
|||||||
int fwid, /* frame width? */
|
int fwid, /* frame width? */
|
||||||
int fhgt, /* frame height? */
|
int fhgt, /* frame height? */
|
||||||
int fspeed, /* speed of scrolling... */
|
int fspeed, /* speed of scrolling... */
|
||||||
long int timer) /* ? */
|
long timer) /* current timer tick */
|
||||||
{
|
{
|
||||||
|
|
||||||
#define VerticalScrolling (fscroll == 'v')
|
|
||||||
#define HorizontalScrolling (fscroll == 'h')
|
|
||||||
|
|
||||||
int vis_width = right - left; /* width of visible frame area */
|
int vis_width = right - left; /* width of visible frame area */
|
||||||
int vis_height = bottom - top; /* height of visible frame area */
|
int vis_height = bottom - top; /* height of visible frame area */
|
||||||
int x, y;
|
|
||||||
int /*fx = 0,*/ fy = 0; /* Scrolling offset for the frame... */
|
int /*fx = 0,*/ fy = 0; /* Scrolling offset for the frame... */
|
||||||
int length, speed;
|
|
||||||
int str_length = BUFSIZE-1;
|
|
||||||
int reset = 1;
|
|
||||||
|
|
||||||
debug(RPT_DEBUG, "%s(list=%p, fscroll='%c', left=%d, top=%d, "
|
debug(RPT_DEBUG, "%s(list=%p, fscroll='%c', left=%d, top=%d, "
|
||||||
"right=%d, bottom=%d, fwid=%d, fhgt=%d, fspeed=%d, timer=%d)",
|
"right=%d, bottom=%d, fwid=%d, fhgt=%d, fspeed=%d, timer=%ld)",
|
||||||
__FUNCTION__, list, fscroll, left,top, right, bottom,
|
__FUNCTION__, list, fscroll, left,top, right, bottom,
|
||||||
fwid, fhgt, fspeed, timer);
|
fwid, fhgt, fspeed, timer);
|
||||||
|
|
||||||
/* return on no data or illegal height */
|
/* return on no data or illegal height */
|
||||||
if (!list || (fhgt <= 0))
|
if ((list == NULL) || (fhgt <= 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (VerticalScrolling) {
|
if (fscroll == 'v') { /* vertical scrolling */
|
||||||
// FIXME: timer may be negative (this should be changed generally)
|
|
||||||
// only set offset !=0 when fspeed is != 0 and there is something to scroll
|
// only set offset !=0 when fspeed is != 0 and there is something to scroll
|
||||||
if (fspeed && (fhgt > vis_height)) {
|
if (fspeed && (fhgt > vis_height)) {
|
||||||
int fy_max = fhgt - vis_height + 1;
|
int fy_max = fhgt - vis_height + 1;
|
||||||
@@ -198,7 +191,8 @@ render_frame(LinkedList *list,
|
|||||||
|
|
||||||
fy = max(fy, 0); // safeguard against negative values
|
fy = max(fy, 0); // safeguard against negative values
|
||||||
}
|
}
|
||||||
} else if (HorizontalScrolling) {
|
}
|
||||||
|
else if (fscroll == 'h') { /* horizontal scrolling */
|
||||||
/* TODO: Frames don't scroll horizontally yet! */
|
/* TODO: Frames don't scroll horizontally yet! */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,25 +204,24 @@ render_frame(LinkedList *list,
|
|||||||
char str[BUFSIZE]; /* scratch buffer */
|
char str[BUFSIZE]; /* scratch buffer */
|
||||||
Widget *w = (Widget *) LL_Get(list);
|
Widget *w = (Widget *) LL_Get(list);
|
||||||
|
|
||||||
if (!w)
|
if (w == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* TODO: Make this cleaner and more flexible!*/
|
/* TODO: Make this cleaner and more flexible! */
|
||||||
switch (w->type) {
|
switch (w->type) {
|
||||||
case WID_STRING:
|
case WID_STRING:
|
||||||
if ((w->x > 0) && (w->y > 0) && (w->text) &&
|
if ((w->x > 0) && (w->y > 0) && (w->text) &&
|
||||||
(w->y <= vis_height + fy) && (w->y > fy)) {
|
(w->y <= vis_height + fy) && (w->y > fy)) {
|
||||||
|
int length;
|
||||||
|
|
||||||
w->x = min(w->x, vis_width);
|
w->x = min(w->x, vis_width);
|
||||||
str_length = min(vis_width - w->x + 1, BUFSIZE - 1);
|
length = min(vis_width - w->x + 1, sizeof(str));
|
||||||
strncpy(str, w->text, str_length);
|
strncpy(str, w->text, length);
|
||||||
str[str_length] = 0;
|
str[length] = '\0';
|
||||||
drivers_string(w->x + left, w->y + top - fy, str);
|
drivers_string(w->x + left, w->y + top - fy, str);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WID_HBAR:
|
case WID_HBAR:
|
||||||
if (reset) {
|
|
||||||
reset = 0;
|
|
||||||
}
|
|
||||||
if ((w->x > 0) && (w->y > 0) &&
|
if ((w->x > 0) && (w->y > 0) &&
|
||||||
(w->y <= vis_height + fy) && (w->y > fy)) {
|
(w->y <= vis_height + fy) && (w->y > fy)) {
|
||||||
if (w->length > 0) {
|
if (w->length > 0) {
|
||||||
@@ -245,7 +238,8 @@ render_frame(LinkedList *list,
|
|||||||
int full_len = (display_props->width - w->x - left + 1);
|
int full_len = (display_props->width - w->x - left + 1);
|
||||||
drivers_hbar(w->x + left, w->y + top - fy, full_len, 1000, BAR_PATTERN_FILLED);
|
drivers_hbar(w->x + left, w->y + top - fy, full_len, 1000, BAR_PATTERN_FILLED);
|
||||||
}
|
}
|
||||||
} else if (w->length < 0) {
|
}
|
||||||
|
else if (w->length < 0) {
|
||||||
/* TODO: Rearrange stuff to get left-extending
|
/* TODO: Rearrange stuff to get left-extending
|
||||||
* hbars to draw correctly...
|
* hbars to draw correctly...
|
||||||
* .. er, this'll require driver modifications,
|
* .. er, this'll require driver modifications,
|
||||||
@@ -254,17 +248,15 @@ render_frame(LinkedList *list,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WID_VBAR: /* FIXME: Vbars don't work in frames!*/
|
case WID_VBAR: /* FIXME: Vbars don't work in frames! */
|
||||||
if (reset) {
|
|
||||||
reset = 0;
|
|
||||||
}
|
|
||||||
if ((w->x > 0) && (w->y > 0)) {
|
if ((w->x > 0) && (w->y > 0)) {
|
||||||
if (w->length > 0) {
|
if (w->length > 0) {
|
||||||
/* Improvised len and promille while we have the old widget language */
|
/* Improvised len and promille while we have the old widget language */
|
||||||
int full_len = display_props->height;
|
int full_len = display_props->height;
|
||||||
int promille = (long) 1000 * w->length / display_props->cellheight / full_len;
|
int promille = (long) 1000 * w->length / display_props->cellheight / full_len;
|
||||||
drivers_vbar(w->x, display_props->height, full_len, promille, BAR_PATTERN_FILLED);
|
drivers_vbar(w->x, display_props->height, full_len, promille, BAR_PATTERN_FILLED);
|
||||||
} else if (w->length < 0) {
|
}
|
||||||
|
else if (w->length < 0) {
|
||||||
/* TODO: Rearrange stuff to get down-extending
|
/* TODO: Rearrange stuff to get down-extending
|
||||||
* vbars to draw correctly...
|
* vbars to draw correctly...
|
||||||
* .. er, this'll require driver modifications,
|
* .. er, this'll require driver modifications,
|
||||||
@@ -277,61 +269,58 @@ render_frame(LinkedList *list,
|
|||||||
drivers_icon(w->x, w->y, w->length);
|
drivers_icon(w->x, w->y, w->length);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WID_TITLE: /* FIXME: Doesn't work quite right in frames...*/
|
case WID_TITLE: /* FIXME: Doesn't work quite right in frames... */
|
||||||
if (!w->text)
|
if ((w->text != NULL) && (vis_width >= 8)) {
|
||||||
break;
|
int length = strlen(w->text);
|
||||||
if (vis_width < 8)
|
int x;
|
||||||
break;
|
|
||||||
|
|
||||||
drivers_icon(w->x + left, w->y + top, ICON_BLOCK_FILLED);
|
drivers_icon(w->x + left, w->y + top, ICON_BLOCK_FILLED);
|
||||||
drivers_icon(w->x + left + 1, w->y + top, ICON_BLOCK_FILLED);
|
drivers_icon(w->x + left + 1, w->y + top, ICON_BLOCK_FILLED);
|
||||||
|
|
||||||
length = strlen(w->text);
|
length = min(length, sizeof(str));
|
||||||
length = min(length, BUFSIZE - 1);
|
if (length <= vis_width - 6) {
|
||||||
if (length <= vis_width - 6) {
|
strncpy(str, w->text, length);
|
||||||
strncpy(str, w->text, length);
|
str[length] = '\0';
|
||||||
str[length] = 0;
|
|
||||||
x = length + 5;
|
|
||||||
} else /* Scroll the title, if it doesn't fit...*/
|
|
||||||
{
|
|
||||||
speed = 1;
|
|
||||||
x = timer / speed;
|
|
||||||
y = x / length;
|
|
||||||
|
|
||||||
x %= length;
|
x = length + 4;
|
||||||
x = max(x, 0);
|
}
|
||||||
if (x > length - (vis_width - 6))
|
else { /* Scroll the title, if it doesn't fit... */
|
||||||
x = length - (vis_width - 6);
|
int speed = 1;
|
||||||
|
int offset = timer / speed;
|
||||||
|
int reverse = offset / length;
|
||||||
|
|
||||||
if (y & 1) /* Scrolling backwards...*/
|
offset %= length;
|
||||||
x = (length - (vis_width - 6)) - x;
|
offset = max(offset, 0);
|
||||||
str_length = abs(vis_width - 6);
|
if (offset > length - (vis_width - 6))
|
||||||
str_length = min(str_length, BUFSIZE -1);
|
offset = length - (vis_width - 6);
|
||||||
strncpy(str, w->text + x, str_length);
|
|
||||||
str[str_length] = 0;
|
if (reverse & 1) /* Scrolling backwards... */
|
||||||
x = vis_width - 1;
|
offset = (length - (vis_width - 6)) - offset;
|
||||||
|
length = abs(vis_width - 6);
|
||||||
|
length = min(length, sizeof(str));
|
||||||
|
strncpy(str, w->text + offset, length);
|
||||||
|
str[length] = '\0';
|
||||||
|
|
||||||
|
x = vis_width - 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
drivers_string(w->x + 3 + left, w->y + top, str);
|
||||||
|
|
||||||
|
for ( ; x < vis_width; x++) {
|
||||||
|
drivers_icon(w->x + x + left, w->y + top, ICON_BLOCK_FILLED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drivers_string(w->x + 3 + left, w->y + top, str);
|
|
||||||
|
|
||||||
for (; x<=vis_width; x++) {
|
|
||||||
drivers_icon(w->x + x - 1 + left, w->y + top, ICON_BLOCK_FILLED);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WID_SCROLLER: /* FIXME: doesn't work in frames...*/
|
case WID_SCROLLER: /* FIXME: doesn't work in frames... */
|
||||||
{
|
if ((w->text != NULL) && (w->right >= w->left)) {
|
||||||
|
int length;
|
||||||
int offset;
|
int offset;
|
||||||
int screen_width;
|
int screen_width;
|
||||||
|
|
||||||
if (!w->text)
|
|
||||||
break;
|
|
||||||
if (w->right < w->left)
|
|
||||||
break;
|
|
||||||
/*debug(RPT_DEBUG, "%s: %s %d",__FUNCTION__,w->text,timer);*/
|
/*debug(RPT_DEBUG, "%s: %s %d",__FUNCTION__,w->text,timer);*/
|
||||||
screen_width = abs(w->right - w->left + 1);
|
screen_width = abs(w->right - w->left + 1);
|
||||||
screen_width = min(screen_width, BUFSIZE -1);
|
screen_width = min(screen_width, sizeof(str));
|
||||||
switch (w->length) { /* actually, direction...*/
|
switch (w->length) { /* actually, direction... */
|
||||||
/* FIXED: Horz scrollers don't show the
|
/* FIXED: Horz scrollers don't show the
|
||||||
* last letter in the string... (1-off error?)
|
* last letter in the string... (1-off error?)
|
||||||
*/
|
*/
|
||||||
@@ -340,16 +329,19 @@ render_frame(LinkedList *list,
|
|||||||
if (length <= screen_width) {
|
if (length <= screen_width) {
|
||||||
/* it fits within the box, just render it */
|
/* it fits within the box, just render it */
|
||||||
drivers_string(w->left, w->top, w->text);
|
drivers_string(w->left, w->top, w->text);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int necessaryTimeUnits = 0;
|
int necessaryTimeUnits = 0;
|
||||||
|
|
||||||
if (w->speed > 0) {
|
if (w->speed > 0) {
|
||||||
necessaryTimeUnits = length * w->speed;
|
necessaryTimeUnits = length * w->speed;
|
||||||
offset = (timer % (length * w->speed)) / w->speed;
|
offset = (timer % (length * w->speed)) / w->speed;
|
||||||
} else if (w->speed < 0) {
|
}
|
||||||
|
else if (w->speed < 0) {
|
||||||
necessaryTimeUnits = length / (w->speed * -1);
|
necessaryTimeUnits = length / (w->speed * -1);
|
||||||
offset = (timer % (length / (w->speed * -1))) * w->speed * -1;
|
offset = (timer % (length / (w->speed * -1))) * w->speed * -1;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
if (offset <= length) {
|
if (offset <= length) {
|
||||||
@@ -365,7 +357,8 @@ render_frame(LinkedList *list,
|
|||||||
str[screen_width] = '\0';
|
str[screen_width] = '\0';
|
||||||
|
|
||||||
/*debug(RPT_DEBUG, "scroller %s : %d", str, length-offset);*/
|
/*debug(RPT_DEBUG, "scroller %s : %d", str, length-offset);*/
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
str[0] = '\0';
|
str[0] = '\0';
|
||||||
}
|
}
|
||||||
drivers_string(w->left, w->top, str);
|
drivers_string(w->left, w->top, str);
|
||||||
@@ -376,39 +369,46 @@ render_frame(LinkedList *list,
|
|||||||
if (length <= screen_width) {
|
if (length <= screen_width) {
|
||||||
/* it fits within the box, just render it */
|
/* it fits within the box, just render it */
|
||||||
drivers_string(w->left, w->top, w->text);
|
drivers_string(w->left, w->top, w->text);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
int effLength = length - screen_width;
|
int effLength = length - screen_width;
|
||||||
int necessaryTimeUnits = 0;
|
int necessaryTimeUnits = 0;
|
||||||
|
|
||||||
if (w->speed > 0) {
|
if (w->speed > 0) {
|
||||||
necessaryTimeUnits = effLength * w->speed;
|
necessaryTimeUnits = effLength * w->speed;
|
||||||
if (((timer / (effLength * w->speed)) % 2) == 0) {
|
if (((timer / (effLength * w->speed)) % 2) == 0) {
|
||||||
/*wiggle one way*/
|
/* wiggle one way */
|
||||||
offset = (timer % (effLength * w->speed))
|
offset = (timer % (effLength * w->speed))
|
||||||
/ w->speed;
|
/ w->speed;
|
||||||
} else {
|
|
||||||
/*wiggle the other*/
|
|
||||||
offset = (((timer % (effLength * w->speed))
|
|
||||||
- (effLength * w->speed) + 1)
|
|
||||||
/ w->speed) * -1;
|
|
||||||
}
|
}
|
||||||
} else if (w->speed < 0) {
|
else {
|
||||||
|
/* wiggle the other */
|
||||||
|
offset = (((timer % (effLength * w->speed))
|
||||||
|
- (effLength * w->speed) + 1)
|
||||||
|
/ w->speed) * -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (w->speed < 0) {
|
||||||
necessaryTimeUnits = effLength / (w->speed * -1);
|
necessaryTimeUnits = effLength / (w->speed * -1);
|
||||||
if (((timer / (effLength / (w->speed * -1))) % 2) == 0) {
|
if (((timer / (effLength / (w->speed * -1))) % 2) == 0) {
|
||||||
offset = (timer % (effLength / (w->speed * -1)))
|
offset = (timer % (effLength / (w->speed * -1)))
|
||||||
* w->speed * -1;
|
* w->speed * -1;
|
||||||
} else {
|
|
||||||
offset = (((timer % (effLength / (w->speed * -1)))
|
|
||||||
* w->speed * -1) - effLength + 1) * -1;
|
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
|
offset = (((timer % (effLength / (w->speed * -1)))
|
||||||
|
* w->speed * -1)
|
||||||
|
- effLength + 1) * -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
if (offset <= length) {
|
if (offset <= length) {
|
||||||
strncpy(str, &((w->text)[offset]), screen_width);
|
strncpy(str, &((w->text)[offset]), screen_width);
|
||||||
str[screen_width] = '\0';
|
str[screen_width] = '\0';
|
||||||
/*debug(RPT_DEBUG, "scroller %s : %d", str, length-offset); */
|
/*debug(RPT_DEBUG, "scroller %s : %d", str, length-offset); */
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
str[0] = '\0';
|
str[0] = '\0';
|
||||||
}
|
}
|
||||||
drivers_string(w->left, w->top, str);
|
drivers_string(w->left, w->top, str);
|
||||||
@@ -418,71 +418,76 @@ render_frame(LinkedList *list,
|
|||||||
/* back up after hitting the bottom. They jump back to */
|
/* back up after hitting the bottom. They jump back to */
|
||||||
/* the top instead... (nevermind?) */
|
/* the top instead... (nevermind?) */
|
||||||
case 'v':
|
case 'v':
|
||||||
{
|
length = strlen(w->text);
|
||||||
int i = 0;
|
if (length <= screen_width) {
|
||||||
|
/* no scrolling required... */
|
||||||
|
drivers_string(w->left, w->top, w->text);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int lines_required = (length / screen_width)
|
||||||
|
+ (length % screen_width ? 1 : 0);
|
||||||
|
int available_lines = (w->bottom - w->top + 1);
|
||||||
|
|
||||||
length = strlen(w->text);
|
if (lines_required <= available_lines) {
|
||||||
if (length <= screen_width) {
|
/* easy... */
|
||||||
/* no scrolling required... */
|
int i;
|
||||||
drivers_string(w->left, w->top, w->text);
|
|
||||||
} else {
|
|
||||||
int lines_required = (length / screen_width)
|
|
||||||
+ (length % screen_width ? 1 : 0);
|
|
||||||
int available_lines = (w->bottom - w->top + 1);
|
|
||||||
|
|
||||||
if (lines_required <= available_lines) {
|
for (i = 0; i < lines_required; i++) {
|
||||||
/* easy...*/
|
strncpy(str, &((w->text)[i * screen_width]), screen_width);
|
||||||
for (i = 0; i < lines_required; i++) {
|
str[screen_width] = '\0';
|
||||||
strncpy(str, &((w->text)[i * screen_width]), screen_width);
|
drivers_string (w->left, w->top + i, str);
|
||||||
str[screen_width] = '\0';
|
}
|
||||||
drivers_string (w->left, w->top + i, str);
|
}
|
||||||
|
else {
|
||||||
|
int necessaryTimeUnits = 0;
|
||||||
|
int effLines = lines_required - available_lines + 1;
|
||||||
|
int begin = 0;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
/*debug(RPT_DEBUG, "length: %d sw: %d lines req: %d avail lines: %d effLines: %d ",length,screen_width,lines_required,available_lines,effLines);*/
|
||||||
|
if (w->speed > 0) {
|
||||||
|
necessaryTimeUnits = effLines * w->speed;
|
||||||
|
if (((timer / (effLines * w->speed)) % 2) == 0) {
|
||||||
|
/*debug(RPT_DEBUG, "up ");*/
|
||||||
|
begin = (timer % (effLines * w->speed))
|
||||||
|
/ w->speed;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/*debug(RPT_DEBUG, "down ");*/
|
||||||
|
begin = (((timer % (effLines * w->speed))
|
||||||
|
- (effLines * w->speed) + 1) / w->speed)
|
||||||
|
* -1;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
int necessaryTimeUnits = 0;
|
else if (w->speed < 0) {
|
||||||
int effLines = lines_required - available_lines + 1;
|
necessaryTimeUnits = effLines / (w->speed * -1);
|
||||||
int begin = 0;
|
if (((timer / (effLines / (w->speed * -1))) % 2) == 0) {
|
||||||
|
begin = (timer % (effLines / (w->speed * -1)))
|
||||||
/*debug(RPT_DEBUG, "length: %d sw: %d lines req: %d avail lines: %d effLines: %d ",length,screen_width,lines_required,available_lines,effLines);*/
|
* w->speed * -1;
|
||||||
if (w->speed > 0) {
|
|
||||||
necessaryTimeUnits = effLines * w->speed;
|
|
||||||
if (((timer / (effLines * w->speed)) % 2) == 0) {
|
|
||||||
/*debug(RPT_DEBUG, "up ");*/
|
|
||||||
begin = (timer % (effLines * w->speed))
|
|
||||||
/ w->speed;
|
|
||||||
} else {
|
|
||||||
/*debug(RPT_DEBUG, "down ");*/
|
|
||||||
begin = (((timer % (effLines * w->speed))
|
|
||||||
- (effLines * w->speed) + 1) / w->speed)
|
|
||||||
* -1;
|
|
||||||
}
|
|
||||||
} else if (w->speed < 0) {
|
|
||||||
necessaryTimeUnits = effLines / (w->speed * -1);
|
|
||||||
if (((timer / (effLines / (w->speed * -1))) % 2) == 0) {
|
|
||||||
begin = (timer % (effLines / (w->speed * -1)))
|
|
||||||
* w->speed * -1;
|
|
||||||
} else {
|
|
||||||
begin = (((timer % (effLines / (w->speed * -1)))
|
|
||||||
* w->speed * -1) - effLines + 1)
|
|
||||||
* -1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
begin = 0;
|
|
||||||
}
|
}
|
||||||
/*debug(RPT_DEBUG, "rendering begin: %d timer: %d effLines: %d",begin,timer,effLines); */
|
else {
|
||||||
for (i = begin; i < begin + available_lines; i++) {
|
begin = (((timer % (effLines / (w->speed * -1)))
|
||||||
strncpy(str, &((w->text)[i * (screen_width)]), screen_width);
|
* w->speed * -1) - effLines + 1)
|
||||||
str[screen_width] = '\0';
|
* -1;
|
||||||
/*debug(RPT_DEBUG, "rendering: '%s' of %s", */
|
|
||||||
/*str,w->text); */
|
|
||||||
drivers_string(w->left, w->top + (i - begin), str);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
begin = 0;
|
||||||
|
}
|
||||||
|
/*debug(RPT_DEBUG, "rendering begin: %d timer: %d effLines: %d",begin,timer,effLines); */
|
||||||
|
for (i = begin; i < begin + available_lines; i++) {
|
||||||
|
strncpy(str, &((w->text)[i * (screen_width)]), screen_width);
|
||||||
|
str[screen_width] = '\0';
|
||||||
|
/*debug(RPT_DEBUG, "rendering: '%s' of %s", */
|
||||||
|
/*str,w->text); */
|
||||||
|
drivers_string(w->left, w->top + (i - begin), str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case WID_FRAME:
|
case WID_FRAME:
|
||||||
{
|
{
|
||||||
/* FIXME: doesn't handle nested frames quite right!
|
/* FIXME: doesn't handle nested frames quite right!
|
||||||
@@ -493,16 +498,14 @@ render_frame(LinkedList *list,
|
|||||||
int new_right = min(left + w->right, right);
|
int new_right = min(left + w->right, right);
|
||||||
int new_bottom = min(top + w->bottom, bottom);
|
int new_bottom = min(top + w->bottom, bottom);
|
||||||
|
|
||||||
if ((new_left < right) && (new_top < bottom)) /* Render only if it's visible...*/
|
if ((new_left < right) && (new_top < bottom)) /* Render only if it's visible... */
|
||||||
render_frame(w->frame_screen->widgetlist, w->length, new_left, new_top, new_right, new_bottom, w->width, w->height, w->speed, timer);
|
render_frame(w->frame_screen->widgetlist, w->length, new_left, new_top,
|
||||||
|
new_right, new_bottom, w->width, w->height, w->speed, timer);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case WID_NUM: /* FIXME: doesn't work in frames...*/
|
case WID_NUM: /* FIXME: doesn't work in frames... */
|
||||||
/* NOTE: y=10 means COLON (:)*/
|
/* NOTE: y=10 means COLON (:) */
|
||||||
if ((w->x > 0) && (w->y >= 0) && (w->y <= 10)) {
|
if ((w->x > 0) && (w->y >= 0) && (w->y <= 10)) {
|
||||||
if (reset) {
|
|
||||||
reset = 0;
|
|
||||||
}
|
|
||||||
drivers_num(w->x + left, w->y);
|
drivers_num(w->x + left, w->y);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@ extern int heartbeat;
|
|||||||
extern int backlight;
|
extern int backlight;
|
||||||
extern int output_state;
|
extern int output_state;
|
||||||
|
|
||||||
int render_screen(Screen *s, long int timer);
|
int render_screen(Screen *s, long timer);
|
||||||
/* Renders the given screen. */
|
/* Renders the given screen. */
|
||||||
|
|
||||||
int server_msg(const char *text, int expire);
|
int server_msg(const char *text, int expire);
|
||||||
|
|||||||
Reference in New Issue
Block a user