Fixed Issue 9.
authormoel.mich
Sat, 27 Mar 2010 19:55:09 +0000
changeset 85ec4ccaa1210d
parent 84 05bf128434c6
child 86 b4f0f206173d
Fixed Issue 9.
GUI/SensorNotifyIcon.cs
Hardware/Computer.cs
Hardware/LPC/W836XX.cs
Properties/AssemblyInfo.cs
     1.1 --- a/GUI/SensorNotifyIcon.cs	Sat Mar 27 13:04:34 2010 +0000
     1.2 +++ b/GUI/SensorNotifyIcon.cs	Sat Mar 27 19:55:09 2010 +0000
     1.3 @@ -129,7 +129,6 @@
     1.4        if (icon != null)
     1.5          icon.Dispose();      
     1.6        notifyIcon.Dispose();
     1.7 -      notifyIcon = null;
     1.8  
     1.9        if (brush != null)
    1.10          brush.Dispose();
    1.11 @@ -137,10 +136,8 @@
    1.12          darkBrush.Dispose();
    1.13        pen.Dispose();
    1.14        font.Dispose();
    1.15 -      graphics.Dispose();
    1.16 -      graphics = null;
    1.17 -      bitmap.Dispose();
    1.18 -      bitmap = null;
    1.19 +      graphics.Dispose();      
    1.20 +      bitmap.Dispose();      
    1.21      }
    1.22  
    1.23      private string GetString() {
     2.1 --- a/Hardware/Computer.cs	Sat Mar 27 13:04:34 2010 +0000
     2.2 +++ b/Hardware/Computer.cs	Sat Mar 27 19:55:09 2010 +0000
     2.3 @@ -101,7 +101,6 @@
     2.4            #if !DEBUG
     2.5            } catch (Exception exception) {
     2.6              Utilities.CrashReport.Save(exception);
     2.7 -            throw;
     2.8            }
     2.9            #endif
    2.10          }, null, 1000, 1000);
     3.1 --- a/Hardware/LPC/W836XX.cs	Sat Mar 27 13:04:34 2010 +0000
     3.2 +++ b/Hardware/LPC/W836XX.cs	Sat Mar 27 19:55:09 2010 +0000
     3.3 @@ -90,7 +90,7 @@
     3.4           (ushort)(address + ADDRESS_REGISTER_OFFSET), register);
     3.5        return WinRing0.ReadIoPortByte(
     3.6          (ushort)(address + DATA_REGISTER_OFFSET));
     3.7 -    } 
     3.8 +    }
     3.9  
    3.10      private void WriteByte(byte bank, byte register, byte value) {
    3.11        WinRing0.WriteIoPortByte(
    3.12 @@ -195,6 +195,17 @@
    3.13        return vendorId == WINBOND_VENDOR_ID;
    3.14      }
    3.15  
    3.16 +    private ulong SetBit(ulong target, int bit, int value) {
    3.17 +      if ((value & 1) != value)
    3.18 +        throw new ArgumentException("Value must be one bit only.");
    3.19 +
    3.20 +      if (bit < 0 || bit > 63)
    3.21 +        throw new ArgumentException("Bit out of range.");
    3.22 +
    3.23 +      ulong mask = (((ulong)1) << bit);
    3.24 +      return value > 0 ? target | mask : target & ~mask;
    3.25 +    }
    3.26 +
    3.27      public void Update() {
    3.28  
    3.29        foreach (Sensor sensor in voltages) {
    3.30 @@ -244,22 +255,49 @@
    3.31          }
    3.32        }
    3.33  
    3.34 -      long bits = 0;
    3.35 +      ulong bits = 0;
    3.36        for (int i = 0; i < FAN_BIT_REG.Length; i++)
    3.37          bits = (bits << 8) | ReadByte(0, FAN_BIT_REG[i]);
    3.38 +      ulong newBits = bits;
    3.39        foreach (Sensor sensor in fans) {
    3.40          int count = ReadByte(FAN_TACHO_BANK[sensor.Index], 
    3.41            FAN_TACHO_REG[sensor.Index]);
    3.42 +        
    3.43 +        // assemble fan divisor
    3.44          int divisorBits = (int)(
    3.45            (((bits >> FAN_DIV_BIT2[sensor.Index]) & 1) << 2) |
    3.46            (((bits >> FAN_DIV_BIT1[sensor.Index]) & 1) << 1) |
    3.47             ((bits >> FAN_DIV_BIT0[sensor.Index]) & 1));
    3.48          int divisor = 1 << divisorBits;
    3.49 +       
    3.50          float value = (count < 0xff) ? 1.35e6f / (count * divisor) : 0;
    3.51          sensor.Value = value;
    3.52          if (value > 0)
    3.53 -          ActivateSensor(sensor);        
    3.54 -      }     
    3.55 +          ActivateSensor(sensor);
    3.56 +
    3.57 +        // update fan divisor
    3.58 +        if (count > 192 && divisorBits < 7) 
    3.59 +          divisorBits++;
    3.60 +        if (count < 96 && divisorBits > 0)
    3.61 +          divisorBits--;
    3.62 +
    3.63 +        newBits = SetBit(newBits, FAN_DIV_BIT2[sensor.Index], 
    3.64 +          (divisorBits >> 2) & 1);
    3.65 +        newBits = SetBit(newBits, FAN_DIV_BIT1[sensor.Index], 
    3.66 +          (divisorBits >> 1) & 1);
    3.67 +        newBits = SetBit(newBits, FAN_DIV_BIT0[sensor.Index], 
    3.68 +          divisorBits & 1);
    3.69 +      }
    3.70 +     
    3.71 +      // write new fan divisors 
    3.72 +      for (int i = FAN_BIT_REG.Length - 1; i >= 0; i--) {
    3.73 +        byte oldByte = (byte)(bits & 0xFF);
    3.74 +        byte newByte = (byte)(newBits & 0xFF);
    3.75 +        bits = bits >> 8;
    3.76 +        newBits = newBits >> 8;
    3.77 +        if (oldByte != newByte) 
    3.78 +          WriteByte(0, FAN_BIT_REG[i], newByte);        
    3.79 +      }
    3.80      }
    3.81  
    3.82      public string GetReport() {
     4.1 --- a/Properties/AssemblyInfo.cs	Sat Mar 27 13:04:34 2010 +0000
     4.2 +++ b/Properties/AssemblyInfo.cs	Sat Mar 27 19:55:09 2010 +0000
     4.3 @@ -69,5 +69,5 @@
     4.4  // You can specify all the values or you can default the Build and Revision Numbers 
     4.5  // by using the '*' as shown below:
     4.6  // [assembly: AssemblyVersion("1.0.*")]
     4.7 -[assembly: AssemblyVersion("0.1.27.0")]
     4.8 -[assembly: AssemblyFileVersion("0.1.27.0")]
     4.9 +[assembly: AssemblyVersion("0.1.28.0")]
    4.10 +[assembly: AssemblyFileVersion("0.1.28.0")]