ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
FanController.cpp
Go to the documentation of this file.
1#include "FanController.h"
2
4 this->pin = pin;
5}
6
8 pinMode(pin, OUTPUT);
9}
10
11void FanController::SetPWM(uint8_t pwm) {
12 this->pwm = pwm;
13 analogWrite(pin, pwm);
14}
15
16void FanController::SetSpeed(float ratio) {
17 uint8_t pwm = uint8_t(Mathematics::Map(ratio, 0.0f, 1.0f, 0.0f, 255.0f));
18 SetPWM(pwm);
19}
20
22 return pwm;
23}
Declares the FanController class for managing PWM-based fan speed control.
uint8_t GetPWM()
Retrieves the current PWM value.
void SetSpeed(float ratio)
Sets the fan speed as a ratio of its maximum speed.
void Initialize()
Initializes the fan controller by setting up the pin for PWM output.
FanController(uint8_t pin)
Constructs a FanController with the specified pin.
uint8_t pwm
The current PWM value (0-255).
uint8_t pin
The pin number connected to the fan's PWM input.
void SetPWM(uint8_t pwm)
Sets the PWM value to control the fan speed.
static T Map(T value, T inLow, T inMax, T outMin, T outMax)
Maps a value from one range to another.