|
Howto turn off the screen.
1) Intro
For some applications such as audio applications you don't want to waste battery life on the screen when only the audio is being used. Here is some code to turn the screen on and off.
2) Sample application
Here is a sample application that can be modified.
#include < fcntl.h >
#include < stdio.h >
#include < pthread.h >
#include < unistd.h >
#include < stdlib.h >
#include < sys/time.h >
#include < unistd.h >
#include < sys/ioctl.h >
#include < time.h >
#define VESA_NO_BLANKING 0
#define VESA_VSYNC_SUSPEND 1
#define VESAg_HSYNC_SUSPEND 2
#define VESA_POWERDOWN 3
#define FBIOBLANK 0x4611 /* arg: 0 or vesa level + 1 */
int main( int argc, char *argv[] )
{
int fd,mode;
if (argc>1) {
if (strcmp(argv[1],"-on")==0) mode = 0;
if (strcmp(argv[1],"-off")==0) mode = 1;
} else {
printf("blank -on \n");
printf(" -off\n");
exit(1);
}
if ( mode == 1 ) {
fd = open( "/dev/fb0", O_RDWR);
ioctl( fd, FBIOBLANK,VESA_POWERDOWN );
close(fd);
} else {
fd = open( "/dev/fb0", O_RDWR);
ioctl( fd, FBIOBLANK,VESA_NO_BLANKING );
close(fd);
}
}
|
|