Component: LCD (Generic) (Displays: Alphanumeric)
Author | Matrix Ltd |
Version | 2.4 (Development) |
Category | Displays: Alphanumeric |
Contents
LCD (Generic) component
Generic configurable alphanumeric LCD display component based on the standard Hitachi HD44780 controller IC wiith selectable 4/8 bit interface
This component can be used as a base to create child components
The following components all inherit the traits of LCD (Generic):
Combo Board (EB083) | A simulated version of the EB083 Combo board including LEDs, Switches, LCD, 7-Segs
and analogue inputs. |
LCD (Generic, 20x4) | LCD based on the standard 4 x 20 character unit. |
LCD (EB005, 16x2) | LCD based on the unit used in the Matrix EB005 E-block |
LCD (Grove _ UART) | Standard alphanumeric LCD based on the Grove display module. |
LCD (Grove _ I2C) | Standard alphanumeric LCD based on the Grove I2C LCD module with RGB backlight. |
LCD (I2C) | Standard alphanumeric LCD based on a standard I2C control bus. |
Examples
Connections
For the LCDs to work with the Flowcode LCD component they need to be connected up in 4-bit data mode.
The 4 data signals actually go to the upper data nibble on the LCD as shown below.
Displaying a numeric value
The LCD will retain the contents of the display, for high speed data we only want to have to write to the portion of the display that can change. LCD Demo
Downloadable macro reference
Clear
Clears the entire contents of the display.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
PrintString
Breaks down a string of text and sends it to the LCD via the private RawSend(byte, mask) macro
Parameters
- <- STRING Text
- Enter the text or variable to print to the LCD
- This parameter may be returned back to the caller
Return value
- This call does not return a value
PrintAscii
Takes the ascii value for a character and prints the character
Parameters
- BYTE character
- Holds an ascii value.
Return value
- This call does not return a value
PrintNumber
Based on v5 macro, will allow you to print a number. This is limited to a signed-INT, -32768 to 32767
Parameters
- INT Number
- Enter the number or variable to print to the LCD
Return value
- This call does not return a value
RAMWrite
Modifies the internal memory of the LCD to allow for up to 8 customised characters to be created and stored in the device memory
Parameters
- BYTE Index
- Values 0 to 7
- BYTE d0
- BYTE d1
- BYTE d2
- BYTE d3
- BYTE d4
- BYTE d5
- BYTE d6
- BYTE d7
Return value
- This call does not return a value
ClearLine
Clears a single line on the display and then moves the cursor to the start of the line to allow you to start populating the line with data.
Parameters
- BYTE Line
- The line to clear, zero being the first (top) line of the display
Return value
- This call does not return a value
Cursor
Moves the cursor on the LCD Display
Parameters
- BYTE x
- Set the cursor position in the X plane, 0 is the left most cell
- BYTE y
- Set the cursor position in the Y plane, 0 is the top most cell
Return value
- This call does not return a value
Command
Use this method/macro to send a specific command to the LCD. Refer to the Matrix Multimedia EB006 datasheet for a list of supported instructions. For Non-Matrix LCD's refer to the manufacturers datasheet.
Parameters
- BYTE instruction
- Send a defined command to the LCD Screen. See datasheet for supported commands.
Return value
- This call does not return a value
PrintFormattedNumber
Will allow you to print a number up to 32-bits with signed or unsigned formatting.
Signed = -2147483648 to 2147483647
Unsigned = 0 to 4294967295
Parameters
- ULONG Number
- Enter the number or variable to print to the LCD
- BOOL Format
- 0=Signed, 1=Unsigned
Return value
- This call does not return a value
ScrollDisplay
Scrolls the display left or right by a number of given positions.
Parameters
- BYTE Position
- Holds the number of positions to shift the display
- BYTE Direction
- 0 = left, 1 = right
Return value
- This call does not return a value
RawSend
Sends data to the LCD display
Parameters
- BYTE data
- The data byte to send to the LCD
- BOOL type
- A boolean to indicate command type: true to write data, false to write a command
Return value
- This call does not return a value
RemapCharacter
Assigns a remap character allowing the PrintString function to automatically swap between pre-defined characters.
The characters can be custom (in the range 0-9) or can point to an existing character in the LCD character map.
Parameters
- BYTE RemapIdx
- Remap Index, Range: 0 to (Remap Characters - 1)
- BYTE SearchCharacter
- Character to look for a replace
- BYTE ReplacementCharacter
- New character value to use in place of the search character.
Return value
- This call does not return a value
Start
Startup routine required by the hardware device.
Automatically clears the display after initialising.
Parameters
- This macro has no parameters
Return value
- This call does not return a value
Simulation macro reference
This component does not contain any simulation macros
Property reference
Interface mode
This property is of type Fixed list of ints and can be referenced with the variable name LCD_Mode.
Choose between 4-bit mode, 8-bit mode and 8-bit mode using a port instead of individual pins to improve code efficiency.
Data 0 (11 / 7)
This property is of type Single digital pin and can be referenced with the variable name Pin_Data_0.
Data pin 0 - Connects to Data 4 on the hardware in 4-bit mode or Data 0 in 8-bit mode
Data 1 (12 / 8)
This property is of type Single digital pin and can be referenced with the variable name Pin_Data_1.
Data pin 1 - Connects to Data 5 on the hardware in 4-bit mode or Data 1 in 8-bit mode
Data 2 (13 / 9)
This property is of type Single digital pin and can be referenced with the variable name Pin_Data_2.
Data pin 2 - Connects to Data 6 on the hardware in 4-bit mode or Data 2 in 8-bit mode
Data 3 (14 / 10)
This property is of type Single digital pin and can be referenced with the variable name Pin_Data_3.
Data pin 3 - Connects to Data 7 on the hardware in 4-bit mode or Data 3 in 8-bit mode
Register Select (4)
This property is of type Single digital pin and can be referenced with the variable name Pin_RS.
Register Select Pin - Informs the display if a command or data is about to be sent.
Enable (6)
This property is of type Single digital pin and can be referenced with the variable name Pin_E.
Enable pin - Used to synchronise data writes to the display
Use Read/Write Pin
This property is of type True or false and can be referenced with the variable name LCD_Use_Write.
Set to "true" if the displays R/W pin is not hard wired. Set to "false" if the R/W pin is wired to ground.
Rows
This property is of type Fixed list of ints and can be referenced with the variable name Rows.
Number of lines of characters the LCD can display.
Columns
This property is of type Fixed list of ints and can be referenced with the variable name Columns.
Number of characters the LCD can display on a single line.
Remap Characters
This property is of type Unsigned integer and can be referenced with the variable name RemapCharacters.
Used to allow characters to be replaced with alternate characters.
Custom characters or characters from the LCD memory map can be used as replacements.
Each replacement consumes two bytes of RAM memory and is applied automatically when printing strings.
Delay Timings
This property is of type Unsigned integer and can be referenced with the variable name DelayTiming.
Delay in microseconds used in the display send function.
Most displays will work with the default value of 100us.
Some displays may need a slightly longer delay, 166us is known to work well.
Background Color
This property is of type Color picker and can be referenced with the variable name BackgroundColor.
Simulation only background colour, the actual hardware will have a fixed colour
Line Color
This property is of type Color picker and can be referenced with the variable name LineColor.
Simulation only line colour, the actual hardware will have a fixed colour
Text Color
This property is of type Color picker and can be referenced with the variable name TextColor.
Simulation only text colour, the actual hardware will have a fixed colour
Font
This property is of type Font picker and can be referenced with the variable name Font.
Font to use for simulation, the actual hardware will have a inbuilt fixed font.