Documentation
¶
Overview ¶
Package pwmfan is a set of toolkits to build a pwm fan control program
Index ¶
- func HandleErr(err error)
- func IFNameToIPv4(ifname string) (ip net.IP)
- func LinearClampRemap(input float64, opt ...float64) (output float64)
- func LinearRemap(input float64, opt ...float64) (output float64)
- func PullCPUTemp(CPUTempPath string, Divider float64, Temp chan<- float64)
- func ReadCPUTemperature(CPUTempPath string, Divider float64) (Temperature float64)
- func SignalProcess(Process *os.Process, SigChan <-chan os.Signal, Action func())
- func TriangularWave(small float64, big float64, step float64, ch chan<- float64)
- type Config
- type Fan
- func (fan *Fan) CreateServer() (udpConn *net.UDPConn)
- func (fan Fan) GetCfg() (cfg Config)
- func (fan Fan) GetCycle() (cycle uint)
- func (fan Fan) GetStartCounter() (num uint)
- func (fan Fan) GetState() (state FanState)
- func (fan Fan) GetStopCounter() (num uint)
- func (fan Fan) GetTemp() (temp float64)
- func (fan Fan) GetUDPAddr() (UDPAddr *net.UDPAddr)
- func (fan *Fan) HandleRequest(udpConn *net.UDPConn)
- func (fan *Fan) Monitor()
- func (fan *Fan) ResolveUDPAddr()
- func (fan *Fan) SetCfg(cfg Config)
- func (fan *Fan) SetCycle(cycle uint)
- func (fan *Fan) SetStartCounter(num uint)
- func (fan *Fan) SetState(state FanState)
- func (fan *Fan) SetStopCounter(num uint)
- func (fan *Fan) SetTemp(temp float64)
- func (fan *Fan) SetUDPAddr(udpAddr *net.UDPAddr)
- func (fan Fan) String() string
- func (fan *Fan) UpdateCycleFromState(remapper RemapFunc)
- type FanState
- type RemapFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IFNameToIPv4 ¶ added in v0.2.0
IFNameToIPv4 reads an network interface name, return an net.IP, with the first address of the network interface
func LinearClampRemap ¶
LinearClampRemap is a linear remap function that will clamp output in between opt[2] and opt[3]
func LinearRemap ¶
LinearRemap is a linear remap function
func PullCPUTemp ¶
PullCPUTemp read from a system file constantanious and put temperature into a predifined channel
Note: As for raspberry Pi, CPUTempPath is /sys/class/thermal/thermal_zone0/temp Divider should be set to 1000
func ReadCPUTemperature ¶
ReadCPUTemperature read temprature once from a file and divie raw data by a divider
Note: As for raspberry Pi, CPUTempPath is /sys/class/thermal/thermal_zone0/temp Divider should be set to 1000
func SignalProcess ¶
SignalProcess listen from a os.Notify function's output, when catch signal, Process the Action, then send original to the Process
Types ¶
type Config ¶
type Config struct {
Pin uint
CPUTempPath string
StartCount uint
StopCount uint
StartTemp float64
LowTemp float64
HighTemp float64
PwmFreq uint
StopCycle uint
StartCycle uint
LowCycle uint
HighCycle uint
FullCycle uint
SampleRate uint
NetworkInterfaceName string
ListenPort int
Token string
}
Config contain all information that define a PWM fan's user configuration TODO: try to implement String() method
type Fan ¶
type Fan struct {
State FanState
Cycle uint
Temp float64
Cfg Config
Pin rpio.Pin
StopCounter uint
StartCounter uint
UDPAddr *net.UDPAddr
}
Fan represent a Fan
State, Cycle, Temp should be updated 'in realtime' Pin better not be modified after call NewFan()
TODO: try to implement String() method
func (*Fan) CreateServer ¶ added in v0.2.0
CreateServer use fan's configuration, return a *net.UDPConn object
func (Fan) GetStartCounter ¶
GetStartCounter get fan's current start counter
func (Fan) GetStopCounter ¶
GetStopCounter get fan's current stop counter
func (Fan) GetUDPAddr ¶ added in v0.2.0
GetUDPAddr get fan's udp listening address
func (*Fan) HandleRequest ¶ added in v0.2.0
HandleRequest handle request from network
func (*Fan) Monitor ¶
func (fan *Fan) Monitor()
Monitor is the function to control fan's real-time stat
func (*Fan) ResolveUDPAddr ¶ added in v0.2.0
func (fan *Fan) ResolveUDPAddr()
ResolveUDPAddr resolve the listening udp address from fan config
func (*Fan) SetStartCounter ¶
SetStartCounter set fan's current start counter
func (*Fan) SetStopCounter ¶
SetStopCounter set fan's current stop counter
func (*Fan) SetUDPAddr ¶ added in v0.2.0
SetUDPAddr set fan's udp listening address
func (*Fan) UpdateCycleFromState ¶
UpdateCycleFromState update pwm fan's Cycle information from State information
type FanState ¶
type FanState uint
FanState represent a PWM Fan's running state TODO: try to implement String() method