add driver EyeboxOne for the LCD display on the EyeboxOne (Cedric TESSIER aka NeCetiC)
This commit is contained in:
@@ -4,7 +4,7 @@ sysconf_DATA = lcdproc.conf
|
||||
|
||||
bin_PROGRAMS = lcdproc
|
||||
|
||||
lcdproc_SOURCES = main.c main.h mode.c mode.h batt.c batt.h chrono.c chrono.h cpu.c cpu.h cpu_smp.c cpu_smp.h disk.c disk.h load.c load.h mem.c mem.h machine.h machine_Linux.c machine_OpenBSD.c machine_FreeBSD.c machine_NetBSD.c machine_Darwin.c machine_SunOS.c util.c util.h iface.c iface.h
|
||||
lcdproc_SOURCES = main.c main.h mode.c mode.h batt.c batt.h chrono.c chrono.h cpu.c cpu.h cpu_smp.c cpu_smp.h disk.c disk.h load.c load.h mem.c mem.h eyebox.c eyebox.h machine.h machine_Linux.c machine_OpenBSD.c machine_FreeBSD.c machine_NetBSD.c machine_Darwin.c machine_SunOS.c util.c util.h iface.c iface.h
|
||||
|
||||
lcdproc_LDADD = @ldap_libs@ ../../shared/libLCDstuff.a
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
/* This is the LCDproc client module for EyeboxOne devices
|
||||
|
||||
This allows to use leds, one as a free CPU meter, and one
|
||||
as a free RAM meter.
|
||||
|
||||
All this is in BETA version, take it as a demo...
|
||||
|
||||
Copyright (C) 2006 Cedric TESSIER (aka NeZetiC) http://www.nezetic.info
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "shared/sockets.h"
|
||||
#include "shared/debug.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "mode.h"
|
||||
#include "machine.h"
|
||||
#include "eyebox.h"
|
||||
#include "util.h"
|
||||
|
||||
int
|
||||
eyebox_screen(char display, int init)
|
||||
{
|
||||
#undef CPU_BUF_SIZE
|
||||
#define CPU_BUF_SIZE 4
|
||||
int i, j;
|
||||
double value;
|
||||
static double cpu[CPU_BUF_SIZE + 1][5]; // last buffer is scratch
|
||||
meminfo_type mem[2];
|
||||
load_type load;
|
||||
|
||||
if (init == 0) {
|
||||
sprintf(buffer, "widget_add %c eyebo_cpu string\n", display);
|
||||
sock_send_string(sock, buffer);
|
||||
sprintf(buffer, "widget_add %c eyebo_mem string\n", display);
|
||||
sock_send_string(sock, buffer);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
machine_get_load(&load);
|
||||
machine_get_meminfo(mem);
|
||||
|
||||
// Shift values over by one
|
||||
for (i = 0; i < (CPU_BUF_SIZE - 1); i++)
|
||||
for (j = 0; j < 5; j++)
|
||||
cpu[i][j] = cpu[i + 1][j];
|
||||
|
||||
// Read new data
|
||||
if (load.total > 0L) {
|
||||
cpu[CPU_BUF_SIZE - 1][0] = 100.0 * ((double) load.user / (double) load.total);
|
||||
cpu[CPU_BUF_SIZE - 1][1] = 100.0 * ((double) load.system / (double) load.total);
|
||||
cpu[CPU_BUF_SIZE - 1][2] = 100.0 * ((double) load.nice / (double) load.total);
|
||||
cpu[CPU_BUF_SIZE - 1][3] = 100.0 * ((double) load.idle / (double) load.total);
|
||||
cpu[CPU_BUF_SIZE - 1][4] = 100.0 * (((double) load.user + (double) load.system + (double) load.nice) / (double) load.total);
|
||||
}
|
||||
else {
|
||||
cpu[CPU_BUF_SIZE - 1][0] = 0.0;
|
||||
cpu[CPU_BUF_SIZE - 1][1] = 0.0;
|
||||
cpu[CPU_BUF_SIZE - 1][2] = 0.0;
|
||||
cpu[CPU_BUF_SIZE - 1][3] = 0.0;
|
||||
cpu[CPU_BUF_SIZE - 1][4] = 0.0;
|
||||
}
|
||||
|
||||
// Average values for final result
|
||||
for (i = 0; i < 5; i++) {
|
||||
value = 0.0;
|
||||
for (j = 0; j < CPU_BUF_SIZE; j++)
|
||||
value += cpu[j][i];
|
||||
value /= CPU_BUF_SIZE;
|
||||
cpu[CPU_BUF_SIZE][i] = value;
|
||||
}
|
||||
|
||||
/*
|
||||
* /xBab = Use Bar
|
||||
* a = Bar ID
|
||||
* b = Level
|
||||
*/
|
||||
|
||||
sprintf(buffer, "widget_set %c eyebo_cpu 1 2 {/xB%d%d}\n", display, 2,(int)(cpu[CPU_BUF_SIZE][4]/10));
|
||||
sock_send_string(sock, buffer);
|
||||
|
||||
/*
|
||||
* /xBab = Use Bas
|
||||
* a = Bar ID
|
||||
* b = Level
|
||||
*/
|
||||
|
||||
value = 1.0 - (double) (mem[0].free + mem[0].buffers + mem[0].cache)
|
||||
/ (double) mem[0].total;
|
||||
sprintf(buffer, "widget_set %c eyebo_mem 1 3 {/xB%d%d}\n", display, 1, (int) (value * 10)) ;
|
||||
sock_send_string(sock, buffer);
|
||||
|
||||
return 0;
|
||||
} // End mem_screen()
|
||||
|
||||
void eyebox_clear(void){
|
||||
/*
|
||||
* Clear LEDs before exit
|
||||
*/
|
||||
sock_send_string(sock, "screen_add OFF\n");
|
||||
sock_send_string(sock, "screen_set OFF -priority alert -name {EyeBO}\n");
|
||||
sock_send_string(sock, "widget_add OFF title title\n");
|
||||
sock_send_string(sock, "widget_set OFF title {EYEBOX ONE}\n");
|
||||
sock_send_string(sock, "widget_add OFF text string\n");
|
||||
sock_send_string(sock, "widget_add OFF about string\n");
|
||||
sock_send_string(sock, "widget_add OFF cpu string\n");
|
||||
sock_send_string(sock, "widget_add OFF mem string\n");
|
||||
|
||||
sock_send_string(sock, "widget_set OFF text 1 2 {Reseting Leds...}\n");
|
||||
sock_send_string(sock, "widget_set OFF about 5 4 {EyeBO by NeZetiC}\n");
|
||||
sprintf(buffer, "widget_set OFF cpu 1 2 {/xB%d%d}\n", 2, 0);
|
||||
sock_send_string(sock, buffer);
|
||||
sprintf(buffer, "widget_set OFF mem 1 3 {/xB%d%d}\n", 1, 0);
|
||||
sock_send_string(sock, buffer);
|
||||
usleep(2000000); /* Wait last order execution */
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef CTRL_H
|
||||
#define CTRL_H
|
||||
|
||||
int eyebox_screen (char display, int init);
|
||||
void eyebox_clear(void);
|
||||
|
||||
#endif
|
||||
@@ -34,6 +34,9 @@
|
||||
#include "mem.h"
|
||||
#include "machine.h"
|
||||
#include "iface.h"
|
||||
#ifdef LCDPROC_EYEBOXONE
|
||||
# include "eyebox.h"
|
||||
#endif
|
||||
|
||||
// TODO: Commenting... Everything!
|
||||
|
||||
@@ -433,6 +436,12 @@ HelpScreen (int exit_state)
|
||||
void
|
||||
exit_program(int val)
|
||||
{
|
||||
#ifdef LCDPROC_EYEBOXONE
|
||||
/*
|
||||
* Clear Eyebox Leds
|
||||
*/
|
||||
eyebox_clear();
|
||||
#endif
|
||||
//printf("exit program\n");
|
||||
Quit = 1;
|
||||
sock_close(sock);
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#include "mode.h"
|
||||
#include "main.h"
|
||||
#include "machine.h"
|
||||
#ifdef LCDPROC_EYEBOXONE
|
||||
# include "eyebox.h"
|
||||
#endif
|
||||
|
||||
// TODO: Clean this up... Support multiple display sizes..
|
||||
|
||||
@@ -66,6 +69,13 @@ update_screen(mode *m, int display)
|
||||
int old_status = status;
|
||||
|
||||
if (m && m->func) {
|
||||
#ifdef LCDPROC_EYEBOXONE
|
||||
/* Eyebox Init */
|
||||
if((m->flags & INITIALIZED) == 0)
|
||||
eyebox_screen(m->which,0);
|
||||
/* Eyebox Flush */
|
||||
eyebox_screen(m->which,1);
|
||||
#endif
|
||||
status = m->func(m->timer, display, &(m->flags));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user