mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Option to save flicker-free dimming per AC/DC state https://github.com/seerge/g-helper/issues/3112
This commit is contained in:
@@ -691,4 +691,9 @@ public static class AppConfig
|
|||||||
return ContainsModel("G834JYR") || Is("force_miniled");
|
return ContainsModel("G834JYR") || Is("force_miniled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool SaveDimming()
|
||||||
|
{
|
||||||
|
return Is("save_dimming");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -323,14 +323,32 @@ namespace GHelper.Display
|
|||||||
SetGamma(_brightness);
|
SetGamma(_brightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void InitBrightness()
|
||||||
|
{
|
||||||
|
if (!AppConfig.IsOLED()) return;
|
||||||
|
if (!AppConfig.SaveDimming()) return;
|
||||||
|
|
||||||
|
int brightness = GetBrightness();
|
||||||
|
if (brightness >= 0) SetBrightness(brightness);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsOnBattery()
|
||||||
|
{
|
||||||
|
return AppConfig.SaveDimming() && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetBrightness()
|
||||||
|
{
|
||||||
|
return AppConfig.Get(IsOnBattery() ? "brightness_battery" : "brightness", 100);
|
||||||
|
}
|
||||||
|
|
||||||
public static int SetBrightness(int brightness = -1, int delta = 0)
|
public static int SetBrightness(int brightness = -1, int delta = 0)
|
||||||
{
|
{
|
||||||
if (!AppConfig.IsOLED()) return -1;
|
if (!AppConfig.IsOLED()) return -1;
|
||||||
|
if (brightness < 0) GetBrightness();
|
||||||
if (brightness < 0) brightness = AppConfig.Get("brightness", 100);
|
|
||||||
|
|
||||||
_brightness = Math.Max(0, Math.Min(100, brightness + delta));
|
_brightness = Math.Max(0, Math.Min(100, brightness + delta));
|
||||||
AppConfig.Set("brightness", _brightness);
|
AppConfig.Set(IsOnBattery() ? "brightness_battery" : "brightness", _brightness);
|
||||||
|
|
||||||
brightnessTimer.Start();
|
brightnessTimer.Start();
|
||||||
|
|
||||||
|
|||||||
@@ -256,6 +256,8 @@ namespace GHelper
|
|||||||
settingsForm.AutoKeyboard();
|
settingsForm.AutoKeyboard();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VisualControl.InitBrightness();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -453,7 +453,7 @@ namespace GHelper
|
|||||||
Invoke(delegate
|
Invoke(delegate
|
||||||
{
|
{
|
||||||
sliderGammaIgnore = true;
|
sliderGammaIgnore = true;
|
||||||
sliderGamma.Value = AppConfig.Get("brightness", 100);
|
sliderGamma.Value = VisualControl.GetBrightness();
|
||||||
labelGamma.Text = sliderGamma.Value + "%";
|
labelGamma.Text = sliderGamma.Value + "%";
|
||||||
sliderGammaIgnore = false;
|
sliderGammaIgnore = false;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user