-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClass1.cs
More file actions
128 lines (105 loc) · 3.5 KB
/
Copy pathClass1.cs
File metadata and controls
128 lines (105 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using SimpleLed;
namespace Source.MadMeters
{
public class MadMetersProvider : ISimpleLed
{
private ControlDevice.LedUnit[] leds = new ControlDevice.LedUnit[15];
PerformanceCounter cpuCounter;
PerformanceCounter ramCounter;
public void Dispose()
{
}
public void Configure(DriverDetails driverDetails)
{
cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
}
public List<ControlDevice> GetDevices()
{
for (int i = 0; i < 15; i++)
{
leds[i] = new ControlDevice.LedUnit
{
Data = new ControlDevice.LEDData { LEDNumber = i },
LEDName = "LED " + (i + 1)
};
}
return new List<ControlDevice>
{
new ControlDevice
{
LEDs = leds,
DeviceType = DeviceTypes.Effect,
Name = "CPU Usage",
Driver = this,
ProductImage = Assembly.GetExecutingAssembly().GetEmbeddedImage("Source.MadMeters.madmeter.png")
}
};
}
public void Push(ControlDevice controlDevice)
{
}
private float cpu = 0;
private float cpulerp = 0;
DateTime lastRun=DateTime.MinValue;
public void Pull(ControlDevice controlDevice)
{
if ((DateTime.Now - lastRun).TotalMilliseconds > 200)
{
cpu = cpuCounter.NextValue();
lastRun = DateTime.Now;
}
if (cpulerp < cpu)
{
cpulerp = cpulerp + ((cpu - cpulerp) * 0.2f);
}
if (cpulerp > cpu)
{
cpulerp = cpulerp - ((cpulerp - cpu) * 0.2f);
}
float cpupoop = (cpulerp / 100f);
int idx = (int)(cpupoop * 15);
for (int i = 0; i < 15; i++)
{
if (i < idx)
{
leds[i].Color = new LEDColor((byte) (255 * (cpupoop)), (byte) (255 * (1f-cpupoop)),0);
}
else
{
leds[i].Color = new LEDColor(0, 0, 0);
}
}
}
public DriverProperties GetProperties()
{
return new DriverProperties
{
SupportsPull = true,
SupportsPush = false,
IsSource = true,
Id = Guid.Parse("99440d02-8ca3-4e35-a9a3-88b024cc0e2d"),
Author = "mad ninja",
Blurb = "Monitor your system with your RGB fans and LED strips!",
CurrentVersion = new ReleaseNumber(1,0,0,4),
GitHubLink = "https://github.com/SimpleLed/Source.MadMeters",
IsPublicRelease = true
};
}
public T GetConfig<T>() where T : SLSConfigData
{
return null;
}
public void PutConfig<T>(T config) where T : SLSConfigData
{
}
public string Name()
{
return "MadMeters";
}
public event EventHandler DeviceRescanRequired;
}
}