./sprd/proprietories-source/charge
led的控制部分:
//./sprd/proprietories-source/charge/ui.c
static void led_control(int level) { static int led_flag = 0; LOGE("***led_control***level=%d*led_flag=%d***\n",level,led_flag); if (level > 100) level = 100; else if (level < 0) level = 0; if (level < 90) { if (led_flag != LED_RED) { led_on(LED_RED); led_flag = LED_RED; } } else { if (led_flag != LED_GREEN) { led_on(LED_GREEN); led_flag = LED_GREEN; } } }
//./sprd/proprietories-source/charge/backlight.c
#define LED_GREEN_DEV "/sys/class/leds/green/brightness" #define LED_GREEN_MAX_DEV "/sys/class/leds/green/max_brightness" #define LED_RED_DEV "/sys/class/leds/red/brightness" #define LED_RED_MAX_DEV "/sys/class/leds/red/max_brightness" #define LED_BLUE_DEV "/sys/class/leds/blue/brightness" #define LED_BLUE_MAX_DEV "/sys/class/leds/blue/max_brightness" #define LED_GREEN_DEV_K414 "/sys/class/leds/sc27xx:green/brightness" #define LED_GREEN_MAX_DEV_K414 "/sys/class/leds/sc27xx:green/max_brightness" #define LED_RED_DEV_K414 "/sys/class/leds/sc27xx:red/brightness" #define LED_RED_MAX_DEV_K414 "/sys/class/leds/sc27xx:red/max_brightness" #define LED_BLUE_DEV_K414 "/sys/class/leds/sc27xx:blue/brightness" #define LED_BLUE_MAX_DEV_K414 "/sys/class/leds/sc27xx:blue/max_brightness" static int eng_led_red_test(int brightness) { int fd; int ret; char buffer[8]; fd = open(LED_RED_DEV, O_RDWR); if (fd < 0) { SPRD_DBG("%s: open %s fail", __func__, LED_RED_DEV); fd = open(LED_RED_DEV_K414,O_RDWR); if (fd < 0) { SPRD_DBG("%s: open %s fail", __func__, LED_RED_DEV_K414); return -1; } } memset(buffer, 0, sizeof(buffer)); sprintf(buffer, "%d", brightness); ret = write(fd, buffer, strlen(buffer)); close(fd); return 0; } static int eng_led_blue_test(int brightness) { int fd; int ret; char buffer[8]; fd = open(LED_BLUE_DEV, O_RDWR); if (fd < 0) { SPRD_DBG("%s: open %s fail", __func__, LED_BLUE_DEV); fd = open(LED_BLUE_DEV_K414,O_RDWR); if (fd < 0) { SPRD_DBG("%s: open %s fail", __func__, LED_BLUE_DEV_K414); return -1; } } memset(buffer, 0, sizeof(buffer)); sprintf(buffer, "%d", brightness); ret = write(fd, buffer, strlen(buffer)); close(fd); return 0; } void led_off(void) { SPRD_DBG("%s: *********led_off****", __func__); eng_led_green_test(0); eng_led_red_test(0); eng_led_blue_test(0); } void led_on(int color) { SPRD_DBG("%s: *********led_on****", __func__); if (color == 1) { eng_led_green_test(max_green_led/2); eng_led_red_test(0); eng_led_blue_test(0); } else if (color == 2) { eng_led_red_test(max_red_led/2); eng_led_green_test(0); eng_led_blue_test(0); } else if (color == 3) { eng_led_blue_test(0); eng_led_red_test(max_green_led/2); eng_led_green_test(max_red_led/2); } else { SPRD_DBG("%s: color is %d invalid\n", __func__, color); } }
标签:__,关机,led,brightness,eng,展锐,DEV,充电,LED From: https://www.cnblogs.com/yuanqiangfei/p/18312029