#pragma once
#include "libCharLCD/lcdInterface.h"
class lcd_t
{
public:
lcd_t(lcdType_t type_, ///< LCD type code
ioline_t rsBit_, ///< LCD register select bit
ioline_t wrBit_, ///< LCD register write bit
ioline_t eBit_, ///< LCD enable bit
lcdDataLines_t dBits_ ///< LCD data bits
)
: m_lcd(type_, rsBit_, wrBit_, eBit_, dBits_){};
// initialise the display
void init();
/// \brief clear the display
void clear();
/// \brief Enable or disable the display
void enable(bool ena_);
/// \brief Return the X size (8, 10,16, or 20) of this display
uint8_t displayXsize() const { return m_lcd.displayXsize(); }
/// \brief Return the Y size (1 or 2) of this display
uint8_t displayYsize() const { return m_lcd.displayYsize(); }
/// \brief set cursor position
void gotoxy(uint8_t x_, uint8_t y_);
/// \brief Print a string on the LCD: will terminate on null character or count_
/// characters printed , whichever is first.
///
/// \param str_ Null terminated string
///
/// \param count_ Maximum number of characters to print
void printString(char *str_, uint8_t count_ = 255);
void printString(char const *str_, uint8_t count_ = 255);
/// \brief provides a buffer to format a number into, then uses format_num.
/// \param digits, total digit width including decimal point and sign character
/// \param dp_pos Decimal point position within number counting digits from right
/// \param val value to print
void font_digits(uint8_t digits, uint8_t dp_pos, int val);
/// \brief Define one of 8 user defined graphics
/// \param code : Graphics code from 0..7
/// \param rows : bits 4:0 of rows 0:6 define character .
void defineChar(uint8_t code, uint8_t const *rows);
void defineChar(uint8_t code, uint8_t * rows);
private:
/// \brief formats an integer value with a decimal point in a particular position
/// \param buff Workspace buffer
/// \param digits, total digit width including decimal point and sign character
/// \param dp_pos Decimal point position within number counting digits from right
/// \param val value to print
uint8_t format_num(char *buff, uint8_t digits, uint8_t dp_pos, int val);
lcdInterface_t m_lcd;
};