replica character liquid crystal display control
来源:互联网 发布:nginx ip映射域名 编辑:程序博客网 时间:2024/05/29 08:21
A replica CLCD module control.
Initiated on May 5, 2012
Updated on Feb 21, 2017
Copyright 2012-2017 Conmajia
Nobi's LCM Display
Simple Demo
Here is a demo screenplay of the LCM control. Just in case you understand what I'm talking 'bout.
Basic Background
Character liquid crystal display module (CLCD, or simply LCD/LCM) module is one of the display devices well used for electronic equipments.
Panel Organization
An LCM panel that displays alpha-numeric characters is controlled by its core controller chip like Hitachi's HD44780 or HD44100. Panels are organized in general as shown below.
Inside The Controller
Two things among all the hardware details that you should pay attention are the DDRAM and the CGRAM/CGROM.
DDRAM
DDRAM (display data RAM) is an 80-byte buffer which can hold up to 40 columns by 2 rows of display data. You change a DDRAM byte, you change that character on the screen.
CGRAM/CGROM
Character generator is formed by 2 parts: the CGRAM and the CGROM. With the character generator you can draw custom characters such as symbols, icons and simple Chinese characters.
Implementation
The LCD control is a standard WinForm control derived from the UserControl
class.
[ToolboxBitmap("Lcd\\lcd_logo.bmp")]public partial class DotMatrixLcd : UserControl
With a 2-D array stores all characters to display.
DotMatrixCharacter[][] characters;
A DotMatrixCharacter
represents the data of a character to display. I made this class aControl
so that it can do much more than storing data.
public class DotMatrixCharacter : Controlpublic byte Ddrampublic byte[] Cgrampublic char Character
Generate Character
A generator class is designed to return raw character data for the control.
public sealed class CharacterGenerator{ /// Get character data from DDRAM by address. public static byte[] GetDdram(byte address) { return charset[address]; } /// Get character data from DDRAM to match the given character. public static byte[] GetDdram(char character) { return charset[(byte)character]; } // 8 cgram chars static byte[][] cgram = new byte[8][]; // for dummy static byte[] emptyChar ={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /// Store character data in CGRAM registers by index. public static void SetCgram(byte[] data, int index) { if (data == null || data.Length != 8) return; if (index < 0 || index > 7) return; cgram[index] = data; } /// Get CGRAM character data by index. public static byte[] GetCgram(int index) { if (index < 0 || index > 7) return emptyChar; return cgram[index]; } // 256x8 bytes (1024 bytes) characters static readonly byte[][] charset = { // 0000 0000 new byte[]{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // 0000 0001 new byte[]{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },// ...
Now all the data is prepared.
Paint A Character
The characters renderer is inside the DotMatrixCharacter
control.
void drawBlocks(Graphics g){ byte[] charData; // check source of char to display for CGRAM support switch (charSource) { case DisplaySource.CGRAM: if (cgramData == null || cgramData.Length != DOT_ROWS) // invalid data, draw empty // all 0x00 charData = new byte[DOT_ROWS]; else charData = cgramData; break; case DisplaySource.DDRAM: default: charData = CharacterGenerator.GetDdram(ddramAddress); break; } // ready to draw byte mask; for (int i = 0; i < DOT_ROWS; i++) { // if use mask = 0x01 (right to left) // the output will be vertical mirrored mask = 0x01 << (DOT_COLS - 1); for (int j = 0; j < DOT_COLS; j++) { if ((mask & charData[i]) == 0) { // 0 - empty if (circleBlock) g.FillEllipse( inactiveBrush, j * (blockSize.Width + spacing), i * (blockSize.Height + spacing), blockSize.Width, blockSize.Height ); else g.FillRectangle( inactiveBrush, j * (blockSize.Width + spacing), i * (blockSize.Height + spacing), blockSize.Width, blockSize.Height ); } else { // 1 - fill if (circleBlock) g.FillEllipse( activeBrush, j * (blockSize.Width + spacing), i * (blockSize.Height + spacing), blockSize.Width, blockSize.Height ); else g.FillRectangle( activeBrush, j * (blockSize.Width + spacing), i * (blockSize.Height + spacing), blockSize.Width, blockSize.Height ); } // next bit //mask <<= 1; // msb to lsb mask >>= 1; } }}
With the built-in renderer, the final LCD module control can obtain the extensibility to switch between different display contents like character displays, graphic dot matrix display, etc.
Full Project Source & Demo Executive
You can download them here:
Project source code: → Click to download
Demo executive file: → Click to download
References
- How to Use Character LCD Module, elm-chan.org
keywords: LCD、LCM、液晶显示、编程、图形界面、硬件
- replica character liquid crystal display control
- replica character liquid crystal display control
- replica character liquid crystal display control
- replica character liquid crystal display control
- replica character liquid crystal display control
- replica character liquid crystal display control
- replica character liquid crystal display control
- liquid crystal display-液晶显示器
- Control character
- Unescaped control character around character
- Quorum-based voting for replica control
- Unescaped control character around character 344.
- Unescaped control character around character 189
- Display _RecordsetPtr via ListView control
- how to display chinese character properly
- unity3d碰撞之character control与rigidbody
- Embeddable Crystal Reports Designer Control Sample 源代码调试说明
- Crystal Image Toolkit: thumbnail image control and picture viewing.
- JVM内存配置详解
- AVL
- android 5.1源码 去除搜索栏
- Ural 1416 Confidential(最小生成树+次小生成树)
- MD5加密
- replica character liquid crystal display control
- 专访DeepID发明者孙祎:关于深度学习与人脸算法的深层思考
- struts2 文件上传
- PAT 1117 Eddington Number
- cron表达式用法说明
- HTTp缓存机制及原理
- 31届宁波市中小学生程序设计竞赛复赛(初中组)
- Js 获取url、字符串中特定参数的值
- Spring4 整合EhCache实现页面缓存 零配置