字符型液晶屏模拟控件(En)
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 a Control so that it can do much more than storing data.
public class DotMatrixCharacter : Control
public byte Ddram
public byte[] Cgram
public 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
字符型液晶屏模拟控件(En)的更多相关文章
- CAD全屏显示控件
主要用到函数说明: MxDrawXCustomFunction::Mx_FullScreen 全屏显示控件,详细说明如下: 参数 说明 int iFull = 2 0: 不完屏,1:全屏,2:自动切换 ...
- 基于stm32f4的ucGUI通过外部flash存储汉字库显示任意英文字符和汉字组合(控件可用)
在做一个用到ucGUI的项目的时候要用到不定的汉字和英文字符,但是ucGUI本身又不支持读取芯片外部flash的字库来显示,于是查了下资料,如下: http://www.cnblogs.com/hik ...
- 模拟winform里的控件的事件和委托机制
参考:.NET 中的委托 委托的两大用处 1.委托可以实现方法作为参数进行传递,如 /// <summary> /// the English speaker. /// </summ ...
- C#在截屏时将截屏之前需要隐藏的控件也截入
最近我在项目中遇到一个让我十分头疼的问题,就是我在截屏时也将截屏之前隐藏的控件也截入了. 情况:我在Winform窗体有个截屏功能按钮,实现在调用WPF全屏后截屏,但在截屏WPF界面前将界面里的一个L ...
- Android 中常见控件的介绍和使用
1 TextView文本框 1.1 TextView类的结构 TextView 是用于显示字符串的组件,对于用户来说就是屏幕中一块用于显示文本的区域.TextView类的层次关系如下: java.la ...
- Android 控件属性介绍
1.LinearLayout(线性布局): 可以分为水平线性:android:orientation= " horizontal " 和垂直线性:android:orientati ...
- 银行支票和汇票中使用的专用字体MICR E13B条形码控件字体
MICR E13B条形码控件字体是一种在美国.加拿大.波多黎各.巴拿马.英国和其它少数国家的银行支票和汇票中使用的专用字体,主要用来打印适用于磁性和光学字符识别系统的MICR字符.MICR E13B条 ...
- MFC中树控件CTreeCtrl的用法
树形控件可以用于树形的结构,其中有一个根接点(Root)然后下面有许多子结点,而每个子结点上有允许有一个或多个或没有子结点.MFC中使用CTreeCtrl类来封装树形控件的各种操作.通过调用 BOOL ...
- windows 编程 —— 子窗口 与 子窗口控件
目录: 子窗口与主窗口的交互 子窗口控件 按钮类别 button 滚动条类别 scrollbar 静态类别 static 编辑框类别 edit 清单方块 listbox 子窗口与主窗口的交互 创建窗 ...
随机推荐
- BZOJ_2792_[Poi2012]Well_二分答案
BZOJ_2792_[Poi2012]Well_二分答案 Description 给出n个正整数X1,X2,...Xn,可以进行不超过m次操作,每次操作选择一个非零的Xi,并将它减一. 最终要求存在某 ...
- keepalived工作原理和配置说明
keepalived是什么 keepalived是集群管理中保证集群高可用的一个服务软件,其功能类似于heartbeat,用来防止单点故障. keepalived工作原理 keepalived是以VR ...
- 【爆料】-《西澳大学毕业证书》UWA一模一样原件
☞西澳大学毕业证书[微/Q:2544033233◆WeChat:CC6669834]UC毕业证书/联系人Alice[查看点击百度快照查看][留信网学历认证&博士&硕士&海归&a ...
- Postman-----如何导入和导出
此处介绍2种导出和导入的操作方法,一种是通过分享link,另一种是导出json文件,再次导入,个人推荐link的方式,简单方便,下面将详细介绍. 第一种:分享链接,导入链接的方式 1.1.生成link ...
- RPC基于http协议通过netty支持文件上传下载
本人在中间件研发组(主要开发RPC),近期遇到一个需求:RPC基于http协议通过netty支持文件上传下载 经过一系列的资料查找学习,终于实现了该功能 通过netty实现文件上传下载,主要在编解码时 ...
- 前端笔记之NodeJS(三)Express&ejs模板引擎&请求识别
一.Express框架 1.1基本使用 创建http服务器特别麻烦,express框架解决了这个的问题. Express在node界的地位,就相当于jQuery在DOM界的地位.jQuery的核心就是 ...
- Java进阶篇设计模式之六 ----- 组合模式和过滤器模式
前言 在上一篇中我们学习了结构型模式的外观模式和装饰器模式.本篇则来学习下组合模式和过滤器模式. 组合模式 简介 组合模式是用于把一组相似的对象当作一个单一的对象.组合模式依据树形结构来组合对象,用来 ...
- C#编写扫雷游戏
翻看了下以前大学学习的一些小项目,突然发现有个项目比较有意思,觉得有必要把它分享出来.当然现在看来,里面有很多的不足之处,但因博主现在已经工作,没有时间再去优化.这个项目就是利用C#编写一个Windo ...
- Hello World 程序的起源与历史
这是一个最著名的程序.对每一位程序员来说,这个程序几乎是每一门编程语言中的第一个示例程序.那么,这个著名的程序究竟从何而来呢? 实际上,这个程序的功能只是告知计算机显示 Hello World 这句话 ...
- RFI to RCE challenge
http://www.zixem.altervista.org/RCE/level1.php 构造payload: https://zixem.altervista.org/RCE/level1.ph ...