class Component::Fan

Fan loader class

Public Instance Methods

update() click to toggle source

Read in the enabled state, max state, and target state.

Although _target can be read in and manipulated, it is pointlessly risky to manipulate it, when the PWM controller in the core module already does this.

Due to it being a mechanical RPM target, it will also CONSTANTLY need to readjust, rather than just keeping the pulse width setting the same and letting the motor do the lifting. Setting this forces the driver to take an active role in manipulating the speed, when it changes by even a small margin.

Whether I will add this later or recommend users overload it themselves, ##
I am not yet sure. Unlike the power cap, this does not provide any real ##
benefit, and it can freeze up the driver, at least as tested on my system. ##
    # File lib/radeonnoise/parts.rb
 97 def update
 98   @current.each do |k,v|
 99     # If the value, when converted to an integer, is 1, it is enabled.
100     # If it is 1, the result should be true. `.zero?` returns true if 0,
101     # so invert it.
102     @current[k][:enabled] = !File.read("#{@path}/#{k}_enable").to_i.zero?
103     # The current speed of the fan
104     @current[k][:rpm_current] = File.read("#{@path}/#{k}_input").to_i
105     # As the below 2 values, _min and _max, cannot be changed, I have
106     # implemented them as such.
107     #
108     # _min is probably locked by firmware or the card's BIOS. However,
109     # it is here, anyway. Even root cannot modify this.
110     @current[k][:rpm_min] ||= File.read("#{@path}/#{k}_min").to_i
111     # _max does not seem editable either, but unlike _min, it is
112     # definitely useful to know the card's max RPM.
113     @current[k][:rpm_max] ||= File.read("#{@path}/#{k}_max").to_i
114   end
115 end