make LowLoad / HighLoad lcdproc.conf parameters instead compile time options
This commit is contained in:
@@ -68,6 +68,10 @@ Active=True
|
|||||||
[Load]
|
[Load]
|
||||||
# Show screen
|
# Show screen
|
||||||
Active=True
|
Active=True
|
||||||
|
# Min Load Avg at which the backlight will be turned off [default: 0.05]
|
||||||
|
LowLoad=0.05
|
||||||
|
# Max Load Avg at which the backlight will start blinking [default: 1.3]
|
||||||
|
HighLoad=1.3
|
||||||
|
|
||||||
|
|
||||||
[TimeDate]
|
[TimeDate]
|
||||||
|
|||||||
+13
-4
@@ -8,6 +8,7 @@
|
|||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "shared/configfile.h"
|
||||||
#include "shared/sockets.h"
|
#include "shared/sockets.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "mode.h"
|
#include "mode.h"
|
||||||
@@ -30,13 +31,19 @@ xload_screen (int rep, int display, int *flags_ptr)
|
|||||||
{
|
{
|
||||||
static int gauge_hgt = 0;
|
static int gauge_hgt = 0;
|
||||||
static double loads[LCD_MAX_WIDTH];
|
static double loads[LCD_MAX_WIDTH];
|
||||||
|
static double lowLoad = LOAD_MIN;
|
||||||
|
static double highLoad = LOAD_MAX;
|
||||||
int loadtop, i;
|
int loadtop, i;
|
||||||
double loadmax = 0, factor;
|
double loadmax = 0, factor;
|
||||||
int status = 0;
|
int status = BACKLIGHT_ON;
|
||||||
|
|
||||||
if ((*flags_ptr & INITIALIZED) == 0) {
|
if ((*flags_ptr & INITIALIZED) == 0) {
|
||||||
*flags_ptr |= INITIALIZED;
|
*flags_ptr |= INITIALIZED;
|
||||||
|
|
||||||
|
/* get config values */
|
||||||
|
lowLoad = config_get_float("Load", "LowLoad", 0, LOAD_MIN);
|
||||||
|
highLoad = config_get_float("Load", "HighLoad", 0, LOAD_MAX);
|
||||||
|
|
||||||
gauge_hgt = (lcd_hgt > 2) ? (lcd_hgt - 1) : lcd_hgt;
|
gauge_hgt = (lcd_hgt > 2) ? (lcd_hgt - 1) : lcd_hgt;
|
||||||
memset (loads, '\0', sizeof (double) * LCD_MAX_WIDTH);
|
memset (loads, '\0', sizeof (double) * LCD_MAX_WIDTH);
|
||||||
|
|
||||||
@@ -105,9 +112,11 @@ xload_screen (int rep, int display, int *flags_ptr)
|
|||||||
sock_send_string (sock, tmp);
|
sock_send_string (sock, tmp);
|
||||||
|
|
||||||
// set return status depending on max & current load
|
// set return status depending on max & current load
|
||||||
status = (loadmax > LOAD_MIN) ? BACKLIGHT_ON : BACKLIGHT_OFF;
|
if (lowLoad < highLoad) {
|
||||||
if (loads[lcd_wid - 2] > LOAD_MAX)
|
status = (loadmax > lowLoad) ? BACKLIGHT_ON : BACKLIGHT_OFF;
|
||||||
status = BLINK_ON;
|
if (loads[lcd_wid - 2] > highLoad)
|
||||||
|
status = BLINK_ON;
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
} // End xload_screen()
|
} // End xload_screen()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#define LOAD_MAX 1.3
|
#define LOAD_MAX 1.3
|
||||||
#endif
|
#endif
|
||||||
#ifndef LOAD_MIN
|
#ifndef LOAD_MIN
|
||||||
#define LOAD_MIN 0.5
|
#define LOAD_MIN 0.05
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int xload_screen (int rep, int display, int *flags_ptr);
|
int xload_screen (int rep, int display, int *flags_ptr);
|
||||||
|
|||||||
@@ -225,22 +225,6 @@ AC_DEFINE_UNQUOTED(PROTOCOL_VERSION, "0.3", [Define version of lcdproc client-se
|
|||||||
AC_DEFINE_UNQUOTED(API_VERSION, "0.5", [Define version of lcdproc API])
|
AC_DEFINE_UNQUOTED(API_VERSION, "0.5", [Define version of lcdproc API])
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_WITH(loadmax,
|
|
||||||
[ --with-loadmax=<load> Max Load Avg at which the backlight will]
|
|
||||||
[ start blinking [1.3]],
|
|
||||||
LOAD_MAX=$withval,
|
|
||||||
LOAD_MAX=1.3
|
|
||||||
)
|
|
||||||
AC_DEFINE_UNQUOTED(LOAD_MAX, $LOAD_MAX, [Define max Load Avg at which the backlight will start blinking])
|
|
||||||
|
|
||||||
AC_ARG_WITH(loadmin,
|
|
||||||
[ --with-loadmin=<load> Min Load Avg at which the backlight will]
|
|
||||||
[ turn off (asleep) [0.05]],
|
|
||||||
LOAD_MIN=$withval,
|
|
||||||
LOAD_MIN=0.05
|
|
||||||
)
|
|
||||||
AC_DEFINE_UNQUOTED(LOAD_MIN, $LOAD_MIN, [Define min Load Avg at which the backlight will turn off])
|
|
||||||
|
|
||||||
AC_MODULES_INFO
|
AC_MODULES_INFO
|
||||||
|
|
||||||
dnl ######################################################################
|
dnl ######################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user