📟 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 ...
随机推荐
- WebClient.DownLoadString报错:连接被意外关闭
调用WebClient的DownLoadString方法调用接口,当数据量比较小的时候(十几条数据)一切正常.后来对方突然放了一千多条数据,然后就报错了:连接被意外关闭. 先是以为是对方接口没有在输出 ...
- PHP条件语句if的使用
方法/步骤 if(条件){是否执行的代码...}:这样的用法常用于判断单一条件,当然,可以可以用逻辑符号将多个条件组合成同一条件. if else语句:如果条件不成立,就会执行else后面{}里的代码 ...
- ip 百度地图 php
已知一个IP $ipname=api_hits($DT_IP); -------------- //apifunction getAddressComponent($ak, $longitude, $ ...
- 阿里巴巴Java开发手册评
2016年底的时候阿里巴巴公开了其在内部使用的Java编程规范.随后进行了几次版本修订,目前的版本为v1.0.2版.下载地址可以在其官方社区-云栖社区https://yq.aliyun.com/art ...
- Python自建logging模块
本章将介绍Python内建模块:日志模块,更多内容请从参考:Python学习指南 简单使用 最开始,我们用最短的代码体验一下logging的基本功能. import logging logger = ...
- 2017-06-28(passwd 主要组与附属组 gpasswd newgrp groups)
passwd passwd -l 用户名 (锁定用户) passwd -u 用户名 (解锁用户) passwd -d 用户名 (清楚用户密码) 主要组与附属组 一个用户可以同时属于多个组,其中一个 ...
- 关于今天esp8266运行失控问题和oled与串口共存尝试成功的总结
今天2017-12-1720:24:22下午esp8266再次无法刷入固件,导致我一度崩溃,本来已经认为esp8266已经相当稳定了,没想到今天又运行出错,总结如下 今天2017-12-17esp无法 ...
- Linux PHP多版本切换 超简单办法
今天在帮别人安装一个不知所谓的东西时碰到,三版本的PHP环境,我感觉那个人也是666哒,他使用的是AMH快速开发工具 有图有真相!!! 然后就顺便写下怎么快速,简便切换php版本 首先:find命令找 ...
- linkin大话数据结构--Collection和Iterator
linkin大话数据结构--Collection和Iterator Java 集合就像一种容器,可以把多个对象的引用放入容器中.Java 集合类可以用于存储数量不等的多个对象,还可用于保存具有映射关系 ...
- PHP 运行 php-fpm 报错
报错如下: [27-Aug-2017 18:34:23] WARNING: Nothing matches the include pattern '/usr/local/php/etc/php- ...