-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hepa-uv): Add the ability to set the duty cycle for the HEPA fan. (
#747)
- Loading branch information
Showing
19 changed files
with
460 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "hepa-uv/firmware/hepa_control_hardware.hpp" | ||
|
||
#include "hepa-uv/firmware/hepa_hardware.h" | ||
|
||
using namespace hepa_control_hardware; | ||
|
||
void HepaControlHardware::set_hepa_fan_speed(uint32_t duty_cycle) { | ||
set_hepa_fan_pwm(duty_cycle); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "hepa-uv/firmware/hepa_hardware.h" | ||
#include "timer_hardware.h" | ||
|
||
static uint32_t clamp(uint32_t val, uint32_t min, uint32_t max) { | ||
if (val < min) return min; | ||
if (val > max) return max; | ||
return val; | ||
} | ||
|
||
void set_hepa_fan_pwm(uint32_t duty_cycle) { | ||
// calculate the pulse width from the duty cycle | ||
htim3.Instance->CCR1 = clamp(duty_cycle, 0, 100) * htim3.Init.Period / 100; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.