原创 LCD BackLight Control for utulinux 2440 LCD 背光控制

2010-2-27 13:57 4405 13 13 分类: MCU/ 嵌入式

LCD BackLight Control for utulinux 2440 LCD 背光控制          


          注解:borlittle


仅供学习参考,源代码版权归原著者所有


 

/*


 *    Copyright (C) 2007 UTULinux


 *


 *  LCD BackLight Control V0.01


 *  LCD 背光控制


 *  This file is subject to the terms and conditions of the GNU General Public


 *  License. See the file COPYING in the main directory of this archive for


 *  more details.


 *


 */


 */


#include <stdlib.h>                   /*标准库函数头文件*/


#include <fcntl.h>                    /*文件控制操作头文件*/


#include <string.h>                   /*字符操作头文件*/


#include <sys/ioctl.h>                /*特殊I/O控制函数ioctl头文件,在系统目录的sys目录下*/


#include <linux/fb.h>                 /*FrameBuffer设备驱动头文件位于ARM\arm-linux\include\linux\fb.h*/


int main(int argc, char** argv)       /*带参数主函数*/


{


    if ( argc == 1 )                  /*提供shell操作提示*/     


       {


              printf("Useage:fbtools on\n");


              printf("       fbtools off\n");


              return 1;


       }


       int fb = open("/dev/fb0", O_RDWR);   /*打开设备*/


       if( fb < 0 ) 


       {


              printf("Cann't open /dev/fb0\n");  /*打开失败,提示错误*/


              return 1;


       }


    int on = 0;


    if( strcmp( argv[1], "on" ) == 0 )   /*处理控制数据*/


        on = 4;


    else if( strcmp( argv[1], "off" ) == 0 )


        on = 2;


       ioctl(fb, FBIOBLANK, on );  /*控制I/O设备点亮/关闭背光*/


       close(fb);                  /*关闭退出*/


}

文章评论0条评论)

登录后参与讨论
我要评论
0
13
关闭 站长推荐上一条 /2 下一条