📟 Character Liquid Crystal Display Control (English)
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
📟 Character Liquid Crystal Display Control (English)的更多相关文章
- 液晶顯示器 LCD (Liquid Crystal Disply )
常見的液晶顯示器按物理結構分為四種: (1)扭曲向列型(TN-Twisted Nematic): (2)超扭曲向列型(STN-Super TN): (3)雙層超扭曲向列型(DSTN-Dual Scan ...
- 📉 Draggable Curve Control (English)
Conmajia 2012 Updated on Feb. 18, 2018 In Photoshop, there is a very powerful feature called Curve A ...
- A GDI+ Based Character LCD Control
This is a renew. A GDI+ Based Character LCD Control by Conmajia Character liquid crystal display (LC ...
- 字符型液晶屏模拟控件(En)
A replica CLCD module control. Initiated on May 5, 2012 Updated on Feb 21, 2017 Copyright 2012-2017 ...
- Display controller
Field of the Invention The present invention relates to a display controller. Background to the inve ...
- 模式识别之ocr项目---(模板匹配&BP神经网络训练)
摘 要 在MATLAB环境下利用USB摄像头采集字符图像,读取一帧保存为图像,然后对读取保存的字符图像,灰度化,二值化,在此基础上做倾斜矫正,对矫正的图像进行滤波平滑处理,然后对字符区域进行提取分割出 ...
- 字符识别OCR研究一(模板匹配&BP神经网络训练)
摘 要 在MATLAB环境下利用USB摄像头採集字符图像.读取一帧保存为图像.然后对读取保存的字符图像,灰度化.二值化,在此基础上做倾斜矫正.对矫正的图像进行滤波平滑处理,然后对字符区域进行提取切割出 ...
- Method for address space layout randomization in execute-in-place code
The present application relates generally to laying out address space for execute-in-place code and, ...
- Method and apparatus for encoding data to be self-describing by storing tag records describing said data terminated by a self-referential record
A computer-implemented method and apparatus in a computer system of processing data generated by a f ...
随机推荐
- C++ 不定参数(转)
转自:http://www.cnblogs.com/jerrychenfly/archive/2010/10/22/1858232.html 下面,我们来看一下,如果在c++的函数中接收数量不定的函数 ...
- console.log()的作用是什么
主要是方便你调式javascript用的.你可以看到你在页面中输出的内容. 相比alert他的优点是: 他能看到结构话的东西,如果是alert,淡出一个对象就是[object object],但是co ...
- vue-cli脚手架的.babelrc文件 详解
{ // 此项指明,转码的规则 "presets": [ // env项是借助插件babel-preset-env,下面这个配置说的是babel对es6,es7,es8进行转码,并 ...
- C#编写影院售票系统(A project with a higher amount of gold )(2:相关代码)
此篇文章为项目代码,,,需要项目需求 ,思路分析与窗体效果请访问:http://www.cnblogs.com/lsy131479/p/8367304.html 项目类图: 影院类: using Sy ...
- 将js进行到底:node学习笔记2
node重要API之FS--CLI编程初体验 所谓的"fs"就是file system! 当下几乎任何一门编程语言都会提供对文件系统读写的API,比如c语言的open()函数. 而 ...
- android 基础02 - Activity 的生命周期及状态
返回栈 Android 中的 Activity 是可以层叠的,当我们启动一个新的 Activity 时,就会覆盖在原有的 Activity 之上, 点击 Back 会销毁当前 Activity,下面的 ...
- redux学习日志:关于react-redux
首先先强调一句:一定要多读官方文档,而且要精读,否则你会忽略掉很多东西! 一,Provider 刚开始看的时候,大致浏览了一下,知道了这个组件是能够接收store作为它的属性,然后它里面的子组件就可以 ...
- IronFort---基于Django和Websocket的堡垒机
WebSSH有很多,基于Django的Web服务也有很多,使用Paramiko在Python中进行SSH访问的就更多了.但是通过gevent将三者结合起来,实现通过浏览器访问的堡垒机就很少见了.本文将 ...
- 2017-06-20 (pwd ls cd)
pwd pwd 显示当前所在的位置 pwd -P 如果是链接文件,显示链接文件所指的位置 ls ls 查询目录中的内容 ls -a 显示所有的文件,包含隐藏的文件 -l 显示详细的信息 ...
- Django 模版中如何对主菜单进行选中?
问题描叙: 在实际模版中,返回的页面我们想要主菜单保持一种状态,这个主菜单进去的子页面,都需要保持主菜单选择状态 例如 主菜单是 课程, 下面展现的章节和视频页面时候, 课程这个主菜单在展现这个菜单下 ...