ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
FanController Class Reference

Manages PWM-based fan speed control. More...

#include <FanController.h>

Public Member Functions

 FanController (uint8_t pin)
 Constructs a FanController with the specified pin.
 
void Initialize ()
 Initializes the fan controller by setting up the pin for PWM output.
 
void SetPWM (uint8_t pwm)
 Sets the PWM value to control the fan speed.
 
void SetSpeed (float ratio)
 Sets the fan speed as a ratio of its maximum speed.
 
uint8_t GetPWM ()
 Retrieves the current PWM value.
 

Private Attributes

uint8_t pin
 The pin number connected to the fan's PWM input.
 
uint8_t pwm
 The current PWM value (0-255).
 

Detailed Description

Manages PWM-based fan speed control.

The FanController class provides functionality for initializing a fan, setting its speed using PWM signals, and retrieving the current PWM value.

Definition at line 24 of file FanController.h.

Constructor & Destructor Documentation

◆ FanController()

Constructs a FanController with the specified pin.

Parameters
pinThe pin number connected to the fan's PWM input.

Definition at line 3 of file FanController.cpp.

References pin.

Member Function Documentation

◆ GetPWM()

uint8_t GetPWM ( )

Retrieves the current PWM value.

Returns
The current PWM value (0-255).

Definition at line 21 of file FanController.cpp.

References pwm.

◆ Initialize()

void Initialize ( )

Initializes the fan controller by setting up the pin for PWM output.

Definition at line 7 of file FanController.cpp.

References pin.

Referenced by ProtogenProject::Initialize().

◆ SetPWM()

void SetPWM ( uint8_t  pwm)

Sets the PWM value to control the fan speed.

Parameters
pwmThe PWM value (0-255) to set.

Definition at line 11 of file FanController.cpp.

References pin, and pwm.

Referenced by SetSpeed(), and ProtogenProject::UpdateFace().

◆ SetSpeed()

void SetSpeed ( float  ratio)

Sets the fan speed as a ratio of its maximum speed.

Parameters
ratioA float value between 0.0 and 1.0 representing the speed ratio.

Definition at line 16 of file FanController.cpp.

References Mathematics::Map(), pwm, and SetPWM().

Member Data Documentation

◆ pin

uint8_t pin
private

The pin number connected to the fan's PWM input.

Definition at line 26 of file FanController.h.

Referenced by FanController(), Initialize(), and SetPWM().

◆ pwm

uint8_t pwm
private

The current PWM value (0-255).

Definition at line 27 of file FanController.h.

Referenced by GetPWM(), SetPWM(), and SetSpeed().


The documentation for this class was generated from the following files: