OK, I solved it - somewhat.
Although it doesn't have /dev/batt, F200 still has /dev/mssp2adc, which gives you 4 level power indicator: high/mid/low/empty. It's not as detailed as /dev/batt, but sufficient for my app.
When opened and read, /dev/mssp2adc returns 4 byte structure of:
typedef struct {
unsigned short batt;
unsigned short remocon;
} MMSP2ADC;
The value batt has one of the following:
#define BATT_LEVEL_HIGH 0
#define BATT_LEVEL_MID 1
#define BATT_LEVEL_LOW 2
#define BATT_LEVEL_EMPTY 3
Sample code on how to read this is as follows:
typedef struct {
unsigned short batt;
unsigned short remocon;
} MMSP2ADC;
int mmsp2adc(void)
{
int fd, rv;
MMSP2ADC val;
fd = open("/dev/mmsp2adc", O_RDONLY);
//printf ("fd %d\n", fd);
if (fd < 0) {
fprintf (stderr, "cannot open /dev/mmsp2adc, errno = %d\n", errno);
return -1;
}
rv = read (fd, &val, sizeof(MMSP2ADC));
//printf ("rv %d, val.batt %d, val.remocon %d\n", rv, val.batt, val.remocon);
close (fd);
return val.batt;
}
You have to do ioctl() to get the legitimate value for val.remocon. But for now, I only care about the value in val.batt.
Thanks,
naomaru said:
Thanks, everyone,
Both gp2xmenu and mplayer (on option panel) on F200 have a battery indicator, so there must be some way to obtain battery charge information from software. Unfortuantely, source code is not available for either gp2xmenu or mplayer for F200, so I can't figure out how ...
There seems to exist a character driver for /dev/batt exists in Firmware 4.0.0 (drivers/char/mmsp2_batt.c). However, hacking kernel on F200 looks too dangerous and difficult, because I can't telnet to F200 ...
Any idea??
simonb said:
Squidge said:
Now it's in the right forum
I think GPH removed the battery checking circuitry from the F200 as there "low battery level" light was inconsistent and sometimes completely wrong. To see if they just removed it from the kernel however, scan the analog input ports of the processor as thats where they used to place it (with 10-bit conversion if I remember correctly).
Squidge,
The kernel source (in 4.0.0) for that functionality doesn't compile... I did actually wonder if that was the reason they removed the LED from the final design too ;-)