@@ -53,6 +53,7 @@ public enum AuraMode : int
5353 HEATMAP = 20 ,
5454 GPUMODE = 21 ,
5555 AMBIENT = 22 ,
56+ BATTERY = 23 ,
5657 }
5758
5859 public enum AuraSpeed : int
@@ -107,6 +108,7 @@ public static class Aura
107108 { AuraMode . HEATMAP , "Heatmap" } ,
108109 { AuraMode . GPUMODE , "GPU Mode" } ,
109110 { AuraMode . AMBIENT , "Ambient" } ,
111+ { AuraMode . BATTERY , "Battery" } ,
110112 } ;
111113
112114 private static Dictionary < AuraMode , string > _modesDynamicLighting = new Dictionary < AuraMode , string >
@@ -124,6 +126,7 @@ public static class Aura
124126 { AuraMode . AuraColorCycle , Properties . Strings . AuraColorCycle } ,
125127 { AuraMode . AuraRainbow , Properties . Strings . AuraRainbow } ,
126128 { AuraMode . AuraStrobe , Properties . Strings . AuraStrobe } ,
129+ { AuraMode . BATTERY , "Battery" } ,
127130 } ;
128131
129132 private static Dictionary < AuraMode , string > _modesStrix = new Dictionary < AuraMode , string >
@@ -142,6 +145,7 @@ public static class Aura
142145 { AuraMode . Flash , "Flash" } ,
143146 { AuraMode . HEATMAP , "Heatmap" } ,
144147 { AuraMode . AMBIENT , "Ambient" } ,
148+ { AuraMode . BATTERY , "Battery" } ,
145149 } ;
146150
147151 static Aura ( )
@@ -248,6 +252,10 @@ private static void Timer_Elapsed(object? sender, System.Timers.ElapsedEventArgs
248252 {
249253 CustomRGB . ApplyHeatmap ( ) ;
250254 }
255+ else if ( Mode == AuraMode . BATTERY )
256+ {
257+ CustomRGB . ApplyBattery ( ) ;
258+ }
251259 else if ( Mode == AuraMode . AMBIENT )
252260 {
253261 CustomRGB . ApplyAmbient ( ) ;
@@ -697,6 +705,14 @@ public static void ApplyAura(double colorDim = 1)
697705 return ;
698706 }
699707
708+ if ( Mode == AuraMode . BATTERY )
709+ {
710+ CustomRGB . ApplyBattery ( true ) ;
711+ timer . Enabled = true ;
712+ timer . Interval = 30000 ;
713+ return ;
714+ }
715+
700716 if ( Mode == AuraMode . AMBIENT )
701717 {
702718 CustomRGB . ApplyAmbient ( true ) ;
@@ -770,6 +786,14 @@ public static class CustomRGB
770786 static Color colorWarm = ColorTranslator . FromHtml ( AppConfig . GetString ( "color_warm" , "#FFFF00" ) ) ;
771787 static Color colorHot = ColorTranslator . FromHtml ( AppConfig . GetString ( "color_hot" , "#FF0000" ) ) ;
772788
789+ static float battLow = 20f ;
790+ static float battMid = 60f ;
791+ static float battHigh = 100f ;
792+
793+ static Color colorLow = Color . Red ;
794+ static Color colorMid = Color . Yellow ;
795+ static Color colorHigh = Color . Lime ;
796+
773797 static Color colorUltimate = ColorTranslator . FromHtml ( AppConfig . GetString ( "color_ultimate" , "#FF0000" ) ) ;
774798 static Color colorStandard = ColorTranslator . FromHtml ( AppConfig . GetString ( "color_standard" , "#FFFF00" ) ) ;
775799 static Color colorEco = ColorTranslator . FromHtml ( AppConfig . GetString ( "color_eco" , "#008000" ) ) ;
@@ -812,7 +836,34 @@ public static void ApplyHeatmap(bool init = false)
812836 ApplyDirect ( color , init ) ;
813837 }
814838
839+ public static void ApplyBattery ( bool init = false )
840+ {
841+ float battery = ( float ) HardwareControl . GetBatteryChargePercentage ( ) ;
842+ Color color = colorLow ;
843+
844+ if ( battery < battLow )
845+ {
846+ color = colorLow ;
847+ }
848+ else if ( battery < battMid )
849+ {
850+ // Low → Mid
851+ float t = ( battery - battLow ) / ( battMid - battLow ) ;
852+ color = ColorUtils . GetWeightedAverage ( colorLow , colorMid , t ) ;
853+ }
854+ else if ( battery < battHigh )
855+ {
856+ // Mid → High
857+ float t = ( battery - battMid ) / ( battHigh - battMid ) ;
858+ color = ColorUtils . GetWeightedAverage ( colorMid , colorHigh , t ) ;
859+ }
860+ else
861+ {
862+ color = colorHigh ;
863+ }
815864
865+ ApplyDirect ( color , init ) ;
866+ }
816867
817868 public static void ApplyAmbient ( bool init = false )
818869 {
0 commit comments