led灯驱动电源维修(万用表怎么测led驱动器好坏)

  • 时间:
  • 浏览:79
  • 来源:奥一装修网

led灯驱动电源维修技巧

由于项目中使用的LED灯与Android原生的LED灯不同,因此您需要调整驱动程序并修改驱动程序接口文件。注意:本文仅举例说明对LED灯驱动器接口文件的修改。有关从应用程序到驱动程序层的特定LED调用过程,请参阅我的其他文章Android4。4 LightsService使用说明。目标文件位置:vendor / xxx /开源/libs/liblights/lights。c一些修改的注释定义LOG_TAG“灯” include include include

led灯电源维修视频

include include include include include include

led驱动电源维修实例

include include include include include include

家里led驱动电源怎么换

include static pthread_once_t g_init = PTHREAD_ONCE_INIT;静态pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER; //结构:LED对应的文件节点路径和句柄struct led_prop {const char * filename; int fd;}; //结构:每个LED可以由节点操作,根据用于定义struct led {struct led_prop亮度; //亮度struct led_prop delay_on; //闪烁时的熄灭时间struct led_prop delay_off; //闪烁struct led_prop触发器时点亮时间; //闪烁时的亮度}; //定义所有LED灯,仅在此处使用三个枚举{RED_LED,//红色LED灯GREEN_LED,//绿色LED灯L CD_BACKLIGHT,// LCD背光NUM_LEDS,}; //定义LED文件节点,请务必按照LED驱动器结构led led 【NUM_LEDS】 = {【RED_LED】 = {。brightness = {“ / sys / class / leds / red / bright”指定的路径填写,0},//正常亮度。 Delay_on = {“ / sys / class / leds /红色/ delay_on”,0},// LED闪烁关闭时间。 Delay_off = {“ / sys / class / leds /红色/ delay_off”,0},// LED闪烁时间。triggers= {“ / sys / class / leds / red /触发”,0},// LED闪烁时的亮度},【GREEN_LED】 = {。brightness = {“ / sys / class / leds / green /亮度”,0},。delay_on = {“ / sys / class / leds / green / delay_on”,0},。delay_off = {“ / sys / class / leds / green / delay_off”,0},。triggers = {“ / sys / class / leds / green / triggers”,0},},【LCD_BACKLIGHT】 = {。brightness = {“ / sys / class /背光/ sprd_backlight /亮度“,-1},},【BUTTONS_LED】 = {},}; void init_g_lock(void){pthread_mutex_init(&g_lock,NULL);} //初始化所有节点,即打开节点文件以获取句柄。void init_globals(void){int i; for(i = 0; i fd = -1; if(!prop-》文件名)返回0; //打开文件fd =打开(prop-》文件名,O_RDWR); if(fd文件名,strerror(errno)); return -errno;} //获取句柄prop-》 fd = fd; return 0;} //将数据写入指定的文件,这是写入LED节点的实际方法static int write_int(struct led_prop * prop,int值){int fd;静态int been_warned; yet_warned = 0; ALOGE(“文件:%s,函数:%s,路径=%s,值=%d \ n”,__FILE __,__ func __,prop-》文件名,值); // fd =打开(path,O_RDWR); fd =打开(prop-》文件名,O_RDWR); if(fd》 = 0){char缓冲区【20】;int amt =写(fd,缓冲区,字节);关闭(fd);返回amt == -1? -errno:0;}否则{if(already_warned == 0){ALOGE(“文件:%s,函数:%s,无法打开%s,fd =%d \ n”,__ FILE __,__ func __,prop-》文件名,fd); yet_warned = 1;} return -errno;}} //将RGB颜色转换为亮度值,实际上是将颜色值取为静态int rgb_to_brightness(struct light_state_t const * state){int color = state-》 color&0x00ffffff; return((77 *((color 》》 16)&0x00ff))+(150 *((color 》》 8)&0x00ff))+(29 *(color&0x00ff)))》》 8;} //设置背光亮度static int set_light_backlight(struct light_device_t * dev,struct light_state_t const * state){int err = 0;ALOGD(“文件:%s,功能:%s,亮度=%d \ n”,__ FILE __,__ func__,亮度); if(NULL == leds 【LCD_BACKLIGHT】 。brightness。filename){ALOGE(“ file:%s,func:%s,不支持的光!\ n”,__FILE__,__func__); return -EINVAL;} pthread_mutex_lock(&g_lock); err = write_int(&led 【LCD_BACKLIGHT】。亮度,亮度); pthread_mutex_unlock(&g_lock); return er} //确定LED灯是否亮着,颜色值也代表亮度0-255静态int is_lit(struct light_state_t const * state){返回状态-》 color&0x00ffffff; //返回颜色值} //设置按键背光静态int set_light_keyboard(struct light_device_t * dev,struct light_state_t const * state){int err = 0; int = is_lit(状态); ALOGD(“文件:%s,函数:%s,=%d \ n”,__ FILE __,__ func __,on);ALOGE(“文件:%s,功能:%s,不受支持的光!\ N”,__ FILE __,__ func__); return -EINVAL;} pthread_mutex_lock(&g_lock); err = write_int(LIGHT_KEYBOARD,on?255:0); pthread_mutex_unlock(&g_lock); return err;} //关闭LED灯static int close_lights(struct light_device_t * dev){int i; ALOGV(“文件:%s,函数:%s \ n”,__ FILE __,__ func__); for(i = 0; i color&0xFFFFFF; if(colorRGB == 0xFFFFFF){/ *白色* / colorRGB = 0x0;} colorR =(colorRGB 》》 16)&0x00ff; colorG =(colorRGB 》》 8)&0x00ff ;; colorB = colorRGB&0x00ff; ALOGD(“文件:%s,func:%s,colorR =%d,colorG =%d,colorB =%d \ n”,__ FILE __,__ func __,colorR,colorG,colorB);pthread_mutex_lock(&g_lock); //设置闪光模式开关(state-》 flashMode){case LIGHT_FLASH_HARDWARE:case LIGHT_FLASH_TIMED:delay_on = state-》 flashOnMS; delay_off =状态-》 flashOffMS;打破;情况LIGHT_FLASH_NONE:默认值:delay_on = 0; delay_off = 0;打破; ALOGD(“ set_led_state colorRGB =%08X,未知模式%d \ n”,colorRGB,state-》 flashMode);} if(delay_on》 0 && delay_off》 0){if(colorR){//注意首先设置了delay_on和delay_off ,然后设置触发器triggers = colorR; //颜色值代表亮度值write_int(&led 【RED_LED】 。delay_on,delay_on);write_int(&leds 【RED_LED】 。triggers,0);} else {/ * off * / write_int(&leds 【RED_LED】 。triggers,0); write_int(&leds 【RED_LED】 。brightness,0);}如果(colorG){触发器= colorG; write_int(&leds 【GREEN_LED】 。delay_on,delay_on); write_int(&leds 【GREEN_LED】 。delay_off,delay_on); write_int(&leds 【GREEN_LED】 。triggers,0);}其他{/ * off * / write_int(&leds 【GREEN_LED】 。triggers,0); write_int(&leds 【GREEN_LED】 。brightness,0);}}否则{if(colorR){亮度= colorR; write_int(&led 【RED_LED】。亮度,亮度);}否则{/ *关闭* /write_int(&leds 【RED_LED】 。triggers,0); write_int(&leds 【RED_LED】 。delay_on,0); write_int(&leds 【RED_LED】 。delay_off,0);}如果(colorG){亮度= colorG; write_int(&led 【GREEN_LED】 。brightness,0);}其他{/ * off * / write_int(&led 【GREEN_LED】 。brightness,0); write_int(&leds 【GREEN_LED】 。triggers,0); write_int(&leds 【GREEN_LED】 。delay_on,0); write_int(&leds 【GREEN_LED】 。delay_off,0);}} pthread_mutex_unlock(&g_lock); return 0;} //设置通知LED指示器,实际上,调用set_lightsstatic int set_light_leds_notifications(struct light_device_t * dev,struct light_state_t const * state){set_lights(dev,state); return -EINVAL;} //设置警告灯,也称为set_lightsstatic int set_light_leds_attention(struct light_device_t * dev,struct light_state_t const * state){ALOGE(“ file:%s,func:%s,light!\ n”,__FILE__, __func__); set_lights(dev,state); return -EINVAL;} //打开LED灯static int open_lights(const struct hw_module_t * module,char const * name,struct hw_device_t ** device){int(* set_light)(struct light_device_t * dev,struct light_state_t const * state ); ALOGV(“文件:%s,函数:%s name =%s \ n”,__ FILE __,__ func__,名称); //如果(0 == strcmp(LIGHT_ID_BACKLIGHT,name)),则根据LED灯ID值设置功能指针set_light的不同功能。//背光set_light = set_light_backlight;set_light = set_light_keyboard;否则if(0 == strcmp(LIGHT_ID_NOTIFICATIONS,name))//绿色LED灯set_light = set_light_leds_notifications;否则if(0 == strcmp(LIGHT_ID_ATTENTION,name))//红色LED灯set_light = set_light_leds_attention;否则if(0 == strcmp(LIGHT_ID_BATTERY,name))//绿色LED灯set_light = set_light_leds_notifications;否则返回-EINVAL; pthread_once(&g_init,init_g_lock); // pthread_once(&g_init,init_globals); struct light_device_t * of = dev(malloc struct light_device_t)); memset(dev,0,sizeof(* dev)); //设置其他信息dev-》 common。tag = HARDWARE_DEVICE_TAG; dev-》 common。version = 0;dev-》 common。close =(int(*)(struct hw_device_t *))close_lights; dev-》 set_light = set_light; *设备=(结构hw_device_t *)开发;返回0;)静态结构hw_module_methods_t lights_module_methods = {。open = open_lights,}; / * *灯光模块* / struct hw_module_t HAL_MODULE_INFO_SYM = {。tag = HARDWARE_MODULE_TAG,。version_major = 1,。version_minor = 0,。id = LIGHTS_HARDWARE_MODULE_ID,。name =“ lights Module”,。author =“ Google,Inc。” ,。methods =&lights_module_methods,}; //关闭节点static void close_prop(struct led_prop * prop){int fd;如果(prop-》 fd》 0)关闭(prop-》 fd); //关闭文件返回;}