Livello Serbatoio v0.13
This project realizes a simple device to monitor the water level in a tank.
|
Helper class to write on LCD. More...
Public Member Functions | |
LcdHelper (void) | |
Class default constructor. | |
void | begin (LiquidCrystal *const lcd, const int32_t backlight_dpin=-1) |
Initializes this instance with current LCD instance. | |
void | turn_on_backlight (void) |
Turns on the LCD backlight if configured. | |
void | turn_off_backlight (void) |
Turns off the LCD backlight if configured. | |
void | clear (void) |
Clears the current LCD content (the internal buffer) and resets the cursor position. | |
void | setCursor (const uint16_t c, const uint16_t r) |
Sets the cursor position if valid (in LCD sizes). | |
void | home (void) |
Sets the cursor position to (0, 0). | |
void | print (const char *str, const uint16_t str_length=LCD_COLS) |
Prints a string to the internal buffer without exceeding the limits of the LCD. | |
void | print (const int32_t number) |
Prints a number to the LCD. | |
void | print (const String &str) |
Prints a String to the LCD. | |
void | print (const int16_t number) |
Prints a integer number to the LCD. | |
void | print (const uint16_t number) |
Prints a integer number to the LCD. | |
void | print (const float64_t number) |
Prints a floating point number to the LCD. | |
void | write (const int32_t special_char_index) |
Writes a special character to the LCD. | |
void | update_lcd (void) |
Updates the LCD HW with the current written data. | |
Private Member Functions | |
bool | is_special_symbol (const uint16_t r, const uint16_t c) |
Checks if the symbol in the given position is special or not. | |
bool | need_update (void) |
Checks if the LCD HW view needs an update. | |
Private Attributes | |
uint16_t | cursor_r |
uint16_t | cursor_c |
int32_t | backlight_digital_pin |
char | lcd_matrix [LCD_ROWS][LCD_COLS] |
char | last_lcd_matrix [LCD_ROWS][LCD_COLS] |
bool | special_char_map [LCD_ROWS][LCD_COLS] |
bool | last_special_char_map [LCD_ROWS][LCD_COLS] |
LiquidCrystal * | lcd_instance |
Static Private Attributes | |
static const char | EMPTY_CHAR = ' ' |
Helper class to write on LCD.
The purpose is to try the optimization of writings on LCD to prevent unwanted screen flickering. It uses a buffer to keep the current LCD content. When the user writes using the "print" or "write" methods, data are written in the buffer. The user has in charge the responsibility to update the LCD view by explicitly invoking the "update_lcd" method. The latter verifies which characters have been changed from previous view and updates only the different ones.
|
inline |
Class default constructor.
|
inline |
Initializes this instance with current LCD instance.
[in] | lcd | The pointer to the LiquidCrystal lcd instance. |
[in] | backlight_dpin | The digital pin number used to control LCD backlight (default: -1, if not controllable). |
|
inline |
Clears the current LCD content (the internal buffer) and resets the cursor position.
|
inline |
Sets the cursor position to (0, 0).
|
inlineprivate |
Checks if the symbol in the given position is special or not.
Checks if the symbol is a number in 0-9 and it flagged true in special_char_map.
[in] | r | The row. |
[in] | c | The column. |
r
, c
) is special or false otherwise.
|
inlineprivate |
Checks if the LCD HW view needs an update.
Checks if there is a symbol different from the currently displayed data
|
inline |
Prints a string to the internal buffer without exceeding the limits of the LCD.
[in] | str | The string (char pointer). |
[in] | str_length | The string length. |
|
inline |
Prints a floating point number to the LCD.
[in] | number | The number to write. |
|
inline |
Prints a integer number to the LCD.
[in] | number | The number to write. |
|
inline |
Prints a number to the LCD.
[in] | number | The integer number to write. |
|
inline |
Prints a String to the LCD.
[in] | str | The string to write. |
|
inline |
Prints a integer number to the LCD.
[in] | number | The number to write. |
|
inline |
Sets the cursor position if valid (in LCD sizes).
[in] | c | The column index. |
[in] | r | The row index. |
|
inline |
Turns off the LCD backlight if configured.
|
inline |
Turns on the LCD backlight if configured.
|
inline |
Updates the LCD HW with the current written data.
|
inline |
Writes a special character to the LCD.
It writes the number on the buffer and set to true the special_char_map matrix in the corresponding position on screen.
[in] | special_char_index | The special character number. |
|
private |
|
private |
|
private |
|
staticprivate |
|
private |