Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
SetpointProfileRunner.cpp
Go to the documentation of this file.
1
#include "
SetpointProfileRunner.h
"
2
3
SetpointProfileRunner::SetpointProfileRunner
(
Humidistat
*
humidistat
)
4
:
humidistat
(*
humidistat
) {}
5
6
void
SetpointProfileRunner::update
() {
7
if
(!
running
) {
8
return
;
9
}
10
11
humidistat
.
sp
=
profile
[
getCurrentPoint
()].sp;
12
13
if
(millis() -
timeStart
>
profile
.back().time*1000) {
14
// Reached end of profile
15
running
=
false
;
16
}
17
}
18
19
void
SetpointProfileRunner::toggle
() {
20
timeStart
= millis();
21
running
= !
running
;
22
}
23
24
void
SetpointProfileRunner::setProfile
(
const
etl::span<const Point> &profile) {
25
this->profile =
profile
;
26
}
27
28
bool
SetpointProfileRunner::isRunning
()
const
{
29
return
running
;
30
}
31
32
size_t
SetpointProfileRunner::getCurrentPoint
()
const
{
33
// Loop backwards over profile, returning the first (largest) index of the point whose time is less than runtime
34
for
(
size_t
i =
profile
.size() - 1; i >= 0; i--) {
35
if
(millis() -
timeStart
>
profile
[i].time*1000) {
36
return
i;
37
}
38
}
39
}
SetpointProfileRunner.h
Controller::sp
double sp
Setpoint.
Definition
Controller.h:22
Humidistat
Base class for a humidistat. Holds a reference to a HumiditySensor instance.
Definition
Humidistat.h:10
SetpointProfileRunner::update
void update()
Run the profile (if running). Call this periodically.
Definition
SetpointProfileRunner.cpp:6
SetpointProfileRunner::setProfile
void setProfile(const etl::span< const Point > &profile)
Set the profile.
Definition
SetpointProfileRunner.cpp:24
SetpointProfileRunner::running
bool running
Definition
SetpointProfileRunner.h:15
SetpointProfileRunner::humidistat
Humidistat & humidistat
Definition
SetpointProfileRunner.h:12
SetpointProfileRunner::isRunning
bool isRunning() const
Get the run state.
Definition
SetpointProfileRunner.cpp:28
SetpointProfileRunner::timeStart
uint32_t timeStart
Definition
SetpointProfileRunner.h:14
SetpointProfileRunner::getCurrentPoint
size_t getCurrentPoint() const
Get the index of the current Point in the profile.
Definition
SetpointProfileRunner.cpp:32
SetpointProfileRunner::toggle
void toggle()
Toggle the run state.
Definition
SetpointProfileRunner.cpp:19
SetpointProfileRunner::SetpointProfileRunner
SetpointProfileRunner(Humidistat *humidistat)
Constructor.
Definition
SetpointProfileRunner.cpp:3
SetpointProfileRunner::profile
etl::span< const Point > profile
Definition
SetpointProfileRunner.h:13
humidistat
SerialLogger< cHumidistat > serialLogger & humidistat
Definition
main.cpp:84
src
SetpointProfileRunner.cpp
Generated by
1.12.0