Turning off the screen
From OESF
(revert to remove spam) |
|||
(One intermediate revision not shown.) | |||
Current revision
Howto turn off the screen.
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. There are two ways to turn the screen on and off. One uses QCOP messages and does not take much code and can be done from the command line. The other way uses IOCTLs, which is useful especially when Qtopia is not running.
QCOP Method
Below are the two lines of code required in a Qtopia app to blank the screen:
QCopEnvelope e("QPE/System", "setBlankLCD(int)");
e << 1;
To do the same on the command line run this command:
qcop QPE/System 'setBlankLCD(int)' 1
In both cases, only the Cancel button will turn the screen on again.
IOCTL Method
Here is a sample application that can be modified. It both turns the screen both off and on.
#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 FBIOBLANK0x4611/* 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);
}
}

