Showing 1 changed files with 9 additions and 6 deletions
+9 -6
display.h
... ...
@@ -15,8 +15,7 @@
15 15
   #define LINE6 60 //M5Only
16 16
   #define LINEBOTTOM 72
17 17
   //Battery see : http://community.m5stack.com/topic/1361/ischarging-and-getbatterylevel/5
18
-  //#define VMAX 3500.0f //
19
-  #define VMAX 3900.0f // Observed Maximum: 3943.5 after 7h charge
18
+  #define VMAX 4000.0f // Observed Maximum: 4161.3 after 7h charge
20 19
   #define VMIN 2973.0f // Observed Minimum: 2973.0
21 20
   #define COLUMN_BAT 80
22 21
 #endif //_M5STICKC_H_  
... ...
@@ -84,10 +83,14 @@ void DisplayButtonStatus() {
84 83
   M5.Lcd.fillRect(0, LINEBOTTOM, 50, 10, BLACK);
85 84
   M5.Lcd.fillRect(COLUMN_BAT, LINEBOTTOM, 60, 10, BLACK);
86 85
   M5.Lcd.printf("%.1fmV",BatteryValue);
87
-  if( BatteryPercent <= 80 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(0x7bef, BLACK);M5.Lcd.printf("%.0f%%",BatteryPercent); }
88
-  else if( BatteryPercent > 80 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(0x7bef, BLACK);M5.Lcd.printf("%.1f%%",BatteryPercent); }
89
-  else if( BatteryPercent > 90 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(0x7bef, BLACK);M5.Lcd.printf("%.2f%%",BatteryPercent); }
90
-  else if( BatteryPercent > 95 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(0x7bef, BLACK);M5.Lcd.printf("%.3f%%",BatteryPercent); }
86
+  if( BatteryPercent > 95 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(GREEN, BLACK);M5.Lcd.printf("%.3f%%",BatteryPercent); }
87
+  else if( BatteryPercent > 90 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(GREEN, BLACK);M5.Lcd.printf("%.2f%%",BatteryPercent); }
88
+  else if( BatteryPercent > 60 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(GREEN, BLACK);M5.Lcd.printf("%.1f%%",BatteryPercent); }
89
+  else if( BatteryPercent > 60 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(GREEN, BLACK);M5.Lcd.printf("%.1f%%",BatteryPercent); }
90
+  else if( BatteryPercent > 40 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(0xff80, BLACK);M5.Lcd.printf("%.0f%%",BatteryPercent); } //Yellow
91
+  else if( BatteryPercent > 30 ) { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(0xfbe4, BLACK);M5.Lcd.printf("%.0f%%",BatteryPercent); } //Orange
92
+  else { M5.Lcd.setCursor(COLUMN_BAT, LINEBOTTOM, 1);M5.Lcd.setTextColor(RED, BLACK);M5.Lcd.printf("%.0f%%",BatteryPercent); } //Red
93
+
91 94
   Serial.println(BatteryValue);
92 95
   #endif //_M5STICKC_H_
93 96
 }