9 #ifndef _LCD_DRIVER_HPP 10 #define _LCD_DRIVER_HPP 14 #include "general_timer/general_timer.hpp" 24 static const uint32_t LCD_MAX_PRINT_STRING = 32;
30 static const uint32_t TOTAL_PARALLEL_PIN = 4;
37 static const uint32_t PIN_DESCRIPTION_LEN = 3;
42 static const uint32_t PIN_DESC_CLOCK_INDEX = 0;
46 static const uint32_t PIN_DESC_PORT_INDEX = 1;
51 static const uint32_t PIN_DESC_PIN_INDEX = 2;
57 static const uint32_t MAX_TOTAL_CUSTOM_PATTERN = 8;
61 static const uint32_t CUSTOM_CHAR_PATTERN_LEN = 8;
71 uint32_t regSelectPin[PIN_DESCRIPTION_LEN];
72 uint32_t readWritePin[PIN_DESCRIPTION_LEN];
73 uint32_t enablePin[PIN_DESCRIPTION_LEN];
74 uint32_t backLightPin[PIN_DESCRIPTION_LEN];
81 uint32_t parallelPinList[TOTAL_PARALLEL_PIN][PIN_DESCRIPTION_LEN];
117 void parallelDataRead(
const bool &isDataReg, uint8_t *readDataBuf,
const uint32_t &totalReadData);
128 void parallelDataWrite(
const uint8_t *dataList,
const uint32_t &dataLen,
const bool &isDataReg);
150 void pinModeSwitch(
const uint32_t pinDesc[PIN_DESCRIPTION_LEN],
const bool &isInput);
159 void pinWrite(
const uint32_t pinDesc[PIN_DESCRIPTION_LEN],
const bool &output);
167 bool pinRead(
const uint32_t pinDesc[PIN_DESCRIPTION_LEN]);
174 void pinPadConfig(
const uint32_t pinDesc[PIN_DESCRIPTION_LEN]);
180 void pinDescCheck(uint32_t pinDesc[PIN_DESCRIPTION_LEN]);
191 void comSetup(
const bool &isDataReg,
const bool &isReadMode);
223 void comSwitch(
const bool &iscomEnabled);
251 const bool &cursorOn,
252 const bool &isCursorBlink);
264 const bool &is2Lines,
265 const bool &is5x10Font);
307 void dataWrite4Bit(
const uint32_t &dataToWrite,
const bool &stopAfterWrite);
323 void ramDataWrite(
const uint8_t *data,
const uint32_t dataLen,
const bool &isTextMode);
338 const uint32_t &totalDataRead,
339 const uint8_t & startingRamAddr,
340 const bool & isDataRam);
389 const uint32_t &customCharSlot);
398 void lcdSettingSwitch(
const bool &displayOn,
const bool &cursorOn,
const bool &cursorBlinkOn);
void ramDataWrite(const uint8_t *data, const uint32_t dataLen, const bool &isTextMode)
Write to the RAM of the lcd controller, can be data ram or character generator RAM.
Definition: lcd_utils.cpp:230
void newCustomCharAdd(const uint8_t charPattern[CUSTOM_CHAR_PATTERN_LEN], const uint32_t &customCharSlot)
Add new custom character pattern The new pattern will be stored in the custom generator RAM of the lc...
Definition: lcd_driver.cpp:177
the structure used for carrying the lcd controller settings Each pin description is an array of 3 mem...
Definition: lcd_driver.hpp:69
void configWrite(void)
used for writing configs to controller, uses other functions like functionSetCommandCreate to get the...
Definition: lcd_driver.cpp:125
void parallelDataRead(const bool &isDataReg, uint8_t *readDataBuf, const uint32_t &totalReadData)
used for reading the data from the controller RAM/program memory The method will follow procedures ou...
Definition: lcd_utils.cpp:174
uint8_t entryModeCommandCreate(const bool &cursorRightDir, const bool &displayShiftEnabled)
Create a command of entry mode category.
Definition: lcd_utils.cpp:99
void ramDataRead(uint8_t *returnData, const uint32_t &totalDataRead, const uint8_t &startingRamAddr, const bool &isDataRam)
Used for reading the RAM of the lcd controller, it can either be the data ram storing data to be disp...
Definition: lcd_utils.cpp:217
void parallelDataWrite(const uint8_t *dataList, const uint32_t &dataLen, const bool &isDataReg)
used for sending data to the data pins(D0-D7) connected to the LCD The bits are shifted to each pin a...
Definition: lcd_utils.cpp:156
void enable(void)
Start communicating with the lcd and write settings to the lcd controller, this might take more than ...
Definition: lcd_driver.cpp:136
void parallelDataWriteSingle(const uint8_t &data, const bool &isDataReg)
used for writing a single byte to the lcd controller
Definition: lcd_utils.cpp:144
void displayWrite(const char *dataToWrite)
Erase the display and add new text to it starting at position (0,0), this method will be the one used...
Definition: lcd_driver.cpp:157
void lcdReset(void)
reset the LCD and erase all RAM, also reset cursor to (0,0)
Definition: lcd_driver.cpp:192
void parallelModeSwitch(const bool &isInput)
switch all the data pins(like D0-D7) to input mode or output mode Used for quickly switching between ...
Definition: lcd_utils.cpp:138
void lcdSettingSwitch(const bool &displayOn, const bool &cursorOn, const bool &cursorBlinkOn)
Change lcd settings like on/off display, cursor, or blinking mode This method writes to the lcd contr...
Definition: lcd_driver.cpp:186
bool useBacklight
whether the backlight can be turned on/off using pin
Definition: lcd_driver.hpp:70
void registerSelect(const bool &isDataReg)
select data(like RAM) or program register be switching the RS line
Definition: lcd_driver.cpp:88
void pinWrite(const uint32_t pinDesc[PIN_DESCRIPTION_LEN], const bool &output)
switch on/off a pin This is the lowest level function, used for toggling control pin for bitbanging d...
Definition: lcd_utils.cpp:81
uint8_t functionSetCommandCreate(const bool &is8BitDataLen, const bool &is2Lines, const bool &is5x10Font)
Create a command of function set category.
Definition: lcd_utils.cpp:117
void pinPadConfig(const uint32_t pinDesc[PIN_DESCRIPTION_LEN])
configure the pins on things like drive strength(affect rise/fall time of signal), push/pull mode
Definition: lcd_utils.cpp:90
void comModeSwitch(const bool &isReadMode)
switch to read/write mode by switching RW pin
Definition: lcd_driver.cpp:96
void displayAppend(const char *dataToAppend)
Append text to existing text onscreen, this method will also be used the most if there is no need to ...
Definition: lcd_driver.cpp:170
uint8_t cursorDisplayShiftCommandCreate(const bool &isShiftDisplay, const bool &isRight)
create a command to shift the cursor and maybe the display with it
Definition: lcd_utils.cpp:128
bool lcdIsBusy(void)
Read lcd controller memory and see if the lcd is busy with an operation.
Definition: lcd_utils.cpp:268
uint8_t displayCommandCreate(const bool &displayOn, const bool &cursorOn, const bool &isCursorBlink)
Create a command of display category.
Definition: lcd_utils.cpp:107
void pinDescCheck(uint32_t pinDesc[PIN_DESCRIPTION_LEN])
check whether the array describing a pin is valid, will raise assert if not
Definition: lcd_utils.cpp:35
void comStop(void)
stop the communcation by waiting for the current data to be finished transacting and then deassert th...
Definition: lcd_driver.cpp:110
void init(void)
Initialize the lcd driver, by turning on all gpio clocks and set the gpio mode to be ready to drive t...
Definition: lcd_driver.cpp:53
the namespace of the LcdDriver, all lcd controller related files are under this namespace ...
Definition: lcd_driver.cpp:33
LcdConfig _lcdConfig
The LcdDriver copy of the user config received at constructor.
Definition: lcd_driver.hpp:100
void comMaintain(const bool &isReadMode)
temporarily deassert the enable line, wait for the current data to be finished transacting and then a...
Definition: lcd_driver.cpp:116
void comSetup(const bool &isDataReg, const bool &isReadMode)
Utility function used to generate signal to start the communication with the lcd controller The metho...
Definition: lcd_driver.cpp:100
uint32_t _totalBitPerPin
How many bits that each pin has to send, if using 8 then each only has to send 1, but if 4 then each ...
Definition: lcd_driver.hpp:95
void cursorPositionChange(const uint8_t &cursorX, const uint8_t &cursorY)
Change cursor position on an x-y scale This method also changes the data ram position with the cursor...
Definition: lcd_driver.cpp:165
bool pinRead(const uint32_t pinDesc[PIN_DESCRIPTION_LEN])
Read whehther a pin is high or low.
Definition: lcd_utils.cpp:86
uint8_t addrCounterGet(void)
Read lcd controller memory to retrieve the 7 bits address counter This command can be helpful during ...
Definition: lcd_utils.cpp:258
void pinModeSwitch(const uint32_t pinDesc[PIN_DESCRIPTION_LEN], const bool &isInput)
switch a single pin to input/output
Definition: lcd_utils.cpp:73
The main class for the LcdDriver, all interactions with the 1602 lcd controller will be through this ...
Definition: lcd_driver.hpp:89
uint8_t instructionDataRead(void)
Read the lcd controller data to get the busy status and current address counter.
Definition: lcd_utils.cpp:262
void comSwitch(const bool &iscomEnabled)
turn on or off communication by switching the EN pin
Definition: lcd_driver.cpp:92
void addrCounterChange(const uint8_t &addr, const bool &isDataRam)
Change the address counter on the lcd controller This command is used a lot since it changes the addr...
Definition: lcd_utils.cpp:211
GeneralTimer _generalTimer
Instance of general timer used for all timing purposes.
Definition: lcd_driver.hpp:105
void backLedSwitch(const bool &isBackLedOn)
Turn on or off the back light LED The TivaC itself probably doesn't have the current to turn on or of...
Definition: lcd_driver.cpp:152
LcdDriver(const LcdConfig &lcdConfig)
Construct a new Lcd Driver object, doesn't initiate any hardware, just compute data to be ready for f...
Definition: lcd_driver.cpp:48
void dataWrite4Bit(const uint32_t &dataToWrite, const bool &stopAfterWrite)
Used to write only 4 bits using D4-D7 This command is used mainly during the beginning of the communi...
Definition: lcd_utils.cpp:198