diff options
| author | Drashna Jaelre <drashna@live.com> | 2019-08-02 14:02:40 -0700 |
|---|---|---|
| committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-08-30 15:01:52 -0700 |
| commit | cf4575b94a3c65e6535a159fc71fc885aebc2620 (patch) | |
| tree | 2354f2b7a200e02246a564afefedc32357e62b8e /lib/lufa/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.cs | |
| parent | 75ee8df19e0f14ba466f41ab673dde2fe2fdae9c (diff) | |
| download | qmk_firmware-cf4575b94a3c65e6535a159fc71fc885aebc2620.tar.gz qmk_firmware-cf4575b94a3c65e6535a159fc71fc885aebc2620.zip | |
Fix the LUFA lib to use a submodule instead of just files (#6245)
* Remove LUFA files
* Update descriptions for newer version of LUFA
* Create PR6245.md
* Fix CDC(Serial) type errors
* Fix missed merge conflict for AUDIO_DTYPE_CSInterface
Diffstat (limited to 'lib/lufa/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.cs')
| -rw-r--r-- | lib/lufa/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.cs | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/lib/lufa/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.cs b/lib/lufa/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.cs deleted file mode 100644 index 32543fc59..000000000 --- a/lib/lufa/Projects/LEDNotifier/CPUUsageApp/CPUMonitor.cs +++ /dev/null | |||
| @@ -1,115 +0,0 @@ | |||
| 1 | using System; | ||
| 2 | using System.Collections.Generic; | ||
| 3 | using System.ComponentModel; | ||
| 4 | using System.Data; | ||
| 5 | using System.Drawing; | ||
| 6 | using System.Linq; | ||
| 7 | using System.Text; | ||
| 8 | using System.Windows.Forms; | ||
| 9 | using Microsoft.Win32; | ||
| 10 | |||
| 11 | namespace CPUMonitor | ||
| 12 | { | ||
| 13 | public partial class frmCPU : Form | ||
| 14 | { | ||
| 15 | private RegistryKey AppRegKey; | ||
| 16 | |||
| 17 | private const int LIGHT_MAX = 0x1F; | ||
| 18 | |||
| 19 | public frmCPU() | ||
| 20 | { | ||
| 21 | InitializeComponent(); | ||
| 22 | |||
| 23 | nicoNotifyIcon.Icon = this.Icon; | ||
| 24 | nicoNotifyIcon.MouseClick += new MouseEventHandler(TrayIconClick); | ||
| 25 | } | ||
| 26 | |||
| 27 | private void Form1_Load(object sender, EventArgs e) | ||
| 28 | { | ||
| 29 | AppRegKey = Registry.CurrentUser.CreateSubKey("Software\\CPUMonitor"); | ||
| 30 | |||
| 31 | String[] PortNames = System.IO.Ports.SerialPort.GetPortNames(); | ||
| 32 | Array.Sort<String>(PortNames, delegate(string strA, string strB) { return int.Parse(strA.Substring(3)).CompareTo(int.Parse(strB.Substring(3))); }); | ||
| 33 | cmbComPort.Items.Clear(); | ||
| 34 | cmbComPort.Items.AddRange(PortNames); | ||
| 35 | |||
| 36 | cmbComPort.SelectedIndex = System.Convert.ToInt32(AppRegKey.GetValue("Port", "1")) - 1; | ||
| 37 | serSerialPort.PortName = cmbComPort.Text; | ||
| 38 | |||
| 39 | Hide(); | ||
| 40 | } | ||
| 41 | |||
| 42 | private void NotifyLight(int Red, int Green, int Blue) | ||
| 43 | { | ||
| 44 | byte[] buffer = new byte[3]; | ||
| 45 | buffer[0] = (byte)(0x80 | (Red & LIGHT_MAX)); | ||
| 46 | buffer[1] = (byte)(0x40 | (Green & LIGHT_MAX)); | ||
| 47 | buffer[2] = (byte)(0x20 | (Blue & LIGHT_MAX)); | ||
| 48 | |||
| 49 | try | ||
| 50 | { | ||
| 51 | serSerialPort.PortName = cmbComPort.Text; | ||
| 52 | serSerialPort.Open(); | ||
| 53 | serSerialPort.Write(buffer, 0, buffer.Length); | ||
| 54 | serSerialPort.Close(); | ||
| 55 | } | ||
| 56 | catch (Exception e) | ||
| 57 | { | ||
| 58 | |||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | private void tmrCPUTimer_Tick(object sender, EventArgs e) | ||
| 63 | { | ||
| 64 | float CPUUsage = pcCPUUsage.NextValue(); | ||
| 65 | |||
| 66 | int Red = 0; | ||
| 67 | int Green = 0; | ||
| 68 | int Blue = 0; | ||
| 69 | |||
| 70 | if (CPUUsage < 25) | ||
| 71 | { | ||
| 72 | Green = (int)((LIGHT_MAX / 25) * CPUUsage); | ||
| 73 | } | ||
| 74 | else if (CPUUsage < 50) | ||
| 75 | { | ||
| 76 | Blue = (int)((LIGHT_MAX / 25) * (CPUUsage - 25)); | ||
| 77 | Green = LIGHT_MAX - Blue; | ||
| 78 | } | ||
| 79 | else if (CPUUsage < 75) | ||
| 80 | { | ||
| 81 | Red = (int)((LIGHT_MAX / 25) * (CPUUsage - 50)); | ||
| 82 | Blue = LIGHT_MAX - Red; | ||
| 83 | } | ||
| 84 | else | ||
| 85 | { | ||
| 86 | Red = LIGHT_MAX; | ||
| 87 | } | ||
| 88 | |||
| 89 | NotifyLight(Red, Green, Blue); | ||
| 90 | lblCPU.Text = ((int)CPUUsage).ToString() + "%"; | ||
| 91 | } | ||
| 92 | |||
| 93 | private void btnExit_Click(object sender, EventArgs e) | ||
| 94 | { | ||
| 95 | Application.Exit(); | ||
| 96 | } | ||
| 97 | |||
| 98 | private void btnMinimizeToTray_Click(object sender, EventArgs e) | ||
| 99 | { | ||
| 100 | this.Hide(); | ||
| 101 | } | ||
| 102 | |||
| 103 | private void TrayIconClick(object sender, MouseEventArgs e) | ||
| 104 | { | ||
| 105 | this.Show(); | ||
| 106 | this.WindowState = FormWindowState.Normal; | ||
| 107 | } | ||
| 108 | |||
| 109 | private void cbPort_SelectedIndexChanged(object sender, EventArgs e) | ||
| 110 | { | ||
| 111 | AppRegKey.SetValue("Port", cmbComPort.SelectedIndex + 1); | ||
| 112 | serSerialPort.PortName = cmbComPort.Text; | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
