Fixed Issue 9.

This commit is contained in:
Michael Möller
2010-03-27 19:55:09 +00:00
parent a8f639855a
commit 485c80b04b
4 changed files with 46 additions and 12 deletions
+2 -5
View File
@@ -129,7 +129,6 @@ namespace OpenHardwareMonitor.GUI {
if (icon != null)
icon.Dispose();
notifyIcon.Dispose();
notifyIcon = null;
if (brush != null)
brush.Dispose();
@@ -137,10 +136,8 @@ namespace OpenHardwareMonitor.GUI {
darkBrush.Dispose();
pen.Dispose();
font.Dispose();
graphics.Dispose();
graphics = null;
bitmap.Dispose();
bitmap = null;
graphics.Dispose();
bitmap.Dispose();
}
private string GetString() {
-1
View File
@@ -101,7 +101,6 @@ namespace OpenHardwareMonitor.Hardware {
#if !DEBUG
} catch (Exception exception) {
Utilities.CrashReport.Save(exception);
throw;
}
#endif
}, null, 1000, 1000);
+42 -4
View File
@@ -90,7 +90,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
(ushort)(address + ADDRESS_REGISTER_OFFSET), register);
return WinRing0.ReadIoPortByte(
(ushort)(address + DATA_REGISTER_OFFSET));
}
}
private void WriteByte(byte bank, byte register, byte value) {
WinRing0.WriteIoPortByte(
@@ -195,6 +195,17 @@ namespace OpenHardwareMonitor.Hardware.LPC {
return vendorId == WINBOND_VENDOR_ID;
}
private ulong SetBit(ulong target, int bit, int value) {
if ((value & 1) != value)
throw new ArgumentException("Value must be one bit only.");
if (bit < 0 || bit > 63)
throw new ArgumentException("Bit out of range.");
ulong mask = (((ulong)1) << bit);
return value > 0 ? target | mask : target & ~mask;
}
public void Update() {
foreach (Sensor sensor in voltages) {
@@ -244,22 +255,49 @@ namespace OpenHardwareMonitor.Hardware.LPC {
}
}
long bits = 0;
ulong bits = 0;
for (int i = 0; i < FAN_BIT_REG.Length; i++)
bits = (bits << 8) | ReadByte(0, FAN_BIT_REG[i]);
ulong newBits = bits;
foreach (Sensor sensor in fans) {
int count = ReadByte(FAN_TACHO_BANK[sensor.Index],
FAN_TACHO_REG[sensor.Index]);
// assemble fan divisor
int divisorBits = (int)(
(((bits >> FAN_DIV_BIT2[sensor.Index]) & 1) << 2) |
(((bits >> FAN_DIV_BIT1[sensor.Index]) & 1) << 1) |
((bits >> FAN_DIV_BIT0[sensor.Index]) & 1));
int divisor = 1 << divisorBits;
float value = (count < 0xff) ? 1.35e6f / (count * divisor) : 0;
sensor.Value = value;
if (value > 0)
ActivateSensor(sensor);
}
ActivateSensor(sensor);
// update fan divisor
if (count > 192 && divisorBits < 7)
divisorBits++;
if (count < 96 && divisorBits > 0)
divisorBits--;
newBits = SetBit(newBits, FAN_DIV_BIT2[sensor.Index],
(divisorBits >> 2) & 1);
newBits = SetBit(newBits, FAN_DIV_BIT1[sensor.Index],
(divisorBits >> 1) & 1);
newBits = SetBit(newBits, FAN_DIV_BIT0[sensor.Index],
divisorBits & 1);
}
// write new fan divisors
for (int i = FAN_BIT_REG.Length - 1; i >= 0; i--) {
byte oldByte = (byte)(bits & 0xFF);
byte newByte = (byte)(newBits & 0xFF);
bits = bits >> 8;
newBits = newBits >> 8;
if (oldByte != newByte)
WriteByte(0, FAN_BIT_REG[i], newByte);
}
}
public string GetReport() {
+2 -2
View File
@@ -69,5 +69,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.27.0")]
[assembly: AssemblyFileVersion("0.1.27.0")]
[assembly: AssemblyVersion("0.1.28.0")]
[assembly: AssemblyFileVersion("0.1.28.0")]