fans

package
v0.0.0-...-2f3587d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPwmValue = 255
	MinPwmValue = 0
)

Variables

View Source
var (
	FanMap = map[string]Fan{}
)

Functions

func ComputePwmBoundaries

func ComputePwmBoundaries(fan Fan) (startPwm int, maxPwm int)

ComputePwmBoundaries calculates the startPwm and maxPwm values for a fan based on its fan curve data

Types

type CmdFan

type CmdFan struct {
	Config    configuration.FanConfig `json:"config"`
	MovingAvg float64                 `json:"movingAvg"`

	Rpm int `json:"rpm"`
	Pwm int `json:"pwm"`
}

func (*CmdFan) AttachFanCurveData

func (fan *CmdFan) AttachFanCurveData(curveData *map[int]float64) (err error)

func (*CmdFan) GetCurveId

func (fan *CmdFan) GetCurveId() string

func (*CmdFan) GetFanCurveData

func (fan *CmdFan) GetFanCurveData() *map[int]float64

func (*CmdFan) GetId

func (fan *CmdFan) GetId() string

func (*CmdFan) GetMaxPwm

func (fan *CmdFan) GetMaxPwm() int

func (*CmdFan) GetMinPwm

func (fan *CmdFan) GetMinPwm() int

func (*CmdFan) GetPwm

func (fan *CmdFan) GetPwm() (result int, err error)

func (*CmdFan) GetPwmEnabled

func (fan *CmdFan) GetPwmEnabled() (int, error)

func (*CmdFan) GetRpm

func (fan *CmdFan) GetRpm() (int, error)

func (*CmdFan) GetRpmAvg

func (fan *CmdFan) GetRpmAvg() float64

func (*CmdFan) GetStartPwm

func (fan *CmdFan) GetStartPwm() int

func (*CmdFan) IsPwmAuto

func (fan *CmdFan) IsPwmAuto() (bool, error)

func (*CmdFan) SetMaxPwm

func (fan *CmdFan) SetMaxPwm(pwm int, force bool)

func (*CmdFan) SetMinPwm

func (fan *CmdFan) SetMinPwm(pwm int, force bool)

func (*CmdFan) SetPwm

func (fan *CmdFan) SetPwm(pwm int) (err error)

func (*CmdFan) SetPwmEnabled

func (fan *CmdFan) SetPwmEnabled(value ControlMode) (err error)

func (*CmdFan) SetRpmAvg

func (fan *CmdFan) SetRpmAvg(rpm float64)

func (*CmdFan) SetStartPwm

func (fan *CmdFan) SetStartPwm(pwm int, force bool)

func (*CmdFan) ShouldNeverStop

func (fan *CmdFan) ShouldNeverStop() bool

func (*CmdFan) Supports

func (fan *CmdFan) Supports(feature FeatureFlag) bool

type ControlMode

type ControlMode int
const (
	// ControlModeDisabled completely disables control, resulting in a 100% voltage/PWM signal output
	ControlModeDisabled ControlMode = 0
	// ControlModePWM enables manual, fixed speed control via setting the pwm value
	ControlModePWM ControlMode = 1
	// ControlModeAutomatic enables automatic control by the integrated control of the mainboard
	ControlModeAutomatic ControlMode = 2
)

type Fan

type Fan interface {
	GetId() string

	// GetMinPwm returns the lowest PWM value where the fans are still spinning, when spinning previously
	GetMinPwm() int
	SetMinPwm(pwm int, force bool)

	// GetStartPwm returns the min PWM at which the fan starts to rotate from a stand still
	GetStartPwm() int
	SetStartPwm(pwm int, force bool)

	// GetMaxPwm returns the highest PWM value that yields an RPM increase
	GetMaxPwm() int
	SetMaxPwm(pwm int, force bool)

	// GetRpm returns the current RPM value of this fan
	GetRpm() (int, error)
	GetRpmAvg() float64
	SetRpmAvg(rpm float64)

	// GetPwm returns the current PWM value of this fan
	GetPwm() (int, error)
	SetPwm(pwm int) (err error)

	// GetFanCurveData returns the fan curve data for this fan
	GetFanCurveData() *map[int]float64
	AttachFanCurveData(curveData *map[int]float64) (err error)

	// GetCurveId returns the id of the speed curve associated with this fan
	GetCurveId() string

	// ShouldNeverStop indicated whether this fan should never stop rotating
	ShouldNeverStop() bool

	// GetPwmEnabled returns the current "pwm_enabled" value of this fan
	GetPwmEnabled() (int, error)
	SetPwmEnabled(value ControlMode) (err error)
	// IsPwmAuto indicates whether this fan is in "Auto" mode
	IsPwmAuto() (bool, error)

	Supports(feature FeatureFlag) bool
}

func NewFan

func NewFan(config configuration.FanConfig) (Fan, error)

type FeatureFlag

type FeatureFlag int
const (
	FeatureRpmSensor   FeatureFlag = 0
	FeatureControlMode FeatureFlag = 1
)

type FileFan

type FileFan struct {
	Config    configuration.FanConfig `json:"config"`
	MovingAvg float64                 `json:"movingAvg"`

	Pwm int `json:"pwm"`
	Rpm int `json:"rpm"`
}

func (*FileFan) AttachFanCurveData

func (fan *FileFan) AttachFanCurveData(curveData *map[int]float64) (err error)

func (*FileFan) GetCurveId

func (fan *FileFan) GetCurveId() string

func (*FileFan) GetFanCurveData

func (fan *FileFan) GetFanCurveData() *map[int]float64

func (*FileFan) GetId

func (fan *FileFan) GetId() string

func (*FileFan) GetMaxPwm

func (fan *FileFan) GetMaxPwm() int

func (*FileFan) GetMinPwm

func (fan *FileFan) GetMinPwm() int

func (*FileFan) GetPwm

func (fan *FileFan) GetPwm() (result int, err error)

func (*FileFan) GetPwmEnabled

func (fan *FileFan) GetPwmEnabled() (int, error)

func (*FileFan) GetRpm

func (fan *FileFan) GetRpm() (result int, err error)

func (*FileFan) GetRpmAvg

func (fan *FileFan) GetRpmAvg() float64

func (*FileFan) GetStartPwm

func (fan *FileFan) GetStartPwm() int

func (*FileFan) IsPwmAuto

func (fan *FileFan) IsPwmAuto() (bool, error)

func (*FileFan) SetMaxPwm

func (fan *FileFan) SetMaxPwm(pwm int, force bool)

func (*FileFan) SetMinPwm

func (fan *FileFan) SetMinPwm(pwm int, force bool)

func (*FileFan) SetPwm

func (fan *FileFan) SetPwm(pwm int) (err error)

func (*FileFan) SetPwmEnabled

func (fan *FileFan) SetPwmEnabled(value ControlMode) (err error)

func (*FileFan) SetRpmAvg

func (fan *FileFan) SetRpmAvg(rpm float64)

func (*FileFan) SetStartPwm

func (fan *FileFan) SetStartPwm(pwm int, force bool)

func (*FileFan) ShouldNeverStop

func (fan *FileFan) ShouldNeverStop() bool

func (*FileFan) Supports

func (fan *FileFan) Supports(feature FeatureFlag) bool

type HwMonFan

type HwMonFan struct {
	Label        string                  `json:"label"`
	Index        int                     `json:"index"`
	RpmMovingAvg float64                 `json:"rpmMovingAvg"`
	Config       configuration.FanConfig `json:"config"`
	MinPwm       *int                    `json:"minPwm"`
	StartPwm     *int                    `json:"startPwm"`
	MaxPwm       *int                    `json:"maxPwm"`
	FanCurveData *map[int]float64        `json:"fanCurveData"`
	Rpm          int                     `json:"rpm"`
	Pwm          int                     `json:"pwm"`
}

func (*HwMonFan) AttachFanCurveData

func (fan *HwMonFan) AttachFanCurveData(curveData *map[int]float64) (err error)

AttachFanCurveData attaches fan curve data from persistence to a fan Note: When the given data is incomplete, all values up until the highest value in the given dataset will be interpolated linearly returns os.ErrInvalid if curveData is void of any data

func (*HwMonFan) GetCurveId

func (fan *HwMonFan) GetCurveId() string

func (*HwMonFan) GetFanCurveData

func (fan *HwMonFan) GetFanCurveData() *map[int]float64

func (*HwMonFan) GetId

func (fan *HwMonFan) GetId() string

func (*HwMonFan) GetMaxPwm

func (fan *HwMonFan) GetMaxPwm() int

func (*HwMonFan) GetMinPwm

func (fan *HwMonFan) GetMinPwm() int

func (*HwMonFan) GetPwm

func (fan *HwMonFan) GetPwm() (int, error)

func (*HwMonFan) GetPwmEnabled

func (fan *HwMonFan) GetPwmEnabled() (int, error)

func (*HwMonFan) GetRpm

func (fan *HwMonFan) GetRpm() (int, error)

func (*HwMonFan) GetRpmAvg

func (fan *HwMonFan) GetRpmAvg() float64

func (*HwMonFan) GetStartPwm

func (fan *HwMonFan) GetStartPwm() int

func (*HwMonFan) IsPwmAuto

func (fan *HwMonFan) IsPwmAuto() (bool, error)

func (*HwMonFan) SetMaxPwm

func (fan *HwMonFan) SetMaxPwm(pwm int, force bool)

func (*HwMonFan) SetMinPwm

func (fan *HwMonFan) SetMinPwm(pwm int, force bool)

func (*HwMonFan) SetPwm

func (fan *HwMonFan) SetPwm(pwm int) (err error)

func (*HwMonFan) SetPwmEnabled

func (fan *HwMonFan) SetPwmEnabled(value ControlMode) (err error)

SetPwmEnabled writes the given value to pwmX_enable Possible values (unsure if these are true for all scenarios): 0 - no control (results in max speed) 1 - manual pwm control 2 - motherboard pwm control

func (*HwMonFan) SetRpmAvg

func (fan *HwMonFan) SetRpmAvg(rpm float64)

func (*HwMonFan) SetStartPwm

func (fan *HwMonFan) SetStartPwm(pwm int, force bool)

func (*HwMonFan) ShouldNeverStop

func (fan *HwMonFan) ShouldNeverStop() bool

func (*HwMonFan) Supports

func (fan *HwMonFan) Supports(feature FeatureFlag) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL