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

  1. How to Use Character LCD Module, elm-chan.org

📟 Character Liquid Crystal Display Control (English)的更多相关文章

  1. 液晶顯示器 LCD (Liquid Crystal Disply )

    常見的液晶顯示器按物理結構分為四種: (1)扭曲向列型(TN-Twisted Nematic): (2)超扭曲向列型(STN-Super TN): (3)雙層超扭曲向列型(DSTN-Dual Scan ...

  2. 📉 Draggable Curve Control (English)

    Conmajia 2012 Updated on Feb. 18, 2018 In Photoshop, there is a very powerful feature called Curve A ...

  3. A GDI+ Based Character LCD Control

    This is a renew. A GDI+ Based Character LCD Control by Conmajia Character liquid crystal display (LC ...

  4. 字符型液晶屏模拟控件(En)

    A replica CLCD module control. Initiated on May 5, 2012 Updated on Feb 21, 2017 Copyright 2012-2017 ...

  5. Display controller

    Field of the Invention The present invention relates to a display controller. Background to the inve ...

  6. 模式识别之ocr项目---(模板匹配&BP神经网络训练)

    摘 要 在MATLAB环境下利用USB摄像头采集字符图像,读取一帧保存为图像,然后对读取保存的字符图像,灰度化,二值化,在此基础上做倾斜矫正,对矫正的图像进行滤波平滑处理,然后对字符区域进行提取分割出 ...

  7. 字符识别OCR研究一(模板匹配&amp;BP神经网络训练)

    摘 要 在MATLAB环境下利用USB摄像头採集字符图像.读取一帧保存为图像.然后对读取保存的字符图像,灰度化.二值化,在此基础上做倾斜矫正.对矫正的图像进行滤波平滑处理,然后对字符区域进行提取切割出 ...

  8. 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, ...

  9. 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 ...

随机推荐

  1. Entity framework 中Where、First、Count等查询函数使用时要注意

    在.Net开发中,Entity framework是微软ORM架构的最佳官方工具.我们可以使用Lambda表达式在Entity framework中DbSet<T>类上直接做查询(比如使用 ...

  2. JS URI Encode

    javascript中存在几种对URL字符串进行编码的方法:escape/encodeURI/encodeURIComponent.这几种编码所起的作用各不相同. escape 采用ISO Latin ...

  3. union 时只能查出一个表中的信息,另一个表只能查出字段

    原因:news表中title字段的编码,与brand表中的编码不一致导致 y

  4. CSAPP 第二章随笔

    类型转换问题 (1)int -> short 二进制位高位截断,低位保持不变 (2)同类型 unsign -> sign 记住二进制位是不变的 (3)P101页提到的编译器乘法优化问题,一 ...

  5. 豹哥嵌入式讲堂:ARM Cortex-M开发之文件详解(8)- 镜像文件(.bin/.hex/.s19)

    大家好,我是豹哥,猎豹的豹,犀利哥的哥.今天豹哥给大家讲的是嵌入式开发里的image文件(.bin, .hex, .s19). 今天这节课是豹哥<ARM Cortex-M开发之文件详解>主 ...

  6. java垃圾回收的分类

    1.线程数 分为串行垃圾回收器和并行垃圾回收器.串行垃圾回收器一次只使用一个线程进行垃圾回收:并行垃圾回收器一次将开启多个线程同时进行垃圾回收.在并行能力较强的 CPU 上,使用并行垃圾回收器可以缩短 ...

  7. SQLITE3 使用总结(3~5)(转)

    3 不使用回调查询数据库/ `- ^# T6 ?, F: H* m2 ~# ~上 面介绍的 sqlite3_exec 是使用回调来执行 select 操作.还有一个方法可以直接查询而不需要回调.但是, ...

  8. s​q​l​i​t​e​3​-​入​门​教​程

    *** 非常好 http://wenku.baidu.com/link?url=xDoS4prJaGRac0QS0nxdNr6056N-qJIfZ7OhiTharj1ntuIsNy9sWXWvBXLh ...

  9. 微调数据库表结构,30 分钟搞定 WordPress 数据库查询缓慢问题

    同事的美女图片站,基于 WordPress 搭建的,因为数据越来越多,变得慢,我从 PHP slow log 里面看出是 WordPress 有些查询总是很慢,即使已经安装了页面缓存插件,但是由于页面 ...

  10. ajax和跨域

    一.简介 ajax是什么? AJAX(Asynchronous JavaScript and XML) 是一种在无需重新加载整个网页的情况下,能够更新部分网页的技术. AJAX, (异步的JavaSc ...