Module lcd_example::lib::lcd_utils
source · Expand description
JHD162A LCD Driver [By: Jonathan Zurita]
§Detailed Introduction
Welcome! This is the JHD162A LCD Driver documentation! There are three key components to this build:
- Initializing LCD display
-
Writing
static &str
andchar
arrays to LCD - Converting non-char types into characters
Each component will be explained in-depth, including design and implementation choices by the author
§Question 1) Why convert float to a char array?
I personally believed that displaying certain float values such as ADC readings or other fine-tuned data could be proven useful. Therefore, I included a float-to-char function out of the box!
However, the function float_to_array
only supports up to 2 decimal places in accuracy.
§Question 2) Why is it solely in 8-bit mode?
Originally, I started on developing a JHD162A LCD Driver for the STM32F4 series. I started development in 4-bit mode, saving precious gpio pins. However, I decided to take a different route and try out 8-bit mode for the LCD driver.Thankfully the 8-bit mode technically can transmit new characters at a faster rate. Depends mostly your situation (desired rate of data transmission).
§Question 3) Are there next steps in development?
Possible next steps would be to implement a 4-bit mode. Another thing would be to create a example folder? lcd_example.rs should contain an example of analog pin 0 being read and displayed on LCD screen.
Constants§
- Provided in order to convert u8 into proper ASCII char
- BIT_0 🔒BIT_0 through BIT_7 are bit masks in order to process the ASCII char parameter
- BIT_1 🔒
- BIT_2 🔒
- BIT_3 🔒
- BIT_4 🔒
- BIT_5 🔒
- BIT_6 🔒
- BIT_7 🔒
- D0_PIN 🔒
- D1_PIN 🔒
- D2_PIN 🔒
- D3_PIN 🔒
- D4_PIN 🔒
- D5_PIN 🔒
- D6_PIN 🔒
- D7_PIN 🔒
- LED_PIN 🔒All pin macro numbers correspond to their respective index the in the gpio array in main()
- Maximum length for one row of characters
- MS_DELAY 🔒Arbitrary value, user-defined
Functions§
- Clears all data pins (D0-D7)
- Function converts a
f32
into a[char]
array in order to be processed by the LCD display - Clears the LCD display, and sets the cursor back to the beginning
- Fills whole LCD display with characters as a test
- Writes a
[char]
array to the LCD display - Writes a static
&str
to the LCD display