Tiny Core Extensions > TCE 2.x

Watcher, the cpu/mem/swap/battery meter

<< < (2/3) > >>

mavrothal:

--- Quote from: curaga on February 16, 2010, 03:47:11 PM ---Looks like you don't have FLTK (fltk.org), the gui toolkit.

--- End quote ---

It makes sense but I assumed that it can be done on TC and I do have fltk2.tcz and fltk-fluid.tcz, along with compiletc.tcz and base-dev.tcz loaded. Anything else I need? Should it be done in another distro?

To be honest since there is no makefile all I tried was "gcc (or c++/g++) -c watcher.cxx"  ::) but as I said this IS my first stub at compiling, at least from cxx.

 

roberts:
Although I am not familar with the watcher code, to link in the fltk support you would typically use -lfltk

curaga:
g++ -o watcher watcher.cxx -lfltk

Watcher uses fltk 1.1, included in the base and devs in compiletc.

mavrothal:

--- Quote from: curaga on February 17, 2010, 03:43:16 AM ---g++ -o watcher watcher.cxx -lfltk

Watcher uses fltk 1.1, included in the base and devs in compiletc.

--- End quote ---

Worked like a charm.
However, the -bat option gives me segmentation fault, no matter what.
I guess I'll have to understand what exactly is doing to calculate the battery output.
The problem is that while the bat state file reports a number (actually % full) the bat full file reports a word  ???
Just reporting the the output of the -bat state file would be sufficient!
Well,... I have to figure out how to do this :-\

mavrothal:
From what I understand watcher just gives the output of a division between the current bat state and the full one.
The OLPC XO does not have that, but outputs directly the percent full as a 2 digit number.
So I pointed "batnow" to this file, commented out the "batfull" bit and I set the "batmsg" to read "batnow" directly.
so lines 24 to 49 look like that

--- Code: ---float timeout=1.5,mem=0,swap=0,cpu=0,used=0,oldused=0,cputotal=0,oldcputotal=0;
float batnow=0; //batfull=0;
int arg_i=0, fontsize=10, mib=0, showswap=1;
char memind[2]="m", swapind[2]="m", batname[6]="", longpath[PATH_MAX]="", batmsg[10]="";
FILE *meminfo,*cpuinfo,*batinfo;

void batcheckup(){
  sprintf(longpath,"/sys/class/power_supply/%s/capacity",batname);
if((batinfo=fopen(longpath,"r"))==NULL) {
  fprintf(stderr,"Error opening batinfo %s\n",longpath);
  exit(1);
}
fscanf(batinfo,"%f",&batnow);
fclose(batinfo);

/*  sprintf(longpath,"/sys/class/power_supply/%s/capacity",batname);
if((batinfo=fopen(longpath,"r"))==NULL) {
  fprintf(stderr,"Error opening batinfo %s\n",longpath);
  exit(1);
}
fscanf(batinfo,"%f",&batfull);
fclose(batinfo);
*/
sprintf(batmsg," %.1f%%B",(float)(batnow));
}

--- End code ---

Complies and runs fine but as soon as I rum with the -bat option I get segfault.
Tried with different versions of the sprintf, same segfault every time. >:(
Any idea ???

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version