充电状态三色指示灯

一、配置三种颜色

frameworks/base/core/res/res/values/config.xml


799      <!-- Default value for led color when battery is low on charge -->
 800     <integer name="config_notificationsBatteryLowARGB">0xFFFF0000</integer>//红色
 801                     
 802     <!-- Default value for led color when battery is medium charged -->
 803     <integer name="config_notificationsBatteryMediumARGB">0xFF0000FF</integer>//蓝色
 804                     
 805     <!-- Default value for led color when battery is fully charged -->
 806     <integer name="config_notificationsBatteryFullARGB">0xFF00FF00</integer>//绿色

二、不同电量显示不同颜色

frameworks/base/services/core/java/com/android/server/BatteryService.java

818         /**                       
819          * Synchronize on BatteryService.
820          */                       
821         public void updateLightsLocked() {
822             final int level = mBatteryProps.batteryLevel;
823             final int status = mBatteryProps.batteryStatus;
824             if(mIPOBoot)          
825             {                     
826                 //Get led status in IPO mode
827                 getIpoLedStatus();       
828             }                     
829             if (level < mLowBatteryWarningLevel) {
830                 if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
831                     updateLedStatus();   
832                     // Solid red when battery is charging
833                     mBatteryLight.setColor(mBatteryLowARGB);
834                 } else {          
835                     LowLevelFlag = true; 
836                     updateLedStatus();   
837                     // Flash red when battery is low and not charging
838                     mBatteryLight.setFlashing(mBatteryLowARGB, Light.LIGHT_FLASH_TIMED,
839                             mBatteryLedOn, mBatteryLedOff);
840                 }                 
841             } else if (status == BatteryManager.BATTERY_STATUS_CHARGING
842                     || status == BatteryManager.BATTERY_STATUS_FULL) {
843                 if (status == BatteryManager.BATTERY_STATUS_FULL || level >= 90) {                                                                                 
844                     updateLedStatus();   
845                     // Solid green when full or charging and nearly full
846                     mBatteryLight.setColor(mBatteryFullARGB);
847                 } else {          
848                     updateLedStatus();   
849                     // Solid orange when charging and halfway full
850                     //mBatteryLight.setColor(mBatteryMediumARGB);
851                     mBatteryLight.setColor(mBatteryLowARGB);//win.cao
852                 }
853             } else {              
854                 if(ipo_led_on && mIPOBoot){
855                     if (status == BatteryManager.BATTERY_STATUS_FULL || level >= 90) {
856                         mBatteryLight.setColor(mBatteryFullARGB);
857                     }             
858                     else {        
859                         mBatteryLight.setColor(mBatteryMediumARGB);
860                     }             
861                     mIPOBoot = false;
862                     ipo_led_on = false;
863                 }                 
864                 // No lights if not charging and not low
865                 //mBatteryLight.turnOff();
866                 mBatteryLight.setColor(mBatteryMediumARGB);//16-90 Blue win.cao 
867             }                     
868         }    

三、内核驱动配置

109 int vr_set_green_led(int level)
110 {
111     mt_set_gpio_mode(GPIO_GREEN_LED_EN, GPIO_MODE_00);
112     mt_set_gpio_dir(GPIO_GREEN_LED_EN, GPIO_DIR_OUT);
113  
114     if(level > 0)
115     {
116         mt_set_gpio_out(GPIO_GREEN_LED_EN, GPIO_OUT_ONE);
117     }
118     else
119     {
120         mt_set_gpio_out(GPIO_GREEN_LED_EN, GPIO_OUT_ZERO);
121     }
122 }
123  
124 int vr_set_blue_led(int level)
125 {
126     mt_set_gpio_mode(GPIO_BLUE_LED_EN, GPIO_MODE_00);
127     mt_set_gpio_dir(GPIO_BLUE_LED_EN, GPIO_DIR_OUT);
128  
129     if(level > 0)
130     {
131         mt_set_gpio_out(GPIO_BLUE_LED_EN, GPIO_OUT_ONE);
132     }
133     else
134     {
135         mt_set_gpio_out(GPIO_BLUE_LED_EN, GPIO_OUT_ZERO);
136     }
137 }
138  
139  
140 static struct cust_mt65xx_led cust_led_list[MT65XX_LED_TYPE_TOTAL] = {
141     {"red",               MT65XX_LED_MODE_PMIC, MT65XX_LED_PMIC_NLED_ISINK0,{0}},
142     {"green",             MT65XX_LED_MODE_GPIO, (long)vr_set_green_led,{0}},
143     {"blue",              MT65XX_LED_MODE_GPIO, (long)vr_set_blue_led,{0}},
144     {"jogball-backlight", MT65XX_LED_MODE_NONE, -1,{0}},
145     {"keyboard-backlight",MT65XX_LED_MODE_NONE, -1,{0}},
146     {"button-backlight",  MT65XX_LED_MODE_NONE, -1,{0}},
147     {"lcd-backlight",     MT65XX_LED_MODE_CUST_BLS_PWM, (long)disp_bls_set_backlight,{0}},
148 };


发布了154 篇原创文章 · 获赞 12 · 访问量 52万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览