Class LcdCharacterEncodingFactory
Factory for creating Encodings that support different cultures on different LCD Displays.
public class LcdCharacterEncodingFactory
- Inheritance
-
LcdCharacterEncodingFactory
Constructors
LcdCharacterEncodingFactory()
public LcdCharacterEncodingFactory()
Methods
ConvertFont5to8bytes(SpanByte)
Convert a 5 bytes array with 8 bits vertically encoded character representation into a 8 bytes array with the lower 5 bits.
public static byte[] ConvertFont5to8bytes(SpanByte font5)
Parameters
font5
SpanByteA span of bytes, must be 5 bytes length
Returns
- byte[]
A 8 bytes array containing the character
ConvertFont8to5bytes(SpanByte)
Convert a 8 bytes array with 5 lower bit character representation into a 5 bytes array with all bit character representation vertically ordered.
public static byte[] ConvertFont8to5bytes(SpanByte font8)
Parameters
font8
SpanByteA span of bytes, must be 8 bytes length
Returns
- byte[]
A 5 bytes array containing the character
Create(string, string, char, int)
Creates the character mapping optimized for the given culture. Checks whether the characters required for a given culture are available in the installed character map and tries to add them as user-defined characters, if possible.
public LcdCharacterEncoding Create(string culture, string romName, char unknownLetter, int maxNumberOfCustomCharacters)
Parameters
culture
stringCulture for which support is required
romName
stringROM type of attached chip. Supported values: "A00", "A02", "SplC780"
unknownLetter
charLetter that is printed when an unknown character is encountered. This letter must be part of the default rom set
maxNumberOfCustomCharacters
intMaximum number of custom characters supported on the hardware. Should be 8 for Hd44780-controlled displays.
Returns
- LcdCharacterEncoding
The newly created encoding. Whether the encoding can be loaded to a certain display will be decided later.
Exceptions
- ArgumentException
The character specified as unknownLetter must be part of the mapping.
CreateCustomCharacter(byte, byte, byte, byte, byte, byte, byte, byte)
Combines a set of bytes into a pixel map
protected byte[] CreateCustomCharacter(byte byte0, byte byte1, byte byte2, byte byte3, byte byte4, byte byte5, byte byte6, byte byte7)
Parameters
Returns
- byte[]
Examples
Use as follows to create letter 'ü':
CreateCustomCharacter(
0b_01010,
0b_00000,
0b_10001,
0b_10001,
0b_10001,
0b_10011,
0b_01101,
0b_00000)
CreateLetter(char, string)
Creates the given letter for the given ROM type. Overwrite this only if an alternate ROM is used.
protected virtual byte[]? CreateLetter(char character, string romName)
Parameters
Returns
- byte[]
CreateLetterA00(char)
Creates the given letter from a pixel map for Rom Type A00 (7-pixel high letters, bottom row empty)
protected virtual byte[]? CreateLetterA00(char character)
Parameters
character
charCharacter to create
Returns
- byte[]
An 8-Byte array of the pixel map for the created letter.
Remarks
Currently requires the characters to be hardcoded here. Would be nice if we could generate the pixel maps from an existing font, such as Consolas
CreateLetterA02(char)
Creates the given letter from a pixel map for Rom Type A02 (7 or 8 Pixel high letters, bottom row filled)
protected virtual byte[]? CreateLetterA02(char character)
Parameters
character
charCharacter to create
Returns
- byte[]
An 8-Byte array of the pixel map for the created letter.
Remarks
Currently requires the characters to be hardcoded here. Would be nice if we could generate the pixel maps from an existing font, such as Consolas
SpecialLettersForCulture(string, DictionaryCharByte)
Returns the set of special characters required for a given culture/language. This may include diacritics (ä, ö, ø), currency signs (€) or similar chars. If any of the returned characters are not found in the ROM map, CreateLetter(char, string) is called to obtain the pixel representation of the given character. A maximum of 8 extra characters can be added to the ones in the ROM.
protected virtual string SpecialLettersForCulture(string culture, DictionaryCharByte characterMapping)
Parameters
culture
stringCulture to support
characterMapping
DictionaryCharByteThe character map, pre-loaded with the characters from the character ROM. This may be extended by explicitly adding direct mappings where an alternative is allowed (i.e. mapping capital diacritics to normal capital letters É -> E, when there's not enough room to put É into character RAM.
Returns
- string
A string with the set of special characters for a language, i.e. "äöü߀ÄÖÜ" for German