Fixed Issue 9.
This commit is contained in:
@@ -129,7 +129,6 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
if (icon != null)
|
if (icon != null)
|
||||||
icon.Dispose();
|
icon.Dispose();
|
||||||
notifyIcon.Dispose();
|
notifyIcon.Dispose();
|
||||||
notifyIcon = null;
|
|
||||||
|
|
||||||
if (brush != null)
|
if (brush != null)
|
||||||
brush.Dispose();
|
brush.Dispose();
|
||||||
@@ -137,10 +136,8 @@ namespace OpenHardwareMonitor.GUI {
|
|||||||
darkBrush.Dispose();
|
darkBrush.Dispose();
|
||||||
pen.Dispose();
|
pen.Dispose();
|
||||||
font.Dispose();
|
font.Dispose();
|
||||||
graphics.Dispose();
|
graphics.Dispose();
|
||||||
graphics = null;
|
bitmap.Dispose();
|
||||||
bitmap.Dispose();
|
|
||||||
bitmap = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetString() {
|
private string GetString() {
|
||||||
|
|||||||
@@ -101,7 +101,6 @@ namespace OpenHardwareMonitor.Hardware {
|
|||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
Utilities.CrashReport.Save(exception);
|
Utilities.CrashReport.Save(exception);
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}, null, 1000, 1000);
|
}, null, 1000, 1000);
|
||||||
|
|||||||
+42
-4
@@ -90,7 +90,7 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
|||||||
(ushort)(address + ADDRESS_REGISTER_OFFSET), register);
|
(ushort)(address + ADDRESS_REGISTER_OFFSET), register);
|
||||||
return WinRing0.ReadIoPortByte(
|
return WinRing0.ReadIoPortByte(
|
||||||
(ushort)(address + DATA_REGISTER_OFFSET));
|
(ushort)(address + DATA_REGISTER_OFFSET));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WriteByte(byte bank, byte register, byte value) {
|
private void WriteByte(byte bank, byte register, byte value) {
|
||||||
WinRing0.WriteIoPortByte(
|
WinRing0.WriteIoPortByte(
|
||||||
@@ -195,6 +195,17 @@ namespace OpenHardwareMonitor.Hardware.LPC {
|
|||||||
return vendorId == WINBOND_VENDOR_ID;
|
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() {
|
public void Update() {
|
||||||
|
|
||||||
foreach (Sensor sensor in voltages) {
|
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++)
|
for (int i = 0; i < FAN_BIT_REG.Length; i++)
|
||||||
bits = (bits << 8) | ReadByte(0, FAN_BIT_REG[i]);
|
bits = (bits << 8) | ReadByte(0, FAN_BIT_REG[i]);
|
||||||
|
ulong newBits = bits;
|
||||||
foreach (Sensor sensor in fans) {
|
foreach (Sensor sensor in fans) {
|
||||||
int count = ReadByte(FAN_TACHO_BANK[sensor.Index],
|
int count = ReadByte(FAN_TACHO_BANK[sensor.Index],
|
||||||
FAN_TACHO_REG[sensor.Index]);
|
FAN_TACHO_REG[sensor.Index]);
|
||||||
|
|
||||||
|
// assemble fan divisor
|
||||||
int divisorBits = (int)(
|
int divisorBits = (int)(
|
||||||
(((bits >> FAN_DIV_BIT2[sensor.Index]) & 1) << 2) |
|
(((bits >> FAN_DIV_BIT2[sensor.Index]) & 1) << 2) |
|
||||||
(((bits >> FAN_DIV_BIT1[sensor.Index]) & 1) << 1) |
|
(((bits >> FAN_DIV_BIT1[sensor.Index]) & 1) << 1) |
|
||||||
((bits >> FAN_DIV_BIT0[sensor.Index]) & 1));
|
((bits >> FAN_DIV_BIT0[sensor.Index]) & 1));
|
||||||
int divisor = 1 << divisorBits;
|
int divisor = 1 << divisorBits;
|
||||||
|
|
||||||
float value = (count < 0xff) ? 1.35e6f / (count * divisor) : 0;
|
float value = (count < 0xff) ? 1.35e6f / (count * divisor) : 0;
|
||||||
sensor.Value = value;
|
sensor.Value = value;
|
||||||
if (value > 0)
|
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() {
|
public string GetReport() {
|
||||||
|
|||||||
@@ -69,5 +69,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("0.1.27.0")]
|
[assembly: AssemblyVersion("0.1.28.0")]
|
||||||
[assembly: AssemblyFileVersion("0.1.27.0")]
|
[assembly: AssemblyFileVersion("0.1.28.0")]
|
||||||
|
|||||||
Reference in New Issue
Block a user