You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(21) |
Aug
(12) |
Sep
(4) |
Oct
(13) |
Nov
(124) |
Dec
(35) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(19) |
Feb
(1) |
Mar
(10) |
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(50) |
Oct
|
Nov
(15) |
Dec
(39) |
| 2008 |
Jan
(89) |
Feb
(1) |
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(7) |
Feb
(7) |
Mar
(2) |
Apr
(23) |
May
(3) |
Jun
(10) |
Jul
(5) |
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
|
| 2010 |
Jan
(3) |
Feb
(4) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(2) |
| 2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <cza...@us...> - 2009-06-28 18:57:43
|
Revision: 514
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=514&view=rev
Author: czarnyckm
Date: 2009-06-28 18:57:28 +0000 (Sun, 28 Jun 2009)
Log Message:
-----------
- Many fixes, clean up
- Changed version to 1.90
- CPU Frequency use proper sysfs variable
- New Summary Screen indicators
- Network current traffic info in the bottom line
- Refactor CPU variants into separates additional screens: Summary, CPU and CPU Freq.
- New Fan Speed Screen
- After change screen cycle the info bar content is set to the screen default one.
- Net Screen scaling is now controlled with the L4 key
- Force start temperature sensor id with the option -t id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/...)
- Force start fan speed sensor id with the option -f id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/...)
- Force to show temperature [id] in place of the maximal one on the Summary Screen with the option ie -gt 1
(the id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input)
- On the Fan / Temp Screen Current sensor is controlled with the L4 key (on systems with more then one sensor only).
- Every Screen has his own mode now (except Swap, Memory and Battery Screen)
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/configure.in
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-14 13:31:49 UTC (rev 513)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-28 18:57:28 UTC (rev 514)
@@ -28,4 +28,19 @@
- Clean up
SVN 513:
- Improve bottom line and keywatch logic
-
+SVN 514:
+- Many fixes, clean up
+- Changed version to 1.90
+- CPU Frequency use proper sysfs variable
+- New Summary Screen indicators
+- Network current traffic info in the bottom line
+- Refactor CPU variants into separates additional screens: Summary, CPU and CPU Freq.
+- New Fan Speed Screen
+- After change screen cycle the info bar content is set to the screen default one.
+- Net Screen scaling is now controlled with the L4 key
+- Force start temperature sensor id with the option -t id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/...)
+- Force start fan speed sensor id with the option -f id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/...)
+- Force to show temperature [id] in place of the maximal one on the Summary Screen with the option ie -gt 1
+ (the id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input)
+- On the Fan / Temp Screen Current sensor is controlled with the L4 key (on systems with more then one sensor only).
+- Every Screen has his own mode now (except Swap, Memory and Battery Screen)
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-06-14 13:31:49 UTC (rev 513)
+++ trunk/g15daemon-clients/g15stats/README 2009-06-28 18:57:28 UTC (rev 514)
@@ -1,12 +1,15 @@
-G15Stats - a CPU/Memory/Swap/Network/Battery usage meter for G15Daemon.
+G15Stats - a CPU/Memory/Swap/Network/Battery/Temperature/Fan Speed/CPU Frequencies usage meter for G15Daemon.
-This first version of G15Stats requires libgtop development packages to be
-installed before compilation.
+The G15Stats requires libgtop development packages to be installed before compilation.
Features:
-CPU Screen displays graphs of User/System/Nice and Idle time, along with frequency,
-LoadAVG and Uptime.
+Summary Screen displays 4 or 5 indicators from CPU/Frequency/Memory/NET/Temperature/Fan Speed/Swap,
+ along with current time.
+CPU Screen displays graphs of User/System/Nice and Idle time, along with LoadAVG and Uptime.
+
+Frequency Screen displays all CPU cores frequency with the total
+
Memory Screen displays Memory Total & Free, and graph of Used vs
Buffered+Cached Memory.
@@ -17,8 +20,10 @@
Battery Status Screen displays battery charge data for up to three batteries
-Temperature Screen displays temperature current status for up to three sensors
+Temperature Screen displays temperature status for available sensors
+Fan Speed Screen displays fan current speed for the available sensors
+
Options:
-i interface Gather statistics from named interface (ie -i eth0)
-d Run in background (daemonise)
@@ -26,9 +31,14 @@
default is to scale against the highest peak in the current graph.
-h Show help
-u Display unicore graphs only on the CPU screen
--s id Force to monitor temperature sensor id (ie -s 1)
+-t id Force to monitor temperature sensor id on start (ie -t 1)
The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input
- Default the sensor id is autoetected.
+ Default the sensor id is auto-detected.
+-f id Force to monitor fan speed sensor id on start (ie -f 1)
+ The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/fan1_input
+ Default the sensor id is auto-detected.
+-gt id Show temperature [id] in place of the maximal one on the Summary Screen with the option -gt id ie -gt 1
+ The id should point to sysfs path /sys/class/hwmon/hwmon../device/temp[id]_input
Usage:
$> g15stats
@@ -37,7 +47,7 @@
L2: Previous Screen
L3: Next Screen
-L4: Alternative Screen (Work at this moment with the CPU Screen only)
+L4: Alternative Screen (Doesn't work on Swap, Memory and Battery Screen)
L5: Bottom Info bar mode
BUGS:
Modified: trunk/g15daemon-clients/g15stats/configure.in
===================================================================
--- trunk/g15daemon-clients/g15stats/configure.in 2009-06-14 13:31:49 UTC (rev 513)
+++ trunk/g15daemon-clients/g15stats/configure.in 2009-06-28 18:57:28 UTC (rev 514)
@@ -1,7 +1,7 @@
AC_INIT(g15stats,[1.1], [mla...@us...])
PACKAGE=g15stats
-VERSION=1.1
+VERSION=1.90
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-14 13:31:49 UTC (rev 513)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-28 18:57:28 UTC (rev 514)
@@ -24,7 +24,7 @@
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
-This is a simple stats client showing graphs for CPU, MEM & Swap usage, Network traffic and Battery life.
+This is a simple stats client showing graphs for CPU, MEM & Swap usage, Network traffic, Temperatures, CPU Frequency and Battery life.
*/
#define _GNU_SOURCE 1
@@ -58,32 +58,53 @@
int g15screen_fd;
-int cycle = 0;
-int info_cycle = 0;
+int cycle = 0;
+int info_cycle = 0;
/** Holds the mode type variable of the application running */
-int mode = 0;
+int mode[MAX_SCREENS];
/** Holds the sub mode type variable of the application running */
-int submode = 0;
+int submode = 0;
-int have_freq = 1;
-int have_sensor = 1;
-int have_bat = 1;
-int have_nic = 0;
+int info_cycle_timer = -1;
-int sensor_id = 0;
+// Summary Screen indicators count 4 or 5
+int summary_rows = 4;
+int have_freq = 2;
+_Bool have_temp = 1;
+_Bool have_fan = 1;
+_Bool have_bat = 1;
+_Bool have_nic = 0;
+
+_Bool sensor_type_temp[MAX_SENSOR];
+_Bool sensor_type_fan[MAX_SENSOR];
+
+_Bool sensor_lost_temp[MAX_SENSOR];
+_Bool sensor_lost_fan[MAX_SENSOR];
+
+int sensor_temp_id = 0;
+int sensor_temp_main = 0;
+
+int sensor_fan_id = 0;
+
/** Holds the number of the cpus */
int ncpu;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
-unsigned long net_max_in=0;
-unsigned long net_max_out=0;
+unsigned long net_max_in = 100;
+unsigned long net_max_out = 100;
-unsigned long previous_in;
-unsigned long previous_out;
+unsigned long net_cur_in = 0;
+unsigned long net_cur_out = 0;
+float temp_tot_cur = 1;
+float temp_tot_max = 1;
+
+float fan_tot_cur = 1;
+float fan_tot_max = 1;
+
_Bool net_scale_absolute=0;
pthread_cond_t wake_now = PTHREAD_COND_INITIALIZER;
@@ -94,31 +115,55 @@
return b;
}
+void format_float(char *tmpstr, char *format_less, char * format_great, float value){
+ if (value < 9.9) {
+ sprintf(tmpstr,format_less,value);
+ } else {
+ sprintf(tmpstr,format_great,(unsigned long)value);
+ }
+}
+
+char * show_bytes_short(unsigned long bytes) {
+ static char tmpstr[32];
+ if(bytes>=1024*1024) {
+ format_float(tmpstr, "%4.1fM","%4liM", (float)bytes / (1024*1024));
+ }
+ else if(bytes >= 1024) {
+ format_float(tmpstr, "%4.1fk","%4lik", (float)bytes / 1024);
+ }
+ else {
+ sprintf(tmpstr,"%4liB",bytes);
+ }
+ return tmpstr;
+}
+
+
char * show_bytes(unsigned long bytes) {
static char tmpstr[32];
- if(bytes>1024*1024) {
- bytes = bytes / (1024*1024);
- sprintf(tmpstr,"%liMb",bytes);
+ if(bytes>=1024*1024) {
+ format_float(tmpstr, "%2.1fMB","%liMB", (float)bytes / (1024*1024));
}
- else if(bytes<1024*1024 && bytes > 1024) {
- bytes = bytes / 1024;
- sprintf(tmpstr,"%likb",bytes);
+ else if(bytes >= 1024) {
+ format_float(tmpstr, "%2.1fMB","%likB", (float)bytes / 1024);
}
- else if(bytes<1024) {
- sprintf(tmpstr,"%lib",bytes);
+ else {
+ sprintf(tmpstr,"%liB",bytes);
}
return tmpstr;
}
-char * show_hertz_logic(int hertz, char * hz) {
+char * show_hertz_logic(int hertz, char *hz) {
static char tmpstr[32];
- if (hertz > 1000000) {
- sprintf(tmpstr, " %3.1fG%s", ((float)hertz / 1000000), hz);
- } else if (hertz > 1000) {
- sprintf(tmpstr, " %3.fM%s", ((float)hertz / 1000), hz);
+ if (hertz >= 1000000) {
+ format_float(tmpstr, "%3.1fG","%3.fG", (float)hertz / 1000000);
+ } else if (hertz >= 1000) {
+ format_float(tmpstr, "%3.1fM","%3liM", (float)hertz / 1000);
} else {
- sprintf(tmpstr, " %3iK%s", hertz, hz);
+ sprintf(tmpstr, "%3iK", hertz);
}
+ if (strlen((char *)hz) > 0) {
+ strcat(tmpstr, hz);
+ }
return tmpstr;
}
@@ -130,6 +175,42 @@
return show_hertz_logic(hertz, "Hz");
}
+void print_vert_label_logic(g15canvas *canvas, char *label, unsigned int sx){
+ int i;
+ int len =strlen((char *)label);
+ if (len > 5) {
+ len = 5;
+ }
+ int starty = 0;
+ int incy = 0;
+ switch (len){
+ case 6 :
+ break;
+ case 5 :
+ starty = 0;
+ break;
+ case 4 :
+ starty = 4;
+ break;
+ case 3 :
+ starty = 3;
+ incy = 4;
+ break;
+ default :
+ return;
+ }
+ char val[2];
+ for (i=0; i<len; i++) {
+ memcpy (val, &(label[i]), 1);
+ val[1] = '\0';
+ g15r_renderString (canvas, (unsigned char*)val, i, G15_TEXT_MED, sx, starty+(i*incy));
+ }
+}
+
+void print_vert_label(g15canvas *canvas, char *label){
+ print_vert_label_logic(canvas, label, TEXT_RIGHT);
+}
+
void drawBar_reversed (g15canvas * canvas, int x1, int y1, int x2, int y2, int color,
int num, int max, int type)
{
@@ -177,6 +258,21 @@
}
}
+void drawBar_both(g15canvas *canvas, int y1, int y2, int bar_current, int bar_total, int rbar_current, int rbar_total) {
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, bar_current, bar_total, 4);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, rbar_current, rbar_total, 5);
+}
+
+void drawLine_both(g15canvas *canvas, int y1, int y2) {
+ g15r_drawLine(canvas, VL_LEFT, y1, VL_LEFT, y2, G15_COLOR_BLACK);
+ g15r_drawLine(canvas, VL_LEFT + 1, y1, VL_LEFT + 1, y2, G15_COLOR_BLACK);
+}
+
+void drawAll_both(g15canvas *canvas, int y1, int y2, int bar_current, int bar_total, int rbar_current, int rbar_total) {
+ drawBar_both(canvas, y1, y2, bar_current, bar_total, rbar_current, rbar_total);
+ drawLine_both(canvas, y1, y2);
+}
+
int daemonise(int nochdir, int noclose) {
pid_t pid;
@@ -221,10 +317,10 @@
}
}
-int get_sysfs_value(char * filename) {
- static int ret_val = -1;
+int get_sysfs_value(char *filename) {
+ int ret_val = -1;
FILE *fd_main;
- char tmpstr [MAX_LINES];
+ static char tmpstr [MAX_LINES];
fd_main = fopen(filename, "r");
if (fd_main != NULL) {
@@ -239,17 +335,28 @@
return ret_val;
}
-int get_processor_freq(char * which, int core) {
- char tmpstr [MAX_LINES];
+int get_processor_freq(char *which, int core) {
+ static char tmpstr [MAX_LINES];
sprintf(tmpstr, "/sys/devices/system/cpu/cpu%d/cpufreq/%s", core, which);
return get_sysfs_value(tmpstr);
}
int get_cpu_freq_cur(int core) {
- int ret_val = get_processor_freq("cpuinfo_cur_freq", core);
+ int ret_val;
+ switch (have_freq) {
+ case 2:
+ ret_val = get_processor_freq("scaling_cur_freq", core);
+ break;
+ default:
+ ret_val = get_processor_freq("cpuinfo_%s_freq", core);
+ break;
+ }
if ((!core) && (ret_val == SENSOR_ERROR)) {
- have_freq = 0;
- printf("Frequency sensor doesn't appear to exist with id=%d . ", sensor_id);
+ have_freq--;
+ if (have_freq < 0) {
+ have_freq = 0;
+ }
+ printf("Frequency sensor doesn't appear to exist for core=%d . ", core);
}
return ret_val;
}
@@ -262,12 +369,32 @@
return get_processor_freq("cpuinfo_min_freq", core);
}
-int get_temp(char * which, int id) {
+int get_hwmon(int sensor_id, char *sensor, char *which, int id, _Bool sensor_type) {
char tmpstr [MAX_LINES];
- sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_%s", sensor_id, id, which);
+ if(sensor_type) {
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/%s%d_%s", sensor_id, sensor, id, which);
+ } else {
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/%s%d_%s", sensor_id, sensor, id, which);
+ }
return get_sysfs_value(tmpstr);
}
+int get_fan(char *which, int id) {
+ return get_hwmon(sensor_fan_id, "fan", which, id, sensor_type_fan[sensor_fan_id]);
+}
+
+int get_fan_cur(int id) {
+ return get_fan("input", id);
+}
+
+int get_fan_max(int id) {
+ return get_fan("alarm", id);
+}
+
+int get_temp(char *which, int id) {
+ return get_hwmon(sensor_temp_id, "temp", which, id, sensor_type_temp[sensor_temp_id]);
+}
+
int get_temp_cur(int id) {
return get_temp("input", id);
}
@@ -276,8 +403,120 @@
return get_temp("max", id);
}
-void print_sys_load_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
+int get_next(int sensor_id, _Bool *sensor_lost){
+ int new_sensor_id;
+ new_sensor_id = sensor_id;
+ do {
+ new_sensor_id++;
+ if (new_sensor_id >= MAX_SENSOR) {
+ new_sensor_id = 0;
+ }
+ if (!sensor_lost[new_sensor_id]){
+ return new_sensor_id;
+ }
+ } while(sensor_id != new_sensor_id);
+ return SENSOR_ERROR;
+}
+
+int get_temperature(g15_stats_info *temps) {
+ int count = 0;
+ temp_tot_cur = 0;
+
+ for (count = 0; count < NUM_TEMP; count++) {
+ if ((temps[count].cur = get_temp_cur(count + 1)) == SENSOR_ERROR) {
+ break;
+ }
+ temps[count].cur /= 1000;
+ temps[count].max = get_temp_max(count + 1);
+ temps[count].max /= 1000;
+
+ if (temp_tot_max < temps[count].max) {
+ temp_tot_max = temps[count].max;
+ }
+
+ if ((sensor_temp_main == (count +1)) || ((!sensor_temp_main) && (temp_tot_cur <temps[count].cur))) {
+ temp_tot_cur = temps[count].cur;
+ }
+ }
+ if ((!count) && (temps[0].cur == SENSOR_ERROR)) {
+ if (sensor_type_temp[sensor_temp_id]) {
+ sensor_lost_temp[sensor_temp_id] = 1;
+ printf("Temperature sensor doesn't appear to exist with id=%d .\n", sensor_temp_id);
+ sensor_temp_id = get_next(sensor_temp_id, sensor_lost_temp);
+ if (sensor_temp_id != SENSOR_ERROR) {
+ return get_temperature(temps);
+ }
+ } else {
+ sensor_type_temp[sensor_temp_id] = 1;
+ return get_temperature(temps);
+ }
+
+ if (sensor_temp_id == SENSOR_ERROR) {
+ have_temp = 0;
+ printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
+ return 0;
+ }
+ }
+
+ if (count >= NUM_TEMP) {
+ count = NUM_TEMP;
+ } else if(temps[count].cur != SENSOR_ERROR) {
+ count++;
+ }
+ return count;
+}
+
+int get_fans(g15_stats_info *fans) {
+ int count = 0;
+ fan_tot_cur = 0;
+ for (count = 0; count < NUM_FAN; count++) {
+
+ if ((fans[count].cur = get_fan_cur(count + 1)) == SENSOR_ERROR) {
+ break;
+ }
+ fans[count].max = get_fan_max(count + 1);
+
+ if (fan_tot_max < fans[count].max) {
+ fan_tot_max = fans[count].max;
+ }
+
+ if (fan_tot_cur <fans[count].cur) {
+ fan_tot_cur = fans[count].cur;
+ }
+
+ if (fan_tot_max < fan_tot_cur) {
+ fan_tot_max = (fan_tot_cur * 1.2);
+ }
+ }
+ if ((!count) && (fans[count].cur == SENSOR_ERROR)) {
+ if (sensor_type_fan[sensor_fan_id]) {
+ sensor_lost_fan[sensor_fan_id] = 1;
+ printf("Fan sensor doesn't appear to exist with id=%d .\n", sensor_fan_id);
+ sensor_fan_id = get_next(sensor_fan_id, sensor_lost_fan);
+ if (sensor_fan_id != SENSOR_ERROR) {
+ return get_fans(fans);
+ }
+ } else {
+ sensor_type_fan[sensor_fan_id] = 1;
+ return get_fans(fans);
+ }
+ if (sensor_fan_id == SENSOR_ERROR) {
+ have_fan = 0;
+ printf("Fan sensor doesn't appear to exist. Fan screen will be disabled.\n");
+ return 0;
+ }
+
+ }
+
+ if (count >= NUM_FAN) {
+ count = NUM_FAN;
+ } else if(fans[count].cur != SENSOR_ERROR) {
+ count++;
+ }
+ return count;
+}
+
+void print_sys_load_info(g15canvas *canvas, char *tmpstr) {
glibtop_loadavg loadavg;
glibtop_uptime uptime;
@@ -294,76 +533,73 @@
hours=(int)hours-(days*24);
sprintf(tmpstr,"LoadAVG %.2f %.2f %.2f | Uptime %.fd%.fh",loadavg.loadavg[0],loadavg.loadavg[1],loadavg.loadavg[2],days,hours);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void print_mem_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
+void print_mem_info(g15canvas *canvas, char *tmpstr) {
glibtop_mem mem;
glibtop_get_mem(&mem);
- sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ sprintf(tmpstr,"Memory Used %dMB | Memory Total %dMB",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void print_swap_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
+void print_swap_info(g15canvas *canvas, char *tmpstr) {
glibtop_swap swap;
glibtop_get_swap(&swap);
- sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ sprintf(tmpstr,"Swap Used %dMB | Swap Avail. %dMB",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void print_net_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
+void print_net_peak_info(g15canvas *canvas, char *tmpstr) {
sprintf(tmpstr,"Peak IN %s/s|",show_bytes(net_max_in));
strcat(tmpstr,"Peak OUT ");
strcat(tmpstr,show_bytes(net_max_out));
strcat(tmpstr,"/s");
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void print_freq_info(g15canvas *canvas) {
- char tmpstr[MAX_LINES];
- int normal = 1;
+void print_net_current_info(g15canvas *canvas, char *tmpstr) {
+ sprintf(tmpstr,"Current IN %s/s|",show_bytes(net_cur_in));
+ strcat(tmpstr,"Current OUT ");
+ strcat(tmpstr,show_bytes(net_cur_out));
+ strcat(tmpstr,"/s");
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
+}
+
+void print_freq_info(g15canvas *canvas, char *tmpstr) {
+ char proc[12];
int core;
init_cpu_count();
- if (ncpu < 5) {
- sprintf(tmpstr, "%s", "CPU ");
- } else if (ncpu > 5) {
- normal = 0;
- sprintf(tmpstr, "%s", "");
- } else {
- sprintf(tmpstr, "%s", "");
- }
+ sprintf(tmpstr, "%s", "");
- for (core = 0; core < ncpu; core++) {
- if (normal) {
+ for (core = 0; (core < ncpu) && (core < 6); core++) {
+ sprintf(proc, "C%d ", core);
+ strcat(tmpstr,proc);
+ if (ncpu < 5) {
strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
} else {
strcat(tmpstr, show_hertz_short(get_cpu_freq_cur(core)));
}
if ((core + 1) < ncpu) {
- strcat(tmpstr, " |");
+ strcat(tmpstr, "|");
}
}
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, BOTTOM_ROW);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
}
-void print_time_info(g15canvas *canvas){
- char tmpstr[MAX_LINES];
+void print_time_info(g15canvas *canvas, char *tmpstr){
time_t now;
time(&now);
sprintf(tmpstr,"%s",ctime(&now));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
-void draw_mem_screen(g15canvas *canvas) {
+void draw_mem_screen(g15canvas *canvas, char *tmpstr) {
glibtop_mem mem;
- char tmpstr[MAX_LINES];
glibtop_get_mem(&mem);
@@ -387,18 +623,13 @@
g15r_drawBar(canvas,BAR_START,23,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,mem_cached,mem_total,4);
drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,mem_free,mem_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
+ drawLine_both(canvas, 1, BAR_BOTTOM);
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+ print_vert_label(canvas, "FREE");
}
-void draw_swap_screen(g15canvas *canvas) {
+void draw_swap_screen(g15canvas *canvas, char *tmpstr) {
glibtop_swap swap;
- char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -411,25 +642,131 @@
sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap_used/(float)swap_total)*100));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 19);
- g15r_drawBar(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,swap_used,swap_total,4);
+ drawAll_both(canvas, 1, BAR_BOTTOM, swap_used, swap_total, swap_total-swap_used, swap_total);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,swap_total-swap_used,swap_total,5);
+ print_vert_label(canvas, "FREE");
+}
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
+void print_label(g15canvas *canvas, char *tmpstr, int cur_shift) {
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, cur_shift + 1);
+}
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+void draw_summary_screen(g15canvas *canvas, char *tmpstr, int y1, int y2, int shift, int id) {
+ // Memory section
+ glibtop_mem mem;
+ glibtop_get_mem(&mem);
+ int mem_total = (mem.total / 1024);
+ int mem_used = mem_total - (mem.free / 1024);
+
+ int cur_shift = shift * id;
+
+ int y;
+ int last_y;
+ int j;
+ int step;
+ int count;
+
+ // Memory section
+ sprintf(tmpstr, "MEM %3.f%%", ((float) (mem_used) / (float) mem_total)*100);
+ print_label(canvas, tmpstr, cur_shift);
+
+ drawAll_both(canvas, cur_shift + y1, cur_shift + y2, mem_used + 1, mem_total, mem_total - mem_used, mem_total);
+
+ id++;
+ cur_shift += shift;
+
+ // Network section
+ if (have_nic) {
+ y = y2 / 2;
+
+ drawLine_both(canvas, cur_shift + y1, cur_shift + y2);
+ drawBar_both(canvas, cur_shift + y1, cur_shift + y, net_cur_in + 1, net_max_in, net_max_in - net_cur_in, net_max_in);
+
+ if ((y * 2) < y2) {
+ y++;
+ }
+
+ drawBar_both(canvas, cur_shift + y, cur_shift + y2, net_cur_out + 1, net_max_out, net_max_out - net_cur_out, net_max_out);
+
+ if (net_cur_in > net_cur_out) {
+ sprintf(tmpstr, "IN %s", show_bytes_short((int) net_cur_in));
+ } else {
+ sprintf(tmpstr, "OUT%s", show_bytes_short((int) net_cur_out));
+ }
+ print_label(canvas, tmpstr, cur_shift);
+
+ id++;
+ cur_shift += shift;
+ }
+ // Temperature section
+ if ((have_temp) && (id < summary_rows)) {
+ g15_stats_info sensors[NUM_FAN];
+ count = get_temperature(sensors);
+ if ((count) && (have_temp)) {
+ j = 0;
+ step = (int) (y2 / count);
+ y = cur_shift + y1;
+ for (j = 0; j < count; j++) {
+ last_y = y;
+ y += step;
+ drawBar_both(canvas, last_y, y, sensors[j].cur + 1, temp_tot_max, temp_tot_max - sensors[j].cur, temp_tot_max);
+ }
+ drawLine_both(canvas, cur_shift + y1, y);
+
+ sprintf(tmpstr, "TEM %3.f\xb0", temp_tot_cur);
+ print_label(canvas, tmpstr, cur_shift);
+
+ id++;
+ cur_shift += shift;
+ }
+ }
+
+ // Fan section
+ if ((have_fan) && (id < summary_rows)) {
+ g15_stats_info sensors[NUM_FAN];
+ count = get_fans(sensors);
+ if ((count) && (have_fan)) {
+ j = 0;
+ step = (int) (y2 / count);
+ y = cur_shift + y1;
+ for (j = 0; j < count; j++) {
+ last_y = y;
+ y += step;
+ drawBar_both(canvas, last_y, y, sensors[j].cur + 1, fan_tot_max, fan_tot_max - sensors[j].cur, fan_tot_max);
+ }
+ drawLine_both(canvas, cur_shift + y1, y);
+
+ sprintf(tmpstr, "RPM%5.f", fan_tot_cur);
+ print_label(canvas, tmpstr, cur_shift);
+
+ id++;
+ cur_shift += shift;
+ }
+ }
+
+ // Swap section
+ if (id < summary_rows) {
+ glibtop_swap swap;
+
+ glibtop_get_swap(&swap);
+
+ int swap_used = swap.used / 1024;
+ int swap_total = swap.total / 1024;
+
+ drawAll_both(canvas, cur_shift + y1, cur_shift + y2, swap_used, swap_total, swap_total - swap_used, swap_total);
+
+ sprintf(tmpstr, "Swp %3i%%", (unsigned int) (((float) swap_used / (float) swap_total)*100));
+ print_label(canvas, tmpstr, cur_shift);
+
+ id++;
+ cur_shift += shift;
+ }
}
-
/* draw cpu screen. if drawgraph = 0 then no graph is drawn */
-void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, int drawgraph, int printlabels, int cpuandmemory) {
+void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, char *tmpstr, int drawgraph, int printlabels, int cpuandmemory) {
int total,user,nice,sys,idle;
int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,last_irq;
- char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -469,35 +806,29 @@
g15r_drawBar(canvas,BAR_START,23,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,b_nice+1,b_total,4);
drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,b_idle+1,b_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
+ drawLine_both(canvas, 1, BAR_BOTTOM);
}
if (cpuandmemory) {
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 3);
- g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 3);
- g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 3);
- g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 3);
+ print_vert_label(canvas, "TOTAL");
sprintf(tmpstr,"CPU %3.f%%",((float)(b_total-b_idle)/(float)b_total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 5);
+ print_label(canvas, tmpstr, 0);
+ } else if ((cycle == SCREEN_FREQ) && (!mode[SCREEN_FREQ]) && (have_freq)) {
+ print_vert_label(canvas, "FREQ");
} else {
- g15r_renderString (canvas, (unsigned char*)"I", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"d", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"l", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"e", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+ print_vert_label(canvas, "Idle");
}
}
-void draw_cpu_screen_unicore(g15canvas *canvas, int drawgraph, int printlabels) {
+void draw_cpu_screen_unicore(g15canvas *canvas, char *tmpstr, int drawgraph, int printlabels) {
glibtop_cpu cpu;
glibtop_get_cpu(&cpu);
- draw_cpu_screen_unicore_logic(canvas, cpu, drawgraph, printlabels, 0);
+ draw_cpu_screen_unicore_logic(canvas, cpu, tmpstr, drawgraph, printlabels, 0);
}
-void draw_cpu_screen_multicore(g15canvas *canvas, int unicore) {
+void draw_cpu_screen_multicore(g15canvas *canvas, char *tmpstr, int unicore) {
glibtop_cpu cpu;
- char tmpstr[MAX_LINES];
int core,ncpumax;
int divider = 0;
@@ -512,67 +843,95 @@
glibtop_get_cpu(&cpu);
- if ((ncpu==1 && ((mode == MODE_CPU_USR_SYS_NCE_1) || (mode == MODE_CPU_USR_SYS_NCE_2)))
- || (unicore)) {
- draw_cpu_screen_unicore_logic(canvas, cpu, 1, 1, 0);
- return;
- } else if (((ncpu > 5) && (mode != MODE_CPU_SUMARY))
- || (mode == MODE_CPU_USR_SYS_NCE_1)
- || (mode == MODE_CPU_USR_SYS_NCE_2)) {
- draw_cpu_screen_unicore_logic(canvas, cpu, 0, 1, 0);
- } else if (mode != MODE_CPU_SUMARY){
- draw_cpu_screen_unicore_logic(canvas, cpu, 0, 0, 0);
- } else {
- draw_cpu_screen_unicore_logic(canvas, cpu, 0, 0, 1);
+ switch (cycle) {
+ case SCREEN_SUMMARY :
+ draw_cpu_screen_unicore_logic(canvas, cpu, tmpstr, 0, 0, 1);
+ break;
+ case SCREEN_CPU :
+ if ((unicore) || (ncpu==1)) {
+ draw_cpu_screen_unicore_logic(canvas, cpu, tmpstr, 1, 1, 0);
+ return;
+ }
+ draw_cpu_screen_unicore_logic(canvas, cpu, tmpstr, 0, 1, 0);
+ break;
+ case SCREEN_FREQ :
+ draw_cpu_screen_unicore_logic(canvas, cpu, tmpstr, 0, 0, 0);
+ break;
}
int y1=0, y2=BAR_BOTTOM;
- int current_value=1, mem_used=1, mem_total=1;
+ int shift = 12;
+ int shift2 = 24;
+ int current_value=1;
+ int freq_cur = 1, freq_total = 1;
+ int freq_sum = 0;
+ float result;
+
int spacer = 1;
int height = 8;
- if (mode) {
- switch (mode) {
- case MODE_CPU_TOTAL :
- if(ncpu > 11){
- spacer = 0;
+ switch (cycle) {
+ case SCREEN_FREQ :
+ if(ncpu > 11){
+ spacer = 0;
+ }
+ height = 36;
+ break;
+ case SCREEN_CPU :
+ if(ncpu > 4){
+ spacer = 0;
+ }
+ height = 12;
+
+ ncpumax = height;
+ break;
+ case SCREEN_SUMMARY :
+ spacer = 0;
+ if (mode[SCREEN_SUMMARY]) {
+ summary_rows = 5;
+ switch (ncpu) {
+ case 1 :
+ case 2 :
+ height = 6;
+ shift = 7;
+ shift2 = (2 * shift);
+ break;
+ case 3 :
+ height = 6;
+ shift = height;
+ shift2 = (2 * shift) -1;
+ break;
+ default :
+ height = 8;
+ shift = 7;
+ shift2 = (2 * shift)-1;
+ break;
}
- height = 36;
- break;
- case MODE_CPU_USR_SYS_NCE_2 :
- if(ncpu > 4){
- spacer = 0;
+ } else {
+ summary_rows = 4;
+ if (ncpu % 2){
+ height = 9;
+ shift = height;
+ shift2 = (2 * shift)-1;
+ } else {
+ height = 9;
+ shift = height;
+ shift2 = (2 * shift);
}
- height = 12;
+ }
- ncpumax = height;
- break;
- case MODE_CPU_SUMARY :
- if(ncpu>6){
- spacer = 0;
- }
- height = 16;
+ ncpumax = height;
+ break;
+ }
- ncpumax = height;
- glibtop_mem mem;
- glibtop_get_mem(&mem);
- mem_total = (mem.total / 1024);
- mem_used = mem_total - (mem.free / 1024);
+ if (ncpumax < ncpu) {
+ height = (height - ((ncpumax - 1) * spacer)) / (ncpumax);
+ } else {
+ height = (height - ((ncpu - 1) * spacer)) / (ncpu);
+ }
- sprintf(tmpstr,"MEM %3.f%%",((float)(mem_used)/(float)mem_total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 24);
- break;
- }
-
- if (ncpumax < ncpu) {
- height = (height - ((ncpumax - 1) * spacer)) / (ncpumax);
- } else {
- height = (height - ((ncpu - 1) * spacer)) / (ncpu);
- }
-
- if (height < 1) {
- height = 1;
- }
+ if (height < 1) {
+ height = 1;
}
for(core = 0; ((core < ncpu) && (core < ncpumax)); core++) {
@@ -598,81 +957,107 @@
last_irq[core] = cpu.xcpu_irq[core];
last_iowait[core] = cpu.xcpu_iowait[core];
- if (mode) {
- y1 = (core * height) + (core * spacer);
- y2 = y1 + height - 1;
- current_value = b_total - b_idle;
- }
+ y1 = (core * height) + (core * spacer);
+ y2 = y1 + height - 1;
- switch (mode) {
- case MODE_CPU_USR_SYS_NCE_1 :
- divider = 9/ncpu;
- g15r_drawBar(canvas,BAR_START,(divider*core),BAR_END,(divider+(divider*(core))),G15_COLOR_BLACK,b_user+1,b_total,4);
- g15r_drawBar(canvas,BAR_START,12+(divider*(core)),BAR_END,12+(divider+(divider*(core))),G15_COLOR_BLACK,b_sys+1,b_total,4);
- y1 = 0;
- y2 = 24+(divider+(divider*(core)));
- g15r_drawBar(canvas,BAR_START,24+(divider*(core)),BAR_END,y2,G15_COLOR_BLACK,b_nice+1,b_total,4);
-
- divider = y2/ncpu;
- drawBar_reversed(canvas,BAR_START,(divider*core),BAR_END,y2,G15_COLOR_BLACK,b_idle+1,b_total,5);
- break;
- case MODE_CPU_TOTAL :
- if (ncpu < 6) {
- if (have_freq) {
- sprintf(tmpstr,"%s", show_hertz(get_cpu_freq_cur(core)));
- } else {
- sprintf(tmpstr,"CPU%.f%3.f%%",(float)core,((float)(b_total-b_idle)/(float)b_total)*100);
+ switch (cycle) {
+ case SCREEN_FREQ:
+ if ((!mode[SCREEN_FREQ]) && (have_freq)) {
+ freq_cur = get_cpu_freq_cur(core);
+ if (ncpu < 6) {
+ result = ((float) (b_total - b_idle) / (float) b_total)*100;
+ if (result < 100.0) {
+ sprintf(tmpstr, "%2.f%% %s", result, show_hertz_short(freq_cur));
+ } else {
+ sprintf(tmpstr, "%3.f%%%s", result, show_hertz_short(freq_cur));
+ }
+ if (ncpu < 5) {
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1);
+ } else {
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, y1 + 1);
+ }
}
- if (ncpu < 5) {
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, y1+1);
- } else {
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 1, y1+1);
+ freq_total = get_cpu_freq_max(core);
+ drawBar_both(canvas, y1, y2, freq_cur, freq_total, freq_total - freq_cur, freq_total);
+ y1 = 0;
+ } else {
+ if (core < 6) {
+ if (have_freq) {
+ freq_cur = get_cpu_freq_cur(core);
+ sprintf(tmpstr, "%s%3.f%%", show_hertz_short(freq_cur), ((float) (b_total - b_idle) / (float) b_total)*100);
+ } else {
+ sprintf(tmpstr, "CPU%.f%3.f%%", (float) core, ((float) (b_total - b_idle) / (float) b_total)*100);
+ }
+ if (ncpu < 5) {
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, y1 + 1);
+ } else {
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 1, y1 + 1);
+ }
}
+ current_value = b_total - b_idle;
+ drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
+ y1 = 0;
}
-
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
- y1 = 0;
break;
- case MODE_CPU_USR_SYS_NCE_2 :
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
- g15r_drawBar(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_sys+1,b_total,4);
- g15r_drawBar(canvas, BAR_START,24+y1,BAR_END,24+y2,G15_COLOR_BLACK,b_nice+1,b_total,4);
+ case SCREEN_CPU:
+ if (mode[SCREEN_CPU]) {
+ divider = 9 / ncpu;
+ g15r_drawBar(canvas, BAR_START, (divider * core), BAR_END, (divider + (divider * (core))), G15_COLOR_BLACK, b_user + 1, b_total, 4);
+ g15r_drawBar(canvas, BAR_START, shift + (divider * (core)), BAR_END, shift + (divider + (divider * (core))), G15_COLOR_BLACK, b_sys + 1, b_total, 4);
+ y1 = 0;
+ y2 = shift2 + (divider + (divider * (core)));
+ g15r_drawBar(canvas, BAR_START, shift2 + (divider * (core)), BAR_END, y2, G15_COLOR_BLACK, b_nice + 1, b_total, 4);
+ divider = y2 / ncpu;
+ drawBar_reversed(canvas, BAR_START, (divider * core), BAR_END, y2, G15_COLOR_BLACK, b_idle + 1, b_total, 5);
+ } else {
+ current_value = b_total - b_idle;
+ drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
- drawBar_reversed(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_total-b_sys,b_total,5);
+ drawBar_both(canvas, shift + y1, shift + y2, b_sys + 1, b_total, b_total - b_sys, b_total);
- y2 += 24;
- drawBar_reversed(canvas, BAR_START,24+y1,BAR_END, y2,G15_COLOR_BLACK,b_total-b_nice,b_total,5);
+ y2 += shift2;
+ drawBar_both(canvas, shift2 + y1, y2, b_nice + 1, b_total, b_total - b_nice, b_total);
- y1 = 0;
+ y1 = 0;
+ }
break;
- case MODE_CPU_SUMARY :
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
- g15r_drawBar(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_used+1, mem_total,4);
+ case SCREEN_SUMMARY:
+ current_value = b_total - b_idle;
+ drawBar_both(canvas, y1, y2, current_value, b_total, b_total - current_value, b_total);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
- drawBar_reversed(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_total - mem_used, mem_total,5);
+ if (have_freq) {
+ freq_cur = get_cpu_freq_cur(core);
+ freq_total = get_cpu_freq_max(core);
+ freq_sum = maxi(freq_sum, freq_cur);
+ drawBar_both(canvas, shift + y1, shift + y2, freq_cur, freq_total, freq_total - freq_cur, freq_total);
+ }
+
y1 = 0;
break;
}
}
- g15r_drawLine (canvas, VL_LEFT, y1, VL_LEFT, y2, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, y1, VL_LEFT+1, y2, G15_COLOR_BLACK);
+ drawLine_both(canvas, y1, y2);
- if(mode == MODE_CPU_SUMARY) {
- g15r_drawLine (canvas, VL_LEFT, 19+y1, VL_LEFT, 19+y2, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 19+y1, VL_LEFT+1, 19+y2, G15_COLOR_BLACK);
+ if (cycle == SCREEN_SUMMARY) {
+ if (have_freq) {
+ drawLine_both(canvas, shift + y1, shift + y2);
+
+ sprintf(tmpstr, "FRQ %s", show_hertz_short((int) freq_sum));
+ print_label(canvas, tmpstr, shift);
+
+ draw_summary_screen(canvas, tmpstr, y1, y2, shift, 2);
+ } else {
+ draw_summary_screen(canvas, tmpstr, y1, y2, shift, 1);
+ }
}
}
-void draw_net_screen(g15canvas *canvas, char *interface) {
+void draw_net_screen(g15canvas *canvas, char *tmpstr, char *interface) {
int i;
int x=0;
- char tmpstr[128];
- x=0;
+
float diff=0;
float height=0;
float last=0;
@@ -725,9 +1110,15 @@
sprintf(tmpstr,"%s",interface);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_LARGE, 25-(strlen(tmpstr)*9)/2, 14);
+
+ if (net_scale_absolute) {
+ print_vert_label_logic(canvas, "ABS ", 47);
+ } else {
+ print_vert_label_logic(canvas, "REL ", 47);
+ }
}
-void draw_bat_screen(g15canvas *canvas, int all) {
+void draw_bat_screen(g15canvas *canvas, char *tmpstr, int all) {
g15_stats_bat_info bats[NUM_BATS];
long tot_max_charge = 0;
@@ -737,7 +1128,6 @@
FILE *fd_info;
char line [MAX_LINES];
char value [MAX_LINES];
- char tmpstr [MAX_LINES];
int i = 0;
for (i = 0; i < NUM_BATS; i++)
@@ -812,13 +1202,9 @@
if (all) {
g15r_clearScreen (canvas, G15_COLOR_WHITE);
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"U", 1, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"L", 2, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"L", 3, G15_TEXT_MED, 155, 4);
+ print_vert_label(canvas, "FULL");
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
+ drawLine_both(canvas, 1, BAR_BOTTOM);
for (i = 0; i < NUM_BATS; i++)
{
@@ -875,99 +1261,116 @@
strcat (tmpstr, extension);
}
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, INFO_ROW);
}
}
-void draw_temp_screen(g15canvas *canvas, int all) {
+void draw_temp_screen(g15canvas *canvas, char *tmpstr, int all) {
+ static g15_stats_info temps[NUM_TEMP];
+ int count = get_temperature(temps);
- g15_stats_temp_info temps[NUM_TEMP];
- float tot_max_temp = 1;
+ if ((!count) || (temps[0].cur == SENSOR_ERROR)) {
+ return;
+ }
- char tmpstr [MAX_LINES];
-
- int count = 0;
int j = 0;
- for (count = 0; count < NUM_TEMP; count++) {
- if ((temps[count].cur_temp = get_temp_cur(count + 1)) == SENSOR_ERROR) {
- break;
- }
- temps[count].cur_temp /= 1000;
+ int shift;
+ shift = 32 / count;
+
+ if (count) {
if (all) {
- temps[count].max_temp = get_temp_max(count + 1);
- temps[count].max_temp /= 1000;
+ g15r_clearScreen(canvas, G15_COLOR_WHITE);
+ print_vert_label(canvas, "TEMP");
- if (tot_max_temp < temps[count].max_temp) {
- tot_max_temp = temps[count].max_temp;
+ for (j = 0; j < count; j++) {
+ register int bar_top = (j * shift) + 1 + j;
+ register int bar_bottom = ((j + 1)*shift) + j;
+ sprintf(tmpstr, "t-%d %3.f\xb0", j + 1, temps[j].cur);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1);
+ drawBar_both(canvas, bar_top, bar_bottom, temps[j].cur + 1, temp_tot_max, temp_tot_max - temps[j].cur, temp_tot_max);
}
+ drawLine_both(canvas, 1, ((j*shift) + j-1));
}
+ if ((!all) || (info_cycle == SCREEN_TEMP)) {
+ char extension[16];
+ sprintf(tmpstr, " ");
+ for (j = 0; j < count; j++) {
+ sprintf(extension, "temp%d %1.f\xb0 ", j + 1, temps[j].cur);
+ if (j) {
+ strcat(tmpstr, "| ");
+ }
+ strcat(tmpstr, extension);
+ }
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
+ }
}
- if (!count) {
- if (sensor_id < MAX_SENSOR) {
- printf("Temperature sensor doesn't appear to exist with id=%d . ", sensor_id);
- sensor_id++;
- printf("Let's try id=%d.\n", sensor_id);
- draw_temp_screen(canvas, all);
- } else {
- printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
- have_sensor = 0;
- }
+}
+
+void draw_fan_screen(g15canvas *canvas, char *tmpstr, int all) {
+ static g15_stats_info fans[NUM_FAN];
+ int count = get_fans(fans);
+
+ if ((!count) || (fans[0].cur == SENSOR_ERROR)) {
return;
}
- if ((count + 1) >= NUM_TEMP) {
- count = NUM_TEMP;
- } else {
- count++;
- }
- if (all) {
- g15r_clearScreen(canvas, G15_COLOR_WHITE);
+ int j = 0;
- g15r_renderString(canvas, (unsigned char*) "M", 0, G15_TEXT_MED, 155, 3);
- g15r_renderString(canvas, (unsigned char*) "A", 1, G15_TEXT_MED, 155, 7);
- g15r_renderString(canvas, (unsigned char*) "X", 2, G15_TEXT_MED, 155, 11);
+ int shift;
+ shift = 32 / count;
- g15r_drawLine(canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine(canvas, VL_LEFT + 1, 1, VL_LEFT + 1, 32, G15_COLOR_BLACK);
+ if (count) {
+ if (all) {
+ g15r_clearScreen(canvas, G15_COLOR_WHITE);
+ print_vert_label(canvas, "RPM");
- for (j = 0; j < count; j++) {
- register int bar_top = (j * 10) + 1 + j;
- register int bar_bottom = ((j + 1)*10) + j;
- sprintf(tmpstr, "T-%d %3.f\xb0", j + 1, temps[j].cur_temp);
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, (j * 12) + 2);
- g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
- drawBar_reversed(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
+
+ for (j = 0; j < count; j++) {
+ register int bar_top = (j * shift) + 1 + j;
+ register int bar_bottom = ((j + 1)*shift) + j;
+ sprintf(tmpstr, "F-%d%5.f", j + 1, fans[j].cur);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, bar_top + 1);
+ drawBar_both(canvas, bar_top, bar_bottom, fans[j].cur + 1, fan_tot_max, fan_tot_max - fans[j].cur, fan_tot_max);
+ }
+ drawLine_both(canvas, 1, ((j*shift) + j-1));
}
- }
- if ((!all) || (info_cycle == SCREEN_TEMP)) {
- char extension[16];
- sprintf(tmpstr, " ");
- for (j = 0; j < count; j++) {
- if ((j + 1) != count) {
- sprintf(extension, "Temp%d %3.f\xb0 | ", j + 1, temps[j].cur_temp);
- } else {
- sprintf(extension, "Temp%d %3.f\xb0 ", j + 1, temps[j].cur_temp);
+ if ((!all) || (info_cycle == SCREEN_FAN)) {
+ char extension[16];
+ sprintf(tmpstr, " ");
+ for (j = 0; j < count; j++) {
+ sprintf(extension, "Fan%d %1.f ", j + 1, fans[j].cur);
+ if (j) {
+ strcat(tmpstr, "| ");
+ }
+ strcat(tmpstr, extension);
}
- strcat(tmpstr, extension);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, INFO_ROW);
}
- g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, BOTTOM_ROW);
}
}
void calc_info_cycle(void) {
- static int timer = -1;
info_cycle = cycle;
- timer++;
+ info_cycle_timer++;
if (!submode) {
- switch ((int) (timer / PAUSE)) {
+ switch ((int) (info_cycle_timer / PAUSE)) {
+ case SCREEN_SUMMARY:
+ info_cycle = SCREEN_SUMMARY;
+ break;
case SCREEN_CPU:
info_cycle = SCREEN_CPU;
break;
+ case SCREEN_FREQ:
+ if (have_freq) {
+ info_cycle = SCREEN_FREQ;
+ break;
+ }
+ info_cycle_timer += PAUSE;
case SCREEN_MEM:
info_cycle = SCREEN_MEM;
break;
@@ -979,73 +1382,83 @@
info_cycle = SCREEN_NET;
break;
}
- timer += PAUSE;
+ info_cycle_timer += PAUSE;
case SCREEN_BAT:
if (have_bat) {
info_cycle = SCREEN_BAT;
break;
}
- timer += PAUSE;
+ info_cycle_timer += PAUSE;
case SCREEN_TEMP:
- if (have_sensor) {
+ if (have_temp) {
info_cycle = SCREEN_TEMP;
break;
}
- timer += PAUSE;
- case SCREEN_FREQ:
- if (have_freq) {
- info_cycle = SCREEN_FREQ;
+ info_cycle_timer += PAUSE;
+ case SCREEN_FAN:
+ if (have_fan) {
+ info_cycle = SCREEN_FAN;
break;
}
- timer += PAUSE;
- case SCREEN_TIME:
- info_cycle = SCREEN_TIME;
- break;
+ info_cycle_timer += PAUSE;
+ case SCREEN_NET2:
+ if (have_nic) {
+ info_cycle = SCREEN_NET2;
+ break;
+ }
+ info_cycle_timer += PAUSE;
default:
- timer = 0;
- info_cycle = SCREEN_CPU;
+ info_cycle_timer = 0;
+ info_cycle = SCREEN_SUMMARY;
break;
}
}
}
-void print_info_label(g15canvas *canvas) {
+void print_info_label(g15canvas *canvas, char *tmpstr) {
switch (info_cycle) {
- case SCREEN_CPU:
- print_sys_load_info(canvas);
+ case SCREEN_SUMMARY :
+ print_time_info(canvas, tmpstr);
break;
- case SCREEN_MEM:
- print_mem_info(canvas);
+ case SCREEN_CPU :
+ print_sys_load_info(canvas, tmpstr);
break;
- case SCREEN_SWAP:
- print_swap_info(canvas);
+ case SCREEN_FREQ :
+ print_freq_info(canvas, tmpstr);
break;
- case SCREEN_NET:
- print_net_info(canvas);
+ case SCREEN_MEM :
+ print_mem_info(canvas, tmpstr);
break;
- case SCREEN_BAT:
+ case SCREEN_SWAP :
+ print_swap_info(canvas, tmpstr);
+ break;
+ case SCREEN_NET :
+ print_net_peak_info(canvas, tmpstr);
+ break;
+ case SCREEN_BAT :
if (cycle != SCREEN_BAT) {
- draw_bat_screen(canvas, 0);
+ draw_bat_screen(canvas, tmpstr, 0);
}
break;
- case SCREEN_TEMP:
+ case SCREEN_TEMP :
if (cycle != SCREEN_TEMP) {
- draw_temp_screen(canvas, 0);
+ draw_temp_screen(canvas, tmpstr, 0);
}
break;
- case SCREEN_FREQ:
- print_freq_info(canvas);
+ case SCREEN_FAN :
+ if (cycle != SCREEN_FAN) {
+ draw_fan_screen(canvas, tmpstr, 0);
+ }
break;
- case SCREEN_TIME:
- print_time_info(canvas);
+ case SCREEN_NET2 :
+ print_net_current_info(canvas, tmpstr);
break;
}
}
void keyboard_watch(void) {
unsigned int keystate;
- int change = 0;
- int direction = 0;
+ int change = 0;
while(1) {
recv(g15screen_fd,&keystate,4,0);
@@ -1054,87 +1467,127 @@
}
else if(keystate & G15_KEY_L2) {
cycle--;
- direction = DIRECTION_DOWN;
- change++;
+ change = CHANGE_DOWN;
}
else if(keystate & G15_KEY_L3) {
cycle++;
- direction = DIRECTION_UP;
- change++;
+ change = CHANGE_UP;
}
else if(keystate & G15_KEY_L4) {
- mode++;
- change++;
+ mode[cycle]++;
+ change = CHANGE_MODE;
}
else if(keystate & G15_KEY_L5) {
submode++;
- change++;
+ change = CHANGE_SUBMODE;
}
if (change) {
- change = 0;
- if (cycle < 0) {
- if (have_sensor) {
- cycle = MAX_SCREENS;
- } else if (have_bat) {
- cycle = SCREEN_BAT;
- } else if (have_nic) {
- cycle = SCREEN_NET;
- } else {
- cycle = SCREEN_SWAP;
- }
- }
- if (direction == DIRECTION_UP) {
- switch (cycle) {
- case SCREEN_NET:
- if (have_nic) {
+ switch (change) {
+ case CHANGE_UP :
+ if (cycle > MAX_SCREENS) {
+ cycle = 0;
+ }
+ switch (cycle) {
+ case SCREEN_NET:
+ if (have_nic) {
+ break;
+ }
+ cycle++;
+ case SCREEN_BAT:
+ if (have_bat) {
+ break;
+ }
+ cycle++;
+ case SCREEN_TEMP:
+ if (have_temp) {
+ break;
+ }
+ cycle++;
+ case SCREEN_FAN:
+ if (have_fan) {
+ break;
+ }
+ cycle++;
break;
- }
- cycle++;
- case SCREEN_BAT:
- if (have_bat) {
+ }
+ info_cycle_timer = cycle * PAUSE;
+ break;
+ case CHANGE_DOWN :
+ if (cycle < 0) {
+ cycle = MAX_SCREENS;
+ }
+ switch (cycle) {
+ case SCREEN_FAN:
+ if (have_fan) {
+ break;
+ }
+ cycle--;
+ case SCREEN_TEMP:
+ if (have_temp) {
+ break;
+ }
+ cycle--;
+ case SCREEN_BAT:
+ if (have_bat) {
+ break;
+ }
+ cycle--;
+ case SCREEN_NET:
+ if (have_nic) {
+ break;
+ }
+ cycle--;
break;
- }
- cycle++;
- case SCREEN_TEMP:
- if (have_se...
[truncated message content] |
|
From: <cza...@us...> - 2009-06-14 14:06:23
|
Revision: 513
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=513&view=rev
Author: czarnyckm
Date: 2009-06-14 13:31:49 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
Improve bottom line and keywatch logic
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-13 12:13:32 UTC (rev 512)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-14 13:31:49 UTC (rev 513)
@@ -26,4 +26,6 @@
- CPU frequency info (if available)
- Battery Screen is enabled if available
- Clean up
+SVN 513:
+- Improve bottom line and keywatch logic
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-13 12:13:32 UTC (rev 512)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-14 13:31:49 UTC (rev 513)
@@ -59,13 +59,12 @@
int g15screen_fd;
int cycle = 0;
+int info_cycle = 0;
/** Holds the mode type variable of the application running */
int mode = 0;
/** Holds the sub mode type variable of the application running */
int submode = 0;
-int timer;
-
int have_freq = 1;
int have_sensor = 1;
int have_bat = 1;
@@ -111,18 +110,26 @@
return tmpstr;
}
-char * show_hertz(int hertz) {
+char * show_hertz_logic(int hertz, char * hz) {
static char tmpstr[32];
if (hertz > 1000000) {
- sprintf(tmpstr, " %3.1fGHz", ((float)hertz / 1000000));
+ sprintf(tmpstr, " %3.1fG%s", ((float)hertz / 1000000), hz);
} else if (hertz > 1000) {
- sprintf(tmpstr, " %3.fMHz", ((float)hertz / 1000));
+ sprintf(tmpstr, " %3.fM%s", ((float)hertz / 1000), hz);
} else {
- sprintf(tmpstr, " %3iKHz", hertz);
+ sprintf(tmpstr, " %3iK%s", hertz, hz);
}
return tmpstr;
}
+char * show_hertz_short(int hertz) {
+ return show_hertz_logic(hertz, "");
+}
+
+char * show_hertz(int hertz) {
+ return show_hertz_logic(hertz, "Hz");
+}
+
void drawBar_reversed (g15canvas * canvas, int x1, int y1, int x2, int y2, int color,
int num, int max, int type)
{
@@ -319,15 +326,24 @@
void print_freq_info(g15canvas *canvas) {
char tmpstr[MAX_LINES];
+ int normal = 1;
int core;
init_cpu_count();
- if (ncpu < 4) {
+ if (ncpu < 5) {
sprintf(tmpstr, "%s", "CPU ");
+ } else if (ncpu > 5) {
+ normal = 0;
+ sprintf(tmpstr, "%s", "");
} else {
sprintf(tmpstr, "%s", "");
}
+
for (core = 0; core < ncpu; core++) {
- strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
+ if (normal) {
+ strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
+ } else {
+ strcat(tmpstr, show_hertz_short(get_cpu_freq_cur(core)));
+ }
if ((core + 1) < ncpu) {
strcat(tmpstr, " |");
}
@@ -787,7 +803,7 @@
}
}
- if (i == 0) {
+ if (!i) {
printf("Battery sensor doesn't appear to exist. Battery screen will be disabled.\n");
have_bat = 0;
return;
@@ -821,7 +837,7 @@
drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
}
- if ((!all) || (cycle == SCREEN_BAT)) {
+ if ((!all) || (info_cycle == SCREEN_BAT)) {
float total_charge = 0;
if (tot_max_charge > 0)
{
@@ -870,25 +886,25 @@
char tmpstr [MAX_LINES];
- int i = 0;
+ int count = 0;
int j = 0;
- for (i = 0; i < NUM_TEMP; i++) {
+ for (count = 0; count < NUM_TEMP; count++) {
- if ((temps[i].cur_temp = get_temp_cur(i + 1)) == SENSOR_ERROR) {
+ if ((temps[count].cur_temp = get_temp_cur(count + 1)) == SENSOR_ERROR) {
break;
}
- temps[i].cur_temp /= 1000;
+ temps[count].cur_temp /= 1000;
if (all) {
- temps[i].max_temp = get_temp_max(i + 1);
- temps[i].max_temp /= 1000;
+ temps[count].max_temp = get_temp_max(count + 1);
+ temps[count].max_temp /= 1000;
- if (tot_max_temp < temps[i].max_temp) {
- tot_max_temp = temps[i].max_temp;
+ if (tot_max_temp < temps[count].max_temp) {
+ tot_max_temp = temps[count].max_temp;
}
}
}
- if (i == 0) {
+ if (!count) {
if (sensor_id < MAX_SENSOR) {
printf("Temperature sensor doesn't appear to exist with id=%d . ", sensor_id);
sensor_id++;
@@ -900,38 +916,38 @@
}
return;
}
- if ((i + 1) >= NUM_TEMP) {
- i = NUM_TEMP;
+ if ((count + 1) >= NUM_TEMP) {
+ count = NUM_TEMP;
} else {
- i++;
+ count++;
}
- if (all) {
- g15r_clearScreen (canvas, G15_COLOR_WHITE);
+ if (all) {
+ g15r_clearScreen(canvas, G15_COLOR_WHITE);
- g15r_renderString (canvas, (unsigned char*)"M", 0, G15_TEXT_MED, 155, 3);
- g15r_renderString (canvas, (unsigned char*)"A", 1, G15_TEXT_MED, 155, 7);
- g15r_renderString (canvas, (unsigned char*)"X", 2, G15_TEXT_MED, 155, 11);
+ g15r_renderString(canvas, (unsigned char*) "M", 0, G15_TEXT_MED, 155, 3);
+ g15r_renderString(canvas, (unsigned char*) "A", 1, G15_TEXT_MED, 155, 7);
+ g15r_renderString(canvas, (unsigned char*) "X", 2, G15_TEXT_MED, 155, 11);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine(canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine(canvas, VL_LEFT + 1, 1, VL_LEFT + 1, 32, G15_COLOR_BLACK);
- for (j = 0; j < i; j++) {
- register int bar_top = (j*10) + 1 + j;
- register int bar_bottom = ((j+1)*10) + j;
+ for (j = 0; j < count; j++) {
+ register int bar_top = (j * 10) + 1 + j;
+ register int bar_bottom = ((j + 1)*10) + j;
- sprintf(tmpstr,"T-%d %3.f\xb0", j+1, temps[j].cur_temp);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (j*12) + 2);
+ sprintf(tmpstr, "T-%d %3.f\xb0", j + 1, temps[j].cur_temp);
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_MED, 1, (j * 12) + 2);
g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
- drawBar_reversed(canvas, BAR_START, bar_top,BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
+ drawBar_reversed(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
}
}
- if ((!all) || ((cycle == SCREEN_TEMP) && ((submode) || (timer/PAUSE) == SCREEN_TEMP))) {
+ if ((!all) || (info_cycle == SCREEN_TEMP)) {
char extension[16];
sprintf(tmpstr, " ");
- for (j = 0; j < i; j++) {
- if ((j + 1) != i) {
+ for (j = 0; j < count; j++) {
+ if ((j + 1) != count) {
sprintf(extension, "Temp%d %3.f\xb0 | ", j + 1, temps[j].cur_temp);
} else {
sprintf(extension, "Temp%d %3.f\xb0 ", j + 1, temps[j].cur_temp);
@@ -942,15 +958,59 @@
}
}
-void print_info_label(g15canvas *canvas) {
- int my_cycle = cycle;
+void calc_info_cycle(void) {
+ static int timer = -1;
+ info_cycle = cycle;
timer++;
if (!submode) {
- my_cycle = -1;
+ switch ((int) (timer / PAUSE)) {
+ case SCREEN_CPU:
+ info_cycle = SCREEN_CPU;
+ break;
+ case SCREEN_MEM:
+ info_cycle = SCREEN_MEM;
+ break;
+ case SCREEN_SWAP:
+ info_cycle = SCREEN_SWAP;
+ break;
+ case SCREEN_NET:
+ if (have_nic) {
+ info_cycle = SCREEN_NET;
+ break;
+ }
+ timer += PAUSE;
+ case SCREEN_BAT:
+ if (have_bat) {
+ info_cycle = SCREEN_BAT;
+ break;
+ }
+ timer += PAUSE;
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ info_cycle = SCREEN_TEMP;
+ break;
+ }
+ timer += PAUSE;
+ case SCREEN_FREQ:
+ if (have_freq) {
+ info_cycle = SCREEN_FREQ;
+ break;
+ }
+ timer += PAUSE;
+ case SCREEN_TIME:
+ info_cycle = SCREEN_TIME;
+ break;
+ default:
+ timer = 0;
+ info_cycle = SCREEN_CPU;
+ break;
+ }
}
+}
- switch (my_cycle) {
+void print_info_label(g15canvas *canvas) {
+ switch (info_cycle) {
case SCREEN_CPU:
print_sys_load_info(canvas);
break;
@@ -964,59 +1024,21 @@
print_net_info(canvas);
break;
case SCREEN_BAT:
- //draw_bat_screen(canvas, 0);
+ if (cycle != SCREEN_BAT) {
+ draw_bat_screen(canvas, 0);
+ }
break;
case SCREEN_TEMP:
- //draw_temp_screen(canvas, 0);
- break;
- default:
- switch (timer / PAUSE) {
- case SCREEN_CPU:
- print_sys_load_info(canvas);
- break;
- case SCREEN_MEM:
- print_mem_info(canvas);
- break;
- case SCREEN_SWAP:
- print_swap_info(canvas);
- break;
- case SCREEN_NET:
- print_net_info(canvas);
- break;
- case SCREEN_BAT:
- if (have_bat) {
- if (cycle != SCREEN_BAT)
- draw_bat_screen(canvas, 0);
- break;
- } else {
- timer += PAUSE;
- }
- case SCREEN_TEMP:
- if (have_sensor) {
- if (cycle != SCREEN_TEMP)
- draw_temp_screen(canvas, 0);
- break;
- } else {
- timer += PAUSE;
- }
- case SCREEN_FREQ:
- if (have_freq) {
- if (cycle != SCREEN_FREQ)
- print_freq_info(canvas);
- break;
- } else {
- timer += PAUSE;
- }
- case SCREEN_TIME:
- print_time_info(canvas);
- break;
- default:
- timer=0;
- print_sys_load_info(canvas);
- break;
-
+ if (cycle != SCREEN_TEMP) {
+ draw_temp_screen(canvas, 0);
}
break;
+ case SCREEN_FREQ:
+ print_freq_info(canvas);
+ break;
+ case SCREEN_TIME:
+ print_time_info(canvas);
+ break;
}
}
@@ -1048,68 +1070,71 @@
submode++;
change++;
}
- if (cycle<0)
- {
- if(have_sensor) {
- cycle=MAX_SCREENS;
- } else {
- cycle=MAX_SCREENS - 1;
+
+ if (change) {
+ change = 0;
+ if (cycle < 0) {
+ if (have_sensor) {
+ cycle = MAX_SCREENS;
+ } else if (have_bat) {
+ cycle = SCREEN_BAT;
+ } else if (have_nic) {
+ cycle = SCREEN_NET;
+ } else {
+ cycle = SCREEN_SWAP;
+ }
}
- }
- if (direction == DIRECTION_UP)
- {
- switch (cycle) {
- case SCREEN_NET:
- if (have_nic) {
- break;
- }
- cycle++;
- case SCREEN_BAT:
- if (have_bat) {
- break;
- }
- cycle++;
- case SCREEN_TEMP:
- if (have_sensor) {
- break;
- }
- cycle++;
+ if (direction == DIRECTION_UP) {
+ switch (cycle) {
+ case SCREEN_NET:
+ if (have_nic) {
+ break;
+ }
+ cycle++;
+ case SCREEN_BAT:
+ if (have_bat) {
+ break;
+ }
+ cycle++;
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ break;
+ }
+ cycle++;
+ }
+ } else if (direction == DIRECTION_DOWN) {
+ switch (cycle) {
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ break;
+ }
+ cycle--;
+ case SCREEN_BAT:
+ if (have_bat) {
+ break;
+ }
+ cycle--;
+ case SCREEN_NET:
+ if (have_nic) {
+ break;
+ }
+ cycle--;
+ }
}
- } else if (direction == DIRECTION_DOWN){
- switch (cycle) {
- case SCREEN_TEMP:
- if (have_sensor) {
- break;
- }
- cycle--;
- case SCREEN_BAT:
- if (have_bat) {
- break;
- }
- cycle--;
- case SCREEN_NET:
- if (have_nic) {
- break;
- }
- cycle--;
+ if (cycle > MAX_SCREENS) {
+ //Wrap around the apps
+ cycle = 0;
}
- }
- if (cycle > MAX_SCREENS) {
- //Wrap around the apps
- cycle = 0;
- }
- if (mode > MAX_MODE) {
- mode = 0;
- }
+ if (mode > MAX_MODE) {
+ mode = 0;
+ }
- if (submode > MAX_SUB_MODE) {
- submode = 0;
- }
+ if (submode > MAX_SUB_MODE) {
+ submode = 0;
+ }
- if (change) {
pthread_cond_broadcast(&wake_now);
- change = 0;
}
usleep(100 * 900);
}
@@ -1256,7 +1281,7 @@
pthread_create(&net_thread,NULL,(void*)network_watch,&interface);
while(1) {
-
+ calc_info_cycle();
switch (cycle) {
case SCREEN_CPU:
draw_cpu_screen_multicore(canvas, unicore);
@@ -1271,20 +1296,24 @@
if (have_nic) {
draw_net_screen(canvas, (char*) interface);
break;
- } else
- cycle++;
+ }
+ cycle++;
case SCREEN_BAT:
if (have_bat) {
draw_bat_screen(canvas, 1);
- break;
- } else
- cycle++;
+ if (have_bat) {
+ break;
+ }
+ }
+ cycle++;
case SCREEN_TEMP:
if (have_sensor) {
draw_temp_screen(canvas, 1);
- break;
- } else
- cycle++;
+ if (have_sensor) {
+ break;
+ }
+ }
+ cycle++;
default:
draw_cpu_screen_multicore(canvas, unicore);
cycle = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-13 12:53:31
|
Revision: 512
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=512&view=rev
Author: czarnyckm
Date: 2009-06-13 12:13:32 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
- CPU Screens variants for uni core processors
- CPU frequency info (if available)
- Battery Screen is enabled if available
- Clean up
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-08 21:25:10 UTC (rev 511)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-13 12:13:32 UTC (rev 512)
@@ -19,5 +19,11 @@
- Temperature sensor's autodetect
- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
SVN 511:
-- Improved sensor's autodetect
+- Improve sensor's autodetect
- Clean up
+SVN 512:
+- CPU Screens variants for uni core processors
+- CPU frequency info (if available)
+- Battery Screen is enabled if available
+- Clean up
+
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-06-08 21:25:10 UTC (rev 511)
+++ trunk/g15daemon-clients/g15stats/README 2009-06-13 12:13:32 UTC (rev 512)
@@ -4,7 +4,7 @@
installed before compilation.
Features:
-CPU Screen displays graphs of User/System/Nice and Idle time, along with
+CPU Screen displays graphs of User/System/Nice and Idle time, along with frequency,
LoadAVG and Uptime.
Memory Screen displays Memory Total & Free, and graph of Used vs
@@ -17,6 +17,8 @@
Battery Status Screen displays battery charge data for up to three batteries
+Temperature Screen displays temperature current status for up to three sensors
+
Options:
-i interface Gather statistics from named interface (ie -i eth0)
-d Run in background (daemonise)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-08 21:25:10 UTC (rev 511)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-13 12:13:32 UTC (rev 512)
@@ -64,11 +64,18 @@
/** Holds the sub mode type variable of the application running */
int submode = 0;
-int have_nic=0;
+int timer;
-int have_sensor=1;
-int sensorId = 0;
+int have_freq = 1;
+int have_sensor = 1;
+int have_bat = 1;
+int have_nic = 0;
+int sensor_id = 0;
+
+/** Holds the number of the cpus */
+int ncpu;
+
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -89,7 +96,7 @@
}
char * show_bytes(unsigned long bytes) {
- static char tmpstr[128];
+ static char tmpstr[32];
if(bytes>1024*1024) {
bytes = bytes / (1024*1024);
sprintf(tmpstr,"%liMb",bytes);
@@ -104,6 +111,18 @@
return tmpstr;
}
+char * show_hertz(int hertz) {
+ static char tmpstr[32];
+ if (hertz > 1000000) {
+ sprintf(tmpstr, " %3.1fGHz", ((float)hertz / 1000000));
+ } else if (hertz > 1000) {
+ sprintf(tmpstr, " %3.fMHz", ((float)hertz / 1000));
+ } else {
+ sprintf(tmpstr, " %3iKHz", hertz);
+ }
+ return tmpstr;
+}
+
void drawBar_reversed (g15canvas * canvas, int x1, int y1, int x2, int y2, int color,
int num, int max, int type)
{
@@ -182,6 +201,74 @@
return 0;
}
+void init_cpu_count(void) {
+ // initialize cpu count once
+ if (!ncpu) {
+ const glibtop_sysinfo *cpuinfo = glibtop_get_sysinfo();
+
+ if(cpuinfo->ncpu == 0) {
+ ncpu = 1;
+ } else {
+ ncpu = cpuinfo->ncpu;
+ }
+ }
+}
+
+int get_sysfs_value(char * filename) {
+ static int ret_val = -1;
+ FILE *fd_main;
+ char tmpstr [MAX_LINES];
+
+ fd_main = fopen(filename, "r");
+ if (fd_main != NULL) {
+ if (fgets(tmpstr, MAX_LINES, fd_main) != NULL) {
+ fclose(fd_main);
+ ret_val = atoi(tmpstr);
+ } else
+ fclose(fd_main);
+ } else {
+ ret_val = SENSOR_ERROR;
+ }
+ return ret_val;
+}
+
+int get_processor_freq(char * which, int core) {
+ char tmpstr [MAX_LINES];
+ sprintf(tmpstr, "/sys/devices/system/cpu/cpu%d/cpufreq/%s", core, which);
+ return get_sysfs_value(tmpstr);
+}
+
+int get_cpu_freq_cur(int core) {
+ int ret_val = get_processor_freq("cpuinfo_cur_freq", core);
+ if ((!core) && (ret_val == SENSOR_ERROR)) {
+ have_freq = 0;
+ printf("Frequency sensor doesn't appear to exist with id=%d . ", sensor_id);
+ }
+ return ret_val;
+}
+
+int get_cpu_freq_max(int core) {
+ return get_processor_freq("cpuinfo_max_freq", core);
+}
+
+int get_cpu_freq_min(int core) {
+ return get_processor_freq("cpuinfo_min_freq", core);
+}
+
+int get_temp(char * which, int id) {
+ char tmpstr [MAX_LINES];
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_%s", sensor_id, id, which);
+ return get_sysfs_value(tmpstr);
+}
+
+int get_temp_cur(int id) {
+ return get_temp("input", id);
+}
+
+int get_temp_max(int id) {
+ return get_temp("max", id);
+}
+
void print_sys_load_info(g15canvas *canvas) {
char tmpstr[MAX_LINES];
glibtop_loadavg loadavg;
@@ -200,7 +287,7 @@
hours=(int)hours-(days*24);
sprintf(tmpstr,"LoadAVG %.2f %.2f %.2f | Uptime %.fd%.fh",loadavg.loadavg[0],loadavg.loadavg[1],loadavg.loadavg[2],days,hours);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
void print_mem_info(g15canvas *canvas) {
@@ -209,7 +296,7 @@
glibtop_get_mem(&mem);
sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
void print_swap_info(g15canvas *canvas) {
@@ -218,7 +305,7 @@
glibtop_get_swap(&swap);
sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
void print_net_info(g15canvas *canvas) {
@@ -227,16 +314,35 @@
strcat(tmpstr,"Peak OUT ");
strcat(tmpstr,show_bytes(net_max_out));
strcat(tmpstr,"/s");
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
+void print_freq_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ int core;
+ init_cpu_count();
+ if (ncpu < 4) {
+ sprintf(tmpstr, "%s", "CPU ");
+ } else {
+ sprintf(tmpstr, "%s", "");
+ }
+ for (core = 0; core < ncpu; core++) {
+ strcat(tmpstr, show_hertz(get_cpu_freq_cur(core)));
+ if ((core + 1) < ncpu) {
+ strcat(tmpstr, " |");
+ }
+ }
+
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, BOTTOM_ROW);
+}
+
void print_time_info(g15canvas *canvas){
char tmpstr[MAX_LINES];
time_t now;
time(&now);
sprintf(tmpstr,"%s",ctime(&now));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
}
void draw_mem_screen(g15canvas *canvas) {
@@ -262,11 +368,11 @@
g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,mem_user,mem_total,4);
g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,mem_buffer,mem_total,4);
- g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,mem_cached,mem_total,4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,mem_free,mem_total,5);
+ g15r_drawBar(canvas,BAR_START,23,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,mem_cached,mem_total,4);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,mem_free,mem_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
@@ -289,12 +395,12 @@
sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap_used/(float)swap_total)*100));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 19);
- g15r_drawBar(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,swap_used,swap_total,4);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,swap_used,swap_total,4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,swap_total-swap_used,swap_total,5);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,swap_total-swap_used,swap_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
@@ -344,11 +450,11 @@
if(drawgraph) {
g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,b_user+1,b_total,4);
g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,b_sys+1,b_total,4);
- g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,b_nice+1,b_total,4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,b_idle+1,b_total,5);
+ g15r_drawBar(canvas,BAR_START,23,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,b_nice+1,b_total,4);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,b_idle+1,b_total,5);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
}
if (cpuandmemory) {
g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 3);
@@ -376,8 +482,7 @@
void draw_cpu_screen_multicore(g15canvas *canvas, int unicore) {
glibtop_cpu cpu;
char tmpstr[MAX_LINES];
- const glibtop_sysinfo *cpuinfo;
- int core,ncpu,ncpumax;
+ int core,ncpumax;
int divider = 0;
int total,user,nice,sys,idle;
@@ -385,18 +490,14 @@
static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU],
last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU];
- cpuinfo = glibtop_get_sysinfo();
+ init_cpu_count();
- if(cpuinfo->ncpu == 0)
- ncpu = 1;
- else
- ncpu = cpuinfo->ncpu;
-
ncpumax = ncpu;
glibtop_get_cpu(&cpu);
- if (ncpu==1 || unicore) {
+ if ((ncpu==1 && ((mode == MODE_CPU_USR_SYS_NCE_1) || (mode == MODE_CPU_USR_SYS_NCE_2)))
+ || (unicore)) {
draw_cpu_screen_unicore_logic(canvas, cpu, 1, 1, 0);
return;
} else if (((ncpu > 5) && (mode != MODE_CPU_SUMARY))
@@ -409,7 +510,8 @@
draw_cpu_screen_unicore_logic(canvas, cpu, 0, 0, 1);
}
- int y1=0, y2=32, currentValue, mem_used=1, mem_total=1;
+ int y1=0, y2=BAR_BOTTOM;
+ int current_value=1, mem_used=1, mem_total=1;
int spacer = 1;
int height = 8;
@@ -419,7 +521,7 @@
if(ncpu > 11){
spacer = 0;
}
- height = 37;
+ height = 36;
break;
case MODE_CPU_USR_SYS_NCE_2 :
if(ncpu > 4){
@@ -483,7 +585,7 @@
if (mode) {
y1 = (core * height) + (core * spacer);
y2 = y1 + height - 1;
- currentValue = b_total - b_idle;
+ current_value = b_total - b_idle;
}
switch (mode) {
@@ -500,7 +602,11 @@
break;
case MODE_CPU_TOTAL :
if (ncpu < 6) {
- sprintf(tmpstr,"CPU%.f%3.f%%",(float)core,((float)(b_total-b_idle)/(float)b_total)*100);
+ if (have_freq) {
+ sprintf(tmpstr,"%s", show_hertz(get_cpu_freq_cur(core)));
+ } else {
+ sprintf(tmpstr,"CPU%.f%3.f%%",(float)core,((float)(b_total-b_idle)/(float)b_total)*100);
+ }
if (ncpu < 5) {
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, y1+1);
} else {
@@ -508,17 +614,17 @@
}
}
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
y1 = 0;
break;
case MODE_CPU_USR_SYS_NCE_2 :
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
g15r_drawBar(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_sys+1,b_total,4);
g15r_drawBar(canvas, BAR_START,24+y1,BAR_END,24+y2,G15_COLOR_BLACK,b_nice+1,b_total,4);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
drawBar_reversed(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_total-b_sys,b_total,5);
y2 += 24;
@@ -527,10 +633,10 @@
y1 = 0;
break;
case MODE_CPU_SUMARY :
- g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, current_value, b_total,4);
g15r_drawBar(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_used+1, mem_total,4);
- drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-current_value, b_total,5);
drawBar_reversed(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_total - mem_used, mem_total,5);
y1 = 0;
break;
@@ -540,7 +646,7 @@
g15r_drawLine (canvas, VL_LEFT, y1, VL_LEFT, y2, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, y1, VL_LEFT+1, y2, G15_COLOR_BLACK);
- if(mode == 3) {
+ if(mode == MODE_CPU_SUMARY) {
g15r_drawLine (canvas, VL_LEFT, 19+y1, VL_LEFT, 19+y2, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, 19+y1, VL_LEFT+1, 19+y2, G15_COLOR_BLACK);
}
@@ -676,8 +782,17 @@
tot_cur_charge += bats[i].cur_charge;
tot_max_charge += bats[i].max_charge;
- }
+ } else {
+ break;
+ }
}
+
+ if (i == 0) {
+ printf("Battery sensor doesn't appear to exist. Battery screen will be disabled.\n");
+ have_bat = 0;
+ return;
+ }
+
if (all) {
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -686,8 +801,8 @@
g15r_renderString (canvas, (unsigned char*)"L", 2, G15_TEXT_MED, 155, 4);
g15r_renderString (canvas, (unsigned char*)"L", 3, G15_TEXT_MED, 155, 4);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, BAR_BOTTOM, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, BAR_BOTTOM, G15_COLOR_BLACK);
for (i = 0; i < NUM_BATS; i++)
{
@@ -703,113 +818,93 @@
g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, bats[i].cur_charge, bats[i].max_charge, 4);
}
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,BAR_BOTTOM,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
}
- float total_charge = 0;
- if (tot_max_charge > 0)
- {
- total_charge = ((float)tot_cur_charge/(float)tot_max_charge)*100;
- }
- sprintf (tmpstr,"Total %2.f%% | ", total_charge);
+ if ((!all) || (cycle == SCREEN_BAT)) {
+ float total_charge = 0;
+ if (tot_max_charge > 0)
+ {
+ total_charge = ((float)tot_cur_charge/(float)tot_max_charge)*100;
+ }
+ sprintf (tmpstr,"Total %2.f%% | ", total_charge);
- for (i = 0; i < NUM_BATS; i++)
- {
- char extension[11];
- switch (bats[i].status)
- {
- case -1:
- {
- sprintf(extension, "Bt%d - | ", i);
- break;
- }
- case 0:
- {
- sprintf(extension, "Bt%d F | ", i);
- break;
- }
- case 1:
- {
- sprintf(extension, "Bt%d C | ", i);
- break;
- }
- case 2:
- {
- sprintf(extension, "Bt%d D | ", i);
- break;
- }
- }
+ for (i = 0; i < NUM_BATS; i++)
+ {
+ char extension[11];
+ switch (bats[i].status)
+ {
+ case -1:
+ {
+ sprintf(extension, "Bt%d - | ", i);
+ break;
+ }
+ case 0:
+ {
+ sprintf(extension, "Bt%d F | ", i);
+ break;
+ }
+ case 1:
+ {
+ sprintf(extension, "Bt%d C | ", i);
+ break;
+ }
+ case 2:
+ {
+ sprintf(extension, "Bt%d D | ", i);
+ break;
+ }
+ }
- strcat (tmpstr, extension);
- }
+ strcat (tmpstr, extension);
+ }
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, BOTTOM_ROW);
+ }
}
void draw_temp_screen(g15canvas *canvas, int all) {
- g15_stats_temp_info temps[NUM_TEMP];
- float tot_max_temp = 1;
+ g15_stats_temp_info temps[NUM_TEMP];
+ float tot_max_temp = 1;
- FILE *fd_main;
- char tmpstr [MAX_LINES];
+ char tmpstr [MAX_LINES];
- int i = 0;
- int j = 0;
- for (i = 0; i < NUM_TEMP; i++)
- {
- // Initialize temperature state
- temps[i].max_temp = 1;
- temps[i].cur_temp = 1;
-
- /* /sys/class/hwmon/hwmon0/temp1_input */
- /* /sys/class/hwmon/hwmon1/device/temp1_input */
- sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
- fd_main=fopen (tmpstr,"r");
- if (fd_main!=NULL)
- {
- if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
- {
- temps[i].cur_temp=atoi (tmpstr) / 1000;
- }
- fclose (fd_main);
- } else {
- break;
- }
+ int i = 0;
+ int j = 0;
+ for (i = 0; i < NUM_TEMP; i++) {
- sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
- fd_main=fopen (tmpstr,"r");
- if (fd_main!=NULL)
- {
- if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
- {
- temps[i].max_temp=atoi (tmpstr) / 1000;
- }
- fclose (fd_main);
- }
+ if ((temps[i].cur_temp = get_temp_cur(i + 1)) == SENSOR_ERROR) {
+ break;
+ }
+ temps[i].cur_temp /= 1000;
+ if (all) {
+ temps[i].max_temp = get_temp_max(i + 1);
+ temps[i].max_temp /= 1000;
- if(tot_max_temp < temps[i].max_temp) {
- tot_max_temp = temps[i].max_temp;
- }
-
- }
- if (i == 0) {
- if (sensorId < MAX_SENSOR) {
- printf("Temperature sensor doesn't appear to exist with id=%d . ",sensorId);
- sensorId++;
- printf("Let's try id=%d.\n",sensorId);
- draw_temp_screen(canvas, all);
- } else {
- printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
- have_sensor = 0;
+ if (tot_max_temp < temps[i].max_temp) {
+ tot_max_temp = temps[i].max_temp;
}
- return;
}
- if((i+1) >= NUM_TEMP) {
- i = NUM_TEMP;
+
+ }
+ if (i == 0) {
+ if (sensor_id < MAX_SENSOR) {
+ printf("Temperature sensor doesn't appear to exist with id=%d . ", sensor_id);
+ sensor_id++;
+ printf("Let's try id=%d.\n", sensor_id);
+ draw_temp_screen(canvas, all);
} else {
- i++;
+ printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
+ have_sensor = 0;
}
+ return;
+ }
+ if ((i + 1) >= NUM_TEMP) {
+ i = NUM_TEMP;
+ } else {
+ i++;
+ }
if (all) {
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -817,97 +912,117 @@
g15r_renderString (canvas, (unsigned char*)"M", 0, G15_TEXT_MED, 155, 3);
g15r_renderString (canvas, (unsigned char*)"A", 1, G15_TEXT_MED, 155, 7);
g15r_renderString (canvas, (unsigned char*)"X", 2, G15_TEXT_MED, 155, 11);
-
+
g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
- for (j = 0; j < i; j++) {
+ for (j = 0; j < i; j++) {
register int bar_top = (j*10) + 1 + j;
register int bar_bottom = ((j+1)*10) + j;
sprintf(tmpstr,"T-%d %3.f\xb0", j+1, temps[j].cur_temp);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (j*12) + 2);
- g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
+ g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
drawBar_reversed(canvas, BAR_START, bar_top,BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
- }
}
+ }
+ if ((!all) || ((cycle == SCREEN_TEMP) && ((submode) || (timer/PAUSE) == SCREEN_TEMP))) {
char extension[16];
sprintf(tmpstr, " ");
- for (j = 0; j < i; j++) {
+ for (j = 0; j < i; j++) {
if ((j + 1) != i) {
- sprintf(extension, "Temp%d %3.f\xb0 | ", j+1, temps[j].cur_temp);
+ sprintf(extension, "Temp%d %3.f\xb0 | ", j + 1, temps[j].cur_temp);
} else {
- sprintf(extension, "Temp%d %3.f\xb0 ", j+1, temps[j].cur_temp);
+ sprintf(extension, "Temp%d %3.f\xb0 ", j + 1, temps[j].cur_temp);
}
- strcat (tmpstr, extension);
- }
-
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+ strcat(tmpstr, extension);
+ }
+ g15r_renderString(canvas, (unsigned char*) tmpstr, 0, G15_TEXT_SMALL, 80 - (strlen(tmpstr)*4) / 2, BOTTOM_ROW);
+ }
}
void print_info_label(g15canvas *canvas) {
- static int timer;
int my_cycle = cycle;
timer++;
- if (! submode) {
+ if (!submode) {
my_cycle = -1;
}
- switch (my_cycle){
- case SCREEN_CPU_SCREEN :
+ switch (my_cycle) {
+ case SCREEN_CPU:
print_sys_load_info(canvas);
break;
- case SCREEN_MEM_SCREEN :
+ case SCREEN_MEM:
print_mem_info(canvas);
break;
- case SCREEN_SWAP_SCREEN :
+ case SCREEN_SWAP:
print_swap_info(canvas);
break;
- case SCREEN_NET_SCREEN :
+ case SCREEN_NET:
print_net_info(canvas);
break;
- case SCREEN_BAT_SCREEN :
- draw_bat_screen(canvas, 0);
+ case SCREEN_BAT:
+ //draw_bat_screen(canvas, 0);
break;
- case SCREEN_TEMP_SCREEN :
- draw_temp_screen(canvas, 0);
+ case SCREEN_TEMP:
+ //draw_temp_screen(canvas, 0);
break;
- default :
- if ((timer < PAUSE)) {
- print_sys_load_info(canvas);
- } else if (timer < PAUSE_2) {
- print_mem_info(canvas);
- } else if (timer < PAUSE_3) {
- print_swap_info(canvas);
- } else if (timer < PAUSE_4) {
- draw_bat_screen(canvas, 0);
- } else if (timer < PAUSE_5) {
- print_time_info(canvas);
- } else if (timer < PAUSE_6) {
- if (have_nic) {
+ default:
+ switch (timer / PAUSE) {
+ case SCREEN_CPU:
+ print_sys_load_info(canvas);
+ break;
+ case SCREEN_MEM:
+ print_mem_info(canvas);
+ break;
+ case SCREEN_SWAP:
+ print_swap_info(canvas);
+ break;
+ case SCREEN_NET:
print_net_info(canvas);
- } else {
- timer = PAUSE_6;
+ break;
+ case SCREEN_BAT:
+ if (have_bat) {
+ if (cycle != SCREEN_BAT)
+ draw_bat_screen(canvas, 0);
+ break;
+ } else {
+ timer += PAUSE;
+ }
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ if (cycle != SCREEN_TEMP)
+ draw_temp_screen(canvas, 0);
+ break;
+ } else {
+ timer += PAUSE;
+ }
+ case SCREEN_FREQ:
+ if (have_freq) {
+ if (cycle != SCREEN_FREQ)
+ print_freq_info(canvas);
+ break;
+ } else {
+ timer += PAUSE;
+ }
+ case SCREEN_TIME:
+ print_time_info(canvas);
+ break;
+ default:
+ timer=0;
+ print_sys_load_info(canvas);
+ break;
- }
- }else if(have_sensor) {
- draw_temp_screen(canvas, 0);
- } else {
- print_sys_load_info(canvas);
- timer = 0;
}
break;
}
- if (timer > PAUSE_7) {
- timer=0;
- }
}
void keyboard_watch(void) {
unsigned int keystate;
- int change = 0;
+ int change = 0;
int direction = 0;
while(1) {
@@ -917,12 +1032,12 @@
}
else if(keystate & G15_KEY_L2) {
cycle--;
- direction = 0;
+ direction = DIRECTION_DOWN;
change++;
}
else if(keystate & G15_KEY_L3) {
cycle++;
- direction = 1;
+ direction = DIRECTION_UP;
change++;
}
else if(keystate & G15_KEY_L4) {
@@ -940,37 +1055,63 @@
} else {
cycle=MAX_SCREENS - 1;
}
- }
- if ((!have_nic) && (cycle == SCREEN_NET_SCREEN))
+ }
+ if (direction == DIRECTION_UP)
{
- if (direction) {
- cycle++;
- } else {
- cycle--;
+ switch (cycle) {
+ case SCREEN_NET:
+ if (have_nic) {
+ break;
+ }
+ cycle++;
+ case SCREEN_BAT:
+ if (have_bat) {
+ break;
+ }
+ cycle++;
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ break;
+ }
+ cycle++;
}
+ } else if (direction == DIRECTION_DOWN){
+ switch (cycle) {
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ break;
+ }
+ cycle--;
+ case SCREEN_BAT:
+ if (have_bat) {
+ break;
+ }
+ cycle--;
+ case SCREEN_NET:
+ if (have_nic) {
+ break;
+ }
+ cycle--;
+ }
}
- if ((cycle>MAX_SCREENS) || ((cycle>(MAX_SCREENS-1)) && (!have_sensor)))
- {
- //Wrap around the apps
- cycle=0;
- }
+ if (cycle > MAX_SCREENS) {
+ //Wrap around the apps
+ cycle = 0;
+ }
- if (mode>MAX_MODE)
- {
- mode=0;
+ if (mode > MAX_MODE) {
+ mode = 0;
}
- if (submode>MAX_SUB_MODE)
- {
- submode=0;
+ if (submode > MAX_SUB_MODE) {
+ submode = 0;
}
- if (change)
- {
+ if (change) {
pthread_cond_broadcast(&wake_now);
change = 0;
}
- usleep(100*900);
+ usleep(100 * 900);
}
return;
@@ -1090,7 +1231,7 @@
if(0==strncmp(argv[i],"-s",2)||0==strncmp(argv[i],"--sensor",8)) {
if(argv[i+1]!=NULL) {
i++;
- sensorId = atoi(argv[i]);
+ sensor_id = atoi(argv[i]);
}
}
}
@@ -1116,39 +1257,40 @@
while(1) {
- switch(cycle) {
- case SCREEN_CPU_SCREEN:
- draw_cpu_screen_multicore(canvas,unicore);
- print_info_label(canvas);
- break;
- case SCREEN_MEM_SCREEN:
- draw_mem_screen(canvas);
- print_info_label(canvas);
- break;
- case SCREEN_SWAP_SCREEN:
- draw_swap_screen(canvas);
- print_info_label(canvas);
- break;
- case SCREEN_NET_SCREEN:
- if(have_nic) {
- draw_net_screen(canvas,(char*)interface);
- print_info_label(canvas);
- break;
- }else
- cycle++;
- case SCREEN_BAT_SCREEN:
- draw_bat_screen(canvas,1);
- break;
- case SCREEN_TEMP_SCREEN:
- if(have_sensor) {
- draw_temp_screen(canvas,1);
- break;
- }else
- cycle++;
+ switch (cycle) {
+ case SCREEN_CPU:
+ draw_cpu_screen_multicore(canvas, unicore);
+ break;
+ case SCREEN_MEM:
+ draw_mem_screen(canvas);
+ break;
+ case SCREEN_SWAP:
+ draw_swap_screen(canvas);
+ break;
+ case SCREEN_NET:
+ if (have_nic) {
+ draw_net_screen(canvas, (char*) interface);
+ break;
+ } else
+ cycle++;
+ case SCREEN_BAT:
+ if (have_bat) {
+ draw_bat_screen(canvas, 1);
+ break;
+ } else
+ cycle++;
+ case SCREEN_TEMP:
+ if (have_sensor) {
+ draw_temp_screen(canvas, 1);
+ break;
+ } else
+ cycle++;
default:
- printf("cycle reached %i\n",cycle);
- cycle=0;
+ draw_cpu_screen_multicore(canvas, unicore);
+ cycle = 0;
+ break;
}
+ print_info_label(canvas);
canvas->mode_xor = 0;
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-08 21:25:10 UTC (rev 511)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-13 12:13:32 UTC (rev 512)
@@ -7,27 +7,30 @@
#define MAX_SUB_MODE 1
#define PAUSE 6
-#define PAUSE_2 2*PAUSE
-#define PAUSE_3 3*PAUSE
-#define PAUSE_4 4*PAUSE
-#define PAUSE_5 5*PAUSE
-#define PAUSE_6 6*PAUSE
-#define PAUSE_7 7*PAUSE
#define VL_LEFT 42
#define BAR_START 45
#define MAX_NET_HIST 107
#define BAR_END 153
+#define BAR_BOTTOM 32
#define TEXT_RIGHT 155
#define MAX_LINES 128
+#define BOTTOM_ROW 37
-#define SCREEN_CPU_SCREEN 0
-#define SCREEN_MEM_SCREEN 1
-#define SCREEN_SWAP_SCREEN 2
-#define SCREEN_NET_SCREEN 3
-#define SCREEN_BAT_SCREEN 4
-#define SCREEN_TEMP_SCREEN 5
+#define SENSOR_ERROR -100
+#define DIRECTION_DOWN 1
+#define DIRECTION_UP 2
+
+#define SCREEN_CPU 0
+#define SCREEN_MEM 1
+#define SCREEN_SWAP 2
+#define SCREEN_NET 3
+#define SCREEN_BAT 4
+#define SCREEN_TEMP 5
+#define SCREEN_FREQ 6
+#define SCREEN_TIME 7
+
#define MODE_CPU_USR_SYS_NCE_1 0
#define MODE_CPU_TOTAL 1
#define MODE_CPU_USR_SYS_NCE_2 2
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-08 21:26:18
|
Revision: 511
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=511&view=rev
Author: czarnyckm
Date: 2009-06-08 21:25:10 +0000 (Mon, 08 Jun 2009)
Log Message:
-----------
- Improved sensor's autodetect
- Clean up
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-08 21:25:10 UTC (rev 511)
@@ -16,5 +16,8 @@
SVN 509:
- Temperature sensors depends on the lmsensors sysfs filesystem
SVN 510:
-- Temperature sensor autodetect
-- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
\ No newline at end of file
+- Temperature sensor's autodetect
+- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
+SVN 511:
+- Improved sensor's autodetect
+- Clean up
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-08 21:25:10 UTC (rev 511)
@@ -749,47 +749,43 @@
void draw_temp_screen(g15canvas *canvas, int all) {
g15_stats_temp_info temps[NUM_TEMP];
- long tot_max_temp = 1;
+ float tot_max_temp = 1;
- FILE *fd_input;
- FILE *fd_max;
- char line [MAX_LINES];
+ FILE *fd_main;
char tmpstr [MAX_LINES];
int i = 0;
int j = 0;
for (i = 0; i < NUM_TEMP; i++)
{
- char filename[128];
-
// Initialize temperature state
temps[i].max_temp = 1;
temps[i].cur_temp = 1;
/* /sys/class/hwmon/hwmon0/temp1_input */
/* /sys/class/hwmon/hwmon1/device/temp1_input */
- sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
- fd_input=fopen (filename,"r");
- if (fd_input!=NULL)
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
+ fd_main=fopen (tmpstr,"r");
+ if (fd_main!=NULL)
{
- if (fgets (line,MAX_LINES,fd_input)!=NULL)
+ if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
{
- temps[i].cur_temp=atoi (line) / 1000;
+ temps[i].cur_temp=atoi (tmpstr) / 1000;
}
- fclose (fd_input);
+ fclose (fd_main);
} else {
break;
}
- sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
- fd_max=fopen (filename,"r");
- if (fd_max!=NULL)
+ sprintf(tmpstr, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
+ fd_main=fopen (tmpstr,"r");
+ if (fd_main!=NULL)
{
- if (fgets (line,MAX_LINES,fd_max)!=NULL)
+ if (fgets (tmpstr,MAX_LINES,fd_main)!=NULL)
{
- temps[i].max_temp=atoi (line) / 1000;
+ temps[i].max_temp=atoi (tmpstr) / 1000;
}
- fclose (fd_max);
+ fclose (fd_main);
}
if(tot_max_temp < temps[i].max_temp) {
@@ -798,11 +794,16 @@
}
if (i == 0) {
- if (sensorId < 3) {
+ if (sensorId < MAX_SENSOR) {
+ printf("Temperature sensor doesn't appear to exist with id=%d . ",sensorId);
sensorId++;
+ printf("Let's try id=%d.\n",sensorId);
+ draw_temp_screen(canvas, all);
} else {
+ printf("Temperature sensor doesn't appear to exist. Temperature screen will be disabled.\n");
have_sensor = 0;
}
+ return;
}
if((i+1) >= NUM_TEMP) {
i = NUM_TEMP;
@@ -831,7 +832,7 @@
}
}
- char extension[11];
+ char extension[16];
sprintf(tmpstr, " ");
for (j = 0; j < i; j++) {
if ((j + 1) != i) {
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-07 18:42:32 UTC (rev 510)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-08 21:25:10 UTC (rev 511)
@@ -1,6 +1,7 @@
#define TEXT_LEFT 1
#define NUM_BATS 3
#define NUM_TEMP 3
+#define MAX_SENSOR 3
#define MAX_SCREENS 5
#define MAX_MODE 3
#define MAX_SUB_MODE 1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-07 18:42:36
|
Revision: 510
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=510&view=rev
Author: czarnyckm
Date: 2009-06-07 18:42:32 +0000 (Sun, 07 Jun 2009)
Log Message:
-----------
- Temperature sensor autodetect
- Force user sensor id with the option -s id
(The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-06 23:12:22 UTC (rev 509)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-07 18:42:32 UTC (rev 510)
@@ -14,4 +14,7 @@
SVN 505:
- Bugfix: Render bottom line on the Memory Screen once
SVN 509:
-- Temperature sensors depends on the lmsensors sysfs filesystem
\ No newline at end of file
+- Temperature sensors depends on the lmsensors sysfs filesystem
+SVN 510:
+- Temperature sensor autodetect
+- Force user sensor id with the option -s id (The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input)
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-06-06 23:12:22 UTC (rev 509)
+++ trunk/g15daemon-clients/g15stats/README 2009-06-07 18:42:32 UTC (rev 510)
@@ -24,9 +24,9 @@
default is to scale against the highest peak in the current graph.
-h Show help
-u Display unicore graphs only on the CPU screen
--s device Monitor temperature sensors device (ie -s it87.656)
- device should point to sysfs path /sys/devices/platform/[device]/temp1_input
- depends on the lmsensors
+-s id Force to monitor temperature sensor id (ie -s 1)
+ The id should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input
+ Default the sensor id is autoetected.
Usage:
$> g15stats
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-06 23:12:22 UTC (rev 509)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-07 18:42:32 UTC (rev 510)
@@ -66,8 +66,8 @@
int have_nic=0;
-int have_sensor=0;
-unsigned char sensor[128];
+int have_sensor=1;
+int sensorId = 0;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -746,7 +746,7 @@
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
}
-void draw_temp_screen(g15canvas *canvas, char *sensor, int all) {
+void draw_temp_screen(g15canvas *canvas, int all) {
g15_stats_temp_info temps[NUM_TEMP];
long tot_max_temp = 1;
@@ -762,12 +762,13 @@
{
char filename[128];
- // Initialize battery state
+ // Initialize temperature state
temps[i].max_temp = 1;
temps[i].cur_temp = 1;
- /* /sys/devices/platform/it87.656/temp1_input */
- sprintf(filename, "/sys/devices/platform/%s/temp%d_input",sensor, i+1);
+ /* /sys/class/hwmon/hwmon0/temp1_input */
+ /* /sys/class/hwmon/hwmon1/device/temp1_input */
+ sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_input",sensorId, i+1);
fd_input=fopen (filename,"r");
if (fd_input!=NULL)
{
@@ -780,7 +781,7 @@
break;
}
- sprintf(filename, "/sys/devices/platform/%s/temp%d_max",sensor, i+1);
+ sprintf(filename, "/sys/class/hwmon/hwmon%d/device/temp%d_max",sensorId, i+1);
fd_max=fopen (filename,"r");
if (fd_max!=NULL)
{
@@ -797,7 +798,11 @@
}
if (i == 0) {
- have_sensor = 0;
+ if (sensorId < 3) {
+ sensorId++;
+ } else {
+ have_sensor = 0;
+ }
}
if((i+1) >= NUM_TEMP) {
i = NUM_TEMP;
@@ -866,7 +871,7 @@
draw_bat_screen(canvas, 0);
break;
case SCREEN_TEMP_SCREEN :
- draw_temp_screen(canvas,(char*)sensor,0);
+ draw_temp_screen(canvas, 0);
break;
default :
if ((timer < PAUSE)) {
@@ -887,7 +892,7 @@
}
}else if(have_sensor) {
- draw_temp_screen(canvas,(char*)sensor,0);
+ draw_temp_screen(canvas, 0);
} else {
print_sys_load_info(canvas);
timer = 0;
@@ -1068,8 +1073,8 @@
printf("--unicore (-u) display unicore graphs only on the CPU screen\n");
printf("--help (-h) this help text.\n");
printf("--interface [interface] (-i) monitor network interface [interface] ie -i eth0\n");
- printf("--sensor [device] (-s) monitor temperature sensors [device] ie -s it87.656\n"
- "\t[device] should point to sysfs path /sys/devices/platform/[device]/temp1_input\n");
+ printf("--sensor [id] (-s) monitor temperature sensors [id] ie -s 1\n"
+ "\t[device] should point to sysfs path /sys/class/hwmon/hwmon[id]/device/temp1_input\n");
printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n"
"\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
return 0;
@@ -1083,9 +1088,8 @@
}
if(0==strncmp(argv[i],"-s",2)||0==strncmp(argv[i],"--sensor",8)) {
if(argv[i+1]!=NULL) {
- have_sensor=1;
i++;
- strncpy((char*)sensor,argv[i],128);
+ sensorId = atoi(argv[i]);
}
}
}
@@ -1136,7 +1140,7 @@
break;
case SCREEN_TEMP_SCREEN:
if(have_sensor) {
- draw_temp_screen(canvas,(char*)sensor,1);
+ draw_temp_screen(canvas,1);
break;
}else
cycle++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-06-06 23:12:27
|
Revision: 509
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=509&view=rev
Author: czarnyckm
Date: 2009-06-06 23:12:22 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
- Temperature sensors depends on the lmsensors sysfs filesystem
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/AUTHORS
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/AUTHORS
===================================================================
--- trunk/g15daemon-clients/g15stats/AUTHORS 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/AUTHORS 2009-06-06 23:12:22 UTC (rev 509)
@@ -1,4 +1,6 @@
Mike Lampard <mla...@us...>
Antonio Bartolini <rob...@gm...>
-- patch for relative scaling of net graph.
\ No newline at end of file
+- patch for relative scaling of net graph.
+
+Piotr Czarnecki <cza...@us...>
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-06-06 23:12:22 UTC (rev 509)
@@ -12,4 +12,6 @@
- New default CPU Screen (at this moment for multi core processors only)
- Display unicore graphs only on the CPU screen with the option -u (--unicore)
SVN 505:
-- Bugfix: Render bottom line on the Memory Screen once
\ No newline at end of file
+- Bugfix: Render bottom line on the Memory Screen once
+SVN 509:
+- Temperature sensors depends on the lmsensors sysfs filesystem
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/README 2009-06-06 23:12:22 UTC (rev 509)
@@ -24,6 +24,9 @@
default is to scale against the highest peak in the current graph.
-h Show help
-u Display unicore graphs only on the CPU screen
+-s device Monitor temperature sensors device (ie -s it87.656)
+ device should point to sysfs path /sys/devices/platform/[device]/temp1_input
+ depends on the lmsensors
Usage:
$> g15stats
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-06-06 23:12:22 UTC (rev 509)
@@ -66,6 +66,9 @@
int have_nic=0;
+int have_sensor=0;
+unsigned char sensor[128];
+
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -743,6 +746,100 @@
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
}
+void draw_temp_screen(g15canvas *canvas, char *sensor, int all) {
+
+ g15_stats_temp_info temps[NUM_TEMP];
+ long tot_max_temp = 1;
+
+ FILE *fd_input;
+ FILE *fd_max;
+ char line [MAX_LINES];
+ char tmpstr [MAX_LINES];
+
+ int i = 0;
+ int j = 0;
+ for (i = 0; i < NUM_TEMP; i++)
+ {
+ char filename[128];
+
+ // Initialize battery state
+ temps[i].max_temp = 1;
+ temps[i].cur_temp = 1;
+
+ /* /sys/devices/platform/it87.656/temp1_input */
+ sprintf(filename, "/sys/devices/platform/%s/temp%d_input",sensor, i+1);
+ fd_input=fopen (filename,"r");
+ if (fd_input!=NULL)
+ {
+ if (fgets (line,MAX_LINES,fd_input)!=NULL)
+ {
+ temps[i].cur_temp=atoi (line) / 1000;
+ }
+ fclose (fd_input);
+ } else {
+ break;
+ }
+
+ sprintf(filename, "/sys/devices/platform/%s/temp%d_max",sensor, i+1);
+ fd_max=fopen (filename,"r");
+ if (fd_max!=NULL)
+ {
+ if (fgets (line,MAX_LINES,fd_max)!=NULL)
+ {
+ temps[i].max_temp=atoi (line) / 1000;
+ }
+ fclose (fd_max);
+ }
+
+ if(tot_max_temp < temps[i].max_temp) {
+ tot_max_temp = temps[i].max_temp;
+ }
+
+ }
+ if (i == 0) {
+ have_sensor = 0;
+ }
+ if((i+1) >= NUM_TEMP) {
+ i = NUM_TEMP;
+ } else {
+ i++;
+ }
+
+ if (all) {
+ g15r_clearScreen (canvas, G15_COLOR_WHITE);
+
+ g15r_renderString (canvas, (unsigned char*)"M", 0, G15_TEXT_MED, 155, 3);
+ g15r_renderString (canvas, (unsigned char*)"A", 1, G15_TEXT_MED, 155, 7);
+ g15r_renderString (canvas, (unsigned char*)"X", 2, G15_TEXT_MED, 155, 11);
+
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+
+ for (j = 0; j < i; j++) {
+ register int bar_top = (j*10) + 1 + j;
+ register int bar_bottom = ((j+1)*10) + j;
+
+ sprintf(tmpstr,"T-%d %3.f\xb0", j+1, temps[j].cur_temp);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (j*12) + 2);
+ g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, temps[j].cur_temp + 1, tot_max_temp, 4);
+ drawBar_reversed(canvas, BAR_START, bar_top,BAR_END, bar_bottom, G15_COLOR_BLACK, tot_max_temp - temps[j].cur_temp, tot_max_temp, 5);
+ }
+ }
+
+ char extension[11];
+ sprintf(tmpstr, " ");
+ for (j = 0; j < i; j++) {
+ if ((j + 1) != i) {
+ sprintf(extension, "Temp%d %3.f\xb0 | ", j+1, temps[j].cur_temp);
+ } else {
+ sprintf(extension, "Temp%d %3.f\xb0 ", j+1, temps[j].cur_temp);
+ }
+ strcat (tmpstr, extension);
+ }
+
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
void print_info_label(g15canvas *canvas) {
static int timer;
int my_cycle = cycle;
@@ -753,21 +850,24 @@
}
switch (my_cycle){
- case CYCLE_CPU_SCREEN :
+ case SCREEN_CPU_SCREEN :
print_sys_load_info(canvas);
break;
- case CYCLE_MEM_SCREEN :
+ case SCREEN_MEM_SCREEN :
print_mem_info(canvas);
break;
- case CYCLE_SWAP_SCREEN :
+ case SCREEN_SWAP_SCREEN :
print_swap_info(canvas);
break;
- case CYCLE_NET_SCREEN :
+ case SCREEN_NET_SCREEN :
print_net_info(canvas);
break;
- case CYCLE_BAT_SCREEN :
+ case SCREEN_BAT_SCREEN :
draw_bat_screen(canvas, 0);
break;
+ case SCREEN_TEMP_SCREEN :
+ draw_temp_screen(canvas,(char*)sensor,0);
+ break;
default :
if ((timer < PAUSE)) {
print_sys_load_info(canvas);
@@ -779,15 +879,22 @@
draw_bat_screen(canvas, 0);
} else if (timer < PAUSE_5) {
print_time_info(canvas);
- } else if (have_nic) {
- print_net_info(canvas);
+ } else if (timer < PAUSE_6) {
+ if (have_nic) {
+ print_net_info(canvas);
+ } else {
+ timer = PAUSE_6;
+
+ }
+ }else if(have_sensor) {
+ draw_temp_screen(canvas,(char*)sensor,0);
} else {
print_sys_load_info(canvas);
timer = 0;
}
break;
}
- if (timer > PAUSE_5) {
+ if (timer > PAUSE_7) {
timer=0;
}
}
@@ -795,6 +902,7 @@
void keyboard_watch(void) {
unsigned int keystate;
int change = 0;
+ int direction = 0;
while(1) {
recv(g15screen_fd,&keystate,4,0);
@@ -803,10 +911,12 @@
}
else if(keystate & G15_KEY_L2) {
cycle--;
+ direction = 0;
change++;
}
else if(keystate & G15_KEY_L3) {
cycle++;
+ direction = 1;
change++;
}
else if(keystate & G15_KEY_L4) {
@@ -819,10 +929,21 @@
}
if (cycle<0)
{
- // Wrap around the apps
- cycle=MAX_SCREENS;
+ if(have_sensor) {
+ cycle=MAX_SCREENS;
+ } else {
+ cycle=MAX_SCREENS - 1;
+ }
}
- if (cycle>MAX_SCREENS)
+ if ((!have_nic) && (cycle == SCREEN_NET_SCREEN))
+ {
+ if (direction) {
+ cycle++;
+ } else {
+ cycle--;
+ }
+ }
+ if ((cycle>MAX_SCREENS) || ((cycle>(MAX_SCREENS-1)) && (!have_sensor)))
{
//Wrap around the apps
cycle=0;
@@ -933,7 +1054,7 @@
if(0==strncmp(argv[i],"-d",2)||0==strncmp(argv[i],"--daemon",8)) {
go_daemon=1;
}
- if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",8)) {
+ if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",9)) {
unicore=1;
}
if(0==strncmp(argv[i],"-nsa",4)||0==strncmp(argv[i],"--net-scale-absolute",20)) {
@@ -941,22 +1062,32 @@
}
if(0==strncmp(argv[i],"-h",2)||0==strncmp(argv[i],"--help",6)) {
- printf("%s (c) 2008 Mike Lampard\n",PACKAGE_NAME);
+ printf("%s (c) 2008-2009 Mike Lampard, Piotr Czarnecki\n",PACKAGE_NAME);
printf("\nOptions:\n");
printf("--daemon (-d) run in background\n");
printf("--unicore (-u) display unicore graphs only on the CPU screen\n");
printf("--help (-h) this help text.\n");
printf("--interface [interface] (-i) monitor network interface [interface] ie -i eth0\n");
- printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
+ printf("--sensor [device] (-s) monitor temperature sensors [device] ie -s it87.656\n"
+ "\t[device] should point to sysfs path /sys/devices/platform/[device]/temp1_input\n");
+ printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n"
+ "\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
return 0;
}
- if(0==strncmp(argv[i],"-i",2)||0==strncmp(argv[i],"--interface",8)) {
+ if(0==strncmp(argv[i],"-i",2)||0==strncmp(argv[i],"--interface",11)) {
if(argv[i+1]!=NULL) {
have_nic=1;
i++;
strncpy((char*)interface,argv[i],128);
}
}
+ if(0==strncmp(argv[i],"-s",2)||0==strncmp(argv[i],"--sensor",8)) {
+ if(argv[i+1]!=NULL) {
+ have_sensor=1;
+ i++;
+ strncpy((char*)sensor,argv[i],128);
+ }
+ }
}
if((g15screen_fd = new_g15_screen(G15_G15RBUF))<0){
printf("Sorry, cant connect to the G15daemon\n");
@@ -981,28 +1112,34 @@
while(1) {
switch(cycle) {
- case CYCLE_CPU_SCREEN:
+ case SCREEN_CPU_SCREEN:
draw_cpu_screen_multicore(canvas,unicore);
print_info_label(canvas);
break;
- case CYCLE_MEM_SCREEN:
+ case SCREEN_MEM_SCREEN:
draw_mem_screen(canvas);
print_info_label(canvas);
break;
- case CYCLE_SWAP_SCREEN:
+ case SCREEN_SWAP_SCREEN:
draw_swap_screen(canvas);
print_info_label(canvas);
break;
- case CYCLE_NET_SCREEN:
+ case SCREEN_NET_SCREEN:
if(have_nic) {
draw_net_screen(canvas,(char*)interface);
print_info_label(canvas);
break;
}else
cycle++;
- case CYCLE_BAT_SCREEN:
+ case SCREEN_BAT_SCREEN:
draw_bat_screen(canvas,1);
break;
+ case SCREEN_TEMP_SCREEN:
+ if(have_sensor) {
+ draw_temp_screen(canvas,(char*)sensor,1);
+ break;
+ }else
+ cycle++;
default:
printf("cycle reached %i\n",cycle);
cycle=0;
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-02 14:52:42 UTC (rev 508)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-06-06 23:12:22 UTC (rev 509)
@@ -1,6 +1,7 @@
#define TEXT_LEFT 1
#define NUM_BATS 3
-#define MAX_SCREENS 4
+#define NUM_TEMP 3
+#define MAX_SCREENS 5
#define MAX_MODE 3
#define MAX_SUB_MODE 1
@@ -9,6 +10,8 @@
#define PAUSE_3 3*PAUSE
#define PAUSE_4 4*PAUSE
#define PAUSE_5 5*PAUSE
+#define PAUSE_6 6*PAUSE
+#define PAUSE_7 7*PAUSE
#define VL_LEFT 42
#define BAR_START 45
@@ -17,11 +20,12 @@
#define TEXT_RIGHT 155
#define MAX_LINES 128
-#define CYCLE_CPU_SCREEN 0
-#define CYCLE_MEM_SCREEN 1
-#define CYCLE_SWAP_SCREEN 2
-#define CYCLE_NET_SCREEN 3
-#define CYCLE_BAT_SCREEN 4
+#define SCREEN_CPU_SCREEN 0
+#define SCREEN_MEM_SCREEN 1
+#define SCREEN_SWAP_SCREEN 2
+#define SCREEN_NET_SCREEN 3
+#define SCREEN_BAT_SCREEN 4
+#define SCREEN_TEMP_SCREEN 5
#define MODE_CPU_USR_SYS_NCE_1 0
#define MODE_CPU_TOTAL 1
@@ -35,3 +39,8 @@
long status;
} g15_stats_bat_info;
+typedef struct g15_stats_temp_info
+{
+ float max_temp;
+ float cur_temp;
+} g15_stats_temp_info;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ste...@us...> - 2009-06-02 14:52:45
|
Revision: 508
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=508&view=rev
Author: steelside
Date: 2009-06-02 14:52:42 +0000 (Tue, 02 Jun 2009)
Log Message:
-----------
Testing keycode setting now, from what i can see it is fully functional. Might want a more sweet way of getting the keycodes thou
Modified Paths:
--------------
trunk/g15daemon-clients/g15macro/g15macro.c
Modified: trunk/g15daemon-clients/g15macro/g15macro.c
===================================================================
--- trunk/g15daemon-clients/g15macro/g15macro.c 2009-06-01 21:02:06 UTC (rev 507)
+++ trunk/g15daemon-clients/g15macro/g15macro.c 2009-06-02 14:52:42 UTC (rev 508)
@@ -432,7 +432,7 @@
}
fprintf(f,"#Use this file to define what keycode each key has.\n");
fprintf(f,"#You can use the following command to get the keycodes:.\n");
- fprintf(f,"#xev | grep 'keycode' --line-buffered | grep --line-buffered -o -E 'keycode [0-9]+' | cut -d" " -f 2\n");
+ fprintf(f,"#xev | grep 'keycode' --line-buffered | grep --line-buffered -o -E 'keycode [0-9]+' | cut -d' ' -f 2\n");
fprintf(f,"#Run the command and hit each key, remember in what order you pressed the keys,then write the number returned at the right place.\n");
fprintf(f,"#Keep in mind; each number will appear twice.\n");
fprintf(f,"#Format is Key:Keycode. Example: G1:138\n");
@@ -455,7 +455,7 @@
FILE *f = NULL;
char buf[1024];
unsigned int key=0;
- unsigned int i=0;
+// unsigned int i=0;
unsigned int keycode=0;
while (!f)
@@ -1295,6 +1295,14 @@
/* completely ignore errors and carry on */
XSetErrorHandler(myx_error_handler);
+
+ // Get keycodes for all keys
+ strcpy(GKeyCodeCfg,configDir);
+ strncat(GKeyCodeCfg,"GKeyCodes.cfg",1024-strlen(GKeyCodeCfg));
+ printf("%s\n",GKeyCodeCfg);
+ getKeyDefs(GKeyCodeCfg);
+
+
configure_mmediakeys();
change_keymap(0);
XFlush(dpy);
@@ -1361,10 +1369,6 @@
restore_config(configpath);
}
- strcpy(GKeyCodeCfg,configDir);
- strncat(GKeyCodeCfg,"GKeyCodes.cfg",1024-strlen(GKeyCodeCfg));
- printf("%s\n",GKeyCodeCfg);
- getKeyDefs(GKeyCodeCfg);
if(dump){
printf("G15Macro Dumping Codes...");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ste...@us...> - 2009-06-01 21:02:15
|
Revision: 507
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=507&view=rev
Author: steelside
Date: 2009-06-01 21:02:06 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
gkeycode changing *should* work, haven't tested yet
Modified Paths:
--------------
trunk/g15daemon-clients/g15macro/g15macro.c
Modified: trunk/g15daemon-clients/g15macro/g15macro.c
===================================================================
--- trunk/g15daemon-clients/g15macro/g15macro.c 2009-06-01 07:47:34 UTC (rev 506)
+++ trunk/g15daemon-clients/g15macro/g15macro.c 2009-06-01 21:02:06 UTC (rev 507)
@@ -431,9 +431,10 @@
return False;
}
fprintf(f,"#Use this file to define what keycode each key has.\n");
- fprintf(f,"#You can use xev for each key to figure it out.\n");
- fprintf(f,"#TODO: Better guide to finding out keycodes\n");
-// fprintf(f,"#Run the command and hit each key, then write the number returned at the right place.\n");
+ fprintf(f,"#You can use the following command to get the keycodes:.\n");
+ fprintf(f,"#xev | grep 'keycode' --line-buffered | grep --line-buffered -o -E 'keycode [0-9]+' | cut -d" " -f 2\n");
+ fprintf(f,"#Run the command and hit each key, remember in what order you pressed the keys,then write the number returned at the right place.\n");
+ fprintf(f,"#Keep in mind; each number will appear twice.\n");
fprintf(f,"#Format is Key:Keycode. Example: G1:138\n");
for (i = 0;i < 18;++i)
{
@@ -456,7 +457,7 @@
unsigned int key=0;
unsigned int i=0;
unsigned int keycode=0;
- int keys[18];
+
while (!f)
{
f=fopen(filename,"r");
@@ -477,8 +478,18 @@
if (buf[0] == '#' || strlen(buf) == 0)
continue;
- if (sscanf(buf,"G%i:%i", &key,&keycode))
- printf("%i:%i\n",key,keycode);
+ if (sscanf(buf,"G%i:%i", &key,&keycode)){
+// printf("%i:%i\n",key,keycode);
+// printf("Gkeycode%i:%i\n",key,gkeycodes[key-1]);
+ gkeycodes[key-1] = keycode;
+// printf("Gkeycode%i:%i\n",key,gkeycodes[key-1]);
+ }
+ sscanf(buf,"AudioStop:%i",&mmedia_codes[0]);
+ sscanf(buf,"AudioPlay:%i",&mmedia_codes[1]);
+ sscanf(buf,"AudioPrev:%i",&mmedia_codes[2]);
+ sscanf(buf,"AudioNext:%i",&mmedia_codes[3]);
+ sscanf(buf,"AudioLowerVolume:%i",&mmedia_codes[4]);
+ sscanf(buf,"AudioRaiseVolume:%i",&mmedia_codes[5]);
}
fclose(f);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ste...@us...> - 2009-06-01 07:47:43
|
Revision: 506
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=506&view=rev
Author: steelside
Date: 2009-06-01 07:47:34 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
Initial stuff for handling different gkey-keycodes(not yet done), but this is getting real sloppy, should reorganize alot.
Modified Paths:
--------------
trunk/g15daemon-clients/g15macro/g15macro.c
Modified: trunk/g15daemon-clients/g15macro/g15macro.c
===================================================================
--- trunk/g15daemon-clients/g15macro/g15macro.c 2009-05-28 23:04:27 UTC (rev 505)
+++ trunk/g15daemon-clients/g15macro/g15macro.c 2009-06-01 07:47:34 UTC (rev 506)
@@ -83,6 +83,8 @@
char configpath[1024];
char configDir[1024];
+char GKeyCodeCfg[1024];
+// Sloopppyyy :(
#define MAX_CONFIGS 32
unsigned int numConfigs = 0;
@@ -138,10 +140,10 @@
const char *gkeystring[] = { "G1","G2","G3","G4","G5","G6","G7","G8","G9","G10","G11","G12","G13","G14","G15","G16","G17","G18","Unknown" };
-const int gkeycodes[] = { 177,152,190,208,129,130,231,209,210,136,220,143,246,251,137,138,133,183 };
+int gkeycodes[] = { 177,152,190,208,129,130,231,209,210,136,220,143,246,251,137,138,133,183 };
-const int mmedia_codes[2][6] = { {164, 162, 144, 153, 174, 176}, // For G15 v1
- {174, 172, 173, 171, 122, 123} }; // For G15 v2
+int mmedia_codes[6] = {164, 162, 144, 153, 174, 176}; // For G15 v1
+// {174, 172, 173, 171, 122, 123} }; // For G15 v2
const long mmedia_defaults[] = {
XF86XK_AudioStop,
@@ -413,7 +415,74 @@
}
return mkey_offset;
}
+// Various distributions have started giving
+// different keycodes to the special keys
+// Next 2 functions handles this
+// TODO: We got alot of config files for very little info in each now..
+// Also this is most likely systemwide, but get's written for each user.
+int writeKeyDefs(char *filename)
+{
+ FILE *f;
+ unsigned int i=0;
+ f = fopen(filename,"w");
+ if(!f)
+ {
+ printf("ERROR: Unable to open keycode definition file (%s). Aborting.\n",filename);
+ return False;
+ }
+ fprintf(f,"#Use this file to define what keycode each key has.\n");
+ fprintf(f,"#You can use xev for each key to figure it out.\n");
+ fprintf(f,"#TODO: Better guide to finding out keycodes\n");
+// fprintf(f,"#Run the command and hit each key, then write the number returned at the right place.\n");
+ fprintf(f,"#Format is Key:Keycode. Example: G1:138\n");
+ for (i = 0;i < 18;++i)
+ {
+ fprintf(f,"G%i:%i\n",i+1,gkeycodes[i]);
+ }
+ fprintf(f,"AudioStop:%i\n",mmedia_codes[0]);
+ fprintf(f,"AudioPlay:%i\n",mmedia_codes[1]);
+ fprintf(f,"AudioPrev:%i\n",mmedia_codes[2]);
+ fprintf(f,"AudioNext:%i\n",mmedia_codes[3]);
+ fprintf(f,"AudioLowerVolume:%i\n",mmedia_codes[4]);
+ fprintf(f,"AudioRaiseVolume:%i\n",mmedia_codes[5]);
+ fclose(f);
+ return True;
+}
+void getKeyDefs(char *filename)
+{
+ FILE *f = NULL;
+ char buf[1024];
+ unsigned int key=0;
+ unsigned int i=0;
+ unsigned int keycode=0;
+ int keys[18];
+ while (!f)
+ {
+ f=fopen(filename,"r");
+ if (!f)
+ {
+ if (!writeKeyDefs(filename))
+ return;
+ }
+ }
+
+ printf("Reading keycodes for keys from %s\n",filename);
+ while (!feof(f))
+ {
+ memset(buf,0,sizeof(buf));
+ fgets(buf,sizeof(buf),f);
+
+ // Ignore comments and blanklines
+ if (buf[0] == '#' || strlen(buf) == 0)
+ continue;
+
+ if (sscanf(buf,"G%i:%i", &key,&keycode))
+ printf("%i:%i\n",key,keycode);
+ }
+ fclose(f);
+}
+
/* WARNING: uses global mkey state */
void dump_config(FILE *configfile)
{
@@ -741,7 +810,7 @@
++numConfigs;
// Add it to list of availible configurations
- printf("Adding Config %i with length %i - name %s\n",numConfigs,strlen(cfgName),cfgName);
+ g15macro_log("Adding Config %i with length %i - name %s\n",numConfigs,(int)strlen(cfgName),cfgName);
configs[numConfigs] = malloc(strlen(cfgName)+1); //+1 for null termination
memset(configs[numConfigs],0,sizeof(configs[numConfigs]));
strcpy(configs[numConfigs],cfgName);
@@ -769,17 +838,15 @@
/* ensure that the multimedia keys are configured */
void configure_mmediakeys(){
-
- KeySym newmap[1];
- int i=0;
- pthread_mutex_lock(&x11mutex);
- for(i=0;i<6;i++){
- newmap[0]=mmedia_defaults[i];
- XChangeKeyboardMapping (dpy, mmedia_codes[G15Version][i], 1, newmap, 1);
- }
- XFlush(dpy);
- pthread_mutex_unlock(&x11mutex);
-
+ KeySym newmap[1];
+ int i=0;
+ pthread_mutex_lock(&x11mutex);
+ for(i=0;i<6;i++){
+ newmap[0]=mmedia_defaults[i];
+ XChangeKeyboardMapping (dpy, mmedia_codes/*[G15Version]*/[i], 1, newmap, 1);
+ }
+ XFlush(dpy);
+ pthread_mutex_unlock(&x11mutex);
}
void handle_mkey_switch(unsigned int mkey) {
@@ -1137,7 +1204,7 @@
memset(configDir,0,sizeof(configDir));
strncpy(configDir,getenv("HOME"),1024);
- strncat(configDir,"/.g15macro/",1024-strlen(configpath));
+ strncat(configDir,"/.g15macro/",1024-strlen(configDir));
strncpy(configpath,getenv("HOME"),1024);
@@ -1283,6 +1350,11 @@
restore_config(configpath);
}
+ strcpy(GKeyCodeCfg,configDir);
+ strncat(GKeyCodeCfg,"GKeyCodes.cfg",1024-strlen(GKeyCodeCfg));
+ printf("%s\n",GKeyCodeCfg);
+ getKeyDefs(GKeyCodeCfg);
+
if(dump){
printf("G15Macro Dumping Codes...");
dump_config(stderr);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-05-28 23:04:42
|
Revision: 505
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=505&view=rev
Author: czarnyckm
Date: 2009-05-28 23:04:27 +0000 (Thu, 28 May 2009)
Log Message:
-----------
- Bugfix: Render bottom line on the Memory Screen once
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-27 22:12:03 UTC (rev 504)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-28 23:04:27 UTC (rev 505)
@@ -10,4 +10,6 @@
- Bottom row information rotation switched with the L5 key
- 3 additional CPU graph variants switched with the L4 key (at this moment for multi core processors only)
- New default CPU Screen (at this moment for multi core processors only)
-- Display unicore graphs only on the CPU screen with the option -u (--unicore)
\ No newline at end of file
+- Display unicore graphs only on the CPU screen with the option -u (--unicore)
+SVN 505:
+- Bugfix: Render bottom line on the Memory Screen once
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-27 22:12:03 UTC (rev 504)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-28 23:04:27 UTC (rev 505)
@@ -240,21 +240,27 @@
glibtop_mem mem;
char tmpstr[MAX_LINES];
+ glibtop_get_mem(&mem);
+
+ int mem_total = mem.total / 1024;
+ int mem_free = mem.free / 1024;
+ int mem_user = mem.user / 1024;
+ int mem_buffer = mem.buffer / 1024;
+ int mem_cached = mem.cached / 1024;
+
g15r_clearScreen (canvas, G15_COLOR_WHITE);
- glibtop_get_mem(&mem);
-
- sprintf(tmpstr,"Usr %2.f%%",((float)mem.user/(float)mem.total)*100);
+ sprintf(tmpstr,"Usr %2.f%%",((float)mem_user/(float)mem_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 2);
- sprintf(tmpstr,"Buf %2.f%%",((float)mem.buffer/(float)mem.total)*100);
+ sprintf(tmpstr,"Buf %2.f%%",((float)mem_buffer/(float)mem_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 14);
- sprintf(tmpstr,"Che %2.f%%",((float)mem.cached/(float)mem.total)*100);
+ sprintf(tmpstr,"Che %2.f%%",((float)mem_cached/(float)mem_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 26);
- g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,(mem.user/1024),(mem.total/1024),4);
- g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,(mem.buffer/1024),(mem.total/1024),4);
- g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,(mem.cached/1024),(mem.total/1024),4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(mem.free/1024),(mem.total/1024),5);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,mem_user,mem_total,4);
+ g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,mem_buffer,mem_total,4);
+ g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,mem_cached,mem_total,4);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,mem_free,mem_total,5);
g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
@@ -263,10 +269,6 @@
g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
-
- sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
-
}
void draw_swap_screen(g15canvas *canvas) {
@@ -277,13 +279,16 @@
glibtop_get_swap(&swap);
+ int swap_used = swap.used / 1024;
+ int swap_total = swap.total / 1024;
+
g15r_renderString (canvas, (unsigned char*)"Swap", 0, G15_TEXT_MED, TEXT_LEFT, 9);
- sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap.used/(float)swap.total)*100));
+ sprintf(tmpstr,"Used %i%%",(unsigned int)(((float)swap_used/(float)swap_total)*100));
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 19);
- g15r_drawBar(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(swap.used/1024),swap.total/1024,4);
+ g15r_drawBar(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,swap_used,swap_total,4);
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,(swap.total/1024)-(swap.used/1024),swap.total/1024,5);
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,swap_total-swap_used,swap_total,5);
g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
@@ -292,8 +297,6 @@
g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
-
- print_swap_info(canvas);
}
/* draw cpu screen. if drawgraph = 0 then no graph is drawn */
@@ -432,8 +435,8 @@
ncpumax = height;
glibtop_mem mem;
glibtop_get_mem(&mem);
- mem_used = ((mem.total - mem.free) / 1024);
mem_total = (mem.total / 1024);
+ mem_used = mem_total - (mem.free / 1024);
sprintf(tmpstr,"MEM %3.f%%",((float)(mem_used)/(float)mem_total)*100);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 24);
@@ -446,12 +449,12 @@
height = (height - ((ncpu - 1) * spacer)) / (ncpu);
}
- if(height < 1){
+ if (height < 1) {
height = 1;
}
}
- for(core=0;core<ncpu && core<ncpumax;core++) {
+ for(core = 0; ((core < ncpu) && (core < ncpumax)); core++) {
total = ((unsigned long) cpu.xcpu_total[core]) ? ((double) cpu.xcpu_total[core]) : 1.0;
user = ((unsigned long) cpu.xcpu_user[core]) ? ((double) cpu.xcpu_user[core]) : 1.0;
nice = ((unsigned long) cpu.xcpu_nice[core]) ? ((double) cpu.xcpu_nice[core]) : 1.0;
@@ -476,8 +479,8 @@
if (mode) {
y1 = (core * height) + (core * spacer);
- y2 = y1 + height-1;
- currentValue = b_total-b_idle;
+ y2 = y1 + height - 1;
+ currentValue = b_total - b_idle;
}
switch (mode) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-05-27 22:12:28
|
Revision: 504
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=504&view=rev
Author: czarnyckm
Date: 2009-05-27 22:12:03 +0000 (Wed, 27 May 2009)
Log Message:
-----------
fixed --unicore parameter length
clean up
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-27 21:52:20 UTC (rev 503)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-27 22:12:03 UTC (rev 504)
@@ -6,7 +6,7 @@
- Improve response time when switching screens.
- Battery status monitoring courtesy of Pieter De Wit
- Detect if Network interface is incorrect and disable netscreen. Resolves 100% cpu issue reported by Guy Dierx.
-SVN:
+SVN 504:
- Bottom row information rotation switched with the L5 key
- 3 additional CPU graph variants switched with the L4 key (at this moment for multi core processors only)
- New default CPU Screen (at this moment for multi core processors only)
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-27 21:52:20 UTC (rev 503)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-27 22:12:03 UTC (rev 504)
@@ -421,7 +421,6 @@
}
height = 12;
- //FIXME : It should be tested
ncpumax = height;
break;
case MODE_CPU_SUMARY :
@@ -430,7 +429,6 @@
}
height = 16;
- //FIXME : It should be tested
ncpumax = height;
glibtop_mem mem;
glibtop_get_mem(&mem);
@@ -932,7 +930,7 @@
if(0==strncmp(argv[i],"-d",2)||0==strncmp(argv[i],"--daemon",8)) {
go_daemon=1;
}
- if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",11)) {
+ if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",8)) {
unicore=1;
}
if(0==strncmp(argv[i],"-nsa",4)||0==strncmp(argv[i],"--net-scale-absolute",20)) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cza...@us...> - 2009-05-27 21:52:22
|
Revision: 503
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=503&view=rev
Author: czarnyckm
Date: 2009-05-27 21:52:20 +0000 (Wed, 27 May 2009)
Log Message:
-----------
- Bottom row information rotation switched with the L5 key
- 3 additional CPU graph variants switched with the L4 key (at this moment for multi core processors only)
- New default CPU Screen (at this moment for multi core processors only)
- Display unicore graphs only on the CPU screen with the option -u (--unicore)
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/README
trunk/g15daemon-clients/g15stats/g15stats.c
trunk/g15daemon-clients/g15stats/g15stats.h
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-27 04:26:18 UTC (rev 502)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-05-27 21:52:20 UTC (rev 503)
@@ -6,3 +6,8 @@
- Improve response time when switching screens.
- Battery status monitoring courtesy of Pieter De Wit
- Detect if Network interface is incorrect and disable netscreen. Resolves 100% cpu issue reported by Guy Dierx.
+SVN:
+- Bottom row information rotation switched with the L5 key
+- 3 additional CPU graph variants switched with the L4 key (at this moment for multi core processors only)
+- New default CPU Screen (at this moment for multi core processors only)
+- Display unicore graphs only on the CPU screen with the option -u (--unicore)
\ No newline at end of file
Modified: trunk/g15daemon-clients/g15stats/README
===================================================================
--- trunk/g15daemon-clients/g15stats/README 2009-04-27 04:26:18 UTC (rev 502)
+++ trunk/g15daemon-clients/g15stats/README 2009-05-27 21:52:20 UTC (rev 503)
@@ -23,6 +23,7 @@
-nsa Scale network graphs against highest speed recorded. The
default is to scale against the highest peak in the current graph.
-h Show help
+-u Display unicore graphs only on the CPU screen
Usage:
$> g15stats
@@ -31,6 +32,8 @@
L2: Previous Screen
L3: Next Screen
+L4: Alternative Screen (Work at this moment with the CPU Screen only)
+L5: Bottom Info bar mode
BUGS:
none currently known.
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-27 04:26:18 UTC (rev 502)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-05-27 21:52:20 UTC (rev 503)
@@ -15,7 +15,8 @@
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-(c) 2008-2009 Mike Lampard
+(c) 2008-2009 Mike Lampard
+(c) 2009 Piotr Czarnecki
$Revision$ - $Date$ $Author$
@@ -56,14 +57,24 @@
#include "g15stats.h"
int g15screen_fd;
+
int cycle = 0;
+/** Holds the mode type variable of the application running */
+int mode = 0;
+/** Holds the sub mode type variable of the application running */
+int submode = 0;
+
int have_nic=0;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
+
unsigned long net_max_in=0;
unsigned long net_max_out=0;
+unsigned long previous_in;
+unsigned long previous_out;
+
_Bool net_scale_absolute=0;
pthread_cond_t wake_now = PTHREAD_COND_INITIALIZER;
@@ -74,6 +85,22 @@
return b;
}
+char * show_bytes(unsigned long bytes) {
+ static char tmpstr[128];
+ if(bytes>1024*1024) {
+ bytes = bytes / (1024*1024);
+ sprintf(tmpstr,"%liMb",bytes);
+ }
+ else if(bytes<1024*1024 && bytes > 1024) {
+ bytes = bytes / 1024;
+ sprintf(tmpstr,"%likb",bytes);
+ }
+ else if(bytes<1024) {
+ sprintf(tmpstr,"%lib",bytes);
+ }
+ return tmpstr;
+}
+
void drawBar_reversed (g15canvas * canvas, int x1, int y1, int x2, int y2, int color,
int num, int max, int type)
{
@@ -152,9 +179,66 @@
return 0;
}
+void print_sys_load_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ glibtop_loadavg loadavg;
+ glibtop_uptime uptime;
+
+ glibtop_get_loadavg(&loadavg);
+ glibtop_get_uptime(&uptime);
+
+ float minutes = uptime.uptime/60;
+ float hours = minutes/60;
+ float days = 0.0;
+
+ if(hours>24)
+ days=(int)(hours/24);
+ if(days)
+ hours=(int)hours-(days*24);
+
+ sprintf(tmpstr,"LoadAVG %.2f %.2f %.2f | Uptime %.fd%.fh",loadavg.loadavg[0],loadavg.loadavg[1],loadavg.loadavg[2],days,hours);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+void print_mem_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ glibtop_mem mem;
+ glibtop_get_mem(&mem);
+
+ sprintf(tmpstr,"Memory Used %dMb | Memory Total %dMb",(unsigned int)((mem.buffer+mem.cached+mem.user)/(1024*1024)),(unsigned int)(mem.total/(1024*1024)));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+void print_swap_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ glibtop_swap swap;
+ glibtop_get_swap(&swap);
+
+ sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+void print_net_info(g15canvas *canvas) {
+ char tmpstr[MAX_LINES];
+ sprintf(tmpstr,"Peak IN %s/s|",show_bytes(net_max_in));
+ strcat(tmpstr,"Peak OUT ");
+ strcat(tmpstr,show_bytes(net_max_out));
+ strcat(tmpstr,"/s");
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
+void print_time_info(g15canvas *canvas){
+ char tmpstr[MAX_LINES];
+ time_t now;
+ time(&now);
+
+ sprintf(tmpstr,"%s",ctime(&now));
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
+}
+
void draw_mem_screen(g15canvas *canvas) {
glibtop_mem mem;
- char tmpstr[1024];
+ char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -187,7 +271,7 @@
void draw_swap_screen(g15canvas *canvas) {
glibtop_swap swap;
- char tmpstr[1024];
+ char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
@@ -209,28 +293,18 @@
g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
- sprintf(tmpstr,"Swap Used %dMb | Swap Avail. %dMb",(unsigned int)(swap.used/(1024*1024)),(unsigned int)(swap.total/(1024*1024)));
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
-
+ print_swap_info(canvas);
}
/* draw cpu screen. if drawgraph = 0 then no graph is drawn */
-void draw_cpu_screen_unicore(g15canvas *canvas, int drawgraph) {
- glibtop_cpu cpu;
- glibtop_loadavg loadavg;
- glibtop_uptime uptime;
-
+void draw_cpu_screen_unicore_logic(g15canvas *canvas, glibtop_cpu cpu, int drawgraph, int printlabels, int cpuandmemory) {
int total,user,nice,sys,idle;
int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
static int last_total,last_user,last_nice,last_sys,last_idle,last_iowait,last_irq;
- char tmpstr[1024];
+ char tmpstr[MAX_LINES];
g15r_clearScreen (canvas, G15_COLOR_WHITE);
- glibtop_get_cpu(&cpu);
- glibtop_get_loadavg(&loadavg);
- glibtop_get_uptime(&uptime);
-
total = ((unsigned long) cpu.total) ? ((double) cpu.total) : 1.0;
user = ((unsigned long) cpu.user) ? ((double) cpu.user) : 1.0;
nice = ((unsigned long) cpu.nice) ? ((double) cpu.nice) : 1.0;
@@ -245,60 +319,65 @@
b_irq = cpu.irq - last_irq;
b_iowait= cpu.iowait - last_iowait;
- last_total = total;
- last_user = user;
- last_nice = nice;
- last_sys = sys;
- last_idle = idle;
- last_irq = cpu.irq;
+ last_total = total;
+ last_user = user;
+ last_nice = nice;
+ last_sys = sys;
+ last_idle = idle;
+ last_irq = cpu.irq;
last_iowait = cpu.iowait;
-
- sprintf(tmpstr,"Usr %2.f%%",((float)b_user/(float)b_total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 2);
- sprintf(tmpstr,"Sys %2.f%%",((float)b_sys/(float)b_total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 14);
- sprintf(tmpstr,"Nce %2.f%%",((float)b_nice/(float)b_total)*100);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 26);
+
+ if(printlabels) {
+ sprintf(tmpstr,"Usr %2.f%%",((float)b_user/(float)b_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 2);
+ sprintf(tmpstr,"Sys %2.f%%",((float)b_sys/(float)b_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 14);
+ sprintf(tmpstr,"Nce %2.f%%",((float)b_nice/(float)b_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, 26);
+ }
if(drawgraph) {
g15r_drawBar(canvas,BAR_START,1,BAR_END,10,G15_COLOR_BLACK,b_user+1,b_total,4);
g15r_drawBar(canvas,BAR_START,12,BAR_END,21,G15_COLOR_BLACK,b_sys+1,b_total,4);
g15r_drawBar(canvas,BAR_START,23,BAR_END,32,G15_COLOR_BLACK,b_nice+1,b_total,4);
drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,b_idle+1,b_total,5);
+
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
}
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ if (cpuandmemory) {
+ g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, TEXT_RIGHT, 3);
+ g15r_renderString (canvas, (unsigned char*)"R", 1, G15_TEXT_MED, TEXT_RIGHT, 3);
+ g15r_renderString (canvas, (unsigned char*)"E", 2, G15_TEXT_MED, TEXT_RIGHT, 3);
+ g15r_renderString (canvas, (unsigned char*)"E", 3, G15_TEXT_MED, TEXT_RIGHT, 3);
- g15r_renderString (canvas, (unsigned char*)"I", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"d", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"l", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
- g15r_renderString (canvas, (unsigned char*)"e", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+ sprintf(tmpstr,"CPU %3.f%%",((float)(b_total-b_idle)/(float)b_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 5);
+ } else {
+ g15r_renderString (canvas, (unsigned char*)"I", 0, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"d", 1, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"l", 2, G15_TEXT_MED, TEXT_RIGHT, 4);
+ g15r_renderString (canvas, (unsigned char*)"e", 3, G15_TEXT_MED, TEXT_RIGHT, 4);
+ }
+}
-// sprintf(tmpstr,"IOWait %u, Interrupts/s %u",b_iowait, b_irq);
- float minutes = uptime.uptime/60;
- float hours = minutes/60;
- float days = 0.0;
+void draw_cpu_screen_unicore(g15canvas *canvas, int drawgraph, int printlabels) {
+ glibtop_cpu cpu;
+ glibtop_get_cpu(&cpu);
- if(hours>24)
- days=(int)(hours/24);
- if(days)
- hours=(int)hours-(days*24);
-
- sprintf(tmpstr,"LoadAVG %.2f %.2f %.2f | Uptime %.fd%.fh",loadavg.loadavg[0],loadavg.loadavg[1],loadavg.loadavg[2],days,hours);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
-
+ draw_cpu_screen_unicore_logic(canvas, cpu, drawgraph, printlabels, 0);
}
-void draw_cpu_screen_multicore(g15canvas *canvas, int multicore) {
+void draw_cpu_screen_multicore(g15canvas *canvas, int unicore) {
glibtop_cpu cpu;
- glibtop_loadavg loadavg;
- glibtop_uptime uptime;
+ char tmpstr[MAX_LINES];
const glibtop_sysinfo *cpuinfo;
- int core,ncpu;
+ int core,ncpu,ncpumax;
int divider = 0;
- int total[16],user[16],nice[16],sys[16],idle[16];
- int b_total[16],b_user[16],b_nice[16],b_sys[16],b_idle[16],b_irq[16],b_iowait[16];
- static int last_total[16],last_user[16],last_nice[16],last_sys[16],last_idle[16],last_iowait[16],last_irq[16];
+ int total,user,nice,sys,idle;
+ int b_total,b_user,b_nice,b_sys,b_idle,b_irq,b_iowait;
+ static int last_total[GLIBTOP_NCPU],last_user[GLIBTOP_NCPU],last_nice[GLIBTOP_NCPU],
+ last_sys[GLIBTOP_NCPU],last_idle[GLIBTOP_NCPU],last_iowait[GLIBTOP_NCPU],last_irq[GLIBTOP_NCPU];
cpuinfo = glibtop_get_sysinfo();
@@ -307,64 +386,160 @@
else
ncpu = cpuinfo->ncpu;
- if(ncpu==1 || multicore==0) {
- draw_cpu_screen_unicore(canvas,1);
- return;
- }else
- draw_cpu_screen_unicore(canvas,0);
+ ncpumax = ncpu;
glibtop_get_cpu(&cpu);
- glibtop_get_loadavg(&loadavg);
- glibtop_get_uptime(&uptime);
- for(core=0;core<ncpu;core++) {
- total[core] = ((unsigned long) cpu.xcpu_total[core]) ? ((double) cpu.xcpu_total[core]) : 1.0;
- user[core] = ((unsigned long) cpu.xcpu_user[core]) ? ((double) cpu.xcpu_user[core]) : 1.0;
- nice[core] = ((unsigned long) cpu.xcpu_nice[core]) ? ((double) cpu.xcpu_nice[core]) : 1.0;
- sys[core] = ((unsigned long) cpu.xcpu_sys[core]) ? ((double) cpu.xcpu_sys[core]) : 1.0;
- idle[core] = ((unsigned long) cpu.xcpu_idle[core]) ? ((double) cpu.xcpu_idle[core]) : 1.0;
- b_total[core] = total[core] - last_total[core];
- b_user[core] = user[core] - last_user[core];
- b_nice[core] = nice[core] - last_nice[core];
- b_sys[core] = sys[core] - last_sys[core];
- b_idle[core] = idle[core] - last_idle[core];
- b_irq[core] = cpu.xcpu_irq[core] - last_irq[core];
- b_iowait[core] = cpu.xcpu_iowait[core] - last_iowait[core];
+ if (ncpu==1 || unicore) {
+ draw_cpu_screen_unicore_logic(canvas, cpu, 1, 1, 0);
+ return;
+ } else if (((ncpu > 5) && (mode != MODE_CPU_SUMARY))
+ || (mode == MODE_CPU_USR_SYS_NCE_1)
+ || (mode == MODE_CPU_USR_SYS_NCE_2)) {
+ draw_cpu_screen_unicore_logic(canvas, cpu, 0, 1, 0);
+ } else if (mode != MODE_CPU_SUMARY){
+ draw_cpu_screen_unicore_logic(canvas, cpu, 0, 0, 0);
+ } else {
+ draw_cpu_screen_unicore_logic(canvas, cpu, 0, 0, 1);
+ }
- last_total[core] = total[core];
- last_user[core] = user[core];
- last_nice[core] = nice[core];
- last_sys[core] = sys[core];
- last_idle[core] = idle[core];
+ int y1=0, y2=32, currentValue, mem_used=1, mem_total=1;
+
+ int spacer = 1;
+ int height = 8;
+ if (mode) {
+ switch (mode) {
+ case MODE_CPU_TOTAL :
+ if(ncpu > 11){
+ spacer = 0;
+ }
+ height = 37;
+ break;
+ case MODE_CPU_USR_SYS_NCE_2 :
+ if(ncpu > 4){
+ spacer = 0;
+ }
+ height = 12;
+
+ //FIXME : It should be tested
+ ncpumax = height;
+ break;
+ case MODE_CPU_SUMARY :
+ if(ncpu>6){
+ spacer = 0;
+ }
+ height = 16;
+
+ //FIXME : It should be tested
+ ncpumax = height;
+ glibtop_mem mem;
+ glibtop_get_mem(&mem);
+ mem_used = ((mem.total - mem.free) / 1024);
+ mem_total = (mem.total / 1024);
+
+ sprintf(tmpstr,"MEM %3.f%%",((float)(mem_used)/(float)mem_total)*100);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, TEXT_LEFT, 24);
+ break;
+ }
+
+ if (ncpumax < ncpu) {
+ height = (height - ((ncpumax - 1) * spacer)) / (ncpumax);
+ } else {
+ height = (height - ((ncpu - 1) * spacer)) / (ncpu);
+ }
+
+ if(height < 1){
+ height = 1;
+ }
+ }
+
+ for(core=0;core<ncpu && core<ncpumax;core++) {
+ total = ((unsigned long) cpu.xcpu_total[core]) ? ((double) cpu.xcpu_total[core]) : 1.0;
+ user = ((unsigned long) cpu.xcpu_user[core]) ? ((double) cpu.xcpu_user[core]) : 1.0;
+ nice = ((unsigned long) cpu.xcpu_nice[core]) ? ((double) cpu.xcpu_nice[core]) : 1.0;
+ sys = ((unsigned long) cpu.xcpu_sys[core]) ? ((double) cpu.xcpu_sys[core]) : 1.0;
+ idle = ((unsigned long) cpu.xcpu_idle[core]) ? ((double) cpu.xcpu_idle[core]) : 1.0;
+
+ b_total = total - last_total[core];
+ b_user = user - last_user[core];
+ b_nice = nice - last_nice[core];
+ b_sys = sys - last_sys[core];
+ b_idle = idle - last_idle[core];
+ b_irq = cpu.xcpu_irq[core] - last_irq[core];
+ b_iowait = cpu.xcpu_iowait[core] - last_iowait[core];
+
+ last_total[core] = total;
+ last_user[core] = user;
+ last_nice[core] = nice;
+ last_sys[core] = sys;
+ last_idle[core] = idle;
last_irq[core] = cpu.xcpu_irq[core];
last_iowait[core] = cpu.xcpu_iowait[core];
- divider = 9/ncpu;
- g15r_drawBar(canvas,BAR_START,1+(divider*core),BAR_END,1+(divider+(divider*(core))),G15_COLOR_BLACK,b_user[core]+1,b_total[core],4);
- g15r_drawBar(canvas,BAR_START,13+(divider*(core)),BAR_END,13+(divider+(divider*(core))),G15_COLOR_BLACK,b_sys[core]+1,b_total[core],4);
- g15r_drawBar(canvas,BAR_START,24+(divider*(core)),BAR_END,24+(divider+(divider*(core))),G15_COLOR_BLACK,b_nice[core]+1,b_total[core],4);
- divider = 32/ncpu;
- drawBar_reversed(canvas,BAR_START,1+(divider*core),BAR_END,1+(divider+(divider*(core))),G15_COLOR_BLACK,b_idle[core]+1,b_total[core],5);
+ if (mode) {
+ y1 = (core * height) + (core * spacer);
+ y2 = y1 + height-1;
+ currentValue = b_total-b_idle;
+ }
+
+ switch (mode) {
+ case MODE_CPU_USR_SYS_NCE_1 :
+ divider = 9/ncpu;
+ g15r_drawBar(canvas,BAR_START,(divider*core),BAR_END,(divider+(divider*(core))),G15_COLOR_BLACK,b_user+1,b_total,4);
+ g15r_drawBar(canvas,BAR_START,12+(divider*(core)),BAR_END,12+(divider+(divider*(core))),G15_COLOR_BLACK,b_sys+1,b_total,4);
+ y1 = 0;
+ y2 = 24+(divider+(divider*(core)));
+ g15r_drawBar(canvas,BAR_START,24+(divider*(core)),BAR_END,y2,G15_COLOR_BLACK,b_nice+1,b_total,4);
+
+ divider = y2/ncpu;
+ drawBar_reversed(canvas,BAR_START,(divider*core),BAR_END,y2,G15_COLOR_BLACK,b_idle+1,b_total,5);
+ break;
+ case MODE_CPU_TOTAL :
+ if (ncpu < 6) {
+ sprintf(tmpstr,"CPU%.f%3.f%%",(float)core,((float)(b_total-b_idle)/(float)b_total)*100);
+ if (ncpu < 5) {
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, y1+1);
+ } else {
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 1, y1+1);
+ }
+ }
+
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ y1 = 0;
+ break;
+ case MODE_CPU_USR_SYS_NCE_2 :
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ g15r_drawBar(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_sys+1,b_total,4);
+ g15r_drawBar(canvas, BAR_START,24+y1,BAR_END,24+y2,G15_COLOR_BLACK,b_nice+1,b_total,4);
+
+
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ drawBar_reversed(canvas, BAR_START,12+y1,BAR_END,12+y2,G15_COLOR_BLACK,b_total-b_sys,b_total,5);
+
+ y2 += 24;
+ drawBar_reversed(canvas, BAR_START,24+y1,BAR_END, y2,G15_COLOR_BLACK,b_total-b_nice,b_total,5);
+
+ y1 = 0;
+ break;
+ case MODE_CPU_SUMARY :
+ g15r_drawBar(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, currentValue, b_total,4);
+ g15r_drawBar(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_used+1, mem_total,4);
+
+ drawBar_reversed(canvas, BAR_START, y1, BAR_END, y2, G15_COLOR_BLACK, b_total-currentValue, b_total,5);
+ drawBar_reversed(canvas, BAR_START,19+y1,BAR_END,19+y2,G15_COLOR_BLACK, mem_total - mem_used, mem_total,5);
+ y1 = 0;
+ break;
+ }
}
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
-}
+ g15r_drawLine (canvas, VL_LEFT, y1, VL_LEFT, y2, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, y1, VL_LEFT+1, y2, G15_COLOR_BLACK);
-char * show_bytes(unsigned long bytes) {
- static char tmpstr[128];
- if(bytes>1024*1024) {
- bytes = bytes / (1024*1024);
- sprintf(tmpstr,"%liMb",bytes);
+ if(mode == 3) {
+ g15r_drawLine (canvas, VL_LEFT, 19+y1, VL_LEFT, 19+y2, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 19+y1, VL_LEFT+1, 19+y2, G15_COLOR_BLACK);
}
- else if(bytes<1024*1024 && bytes > 1024) {
- bytes = bytes / 1024;
- sprintf(tmpstr,"%likb",bytes);
- }
- else if(bytes<1024) {
- sprintf(tmpstr,"%lib",bytes);
- }
- return tmpstr;
}
void draw_net_screen(g15canvas *canvas, char *interface) {
@@ -424,16 +599,9 @@
sprintf(tmpstr,"%s",interface);
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_LARGE, 25-(strlen(tmpstr)*9)/2, 14);
-
- sprintf(tmpstr,"Peak IN %s/s|",show_bytes(net_max_in));
- strcat(tmpstr,"Peak OUT ");
- strcat(tmpstr,show_bytes(net_max_out));
- strcat(tmpstr,"/s");
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
-
}
-void draw_bat_screen(g15canvas *canvas) {
+void draw_bat_screen(g15canvas *canvas, int all) {
g15_stats_bat_info bats[NUM_BATS];
long tot_max_charge = 0;
@@ -506,33 +674,34 @@
}
}
+ if (all) {
+ g15r_clearScreen (canvas, G15_COLOR_WHITE);
- g15r_clearScreen (canvas, G15_COLOR_WHITE);
+ g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"U", 1, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"L", 2, G15_TEXT_MED, 155, 4);
+ g15r_renderString (canvas, (unsigned char*)"L", 3, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"F", 0, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"U", 1, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"L", 2, G15_TEXT_MED, 155, 4);
- g15r_renderString (canvas, (unsigned char*)"L", 3, G15_TEXT_MED, 155, 4);
+ g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
+ g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT, 1, VL_LEFT, 32, G15_COLOR_BLACK);
- g15r_drawLine (canvas, VL_LEFT+1, 1, VL_LEFT+1, 32, G15_COLOR_BLACK);
+ for (i = 0; i < NUM_BATS; i++)
+ {
+ register float charge = 0;
+ register int bar_top = (i*10) + 1 + i;
+ register int bar_bottom = ((i+1)*10) + i;
+ if (bats[i].max_charge > 0)
+ {
+ charge = ((float)bats[i].cur_charge/(float)bats[i].max_charge)*100;
+ }
+ sprintf(tmpstr,"Bt%d %2.f%%", i, charge);
+ g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (i*12) + 2);
+ g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, bats[i].cur_charge, bats[i].max_charge, 4);
+ }
- for (i = 0; i < NUM_BATS; i++)
- {
- register float charge = 0;
- register int bar_top = (i*10) + 1 + i;
- register int bar_bottom = ((i+1)*10) + i;
- if (bats[i].max_charge > 0)
- {
- charge = ((float)bats[i].cur_charge/(float)bats[i].max_charge)*100;
- }
- sprintf(tmpstr,"Bt%d %2.f%%", i, charge);
- g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_MED, 1, (i*12) + 2);
- g15r_drawBar(canvas, BAR_START, bar_top, BAR_END, bar_bottom, G15_COLOR_BLACK, bats[i].cur_charge, bats[i].max_charge, 4);
- }
+ drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
+ }
- drawBar_reversed(canvas,BAR_START,1,BAR_END,32,G15_COLOR_BLACK,100-(((float)tot_cur_charge/(float)tot_max_charge)*100),100,5);
-
float total_charge = 0;
if (tot_max_charge > 0)
{
@@ -573,9 +742,58 @@
g15r_renderString (canvas, (unsigned char*)tmpstr, 0, G15_TEXT_SMALL, 80-(strlen(tmpstr)*4)/2, 36);
}
+void print_info_label(g15canvas *canvas) {
+ static int timer;
+ int my_cycle = cycle;
+ timer++;
+ if (! submode) {
+ my_cycle = -1;
+ }
+
+ switch (my_cycle){
+ case CYCLE_CPU_SCREEN :
+ print_sys_load_info(canvas);
+ break;
+ case CYCLE_MEM_SCREEN :
+ print_mem_info(canvas);
+ break;
+ case CYCLE_SWAP_SCREEN :
+ print_swap_info(canvas);
+ break;
+ case CYCLE_NET_SCREEN :
+ print_net_info(canvas);
+ break;
+ case CYCLE_BAT_SCREEN :
+ draw_bat_screen(canvas, 0);
+ break;
+ default :
+ if ((timer < PAUSE)) {
+ print_sys_load_info(canvas);
+ } else if (timer < PAUSE_2) {
+ print_mem_info(canvas);
+ } else if (timer < PAUSE_3) {
+ print_swap_info(canvas);
+ } else if (timer < PAUSE_4) {
+ draw_bat_screen(canvas, 0);
+ } else if (timer < PAUSE_5) {
+ print_time_info(canvas);
+ } else if (have_nic) {
+ print_net_info(canvas);
+ } else {
+ print_sys_load_info(canvas);
+ timer = 0;
+ }
+ break;
+ }
+ if (timer > PAUSE_5) {
+ timer=0;
+ }
+}
+
void keyboard_watch(void) {
unsigned int keystate;
+ int change = 0;
while(1) {
recv(g15screen_fd,&keystate,4,0);
@@ -584,17 +802,19 @@
}
else if(keystate & G15_KEY_L2) {
cycle--;
- pthread_cond_broadcast(&wake_now);
+ change++;
}
else if(keystate & G15_KEY_L3) {
cycle++;
- pthread_cond_broadcast(&wake_now);
+ change++;
}
else if(keystate & G15_KEY_L4) {
- // These can now be passed to the "app" running
+ mode++;
+ change++;
}
else if(keystate & G15_KEY_L5) {
- // These can now be passed to the "app" running
+ submode++;
+ change++;
}
if (cycle<0)
{
@@ -606,6 +826,22 @@
//Wrap around the apps
cycle=0;
}
+
+ if (mode>MAX_MODE)
+ {
+ mode=0;
+ }
+
+ if (submode>MAX_SUB_MODE)
+ {
+ submode=0;
+ }
+
+ if (change)
+ {
+ pthread_cond_broadcast(&wake_now);
+ change = 0;
+ }
usleep(100*900);
}
@@ -616,8 +852,6 @@
char *interface = (char*)iface;
int i=0;
glibtop_netload netload;
- static unsigned long previous_in;
- static unsigned long previous_out;
int mac=0;
glibtop_get_netload(&netload,interface);
@@ -690,14 +924,16 @@
int i;
int go_daemon=0;
unsigned char interface[128];
- int multicore = 0;
+ int unicore = 0;
+ // Set the default CPU Screen mode to mem plus cpu
+ mode = MODE_CPU_SUMARY;
for (i=0;i<argc;i++) {
if(0==strncmp(argv[i],"-d",2)||0==strncmp(argv[i],"--daemon",8)) {
go_daemon=1;
}
- if(0==strncmp(argv[i],"-m",2)||0==strncmp(argv[i],"--multicore",11)) {
- multicore=1;
+ if(0==strncmp(argv[i],"-u",2)||0==strncmp(argv[i],"--unicore",11)) {
+ unicore=1;
}
if(0==strncmp(argv[i],"-nsa",4)||0==strncmp(argv[i],"--net-scale-absolute",20)) {
net_scale_absolute=1;
@@ -707,7 +943,7 @@
printf("%s (c) 2008 Mike Lampard\n",PACKAGE_NAME);
printf("\nOptions:\n");
printf("--daemon (-d) run in background\n");
- printf("--multicore (-m) display graphs for each core on the CPU screen\n");
+ printf("--unicore (-u) display unicore graphs only on the CPU screen\n");
printf("--help (-h) this help text.\n");
printf("--interface [interface] (-i) monitor network interface [interface] ie -i eth0\n");
printf("--net-scale-absolute (-nsa) scale net graphs against maximum speed seen.\n\tDefault is to scale fullsize, similar to apps like gkrellm.\n");
@@ -744,23 +980,27 @@
while(1) {
switch(cycle) {
- case 0:
- draw_cpu_screen_multicore(canvas,multicore);
+ case CYCLE_CPU_SCREEN:
+ draw_cpu_screen_multicore(canvas,unicore);
+ print_info_label(canvas);
break;
- case 1:
+ case CYCLE_MEM_SCREEN:
draw_mem_screen(canvas);
+ print_info_label(canvas);
break;
- case 2:
+ case CYCLE_SWAP_SCREEN:
draw_swap_screen(canvas);
+ print_info_label(canvas);
break;
- case 3:
+ case CYCLE_NET_SCREEN:
if(have_nic) {
draw_net_screen(canvas,(char*)interface);
+ print_info_label(canvas);
break;
}else
cycle++;
- case 4:
- draw_bat_screen(canvas);
+ case CYCLE_BAT_SCREEN:
+ draw_bat_screen(canvas,1);
break;
default:
printf("cycle reached %i\n",cycle);
Modified: trunk/g15daemon-clients/g15stats/g15stats.h
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.h 2009-04-27 04:26:18 UTC (rev 502)
+++ trunk/g15daemon-clients/g15stats/g15stats.h 2009-05-27 21:52:20 UTC (rev 503)
@@ -1,13 +1,33 @@
#define TEXT_LEFT 1
#define NUM_BATS 3
#define MAX_SCREENS 4
+#define MAX_MODE 3
+#define MAX_SUB_MODE 1
+
+#define PAUSE 6
+#define PAUSE_2 2*PAUSE
+#define PAUSE_3 3*PAUSE
+#define PAUSE_4 4*PAUSE
+#define PAUSE_5 5*PAUSE
+
#define VL_LEFT 42
#define BAR_START 45
#define MAX_NET_HIST 107
#define BAR_END 153
#define TEXT_RIGHT 155
-#define MAX_LINES 1024
+#define MAX_LINES 128
+#define CYCLE_CPU_SCREEN 0
+#define CYCLE_MEM_SCREEN 1
+#define CYCLE_SWAP_SCREEN 2
+#define CYCLE_NET_SCREEN 3
+#define CYCLE_BAT_SCREEN 4
+
+#define MODE_CPU_USR_SYS_NCE_1 0
+#define MODE_CPU_TOTAL 1
+#define MODE_CPU_USR_SYS_NCE_2 2
+#define MODE_CPU_SUMARY 3
+
typedef struct g15_stats_bat_info
{
long max_charge;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-27 04:26:27
|
Revision: 502
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=502&view=rev
Author: mlampard
Date: 2009-04-27 04:26:18 +0000 (Mon, 27 Apr 2009)
Log Message:
-----------
g15stats: Detect bad network interface. Resolve issue causing 100% cpu usage.
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-27 04:02:26 UTC (rev 501)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-27 04:26:18 UTC (rev 502)
@@ -5,3 +5,4 @@
SVN:
- Improve response time when switching screens.
- Battery status monitoring courtesy of Pieter De Wit
+- Detect if Network interface is incorrect and disable netscreen. Resolves 100% cpu issue reported by Guy Dierx.
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-27 04:02:26 UTC (rev 501)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-27 04:26:18 UTC (rev 502)
@@ -57,6 +57,7 @@
int g15screen_fd;
int cycle = 0;
+int have_nic=0;
unsigned int net_hist[MAX_NET_HIST][2];
int net_rr_index=0;
@@ -617,10 +618,19 @@
glibtop_netload netload;
static unsigned long previous_in;
static unsigned long previous_out;
+ int mac=0;
+ glibtop_get_netload(&netload,interface);
+ for(i=0;i<8;i++)
+ mac+=netload.hwaddress[i];
+ if(!mac) {
+ printf("Interface %s does not appear to exist. Net screen will be disabled.\n",interface);
+ have_nic = 0;
+ return; // interface probably doesn't exist - no mac address
+ }
+
while(1) {
int j=0, max_in=0, max_out=0;
- glibtop_get_netload(&netload,interface);
if(previous_in+previous_out==0)
goto last;
@@ -644,11 +654,13 @@
}
net_rr_index=i;
i++; if(i>MAX_NET_HIST) i=0;
-
- sleep (1);
+
last:
previous_in = netload.bytes_in;
previous_out = netload.bytes_out;
+ sleep (1);
+ glibtop_get_netload(&netload,interface);
+
}
}
@@ -677,7 +689,6 @@
int i;
int go_daemon=0;
- int have_nic=0;
unsigned char interface[128];
int multicore = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-27 04:02:35
|
Revision: 501
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=501&view=rev
Author: mlampard
Date: 2009-04-27 04:02:26 +0000 (Mon, 27 Apr 2009)
Log Message:
-----------
update g15daemon changelog
Modified Paths:
--------------
trunk/g15daemon-wip/ChangeLog
Modified: trunk/g15daemon-wip/ChangeLog
===================================================================
--- trunk/g15daemon-wip/ChangeLog 2009-04-27 03:51:51 UTC (rev 500)
+++ trunk/g15daemon-wip/ChangeLog 2009-04-27 04:02:26 UTC (rev 501)
@@ -173,3 +173,6 @@
to set the backlight level for the currently shown screen only. Default is
now to disallow clients changing backlight, and to set backlight globally
via the button.
+SVN:
+- Bugfix: Clock plugin can now be disabled.
+
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-27 03:52:00
|
Revision: 500
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=500&view=rev
Author: mlampard
Date: 2009-04-27 03:51:51 +0000 (Mon, 27 Apr 2009)
Log Message:
-----------
Fix borkage that crashed g15daemon if clock plugin was not loaded. Now the clock plugin is treated just like any other. g15 splash screen is shown if no clients are running, otherwise its kept hidden.
Modified Paths:
--------------
trunk/g15daemon-wip/g15daemon/g15_plugins.c
trunk/g15daemon-wip/g15daemon/linked_lists.c
trunk/g15daemon-wip/g15daemon/main.c
Modified: trunk/g15daemon-wip/g15daemon/g15_plugins.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/g15_plugins.c 2009-04-25 13:39:13 UTC (rev 499)
+++ trunk/g15daemon-wip/g15daemon/g15_plugins.c 2009-04-27 03:51:51 UTC (rev 500)
@@ -265,13 +265,8 @@
if(plugin_args->type == G15_PLUGIN_LCD_CLIENT) {
//g15daemon_t *foolist = (g15daemon_t*)*masterlist;
- /* FIXME we should just sort out the linked list stuff instead of overriding it */
- if((int)masterlist->numclients>0){
- clientnode = g15daemon_lcdnode_add(&masterlist);
- }else {
- clientnode = masterlist->tail;
- masterlist->numclients++;
- }
+ clientnode = g15daemon_lcdnode_add(&masterlist);
+
plugin_args->plugin_handle = plugin_handle;
memcpy(clientnode->lcd->g15plugin,plugin_args,sizeof(plugin_s));
plugin_args->args = clientnode;
Modified: trunk/g15daemon-wip/g15daemon/linked_lists.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/linked_lists.c 2009-04-25 13:39:13 UTC (rev 499)
+++ trunk/g15daemon-wip/g15daemon/linked_lists.c 2009-04-27 03:51:51 UTC (rev 500)
@@ -118,6 +118,7 @@
{
lcdnode_t *current_screen = NULL;
pthread_mutex_lock(&lcdlist_mutex);
+
skip:
current_screen = masterlist->current;
@@ -139,8 +140,8 @@
} else {
masterlist->current = masterlist->current->prev;
}
-
- if(masterlist->current->lcd->never_select==1) {
+
+ if(masterlist->current->lcd->never_select==1 || (masterlist->numclients>0 && masterlist->current==masterlist->tail)) {
goto skip;
}
@@ -157,7 +158,8 @@
g15daemon_t **masterlist = NULL;
lcdnode_t **prev = NULL;
lcdnode_t **next = NULL;
-
+ if(oldnode == oldnode->list->tail)
+ return;
pthread_mutex_lock(&lcdlist_mutex);
masterlist = &oldnode->list;
Modified: trunk/g15daemon-wip/g15daemon/main.c
===================================================================
--- trunk/g15daemon-wip/g15daemon/main.c 2009-04-25 13:39:13 UTC (rev 499)
+++ trunk/g15daemon-wip/g15daemon/main.c 2009-04-27 03:51:51 UTC (rev 500)
@@ -62,6 +62,11 @@
/* send event to foreground client's eventlistener */
int g15daemon_send_event(void *caller, unsigned int event, unsigned long value)
{
+
+ if(caller==NULL) {
+ return -1;
+ }
+
switch(event) {
case G15_EVENT_KEYPRESS: {
static unsigned long lastkeys;
@@ -70,7 +75,7 @@
if(!lcd->g15plugin->info)
break;
-
+
int *(*plugin_listener)(plugin_event_t *newevent) = (void*)lcd->g15plugin->info->event_handler;
plugin_event_t *newevent=g15daemon_xmalloc(sizeof(plugin_event_t));
newevent->event = event;
@@ -171,6 +176,8 @@
g15daemon_send_refresh((lcd_t*)caller);
default: {
lcd_t *lcd = (lcd_t*)caller;
+ if(!lcd->g15plugin->info)
+ break;
int *(*plugin_listener)(plugin_event_t *newevent) = (void*)lcd->g15plugin->info->event_handler;
plugin_event_t *newevent=g15daemon_xmalloc(sizeof(plugin_event_t));
newevent->event = event;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2009-04-25 14:43:59
|
Revision: 499
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=499&view=rev
Author: robynhub
Date: 2009-04-25 13:39:13 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
fix
Modified Paths:
--------------
trunk/g15daemon-audio-plugins/g15daemon_audacious/configure.in
Modified: trunk/g15daemon-audio-plugins/g15daemon_audacious/configure.in
===================================================================
--- trunk/g15daemon-audio-plugins/g15daemon_audacious/configure.in 2009-04-25 13:34:42 UTC (rev 498)
+++ trunk/g15daemon-audio-plugins/g15daemon_audacious/configure.in 2009-04-25 13:39:13 UTC (rev 499)
@@ -26,7 +26,7 @@
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([ fcntl.h stdlib.h string.h sys/socket.h unistd.h libg15.h libg15render.h g15daemon_audacius_spectrum.h], [], [], [])
+AC_CHECK_HEADERS([ fcntl.h stdlib.h string.h sys/socket.h unistd.h libg15.h libg15render.h], [], [], [])
dnl check for xmms devel headers
AC_PATH_X
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-25 14:01:14
|
Revision: 498
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=498&view=rev
Author: mlampard
Date: 2009-04-25 13:34:42 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
update g15stats changelog
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/ChangeLog
Modified: trunk/g15daemon-clients/g15stats/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-25 13:17:20 UTC (rev 497)
+++ trunk/g15daemon-clients/g15stats/ChangeLog 2009-04-25 13:34:42 UTC (rev 498)
@@ -2,3 +2,6 @@
1.0
- Change net scale from absolute to relative, with option to revert to
absolute (-nsa --net-scale-absolute).
+SVN:
+- Improve response time when switching screens.
+- Battery status monitoring courtesy of Pieter De Wit
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-25 13:17:25
|
Revision: 497
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=497&view=rev
Author: mlampard
Date: 2009-04-25 13:17:20 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
use pthread methods to immediately change screens on receipt of keypress. greatly improves responsetime.
Modified Paths:
--------------
trunk/g15daemon-clients/g15stats/g15stats.c
Modified: trunk/g15daemon-clients/g15stats/g15stats.c
===================================================================
--- trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-25 11:04:26 UTC (rev 496)
+++ trunk/g15daemon-clients/g15stats/g15stats.c 2009-04-25 13:17:20 UTC (rev 497)
@@ -15,7 +15,7 @@
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-(c) 2008 Mike Lampard
+(c) 2008-2009 Mike Lampard
$Revision$ - $Date$ $Author$
@@ -23,7 +23,7 @@
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
-This is a cpu and memory stats client
+This is a simple stats client showing graphs for CPU, MEM & Swap usage, Network traffic and Battery life.
*/
#define _GNU_SOURCE 1
@@ -65,6 +65,8 @@
_Bool net_scale_absolute=0;
+pthread_cond_t wake_now = PTHREAD_COND_INITIALIZER;
+
unsigned long maxi(unsigned long a, unsigned long b) {
if(a>b)
return a;
@@ -372,12 +374,12 @@
float diff=0;
float height=0;
float last=0;
-
+
+ g15r_clearScreen (canvas, G15_COLOR_WHITE);
glibtop_netload netload;
glibtop_get_netload(&netload,interface);
// in
x=53;
- g15r_clearScreen (canvas, G15_COLOR_WHITE);
for(i=net_rr_index+1;i<MAX_NET_HIST;i++) {
diff = (float) net_max_in / (float) net_hist[i][0];
height = 16-(16/diff);
@@ -581,9 +583,11 @@
}
else if(keystate & G15_KEY_L2) {
cycle--;
+ pthread_cond_broadcast(&wake_now);
}
else if(keystate & G15_KEY_L3) {
cycle++;
+ pthread_cond_broadcast(&wake_now);
}
else if(keystate & G15_KEY_L4) {
// These can now be passed to the "app" running
@@ -648,17 +652,35 @@
}
}
+/* wait for a max of <seconds> seconds.. if condition &wake_now is received leave immediately */
+void g15stats_wait(int seconds) {
+ pthread_mutex_t dummy_mutex;
+ struct timespec timeout;
+ /* Create a dummy mutex which doesn't unlock for sure while waiting. */
+ pthread_mutex_init(&dummy_mutex, NULL);
+ pthread_mutex_lock(&dummy_mutex);
+
+ time(&timeout.tv_sec);
+ timeout.tv_sec += seconds;
+ timeout.tv_nsec = 0L;
+
+ pthread_cond_timedwait(&wake_now, &dummy_mutex, &timeout);
+ pthread_mutex_unlock(&dummy_mutex);
+ pthread_mutex_destroy(&dummy_mutex);
+}
+
int main(int argc, char *argv[]){
g15canvas *canvas;
pthread_t keys_thread;
pthread_t net_thread;
+
int i;
int go_daemon=0;
int have_nic=0;
unsigned char interface[128];
int multicore = 0;
-
+
for (i=0;i<argc;i++) {
if(0==strncmp(argv[i],"-d",2)||0==strncmp(argv[i],"--daemon",8)) {
go_daemon=1;
@@ -687,7 +709,6 @@
strncpy((char*)interface,argv[i],128);
}
}
-
}
if((g15screen_fd = new_g15_screen(G15_G15RBUF))<0){
printf("Sorry, cant connect to the G15daemon\n");
@@ -708,39 +729,37 @@
if(have_nic==1)
pthread_create(&net_thread,NULL,(void*)network_watch,&interface);
-
+
while(1) {
switch(cycle) {
case 0:
draw_cpu_screen_multicore(canvas,multicore);
- break;
+ break;
case 1:
- draw_mem_screen(canvas);
- break;
+ draw_mem_screen(canvas);
+ break;
case 2:
- draw_swap_screen(canvas);
- break;
+ draw_swap_screen(canvas);
+ break;
case 3:
- if(have_nic==1)
- draw_net_screen(canvas,(char*)interface);
- else {
- printf("Please set the interface on the cmdline\n");
- cycle=0;
- }
- break;
+ if(have_nic) {
+ draw_net_screen(canvas,(char*)interface);
+ break;
+ }else
+ cycle++;
case 4:
- draw_bat_screen(canvas);
- break;
+ draw_bat_screen(canvas);
+ break;
default:
- printf("cycle reched %i\n",cycle);
+ printf("cycle reached %i\n",cycle);
+ cycle=0;
}
canvas->mode_xor = 0;
g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN);
-
- sleep(1);
+ g15stats_wait(1);
}
glibtop_close();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2009-04-25 11:04:29
|
Revision: 496
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=496&view=rev
Author: robynhub
Date: 2009-04-25 11:04:26 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
Added header file (finally)
Modified Paths:
--------------
trunk/g15daemon-audio-plugins/g15daemon_audacious/configure.in
trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c
Added Paths:
-----------
trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.h
Modified: trunk/g15daemon-audio-plugins/g15daemon_audacious/configure.in
===================================================================
--- trunk/g15daemon-audio-plugins/g15daemon_audacious/configure.in 2009-04-25 10:53:15 UTC (rev 495)
+++ trunk/g15daemon-audio-plugins/g15daemon_audacious/configure.in 2009-04-25 11:04:26 UTC (rev 496)
@@ -26,7 +26,7 @@
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS([ fcntl.h stdlib.h string.h sys/socket.h unistd.h libg15.h libg15render.h], [], [], [])
+AC_CHECK_HEADERS([ fcntl.h stdlib.h string.h sys/socket.h unistd.h libg15.h libg15render.h g15daemon_audacius_spectrum.h], [], [], [])
dnl check for xmms devel headers
AC_PATH_X
Modified: trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c
===================================================================
--- trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c 2009-04-25 10:53:15 UTC (rev 495)
+++ trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c 2009-04-25 11:04:26 UTC (rev 496)
@@ -65,203 +65,9 @@
#include <X11/Xlib.h>
#include <X11/XF86keysym.h>
+#include "g15daemon_audacious_spectrum.h"
-/* Some useful costants */
-#define WIDTH 256
-#define PLUGIN_VERSION "2.5.8"
-#define PLUGIN_NAME "G15daemon Visualization Plugin"
-#define INFERIOR_SPACE 7 /* space between bars and position bar */
-
-
-/* Time factor of the band dinamics. 3 means that the coefficient of the
- last value is half of the current one's. (see source) */
-#define tau 4.5
-/* Factor used for the diffusion. 4 means that half of the height is
- added to the neighbouring bars */
-#define dif 3
-
-#define ROWLEN 35
-
-/* height of a char */
-#define CHAR_HEIGH 9
-
-/* font size for title */
-#define FONT_SIZE 8
-
-/* separator of line */
-#define SEPARATOR "-"
-
-/* BEGIN CONFIG VARIABLES */
-/* for default values see below */
-
-/* Float. Linearity of the amplitude scale (0.5 for linear, keep in [0.1, 0.49]) */
-static float linearity;
-
-/* Integer. Amplification of the scale. Can be negative. +-30 is a reasonable range */
-static int amplification;
-
-/* Integer. limit (in px) of max length of bars avoid overlap (internal use) */
-static unsigned int limit;
-
-/* Integer. Number of Bars - Must be a divisor of 256! allowed: 2 4 8 16 32 64 128(no space between bars) */
-static unsigned int num_bars;
-
-/* Boolean. Variable to disable keybindings Default: Disabled */
-static unsigned int enable_keybindings;
-
-/* Integer. Visualization type */
-static unsigned int vis_type;
-
-/* Boolean. Peak visualization enable */
-static unsigned int enable_peak;
-
-/* Boolean. Detached peak from bars */
-static unsigned int detached_peak;
-
-/* Boolean. Enable Analog Mode */
-static unsigned int analog_mode;
-
-/* Boolean. Enable Line Mode */
-static unsigned int line_mode;
-
-/* Integer. Step for leds in Analog Mode. Min value: 2 */
-static unsigned int analog_step;
-
-/* Boolean. Show Title */
-static unsigned int show_title;
-
-/* Boolean. Show bar */
-static unsigned int show_pbar;
-
-/* Boolean. Show time in progress bar */
-static unsigned int show_time;
-
-/* Integer. Number of row of title */
-static unsigned int rownum;
-
-/* Boolean. Title overlay */
-static unsigned int title_overlay;
-
-
-/* END CONFIG VARIABLES */
-
-/* Set here defaults values */
-static unsigned int def_vis_type = 0;
-static unsigned int def_num_bars = 32;
-static float def_linearity = 0.37;
-static int def_amplification = 0;
-static unsigned int def_limit = G15_LCD_HEIGHT - INFERIOR_SPACE - CHAR_HEIGH;
-static unsigned int def_enable_peak = TRUE;
-static unsigned int def_detached_peak = TRUE;
-static unsigned int def_analog_mode = FALSE;
-static unsigned int def_line_mode = FALSE;
-static unsigned int def_analog_step = 2;
-static unsigned int def_enable_keybindings = FALSE;
-static unsigned int def_show_title = TRUE;
-static unsigned int def_show_pbar = TRUE;
-static unsigned int def_show_time = TRUE;
-static unsigned int def_rownum = 1;
-static unsigned int def_title_overlay = FALSE;
-
-
-static gint16 bar_heights[WIDTH];
-static gint16 bar_heights_peak[WIDTH];
-static gint16 scope_data[G15_LCD_WIDTH];
-static gdouble scale, x00, y00;
-
-static void g15analyser_init(void);
-static void g15analyser_cleanup(void);
-static void g15analyser_playback_start(void);
-static void g15analyser_playback_stop(void);
-static void g15analyser_render_pcm(gint16 data[2][512]);
-static void g15analyser_render_freq(gint16 data[2][256]);
-static void g15analyser_conf(void);
-static void g15analyser_about(void);
-static gint g15analyser_disable(gpointer data);
-
-static void g15analyser_conf_ok(GtkWidget *w, gpointer data);
-static void g15analyser_conf_apply(void);
-static void g15analyser_conf_cancel(void);
-static void g15analyser_conf_reset(void);
-
-g15canvas *canvas;
-g15font *font;
-
-static unsigned int playing=0, paused=0;
-static int g15screen_fd = -1;
-
-pthread_mutex_t g15buf_mutex;
-
-static Display *dpy;
-static Window root_win;
-
-static int mmedia_timeout_handle;
-static int g15keys_timeout_handle;
-static int g15disp_timeout_handle;
-
-/* scrollin text stuff */
-static int text_start = 60;
-static int text_start2 = -1;
-
-static int lastvolume;
-static int volume;
-
-/* gdk stuff */
-static GtkWidget *configure_win = NULL;
-static GtkWidget *vbox, *hbox;
-static GtkWidget *bbox, *ok, *cancel, *apply, *defaults;
-static GtkWidget *t_options_bars_radio, *t_options_scope_radio;
-static GtkWidget *t_options_effect_no, *t_options_effect_line, *t_options_effect_peak, *t_options_effect_analog;
-static GtkWidget *t_options_vistype;
-static GtkWidget *t_options_bars, *t_options_bars_effects;
-static GtkWidget *g_options_frame ,*g_options_enable_keybindings, *g_options_enable_dpeak;
-static GtkWidget *g_options_show_title, *g_options_show_pbar, *g_options_show_time, *g_options_title_overlay;
-static GtkWidget *g_options_frame_bars;
-static GtkWidget *g_options_frame_bars_effects;
-static GtkWidget *scale_bars, *scale_lin, *scale_ampli, *scale_step, *scale_rownum;
-static GtkObject *adj_bars, *adj_lin, *adj_ampli, *adj_step, *adj_rownum;
-
-static gint tmp_bars=-1, tmp_step=-1, tmp_ampli=-1000, tmp_rownum=-1;
-static gfloat tmp_lin=-1;
-
-VisPlugin g15analyser_vp = {
-#ifdef OLD_PLUGIN
-
- NULL,
- NULL,
- 0,
- PLUGIN_NAME " " PLUGIN_VERSION,
- 1,
- 1,
- g15analyser_init, /* init */
- g15analyser_cleanup, /* cleanup */
- g15analyser_about, /* about */
- g15analyser_conf, /* configure */
- NULL, /* disable_plugin */
- g15analyser_playback_start, /* playback_start */
- g15analyser_playback_stop, /* playback_stop */
- g15analyser_render_pcm, /* render_pcm */
- g15analyser_render_freq /* render_freq */
-
-#else
-
- .description = PLUGIN_NAME " " PLUGIN_VERSION,
- .num_pcm_chs_wanted = 1,
- .num_freq_chs_wanted = 1,
- .init = g15analyser_init, /* init */
- .cleanup = g15analyser_cleanup, /* cleanup */
- .about = g15analyser_about, /* about */
- .configure = g15analyser_conf, /* configure */
- .playback_start = g15analyser_playback_start, /* playback_start */
- .playback_stop = g15analyser_playback_stop, /* playback_stop */
- .render_pcm = g15analyser_render_pcm, /* render_pcm */
- .render_freq = g15analyser_render_freq /* render_freq */
-
-#endif
-};
-
-
#ifndef OLD_PLUGIN
VisPlugin *g15_vp[] = { &g15analyser_vp, NULL };
SIMPLE_VISUAL_PLUGIN(g15, g15_vp);
Added: trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.h
===================================================================
--- trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.h (rev 0)
+++ trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.h 2009-04-25 11:04:26 UTC (rev 496)
@@ -0,0 +1,219 @@
+/*
+ This file is part of g15daemon.
+
+ g15daemon 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
+ (at your option) any later version.
+
+ g15daemon 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 g15daemon; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ (c) 2006-2007 Mike Lampard, Philip Lawatsch, Antonio Bartolini, and others
+
+ This daemon listens on localhost port 15550 for client connections,
+ and arbitrates LCD display. Allows for multiple simultaneous clients.
+ Client screens can be cycled through by pressing the 'L1' key.
+
+ simple analyser xmms plugin for g15daemon
+*/
+
+/* Some useful costants */
+#define WIDTH 256
+#define PLUGIN_VERSION "2.5.8"
+#define PLUGIN_NAME "G15daemon Visualization Plugin"
+#define INFERIOR_SPACE 7 /* space between bars and position bar */
+
+
+/* Time factor of the band dinamics. 3 means that the coefficient of the
+ last value is half of the current one's. (see source) */
+#define tau 4.5
+/* Factor used for the diffusion. 4 means that half of the height is
+ added to the neighbouring bars */
+#define dif 3
+
+#define ROWLEN 35
+
+/* height of a char */
+#define CHAR_HEIGH 9
+
+/* font size for title */
+#define FONT_SIZE 8
+
+/* separator of line */
+#define SEPARATOR "-"
+
+/* BEGIN CONFIG VARIABLES */
+/* for default values see below */
+
+/* Float. Linearity of the amplitude scale (0.5 for linear, keep in [0.1, 0.49]) */
+static float linearity;
+
+/* Integer. Amplification of the scale. Can be negative. +-30 is a reasonable range */
+static int amplification;
+
+/* Integer. limit (in px) of max length of bars avoid overlap (internal use) */
+static unsigned int limit;
+
+/* Integer. Number of Bars - Must be a divisor of 256! allowed: 2 4 8 16 32 64 128(no space between bars) */
+static unsigned int num_bars;
+
+/* Boolean. Variable to disable keybindings Default: Disabled */
+static unsigned int enable_keybindings;
+
+/* Integer. Visualization type */
+static unsigned int vis_type;
+
+/* Boolean. Peak visualization enable */
+static unsigned int enable_peak;
+
+/* Boolean. Detached peak from bars */
+static unsigned int detached_peak;
+
+/* Boolean. Enable Analog Mode */
+static unsigned int analog_mode;
+
+/* Boolean. Enable Line Mode */
+static unsigned int line_mode;
+
+/* Integer. Step for leds in Analog Mode. Min value: 2 */
+static unsigned int analog_step;
+
+/* Boolean. Show Title */
+static unsigned int show_title;
+
+/* Boolean. Show bar */
+static unsigned int show_pbar;
+
+/* Boolean. Show time in progress bar */
+static unsigned int show_time;
+
+/* Integer. Number of row of title */
+static unsigned int rownum;
+
+/* Boolean. Title overlay */
+static unsigned int title_overlay;
+
+
+/* END CONFIG VARIABLES */
+
+/* Set here defaults values */
+static unsigned int def_vis_type = 0;
+static unsigned int def_num_bars = 32;
+static float def_linearity = 0.37;
+static int def_amplification = 0;
+static unsigned int def_limit = G15_LCD_HEIGHT - INFERIOR_SPACE - CHAR_HEIGH;
+static unsigned int def_enable_peak = TRUE;
+static unsigned int def_detached_peak = TRUE;
+static unsigned int def_analog_mode = FALSE;
+static unsigned int def_line_mode = FALSE;
+static unsigned int def_analog_step = 2;
+static unsigned int def_enable_keybindings = FALSE;
+static unsigned int def_show_title = TRUE;
+static unsigned int def_show_pbar = TRUE;
+static unsigned int def_show_time = TRUE;
+static unsigned int def_rownum = 1;
+static unsigned int def_title_overlay = FALSE;
+
+
+static gint16 bar_heights[WIDTH];
+static gint16 bar_heights_peak[WIDTH];
+static gint16 scope_data[G15_LCD_WIDTH];
+static gdouble scale, x00, y00;
+
+static void g15analyser_init(void);
+static void g15analyser_cleanup(void);
+static void g15analyser_playback_start(void);
+static void g15analyser_playback_stop(void);
+static void g15analyser_render_pcm(gint16 data[2][512]);
+static void g15analyser_render_freq(gint16 data[2][256]);
+static void g15analyser_conf(void);
+static void g15analyser_about(void);
+static gint g15analyser_disable(gpointer data);
+
+static void g15analyser_conf_ok(GtkWidget *w, gpointer data);
+static void g15analyser_conf_apply(void);
+static void g15analyser_conf_cancel(void);
+static void g15analyser_conf_reset(void);
+
+static g15canvas *canvas;
+static g15font *font;
+
+static unsigned int playing=0, paused=0;
+static int g15screen_fd = -1;
+
+static pthread_mutex_t g15buf_mutex;
+
+static Display *dpy;
+static Window root_win;
+
+static int mmedia_timeout_handle;
+static int g15keys_timeout_handle;
+static int g15disp_timeout_handle;
+
+/* scrollin text stuff */
+static int text_start = 60;
+static int text_start2 = -1;
+
+static int lastvolume;
+static int volume;
+
+/* gdk stuff */
+static GtkWidget *configure_win = NULL;
+static GtkWidget *vbox, *hbox;
+static GtkWidget *bbox, *ok, *cancel, *apply, *defaults;
+static GtkWidget *t_options_bars_radio, *t_options_scope_radio;
+static GtkWidget *t_options_effect_no, *t_options_effect_line, *t_options_effect_peak, *t_options_effect_analog;
+static GtkWidget *t_options_vistype;
+static GtkWidget *t_options_bars, *t_options_bars_effects;
+static GtkWidget *g_options_frame ,*g_options_enable_keybindings, *g_options_enable_dpeak;
+static GtkWidget *g_options_show_title, *g_options_show_pbar, *g_options_show_time, *g_options_title_overlay;
+static GtkWidget *g_options_frame_bars;
+static GtkWidget *g_options_frame_bars_effects;
+static GtkWidget *scale_bars, *scale_lin, *scale_ampli, *scale_step, *scale_rownum;
+static GtkObject *adj_bars, *adj_lin, *adj_ampli, *adj_step, *adj_rownum;
+
+static gint tmp_bars=-1, tmp_step=-1, tmp_ampli=-1000, tmp_rownum=-1;
+static gfloat tmp_lin=-1;
+
+VisPlugin g15analyser_vp = {
+#ifdef OLD_PLUGIN
+
+ NULL,
+ NULL,
+ 0,
+ PLUGIN_NAME " " PLUGIN_VERSION,
+ 1,
+ 1,
+ g15analyser_init, /* init */
+ g15analyser_cleanup, /* cleanup */
+ g15analyser_about, /* about */
+ g15analyser_conf, /* configure */
+ NULL, /* disable_plugin */
+ g15analyser_playback_start, /* playback_start */
+ g15analyser_playback_stop, /* playback_stop */
+ g15analyser_render_pcm, /* render_pcm */
+ g15analyser_render_freq /* render_freq */
+
+#else
+
+ .description = PLUGIN_NAME " " PLUGIN_VERSION,
+ .num_pcm_chs_wanted = 1,
+ .num_freq_chs_wanted = 1,
+ .init = g15analyser_init, /* init */
+ .cleanup = g15analyser_cleanup, /* cleanup */
+ .about = g15analyser_about, /* about */
+ .configure = g15analyser_conf, /* configure */
+ .playback_start = g15analyser_playback_start, /* playback_start */
+ .playback_stop = g15analyser_playback_stop, /* playback_stop */
+ .render_pcm = g15analyser_render_pcm, /* render_pcm */
+ .render_freq = g15analyser_render_freq /* render_freq */
+
+#endif
+};
Property changes on: trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2009-04-25 10:53:18
|
Revision: 495
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=495&view=rev
Author: robynhub
Date: 2009-04-25 10:53:15 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
Modified Paths:
--------------
trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c
Modified: trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c
===================================================================
--- trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c 2009-04-25 10:43:41 UTC (rev 494)
+++ trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c 2009-04-25 10:53:15 UTC (rev 495)
@@ -1173,7 +1173,7 @@
{
/* render scope */
int y1, y2=(25 - scope_data[0]);
- for (i = 0; i < 160; i++)
+ for (i = 0; i < G15_LCD_WIDTH; i++)
{
y1 = y2;
y2 = (25 - scope_data[i]);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rob...@us...> - 2009-04-25 10:43:54
|
Revision: 494
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=494&view=rev
Author: robynhub
Date: 2009-04-25 10:43:41 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
Right align text for title
Modified Paths:
--------------
trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c
Modified: trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c
===================================================================
--- trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c 2009-04-25 06:48:21 UTC (rev 493)
+++ trunk/g15daemon-audio-plugins/g15daemon_audacious/g15daemon_audacious_spectrum.c 2009-04-25 10:43:41 UTC (rev 494)
@@ -81,15 +81,11 @@
added to the neighbouring bars */
#define dif 3
-/* length of the row. */
-#define ROWLEN 34
+#define ROWLEN 35
/* height of a char */
-#define CHAR_HEIGH 8
+#define CHAR_HEIGH 9
-/* witdh of a char (approx) */
-#define CHAR_WIDTH 5
-
/* font size for title */
#define FONT_SIZE 8
@@ -190,6 +186,7 @@
static void g15analyser_conf_reset(void);
g15canvas *canvas;
+g15font *font;
static unsigned int playing=0, paused=0;
static int g15screen_fd = -1;
@@ -966,7 +963,7 @@
char *title;
char *strtok_ptr;
/* total length of the string */
- int rendstrlen = (ROWLEN * rownum);
+ int rendstrlen = (ROWLEN * rownum);
static int vol_timeout=0;
long chksum=0;
static long last_chksum;
@@ -1036,7 +1033,8 @@
if (*pRendToken != '\0')
- g15r_renderString (canvas, (unsigned char *)pRendToken, 0, FONT_SIZE, 0, NumRow * CHAR_HEIGH);
+ /* g15r_renderString (canvas, (unsigned char *)pRendToken, 0, FONT_SIZE, 0, NumRow * CHAR_HEIGH); */
+ g15r_G15FPrint (canvas, pRendToken, 0, NumRow * CHAR_HEIGH, FONT_SIZE, 2,G15_COLOR_BLACK, 0);
}
pRendStr= &pRendStr[TokenEnd];
@@ -1048,17 +1046,17 @@
}
} else{
/* Only one line */
- int title_pixel = strlen(title) * CHAR_WIDTH;
+ int title_pixel = g15r_testG15FontWidth(font,title);
int i;
// Substitution "_" with " "
for (i = 0 ; i < strlen(title); i++){
if (title[i] == '_')
title[i] = ' ';
}
- if (strlen(title) < ROWLEN){
+ if (title_pixel <= G15_LCD_WIDTH){
- g15r_renderString (canvas, (unsigned char *)title, 0, FONT_SIZE, 0, 0);
-
+ /* g15r_renderString (canvas, (unsigned char *)title, 0, FONT_SIZE, 0, 0); */
+ g15r_G15FPrint (canvas, title, 0, 0, FONT_SIZE, 2,G15_COLOR_BLACK, 0);
} else {
/* title cycle :D */
/* roll it over my soul... (Oasis) */
@@ -1074,8 +1072,8 @@
text_start = text_start2 - title_pixel - 25 % (title_pixel + G15_LCD_WIDTH);
text_start2 = text_start2 % (title_pixel + G15_LCD_WIDTH);
}
- g15r_renderString (canvas, (unsigned char *)title, 0, FONT_SIZE, 160 - text_start2, 0);
- g15r_renderString (canvas, (unsigned char *)title, 0, FONT_SIZE, 160 - text_start, 0);
+ g15r_renderString (canvas, (unsigned char *)title, 0, FONT_SIZE, G15_LCD_WIDTH - text_start2, 0);
+ g15r_renderString (canvas, (unsigned char *)title, 0, FONT_SIZE, G15_LCD_WIDTH - text_start, 0);
}
}
}
@@ -1184,11 +1182,13 @@
}
}
else
- g15r_renderString (canvas, (unsigned char *)"Playback Stopped", 0, 13, 21, 16);
+ /* g15r_renderString (canvas, (unsigned char *)"Playback Stopped", 0, 13, 21, 16); */
+ g15r_G15FPrint (canvas, "Playback Stopped", 21, 16, 13, 1, G15_COLOR_BLACK, 0);
}
else
- g15r_renderString (canvas, (unsigned char *)"Playlist Empty", 0, 13, 34, 16);
+ /* g15r_renderString (canvas, (unsigned char *)"Playlist Empty", 0, 13, 34, 16); */
+ g15r_G15FPrint (canvas, "Playlist Empty", 34, 16, 13, 1, G15_COLOR_BLACK, 0);
if(lastvolume!=get_main_volume() || vol_timeout>=0) {
if(lastvolume!=get_main_volume())
@@ -1283,7 +1283,8 @@
canvas->mode_xor = 0;
}
-
+ /* requesting font size needed */
+ font = g15r_requestG15DefaultFont(FONT_SIZE);
pthread_mutex_unlock(&g15buf_mutex);
/* increase lcd drive voltage/contrast for this client */
g15_send_cmd(g15screen_fd, G15DAEMON_CONTRAST,2);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-25 06:48:29
|
Revision: 493
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=493&view=rev
Author: mlampard
Date: 2009-04-25 06:48:21 +0000 (Sat, 25 Apr 2009)
Log Message:
-----------
Add support for variable-sized fonts to textarea. Auto-resize fonts to fit as much text as possible on the screen.
Modified Paths:
--------------
trunk/g15daemon-clients/g15message/g15message.c
Modified: trunk/g15daemon-clients/g15message/g15message.c
===================================================================
--- trunk/g15daemon-clients/g15message/g15message.c 2009-04-24 09:38:07 UTC (rev 492)
+++ trunk/g15daemon-clients/g15message/g15message.c 2009-04-25 06:48:21 UTC (rev 493)
@@ -42,6 +42,7 @@
#include <libg15render.h>
#include <poll.h>
#include <pthread.h>
+#include <math.h>
#ifndef G15R_FONT_API_V2
#error libg15render 1.4 needed
@@ -78,7 +79,7 @@
}
/* Prints text to an area, tries to cut lines between words. */
-static void render_text_area(g15canvas *canvas, char* text, int y, int chars_per_line, int max_lines, int fontsize, int centered) {
+static void render_text_area(g15canvas *canvas, char* text, int y, int fontsize, int centered) {
/* The position of the text to be printed. */
char* cursor = text;
@@ -90,7 +91,16 @@
int line_no=0;
char* bound, *old_bound;
int x = 0;
+ int pixels_per_line = 160;
+ g15font *font = g15r_requestG15DefaultFont (fontsize);
+ int max_lines = ceil((43-y) / font->lineheight);
+ /* shrink font if necessary to show whole text */
+ while ((g15r_testG15FontWidth(font,text) > (pixels_per_line * max_lines) && fontsize)) {
+ font = g15r_requestG15DefaultFont (--fontsize);
+ max_lines = ceil((43-y) / font->lineheight);
+ }
+
while (cursor < text + strlen(text)) {
bound = cursor;
line_cursor = 0;
@@ -112,17 +122,17 @@
bound++;
line_cursor++;
}
-
text_line[line_cursor++] = ' ';
text_line[line_cursor] = '\0';
/* Try if the line with a new word still fits to the given area. */
- line_width=strlen(text_line);
+ line_width = g15r_testG15FontWidth(font,text_line);
- if (line_width > chars_per_line) {
+ if (line_width > pixels_per_line) {
/* It didn't fit, restore the old line and stop trying to fit more.*/
+ old_line_length--;
text_line[old_line_length] = '\0';
-
+
/* If no words did fit to the line, fit as many characters as possible in it. */
if (old_line_length == 0) {
line_width = 0;
@@ -132,7 +142,7 @@
text_line[line_cursor++] = *bound++;
text_line[line_cursor] = '\0';
/* The last character did not fit. */
- if (x + line_width >= chars_per_line) {
+ if (x + line_width >= pixels_per_line) {
text_line[line_cursor - 1] = '\0';
bound--;
break;
@@ -151,15 +161,8 @@
if (line_no>=max_lines) {
break;
}
- if(centered){
- if(fontsize==G15_TEXT_SMALL)
- x = 80-((strlen(text_line)/2)*4);
- if(fontsize==G15_TEXT_MED)
- x = 80-((strlen(text_line)*5)/2);
- if(fontsize==G15_TEXT_LARGE)
- x = 80-((strlen(text_line)/2)*8);
- }
- g15r_renderString (canvas, (unsigned char *)text_line, line_no, fontsize, x, y);
+
+ g15r_G15FPrint (canvas, text_line, 0, y, fontsize, centered, G15_COLOR_BLACK, line_no);
line_no++;
cursor = bound;
@@ -290,14 +293,14 @@
g15r_pixelBox (canvas, 0, 0, 159 , 9, G15_COLOR_BLACK, 1, 1);
g15r_G15FPrint (canvas,title,0,1,8,G15_JUSTIFY_CENTER,G15_COLOR_BLACK,0);
canvas->mode_xor=0;
- y_offset = 11;
+ y_offset = 12;
}
if(g15r_testG15FontWidth(font,message)>160)
- render_text_area(canvas, message, y_offset, 32, lines_available, G15_TEXT_MED, centered);
- else{
+ render_text_area(canvas, message, y_offset, fontsize, centered);
+ else
g15r_G15FPrint (canvas, message, 0, (21-(wait_for_confirmation==1?5:0)+(show_title==1?7:0))-(font->ascender_height/2), fontsize, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 0);
- }
+
if(wait_for_confirmation) {
g15r_pixelBox (canvas, 0, 34, 159 , 42, G15_COLOR_WHITE, 1, 1);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-24 09:38:15
|
Revision: 492
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=492&view=rev
Author: mlampard
Date: 2009-04-24 09:38:07 +0000 (Fri, 24 Apr 2009)
Log Message:
-----------
small cleanup of clock plugin
Modified Paths:
--------------
trunk/g15daemon-wip/plugins/g15_plugin_clock.c
Modified: trunk/g15daemon-wip/plugins/g15_plugin_clock.c
===================================================================
--- trunk/g15daemon-wip/plugins/g15_plugin_clock.c 2009-04-24 07:36:14 UTC (rev 491)
+++ trunk/g15daemon-wip/plugins/g15_plugin_clock.c 2009-04-24 09:38:07 UTC (rev 492)
@@ -136,7 +136,6 @@
static int draw_digital(g15canvas *canvas)
{
- int narrows=0;
char buf[10];
char ampm[3];
int off = 0;
@@ -162,8 +161,6 @@
strftime(buf,6,"%l:%M",localtime(&currtime));
strftime(ampm,3,"%p",localtime(&currtime));
}
- if(buf[0]==49)
- narrows=1;
if(buf[0]==' ')
off++;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-24 07:36:21
|
Revision: 491
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=491&view=rev
Author: mlampard
Date: 2009-04-24 07:36:14 +0000 (Fri, 24 Apr 2009)
Log Message:
-----------
update g15message changelog
Modified Paths:
--------------
trunk/g15daemon-clients/g15message/ChangeLog
trunk/g15daemon-clients/g15message/g15message.c
Modified: trunk/g15daemon-clients/g15message/ChangeLog
===================================================================
--- trunk/g15daemon-clients/g15message/ChangeLog 2009-04-24 07:32:40 UTC (rev 490)
+++ trunk/g15daemon-clients/g15message/ChangeLog 2009-04-24 07:36:14 UTC (rev 491)
@@ -1,2 +1,4 @@
1.0 01/01/2007
- Initial release
+SVN:
+- Add support for multisize fonts (requires libg15render 1.4+)
Modified: trunk/g15daemon-clients/g15message/g15message.c
===================================================================
--- trunk/g15daemon-clients/g15message/g15message.c 2009-04-24 07:32:40 UTC (rev 490)
+++ trunk/g15daemon-clients/g15message/g15message.c 2009-04-24 07:36:14 UTC (rev 491)
@@ -15,7 +15,7 @@
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- (c) 2006-2007 Mike Lampard
+ (c) 2006-2009 Mike Lampard
$Revision$ - $Date$ $Author$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mla...@us...> - 2009-04-24 07:32:47
|
Revision: 490
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=490&view=rev
Author: mlampard
Date: 2009-04-24 07:32:40 +0000 (Fri, 24 Apr 2009)
Log Message:
-----------
Add some support for multisize fonts.
Modified Paths:
--------------
trunk/g15daemon-clients/g15message/g15message.c
Modified: trunk/g15daemon-clients/g15message/g15message.c
===================================================================
--- trunk/g15daemon-clients/g15message/g15message.c 2009-04-24 06:13:39 UTC (rev 489)
+++ trunk/g15daemon-clients/g15message/g15message.c 2009-04-24 07:32:40 UTC (rev 490)
@@ -43,7 +43,11 @@
#include <poll.h>
#include <pthread.h>
- int g15screen_fd, retval;
+#ifndef G15R_FONT_API_V2
+#error libg15render 1.4 needed
+#endif
+
+int g15screen_fd, retval;
g15canvas *canvas;
int handle_Lkeys() {
@@ -162,7 +166,6 @@
}
}
-
int main(int argc, char **argv)
{
int i=0;
@@ -176,7 +179,9 @@
int lines_available=6;
int leaving = 0;
int centered = 0;
-
+ int fontsize = 0;
+ g15font *font = NULL;
+
if(argc<2) {
printf("%s - A simple message displayer for the G15\n",argv[0]);
printf("Usage: %s <args> \"message\"\n",argv[0]);
@@ -186,6 +191,7 @@
printf(" -c Centre align message text\n");
printf(" -d <secs> show alert for <secs> seconds then exit (default) - overrides the interactive wait options, above.\n");
printf(" -f force stay in foreground until timeout/confirmation.\n");
+ printf(" -s <size> render message with <size> sized text.\n");
printf("\nMessage text will be wrapped to fit on the display\nWith no timeout or wait options message is displayed for 5seconds\n\n");
exit(0);
@@ -239,8 +245,20 @@
}
}
}
+ if(0==strncasecmp(argv[i],"-s",2)){
+ if(argv[i+1]!=NULL){
+ if(isdigit(argv[i+1][0])){
+ i++;
+ fontsize = strtol(argv[i],NULL,10);
+ font = g15r_requestG15DefaultFont (fontsize);
+ }
+ }
+ }
}
-
+ if(!fontsize) {
+ fontsize = 10;
+ font = g15r_requestG15DefaultFont (fontsize);
+ }
if(message==NULL||(g15screen_fd = new_g15_screen(G15_G15RBUF))<0){
if(message==NULL)
printf("No message - nothing to do. exiting\n");
@@ -270,19 +288,15 @@
if(show_title){
canvas->mode_xor=1;
g15r_pixelBox (canvas, 0, 0, 159 , 9, G15_COLOR_BLACK, 1, 1);
- g15r_renderString (canvas, (unsigned char *)title, 0, G15_TEXT_LARGE, 80-((strlen(title)/2)*8), 1);
+ g15r_G15FPrint (canvas,title,0,1,8,G15_JUSTIFY_CENTER,G15_COLOR_BLACK,0);
canvas->mode_xor=0;
y_offset = 11;
}
- if(strlen(message)>32)
+ if(g15r_testG15FontWidth(font,message)>160)
render_text_area(canvas, message, y_offset, 32, lines_available, G15_TEXT_MED, centered);
else{
- if(show_title)
- y_offset+=10;
- else
- y_offset+=18;
- g15r_renderString (canvas, (unsigned char *)message, 0, G15_TEXT_MED, 80-((strlen(message)/2)*5), y_offset);
+ g15r_G15FPrint (canvas, message, 0, (21-(wait_for_confirmation==1?5:0)+(show_title==1?7:0))-(font->ascender_height/2), fontsize, G15_JUSTIFY_CENTER, G15_COLOR_BLACK, 0);
}
if(wait_for_confirmation) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|