/**************************************************************************
* I.MX6 Android backlight modify by C demo
* 说明:
* 因为一些特殊情况,需要添加一个这个简单的控制程序来控制android背光
* 亮度,个人感觉是没有必要的,但是应要求还是加上。
*
* 2016-5-14 深圳 南山平山村 曾剑锋
*************************************************************************/ #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <string.h>
#include <errno.h> #define BACKLIGHT0_PATH "/sys/class/backlight/pwm-backlight.0/brightness"
#define BACKLIGHT1_PATH "/sys/class/backlight/pwm-backlight.1/brightness" //#define BACKLIGHT0_PATH "brightness0"
//#define BACKLIGHT1_PATH "brightness1" int help ( int argc );
int isDigitalStr(char *str);
int file_exists(char *filename);
void writeStringToFile(char *filePath, char *string); int main(int argc, char **argv)
{
int bl0 = ;
int bl1 = ; if ( help( argc ) != )
return -; if ( !isDigitalStr(argv[]) ) {
printf("Please give a numeric string.\n");
return -;
} writeStringToFile(BACKLIGHT0_PATH, argv[]);
writeStringToFile(BACKLIGHT1_PATH, argv[]);
} void writeStringToFile(char *filePath, char *string)
{
int fd = ; if ( file_exists(filePath) ) { fd = open(filePath, O_RDWR); ftruncate(fd, );
write(fd, string, strlen(string)); close(fd); }
} int isDigitalStr(char *str)
{
int len = strlen(str);
char *s = str;
int i = ; while( '' <= *s && *s <= '' && i < len){
s++;
i++;
} if(i == len)
return ;
else
return ;
} int file_exists(char *filename)
{
if (access(filename, F_OK) == ) {
return ;
} else {
printf("%s is not exist.\n", filename);
return ;
}
} int help( int argc )
{
if ( argc != ) {
printf ( "USAGE:\n" );
printf ( " backlight <value>\n" );
printf ( " example:\n" );
printf ( " backlight 0\n" );
return -;
} return ;
}

I.MX6 Android backlight modify by C demo的更多相关文章

  1. I.MX6 Android Linux UART send receive with multi-thread and multi-mode demo

    /******************************************************************************************* * I.MX6 ...

  2. I.MX6 PWM buzzer driver hacking with Demo test

    /***************************************************************************** * I.MX6 PWM buzzer dr ...

  3. I.MX6 Android U-blox miniPCI 4G porting

    /************************************************************************** * I.MX6 Android U-blox m ...

  4. I.MX6 android 移除shutdown功能

    /************************************************************************ * I.MX6 android 移除shutdown ...

  5. I.MX6 Android busybox 从哪里生成的

    /**************************************************************************** * I.MX6 Android busybo ...

  6. I.MX6 Android 5.1 快速合成系统

    /**************************************************************************** * I.MX6 Android 5.1 快速 ...

  7. I.MX6 Android netperf

    /***************************************************************************** * I.MX6 Android netpe ...

  8. I.MX6 android 设置 默认 动态桌面

    /************************************************************************ * I.MX6 android 设置 默认 动态桌面 ...

  9. I.MX6 android 获取framebuffer信息

    /******************************************************************************** * I.MX6 android 获取 ...

随机推荐

  1. CRF++中文分词使用指南

    http://blog.csdn.net/marising/article/details/5769653 前段时间写了中文分词的一些记录里面提到了CRF的分词方法,近段时间又研究了一下,特把方法写下 ...

  2. 用ScriptEngine在java中和javascript交互的例子(JDK6新特性)

    package demo7; import java.util.Arrays; import java.util.List; import javax.script.Invocable; import ...

  3. 错误处理--pure specifier can only be specified for functions

    错误处理--pure specifier can only be specified for functions 今天下载了log4cpp的源代码,在VC6下编译时出现错误: ..\..\includ ...

  4. UVALive 6187 Never Wait for Weights 带权并查集

    题意:每次给出每两个数之间的大小差值.在给出关系的过程中插入询问:数a和数b的差值,若不能确定,输出UNKNOWN 解法:相对大小关系的处理:并查集 1.给出两点的相对大小关系后,找到两个点的根节点, ...

  5. HDU5597/BestCoder Round #66 (div.2) GTW likes function 打表欧拉函数

    GTW likes function      Memory Limit: 131072/131072 K (Java/Others) 问题描述 现在给出下列两个定义: f(x)=f_{0}(x)=\ ...

  6. jackson set properties to default value (取消让jackson 赋予默认值)

    you can define it with Integer rather than int or long. define it with a package type. jackson wont' ...

  7. C# 使用WIN32API设置外部程序窗口无边框

    使用代码 var wnd = win32.FindWindowA(null, "窗口标题"); Int32 wndStyle = win32.GetWindowLong(wnd, ...

  8. 李洪强iOS开发之苹果使用预览截图

    李洪强iOS开发之苹果使用预览截图 01 在预览的图片中选中你要截得区域  02 - command + C   03 - Command + N 04 - Command + S (保存)

  9. activity 的四种启动方式

    Activity启动模式设置: <activity android:name=".MainActivity" android:launchMode="standar ...

  10. spring定时器,5步完成

    spring定时器,5步完成,我们开发的时候会用定时执行任务. 用spring框架时,可以直接使用spring定时功能 1.创建任务调度类,里面一个方法,方法名为work 2. spring配置文件, ...