Skip to content

Commit 4853c09

Browse files
author
seerge
committed
Added model name, and custom fan+ in profile names
1 parent 08704d6 commit 4853c09

File tree

4 files changed

+61
-36
lines changed

4 files changed

+61
-36
lines changed

app/ASUSWmi.cs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -253,28 +253,22 @@ public void TUFKeyboardRGB(int mode, Color color, int speed)
253253

254254
}
255255

256+
const int ASUS_WMI_KEYBOARD_POWER_BOOT = 0x03 << 16;
257+
const int ASUS_WMI_KEYBOARD_POWER_AWAKE = 0x0C << 16;
258+
const int ASUS_WMI_KEYBOARD_POWER_SLEEP = 0x30 << 16;
259+
const int ASUS_WMI_KEYBOARD_POWER_SHUTDOWN = 0xC0 << 16;
256260
public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
257261
{
258-
uint flags;
259-
uint cmd = 1;
260-
261-
flags = 0;
262-
if (boot)
263-
flags |= (1 << 1);
264-
if (awake)
265-
flags |= (1 << 3);
266-
if (sleep)
267-
flags |= (1 << 5);
268-
if (shutdown)
269-
flags |= (1 << 7);
270-
271-
byte[] state = new byte[12];
272-
state[0] = 0xbd;
273-
state[1] = (byte)((cmd != 0) ? (1 << 2) : 0);
274-
state[2] = (byte)flags;
275-
276-
DeviceSet(TUF_KB, state);
277-
Debug.WriteLine(BitConverter.ToString(state));
262+
int state = 0xbd;
263+
264+
if (boot) state = state | ASUS_WMI_KEYBOARD_POWER_BOOT;
265+
if (awake) state = state | ASUS_WMI_KEYBOARD_POWER_AWAKE;
266+
if (sleep) state = state | ASUS_WMI_KEYBOARD_POWER_SLEEP;
267+
if (shutdown) state = state | ASUS_WMI_KEYBOARD_POWER_SHUTDOWN;
268+
269+
state = state | 0x01 << 8;
270+
271+
DeviceSet(TUF_KB_STATE, state);
278272
}
279273

280274
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)

app/AppConfig.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ public AppConfig()
4040
}
4141

4242

43-
44-
public bool ContainsModel(string contains)
43+
public string GetModel()
4544
{
4645
if (_model is null)
4746
{
@@ -56,6 +55,12 @@ public bool ContainsModel(string contains)
5655
}
5756
}
5857

58+
return _model;
59+
}
60+
public bool ContainsModel(string contains)
61+
{
62+
63+
GetModel();
5964
return (_model is not null && _model.Contains(contains));
6065

6166
}

app/Settings.Designer.cs

Lines changed: 18 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/Settings.cs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,24 @@ public SettingsForm()
121121
aTimer = new System.Timers.Timer(500);
122122
aTimer.Elapsed += OnTimedEvent;
123123

124+
// Subscribing for monitor power on events
125+
var settingGuid = new NativeMethods.PowerSettingGuid();
126+
Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
127+
124128
SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version);
125-
Thread t = new Thread(() =>
129+
130+
string model = Program.config.GetModel();
131+
int trim = model.LastIndexOf("_");
132+
if (trim > 0) model = model.Substring(0, trim);
133+
134+
labelModel.Text = model;
135+
136+
Task.Run(async () =>
126137
{
138+
await Task.Delay(TimeSpan.FromSeconds(5));
127139
CheckForUpdatesAsync();
128140
});
129-
t.Start();
130-
t.Join();
131141

132-
// Subscribing for monitor power on events
133-
var settingGuid = new NativeMethods.PowerSettingGuid();
134-
Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
135142

136143
}
137144

@@ -156,8 +163,6 @@ public async void CheckForUpdatesAsync()
156163
var tag = config.GetProperty("tag_name").ToString().Replace("v", "");
157164
var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString();
158165

159-
Thread.Sleep(5000);
160-
161166
var gitVersion = new Version(tag);
162167
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
163168

@@ -506,7 +511,7 @@ public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online)
506511
private void LabelCPUFan_Click(object? sender, EventArgs e)
507512
{
508513
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
509-
RefreshSensors();
514+
RefreshSensors(true);
510515
}
511516

512517
private void PictureColor2_Click(object? sender, EventArgs e)
@@ -808,10 +813,10 @@ private static string FormatFan(int fan)
808813
return " Fan: " + Math.Min(Math.Round(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm
809814
}
810815

811-
private static void RefreshSensors()
816+
private static void RefreshSensors(bool force = false)
812817
{
813818

814-
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
819+
if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
815820
lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds();
816821

817822
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
@@ -902,6 +907,12 @@ public void AutoFansAndPower()
902907

903908
if (Program.config.getConfig("mid_fan") == 1)
904909
Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2));
910+
911+
labelPerf.Text = "Performance Mode+";
912+
913+
} else
914+
{
915+
labelPerf.Text = "Performance Mode";
905916
}
906917

907918
if (Program.config.getConfigPerf("auto_apply_power") == 1)

0 commit comments

Comments
 (0)