From 8f6dfc61f7f1a6c3784b4378cf147736666cce84 Mon Sep 17 00:00:00 2001 From: reinelt Date: Fri, 13 Jun 2003 06:35:56 +0000 Subject: [lcd4linux @ 2003-06-13 06:35:56 by reinelt] added scrolling capability git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@193 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- processor.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 100 insertions(+), 22 deletions(-) diff --git a/processor.c b/processor.c index d193a44..5df882d 100644 --- a/processor.c +++ b/processor.c @@ -1,4 +1,4 @@ -/* $Id: processor.c,v 1.30 2003/02/22 07:53:10 reinelt Exp $ +/* $Id: processor.c,v 1.31 2003/06/13 06:35:56 reinelt Exp $ * * main data processing * @@ -20,6 +20,9 @@ * * * $Log: processor.c,v $ + * Revision 1.31 2003/06/13 06:35:56 reinelt + * added scrolling capability + * * Revision 1.30 2003/02/22 07:53:10 reinelt * cfg_get(key,defval) * @@ -161,6 +164,7 @@ #include #include #include +#include #include "debug.h" #include "cfg.h" @@ -175,25 +179,26 @@ #include "seti.h" #include "exec.h" -#define ROWS 16 +#define ROWS 64 #define GPOS 16 -char *row[ROWS+1]; -int gpo[GPOS+1]; -int rows, cols, xres, yres, supported_bars, gpos; -int token_usage[256]={0,}; - -struct { int total, used, free, shared, buffer, cache, avail; } ram; -struct { double load1, load2, load3, overload; } load; -struct { double user, nice, system, idle; } busy; -struct { int read, write, total, max, peak; } disk; -struct { int rx, tx, total, max, peak, bytes; } net; -struct { int usage, in, out, total, max, peak; } isdn; -struct { int rx, tx, total, max, peak; } ppp; -struct { int perc, stat; double dur; } batt; -struct { double perc, cput; } seti; -struct { int num, unseen;} mail[MAILBOXES+1]; -struct { double val, min, max; } sensor[SENSORS+1]; +static char *row[ROWS+1]; +static int gpo[GPOS+1]; +static int rows, cols, xres, yres, supported_bars, gpos; +static int lines, scroll, turn; +static int token_usage[256]={0,}; + +static struct { int total, used, free, shared, buffer, cache, avail; } ram; +static struct { double load1, load2, load3, overload; } load; +static struct { double user, nice, system, idle; } busy; +static struct { int read, write, total, max, peak; } disk; +static struct { int rx, tx, total, max, peak, bytes; } net; +static struct { int usage, in, out, total, max, peak; } isdn; +static struct { int rx, tx, total, max, peak; } ppp; +static struct { int perc, stat; double dur; } batt; +static struct { double perc, cput; } seti; +static struct { int num, unseen;} mail[MAILBOXES+1]; +static struct { double val, min, max; } sensor[SENSORS+1]; static double query (int token) { @@ -654,12 +659,35 @@ static int process_gpo (int r) return (val > 0.0); } +static int Turn (void) +{ + struct timeval now; + static struct timeval old = {tv_sec:0, tv_usec:0}; + static struct timeval new = {tv_sec:0, tv_usec:0}; + + if (turn<=0) return 0; + + gettimeofday (&now, NULL); + if (now.tv_sec==new.tv_sec ? now.tv_usec>new.tv_usec : now.tv_sec>new.tv_sec) { + old=now; + new.tv_sec =old.tv_sec; + new.tv_usec=old.tv_usec+turn*1000; + while (new.tv_usec>=1000000) { + new.tv_usec-=1000000; + new.tv_sec++; + } + return 1; + } + return 0; +} + void process_init (void) { int i; load.overload=atof(cfg_get("overload","2.0")); + lcd_query (&rows, &cols, &xres, &yres, &supported_bars, &gpos); if (rows>ROWS) { error ("%d rows exceeds limit, reducing to %d rows", rows, ROWS); @@ -669,9 +697,42 @@ void process_init (void) error ("%d gpos exceeds limit, reducing to %d gpos", gpos, GPOS); gpos=GPOS; } - debug ("%d rows, %d columns, %dx%d pixels, %d GPOs", rows, cols, xres, yres, gpos); + debug ("Display: %d rows, %d columns, %dx%d pixels, %d GPOs", rows, cols, xres, yres, gpos); - for (i=1; i<=rows; i++) { + + lines=atoi(cfg_get("Rows","1")); + if (lines<1) { + error ("bad 'Rows' entry in %s, ignoring.", cfg_file()); + lines=1; + } + if (lines>ROWS) { + error ("%d virtual rows exceeds limit, reducing to %d rows", lines, ROWS); + lines=ROWS; + } + if (lines>rows) { + scroll=atoi(cfg_get("Scroll","1")); + if (scroll<1) { + error ("bad 'Scroll' entry in %s, ignoring and using '1'", cfg_file()); + scroll=1; + } + if (scroll>rows) { + error ("'Scroll' entry in %s is %d, > %d display rows.", cfg_file(), scroll, rows); + error ("This may lead to unexpected results!"); + } + turn=atoi(cfg_get("Turn","1000")); + if (turn<1) { + error ("bad 'Turn' entry in %s, ignoring and using '1000'", cfg_file()); + turn=1; + } + debug ("Virtual: %d rows, scroll %d lines every %d msec", lines, scroll, turn); + } else { + lines=rows; + scroll=0; + turn=0; + } + + + for (i=1; i<=lines; i++) { char buffer[8], *p; snprintf (buffer, sizeof(buffer), "Row%d", i); p=cfg_get(buffer,""); @@ -679,6 +740,7 @@ void process_init (void) row[i]=strdup(parse_row(p, supported_bars, token_usage)); } + for (i=1; i<=gpos; i++) { char buffer[8], *p; snprintf (buffer, sizeof(buffer), "GPO%d", i); @@ -690,12 +752,28 @@ void process_init (void) void process (int smooth) { - int i, val; + int i, j, val; char *txt; + static int offset=0; collect_data(); + + if (Turn()) { + offset+=scroll; + while (offset>=lines) { + offset-=lines; + } + // Fixme: this is ugly! + smooth=1; + lcd_clear(); + } + for (i=1; i<=rows; i++) { - txt=process_row (i); + j=i+offset; + while (j>lines) { + j-=lines; + } + txt=process_row (j); if (smooth==0) lcd_put (i, 1, txt); } -- cgit v1.2.3 l1-0/+2 2008-12-31handle config files with <CR><LF> (DOS line ending) ported from volker_dev (r...michael1-2/+6 2008-12-31netinfo plugin ported from volker_dev (r823)michael4-2/+255 2008-12-31format characters in qprintf() with optional length (r821) ported from volker...michael1-9/+63 2008-12-31short circuit evaluation ported from volker_dev (r820,r822,r824)michael1-8/+52 2008-12-31Fixes a buffer underrun error and possible array index issues by mcarey@...michael1-6/+13 2008-12-27ported r819 from volker_devmichael1-17/+21 2008-12-27ported and modified r818 from volker_devmichael3-11/+151 2008-12-27port r817 from volker_devmichael3-24/+944 2008-12-27ported (modified) r815 from voker_devmichael1-3/+23 2008-12-24cleanup & cosmeticsmichael5-22/+31 2008-12-24driver for the PHAnderson serial-to-HD44780 adapter boards by Nicolas Weillmichael5-5/+444 2008-12-24w1retap plugin by Jonathan Hudsonmichael7-0/+298 2008-12-24Enables/controls the backlight on the Pertelian LCD device by Jonathan Hudsonmichael1-10/+13 2008-12-23hddtemp plugin from Scott Bronsonmichael7-0/+343 2008-12-23keypad bug fixedmichael1-1/+1 2008-12-23patch from a.nielsen: inverted parport signals, support GPI on HD44780michael2-24/+89 2008-12-23indent runmichael1-4/+4 2008-11-25fix lcd4linux driver for multible onboard controllersmichux1-4/+4 2008-11-23fix automake - check for libftdimichux4-9/+173 2008-11-22update button_exec plugin - fix segfaultmichux1-3/+2 2008-11-22update fifo plugin - untestedmichux1-1/+1 2008-10-07Replace write to external variable usb_debug by calling usb_set_debug().bwalle7-16/+7 2008-10-06adding GPI to picoLCD for reading button events by Igor Mammedov <niallain@g...michael1-1/+22 2008-10-06properties fixedmichael11-3290/+2675 2008-10-05Rebuild auto-generated autoconf stuff due to last change in drivers.m4.bwalle3-2657/+3297 2008-10-05Add 'ULA200' driver when --with-drivers=all is specifiedbwalle1-0/+1 2008-09-14strftime_tz patch from Bernhard Wallemichael1-0/+11 2008-09-08strftime_tz() plugin by Bernhard Wallemichael1-0/+25 2008-09-03ULA200 driver by Bernhard Wallemichael7-2/+825 2008-09-03indentmichael1-4/+4 2008-08-31Increased the maximum bps to 230400, if defined in <termios.h>.sonic741-2/+7 2008-08-27git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@889 3ae390bd-cb1e-0410-...sonic741-18/+11 2008-08-27D4D updates by Svenmichael1-38/+60 2008-08-03driver for 4D Systems serial displays by Sven Killigmichael9-45/+846 2008-08-03signed/unsigned mismatchmichael1-3/+3 2008-07-26added command functionsmichux1-2/+130 2008-07-15added IRLCD driver by Jean-Philippe Civademichael10-5/+467 2008-07-15'autoreconf -f -i' run & config.rpath addedmichael8-370/+1617