📟 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 ...
随机推荐
- Vs自定义设置
1.固定选项卡独立行显示设置 效果如下 2.语言设置 可以从官网寻找所需版本语言包 https://my.visualstudio.com/downloads 3.代码段设置 可以对现有的进行一些改造 ...
- 【转自知乎】:localhost、127.0.0.1 和 本机IP 三者的区别?
作者:知乎用户链接:https://www.zhihu.com/question/23940717/answer/26230963来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...
- Hive_UDF函数中集合对象初始化的注意事项
UDF函数中定义的集合对象何时初始化 udf函数放在sql中对某个字段进行处理,那么在底层会创建一个该类的对象,这个对象不断的去调用这个evaluate(...)方法,截图如下: 1.1 如果说对 ...
- 如何在vue里面访问php?
如果你选择前端使用vue框架,后端用PHP开发,服务器就不用node了,用Apache就好了 开发中,看你是否想进行前后端的分离.如果你不想进行前后端的分离,可以将vue的项目build之后放到php ...
- IIS 发布 dedecms 网站教程
这里只是说明了配置 php 前后 iis 默认网站属性的变化,其实在配置完 php 后系统的环境变 量等也是发生了相应的变化了的, 这里就不一一列举了, 这些只有在你手动完成 php 的配置 之后才能 ...
- LNMP 与 LAMP 架构的区别及配置解决方案
2014-12-31 10:33| 发布者: digitser| 查看: 5618| 评论: 0|原作者: liangsheng 摘要: LNMP 与 LAMP 架构的区别及配置解决方案 LNMP 的 ...
- Python3 引入模块的方法
例子 import random 产生随机整数 import random secret = random.randint(0,10)
- ASP.NET网络爬虫小研究 HtmlAgilityPack基础,爬取数据保存在数据库中再显示再自己的网页中
1.什么是网络爬虫 关于爬虫百度百科这样定义的:网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本.另外一些 ...
- <%=pageCount %>
<%=pageCount %>,这里是指获取页面控件的值.
- 5分钟把任意网站变成桌面软件--windows版
本文源自于segmentfault的一篇专栏文章:https://segmentfault.com/a/1190000012924855 只不过这篇是MAC版本的,所以我试了下windows版的: ...