Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
ControllerUI Class Referenceabstract

User interface (display and input) for humidistat. Hold references to ButtonReader for keypad input, and Humidistat for updating the humidity setpoint. More...

#include <ControllerUI.h>

Inheritance diagram for ControllerUI:
[legend]
Collaboration diagram for ControllerUI:
[legend]

Public Member Functions

virtual void begin ()=0
 Initialize the display.
 
void update ()
 Update the display and handle input: set Humidistat's setpoint.
 

Protected Member Functions

 ControllerUI (Print *display, const ButtonReader *buttonReader, etl::span< const ThermistorReader, 4 > trs)
 Constructor.
 
void blink (uint8_t col, uint8_t row, const char *buf)
 Print blinking text.
 
void printNTC (uint8_t col, uint8_t row, uint8_t i)
 Print temperature read from thermistors. Handles NaN values as 0.
 
template<typename... T>
void printf (uint8_t col, uint8_t row, const char *fmt, T... args)
 Print formatted data to display, at (col, row). Calculates lengths and creates appropriate buffer internally.
 

Static Protected Member Functions

static void adjustValue (double delta, double &value, uint8_t min, uint8_t max)
 In-/de-crement a variable, while clipping it to [min, max].
 

Protected Attributes

etl::span< const ThermistorReader, 4 > trs
 
unsigned long lastRefreshed = 0
 Last time display was updated (in millis)
 
const uint16_t refreshInterval = config::refreshInterval
 
const uint8_t adjustStep = config::adjustStep
 
const double tolerance = config::tolerance
 

Private Member Functions

virtual void draw ()=0
 Draw main interface (main loop).
 
virtual void drawSplash ()=0
 Draw splash screen.
 
virtual void drawInfo ()=0
 Draw info screen.
 
virtual void clear ()=0
 Clear screen.
 
virtual void setCursor (uint8_t col, uint8_t row)=0
 Set cursor to coordinates.
 
virtual bool handleInput (Buttons state, uint16_t pressedFor)=0
 Handle input.
 

Private Attributes

Print & display
 
const ButtonReaderbuttonReader
 
unsigned long lastPressed = 0
 Last time a keypress event occurred (in millis)
 
const uint16_t buttonDebounceInterval = config::buttonDebounceInterval
 
const uint16_t inputInterval = config::inputInterval
 
const uint16_t blinkInterval = config::blinkInterval
 
const uint16_t splashDuration = config::splashDuration
 
const uint16_t infoDuration = config::infoDuration
 
bool splashDrawn = false
 
bool infoDrawn = false
 
bool screenCleared = false
 

Detailed Description

User interface (display and input) for humidistat. Hold references to ButtonReader for keypad input, and Humidistat for updating the humidity setpoint.

Definition at line 15 of file ControllerUI.h.

Constructor & Destructor Documentation

◆ ControllerUI()

ControllerUI::ControllerUI ( Print * display,
const ButtonReader * buttonReader,
etl::span< const ThermistorReader, 4 > trs )
explicitprotected

Constructor.

Parameters
displayPointer to a Print instance
buttonReaderPointer to a ButtonReader instance
trsSpan over 4 ThermistorReader instances

Definition at line 3 of file ControllerUI.cpp.

Member Function Documentation

◆ adjustValue()

void ControllerUI::adjustValue ( double delta,
double & value,
uint8_t min,
uint8_t max )
staticprotected

In-/de-crement a variable, while clipping it to [min, max].

Parameters
deltaThe amount by which to in-/de-crement
valueValue to adjust
minLower limit
maxUpper limit

Definition at line 67 of file ControllerUI.cpp.

Here is the caller graph for this function:

◆ begin()

virtual void ControllerUI::begin ( )
pure virtual

Initialize the display.

Implemented in CharDisplayUI, and GraphicalDisplayUI< Humidistat_t >.

◆ blink()

void ControllerUI::blink ( uint8_t col,
uint8_t row,
const char * buf )
protected

Print blinking text.

Parameters
colLCD column
rowLCD row
bufBuffer of text to blink

Definition at line 43 of file ControllerUI.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

virtual void ControllerUI::clear ( )
privatepure virtual

Clear screen.

Implemented in CharDisplayUI, and GraphicalDisplayUI< Humidistat_t >.

Here is the caller graph for this function:

◆ draw()

virtual void ControllerUI::draw ( )
privatepure virtual

Draw main interface (main loop).

Implemented in CharDisplayUI, and GraphicalDisplayUI< Humidistat_t >.

Here is the caller graph for this function:

◆ drawInfo()

virtual void ControllerUI::drawInfo ( )
privatepure virtual

Draw info screen.

Implemented in CharDisplayUI, and GraphicalDisplayUI< Humidistat_t >.

Here is the caller graph for this function:

◆ drawSplash()

virtual void ControllerUI::drawSplash ( )
privatepure virtual

Draw splash screen.

Implemented in CharDisplayUI, and GraphicalDisplayUI< Humidistat_t >.

Here is the caller graph for this function:

◆ handleInput()

virtual bool ControllerUI::handleInput ( Buttons state,
uint16_t pressedFor )
privatepure virtual

Handle input.

Parameters
stateKeypad state
pressedForDuration the key has been pressed (in millis)
Returns
1 if button was pressed, 0 if not

Implemented in CharDisplayUI, and GraphicalDisplayUI< Humidistat_t >.

Here is the caller graph for this function:

◆ printf()

template<typename... T>
void ControllerUI::printf ( uint8_t col,
uint8_t row,
const char * fmt,
T... args )
inlineprotected

Print formatted data to display, at (col, row). Calculates lengths and creates appropriate buffer internally.

Parameters
colLCD column
rowLCD row
fmtFormat string
argsArguments specifying data to print

Definition at line 92 of file ControllerUI.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printNTC()

void ControllerUI::printNTC ( uint8_t col,
uint8_t row,
uint8_t i )
protected

Print temperature read from thermistors. Handles NaN values as 0.

Parameters
colLCD column
rowLCD row
iThermistorReader index

Definition at line 58 of file ControllerUI.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCursor()

virtual void ControllerUI::setCursor ( uint8_t col,
uint8_t row )
privatepure virtual

Set cursor to coordinates.

Parameters
colLCD column
rowLCD row

Implemented in CharDisplayUI, and GraphicalDisplayUI< Humidistat_t >.

Here is the caller graph for this function:

◆ update()

void ControllerUI::update ( )

Update the display and handle input: set Humidistat's setpoint.

Definition at line 6 of file ControllerUI.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ adjustStep

const uint8_t ControllerUI::adjustStep = config::adjustStep
protected

Definition at line 58 of file ControllerUI.h.

◆ blinkInterval

const uint16_t ControllerUI::blinkInterval = config::blinkInterval
private

Definition at line 24 of file ControllerUI.h.

◆ buttonDebounceInterval

const uint16_t ControllerUI::buttonDebounceInterval = config::buttonDebounceInterval
private

Definition at line 22 of file ControllerUI.h.

◆ buttonReader

const ButtonReader& ControllerUI::buttonReader
private

Definition at line 18 of file ControllerUI.h.

◆ display

Print& ControllerUI::display
private

Definition at line 17 of file ControllerUI.h.

◆ infoDrawn

bool ControllerUI::infoDrawn = false
private

Definition at line 29 of file ControllerUI.h.

◆ infoDuration

const uint16_t ControllerUI::infoDuration = config::infoDuration
private

Definition at line 26 of file ControllerUI.h.

◆ inputInterval

const uint16_t ControllerUI::inputInterval = config::inputInterval
private

Definition at line 23 of file ControllerUI.h.

◆ lastPressed

unsigned long ControllerUI::lastPressed = 0
private

Last time a keypress event occurred (in millis)

Definition at line 20 of file ControllerUI.h.

◆ lastRefreshed

unsigned long ControllerUI::lastRefreshed = 0
protected

Last time display was updated (in millis)

Definition at line 55 of file ControllerUI.h.

◆ refreshInterval

const uint16_t ControllerUI::refreshInterval = config::refreshInterval
protected

Definition at line 57 of file ControllerUI.h.

◆ screenCleared

bool ControllerUI::screenCleared = false
private

Definition at line 30 of file ControllerUI.h.

◆ splashDrawn

bool ControllerUI::splashDrawn = false
private

Definition at line 28 of file ControllerUI.h.

◆ splashDuration

const uint16_t ControllerUI::splashDuration = config::splashDuration
private

Definition at line 25 of file ControllerUI.h.

◆ tolerance

const double ControllerUI::tolerance = config::tolerance
protected

Definition at line 59 of file ControllerUI.h.

◆ trs

etl::span<const ThermistorReader, 4> ControllerUI::trs
protected

Definition at line 53 of file ControllerUI.h.


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