115 lines
3.1 KiB
C++
115 lines
3.1 KiB
C++
/*
|
|
* Display.hpp
|
|
*
|
|
* Created on: Aug 12, 2023
|
|
* Author: Carst
|
|
*/
|
|
|
|
#ifndef DISPLAY_HPP_
|
|
#define DISPLAY_HPP_
|
|
|
|
#include <cstdint>
|
|
|
|
namespace ElektronischeLast
|
|
{
|
|
class Display
|
|
{
|
|
public:
|
|
/// \brief User defined character number
|
|
typedef enum
|
|
{
|
|
FirstSign = 0, //!< First user defined character (accassible via data 0x0)
|
|
SecondSign = 8, //!< Second user defined character (accassible via data 0x1)
|
|
ThirdSign = 16, //!< Third user defined character (accassible via data 0x2)
|
|
FourthSign = 24, //!< Fourth user defined character (accassible via data 0x3)
|
|
FifthSign = 32, //!< Fifth user defined character (accassible via data 0x4)
|
|
SixthSign = 40, //!< Sixth user defined character (accassible via data 0x5)
|
|
SeventhSign = 48,//!< Seventh user defined character (accassible via data 0x6)
|
|
EithSign = 56 //!< Eith user defined character (accassible via data 0x7)
|
|
} UserDefinedCharakter_t;
|
|
|
|
/// \brief Shift direction
|
|
typedef enum
|
|
{
|
|
ShiftLeft = 0, //!< Shift text left
|
|
ShiftRight = 2 //!< Shift text right
|
|
} ShiftDirection_t;
|
|
|
|
/// \brief Shift mode
|
|
typedef enum
|
|
{
|
|
ShiftOff = 0, //!< Shift disabled
|
|
ShiftOn = 1 //!< Shift enabled
|
|
} ShiftMode_t;
|
|
|
|
/// \brief Display State
|
|
typedef enum
|
|
{
|
|
DisplayOff = 0, //!< Display off
|
|
DispalyOn = 4 //!< Display on
|
|
} Display_t;
|
|
|
|
/// \brief Cursor State
|
|
typedef enum
|
|
{
|
|
CursorOff = 0, //!< Cursor off
|
|
CursorOn = 2 //!< Cursor on
|
|
} Cursor_t;
|
|
|
|
/// \brief Cursor blink mode
|
|
typedef enum
|
|
{
|
|
CursorBlinkOff = 0, //!< no Cursor blink
|
|
CursorBlinkOn = 1 //!< Cursor blink
|
|
} CursorBlink_t;
|
|
|
|
/// \brief Display line selection
|
|
typedef enum
|
|
{
|
|
Line1 = 0, //!< Select first display line
|
|
Line2 = 0x40, //!< Select second display line
|
|
} Line_t;
|
|
|
|
typedef enum
|
|
{
|
|
StateIdle,
|
|
StateDelay,
|
|
StateWaitWhileBusy,
|
|
StateInit01,
|
|
StateInit02,
|
|
StateInit03,
|
|
StateInit04,
|
|
StateInit05,
|
|
StateInit06,
|
|
StateInit07,
|
|
StateInit08,
|
|
StateInit09,
|
|
StateInit10,
|
|
StateWriteData,
|
|
} State_t;
|
|
|
|
void init(void);
|
|
void run(void);
|
|
void set_backlight(bool on);
|
|
void set_cursor(Line_t line, std::uint32_t position);
|
|
void print(const char* const string);
|
|
bool ready_for_data(void);
|
|
private:
|
|
State_t current_state;
|
|
State_t next_state;
|
|
std::uint32_t timer;
|
|
char string[17];
|
|
std::uint8_t pointer;
|
|
bool new_data;
|
|
bool timer_elapsed(void);
|
|
void start_timer(std::uint32_t timeout);
|
|
void lcd_cmd(uint8_t cmd);
|
|
void lcd_data(uint8_t data);
|
|
void write_command_8bit_4pin(std::uint32_t data);
|
|
void write_command_4bit(std::uint32_t command);
|
|
void write_data_4bit(uint8_t data);
|
|
};
|
|
}
|
|
|
|
#endif /* DISPLAY_HPP_ */
|