Swordfish Plugin - LCD Character Generator

mini_lcd_char_gen

18415060694522c931a03191A big thanks to Steven Wright for a great contribution to the Swordfish community.


Every now and then it's handy to have the ability to create a custom character to depict something other than that of the standard ASCII symbols. LCDs can have upto eight programmable characters in use at any one time. This handy plugin allows each character to be created by simple pixel-clicking.

Each character has a 5x8 grid which can be modified as to how you please. In the image below there are several custom characters which are destined to form a progress screen.

mt_nothumb:LCD_Char_Generator_4

 

The textbox below each character allows you to add a short description that will appear in the comment beside each row of the final constant array. Before pasting the final code into the Swordfish IDE, you may wish to change the 'Character set name' - this will become the name of the constant array. By exporting several constant arrays with different names, you can switch between several custom character sets in your final code.

 

Example Code

Swordfish LCD Character Generator Example
Device = 18F2520
Clock = 10
 
#option LCD_DATA = PORTB.4
#option LCD_RS = PORTB.2
#option LCD_EN = PORTB.3
Include "LCD.bas"
 
Const Progress(56) As Byte = ($0F,$10,$10,$10,$10,$10,$10,$0F, // LCD.Write(0) - LH0
$0F,$10,$13,$13,$13,$13,$10,$0F, // LCD.Write(1) - LH1
$1F,$00,$00,$00,$00,$00,$00,$1F, // LCD.Write(2) - M0
$1F,$00,$18,$18,$18,$18,$00,$1F, // LCD.Write(3) - M1
$1F,$00,$1B,$1B,$1B,$1B,$00,$1F, // LCD.Write(4) - M2
$1E,$01,$01,$01,$01,$01,$01,$1E, // LCD.Write(5) - RH0
$1E,$01,$19,$19,$19,$19,$01,$1E) // LCD.Write(6) - RH1
 
DelayMS(1000)
 
LCD.Write(Progress)
LCD.Write(0,1,2,3,4,5,6," ")
 
While True
Wend

 

Importing Existing Character Sets

Making alterations to custom characters is very easy. Simply highlight the constant data, and click [emphasisbold]Import from selected text[/emphasisbold]. The selected characters will load onto the plugin ready for editing.

If an error is encountered when importing from the IDE, ensure that you have the whole of the existing constant array selected first.

 

Installing the Plugin

[div class="download" class2="typo-icon"]Download LCD Programmable Chr Generator[/div]

[div class="alert" class2="typo-icon"]The plugin is built in Visual Basic 2008 Express. If you cannot run the plugin, you may need to install the DotNet  framework from this link.[/div]


Posted: 8 years 5 months ago by itheo92 #7250
itheo92's Avatar
A very nice and informative tutorial.
Posted: 8 years 5 months ago by MMcLaren #7254
MMcLaren's Avatar
With that tool, one might easily construct an 80 element table of the bitmap patterns for LCD characters '0' through '9' and use it to produce a "rolling speedometer" number LCD special effect.

In a nutshell, when it comes time to "roll" a number on the LCD display from let's say "8" to "9", you would replace the "8" character value (0x38) in DDRAM with the value for one of the user defined characters (0x00..0x07) and then you would write new eight byte patterns into the CGRAM for that user defined character eight times to produce the "rolling" effect. This a matter of selecting the correct index into the 80 element "0..9" pattern array, writing eight bytes from the array into CGRAM, pausing a short time, bumping the array index, and doing it again for a total of eight cycles. Then you would replace the user defined character (0x00..0x07) in DDRAM with the new value for "9" (0x39). It sounds much more complicated then it really is.

I should point out that since there are only eight user defined characters, you can only produce the "rolling" effect on eight display characters at any given time.

I've done this with assembly language but I thought you Swordfish gurus might enjoy producing your own simple elegant demo'.

Cheerful regards, Mike

Forum Activity

Member Access