Some of you might remember me posting an LCD Driver for HD44780 controller compatible displays ( *LINK* ). Well, the developing has gone forth and the new driver is smaller, faster, and easier to use! The new public released version is 3.0.
The major change is the way the LCD_Write() function works. In the previous version this function would only set the data pins and clock them in the LCD. Setting whether the data sent was going to the command register or the data register (RS pin) or whether it should read or write (RW pin), had to be done manually before each LCD_Write() call. Well, not anymore!
The new LCD_Write() function is able to properly set the RS and RW pins based on the type of data passed in the function argument. The argument has been extended to the first smallest data type higher than char (8-bit), which is the int data type (16-bit). The lower 8-bits of the parameter are the data to be sent. From the higher 8-bits only the last two bits are used to set the RS and RW pins.
Although, these changes would have brought an incompatibility issue with the previous driver which would never set the RS and RW values (they would be always 0). This is why the RS and RW values passed in the function argument are XOR masked (RS^1 and RW^0). When the RS and RW values passed are 0 or they're not passed at all (for example when passing a char argument) the XOR mask will set RS=1 and RW=0; this means the data is going to be written and it's going in the DATA register of the LCD display.
So, the new function is able to send any configuration mode for the RS and RW pins, but how to remember the proper value to give them if they are XOR-ed? Well, you don't have to worry about that because all the functions provided in the driver already have the RS and RW values preset. But, if for any reason should you need to set the RS and RW pins manually, then read the Fast LCD data type settings section in the driver header file (HD44780.h). There are some constants definitions which can be used to set the pins properly.
Because of the new way LCD_Write() works, the next functions have been deprecated: LCD_Clear(), LCD_Home(), LCD_GoTo(). They're now replaced with some macro definitions which have to be used as parameter for LCD_Write(). Macros have been defined for the LCD settings too (Function set, entry mode set ect..) to make it easier to set the LCD settings at runtime. These macros are only arithmetic operations which the compiler will convert into a number at compilation time. This results in a very lightweight way to make complex changes, by only using LCD_Write(). Usage specifics and examples have been included in the header file of the driver.
Eventually, all these changes of the driver result in way less code overhead, size and execution speed, and it's much easier to use the driver!
As usual, if you have any suggestion or if you made a porting of the driver and would like to share it, please contact me and I'll add your work to this post with the proper author credits.
LICENSE
The driver is released under GPL version 3 License
Make sure you read the License.txt file included in the archive or read it online here:
https://www.gnu.org/licenses/gpl.txt
DISCLAIMER
DOWNLOAD
You can download the driver from the attached zip file.
The major change is the way the LCD_Write() function works. In the previous version this function would only set the data pins and clock them in the LCD. Setting whether the data sent was going to the command register or the data register (RS pin) or whether it should read or write (RW pin), had to be done manually before each LCD_Write() call. Well, not anymore!
The new LCD_Write() function is able to properly set the RS and RW pins based on the type of data passed in the function argument. The argument has been extended to the first smallest data type higher than char (8-bit), which is the int data type (16-bit). The lower 8-bits of the parameter are the data to be sent. From the higher 8-bits only the last two bits are used to set the RS and RW pins.
Although, these changes would have brought an incompatibility issue with the previous driver which would never set the RS and RW values (they would be always 0). This is why the RS and RW values passed in the function argument are XOR masked (RS^1 and RW^0). When the RS and RW values passed are 0 or they're not passed at all (for example when passing a char argument) the XOR mask will set RS=1 and RW=0; this means the data is going to be written and it's going in the DATA register of the LCD display.
So, the new function is able to send any configuration mode for the RS and RW pins, but how to remember the proper value to give them if they are XOR-ed? Well, you don't have to worry about that because all the functions provided in the driver already have the RS and RW values preset. But, if for any reason should you need to set the RS and RW pins manually, then read the Fast LCD data type settings section in the driver header file (HD44780.h). There are some constants definitions which can be used to set the pins properly.
Because of the new way LCD_Write() works, the next functions have been deprecated: LCD_Clear(), LCD_Home(), LCD_GoTo(). They're now replaced with some macro definitions which have to be used as parameter for LCD_Write(). Macros have been defined for the LCD settings too (Function set, entry mode set ect..) to make it easier to set the LCD settings at runtime. These macros are only arithmetic operations which the compiler will convert into a number at compilation time. This results in a very lightweight way to make complex changes, by only using LCD_Write(). Usage specifics and examples have been included in the header file of the driver.
Eventually, all these changes of the driver result in way less code overhead, size and execution speed, and it's much easier to use the driver!
As usual, if you have any suggestion or if you made a porting of the driver and would like to share it, please contact me and I'll add your work to this post with the proper author credits.
LICENSE
The driver is released under GPL version 3 License
Make sure you read the License.txt file included in the archive or read it online here:
https://www.gnu.org/licenses/gpl.txt
DISCLAIMER
DOWNLOAD
You can download the driver from the attached zip file.