I.MX6 Android backlight modify by C demo
/**************************************************************************
* 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的更多相关文章
- I.MX6 Android Linux UART send receive with multi-thread and multi-mode demo
/******************************************************************************************* * I.MX6 ...
- I.MX6 PWM buzzer driver hacking with Demo test
/***************************************************************************** * I.MX6 PWM buzzer dr ...
- I.MX6 Android U-blox miniPCI 4G porting
/************************************************************************** * I.MX6 Android U-blox m ...
- I.MX6 android 移除shutdown功能
/************************************************************************ * I.MX6 android 移除shutdown ...
- I.MX6 Android busybox 从哪里生成的
/**************************************************************************** * I.MX6 Android busybo ...
- I.MX6 Android 5.1 快速合成系统
/**************************************************************************** * I.MX6 Android 5.1 快速 ...
- I.MX6 Android netperf
/***************************************************************************** * I.MX6 Android netpe ...
- I.MX6 android 设置 默认 动态桌面
/************************************************************************ * I.MX6 android 设置 默认 动态桌面 ...
- I.MX6 android 获取framebuffer信息
/******************************************************************************** * I.MX6 android 获取 ...
随机推荐
- H5+ and mui学习记录
基础 1.H5+ 定义实现了一些调用原生方法的对象 2.其他的原生方法可以通过Native.js调用 webview 3.webview是调用原生界面的H5+对象 4.单个webview只承载单个页面 ...
- group_concat
分割字符串 group_concat(a.EvidencesID separator ',') as EvidencesID #在MySQL配置文件(my.ini)中默认无该配置项,使用默认值时,值为 ...
- ELk 几篇好的文章
https://nxlog.co/docs/elasticsearch-kibana/using-nxlog-with-elasticsearch-and-kibana.html http://www ...
- [RM HA4] RM状态存储与还原原理详解
RM状态存储与还原机制详解 转载请注明原始链接http://www.cnblogs.com/shenh062326/p/3562199.html. 摘要 本文基于Apache Hadoop社区最新re ...
- C#计算时间差值
/// <summary> /// 计算时间差值 /// </summary> /// <param name="DateTime1">< ...
- android listview 加载图片错乱(错位)
写道 今天晚上一个朋友介绍我看了一篇文章,也是解决android中listview在加载图片错位的问题,看了之后,感觉写的很好,自己也遇到这个问题,但是又不知道从何下手,看到这篇文章后,我的问题 ...
- android-exploitme(一):生成apk
exploitme是一个国外的android安全测试环境,http://securitycompass.github.io/AndroidLabs/index.html,通过它可以学习一些基本的测试方 ...
- Spring AOP 创建增强类
AOP联盟为增强定义了org.aopalliance.aop.Advice接口,Spring支持5种类型的增强: 1)前置增强:org.springframework.aop.BeforeAd ...
- 《Java编程那点事儿》读书笔记(五)——System,Integer,Calendar,Random和容器
System 1)arraycopy int[] a = {1.2.3.4}; int[] b = new int[5]; System.arraycopy(a,1,b,3,2); //把数组a中从下 ...
- Android控件系列之CheckBox
学习目的: 1.掌握在Android中如何建立CheckBox 2.掌握CheckBox的常用属性 3.掌握CheckBox选中状态变换的事件(监听器) CheckBox简介: CheckBox和Bu ...