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.

  1. [ToolboxBitmap("Lcd\\lcd_logo.bmp")]
  2. public partial class DotMatrixLcd : UserControl

With a 2-D array stores all characters to display.

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

  1. public class DotMatrixCharacter : Control
  2. public byte Ddram
  3. public byte[] Cgram
  4. public char Character

Generate Character

A generator class is designed to return raw character data for the control.

  1. public sealed class CharacterGenerator {
  2. /// Get character data from DDRAM by address.
  3. public static byte[] GetDdram(byte address) {
  4. return charset[address];
  5. }
  6. /// Get character data from DDRAM to match the given character.
  7. public static byte[] GetDdram(char character) {
  8. return charset[(byte) character];
  9. }
  10. // 8 cgram chars
  11. static byte[][] cgram = new byte[8][];
  12. // for dummy
  13. static byte[] emptyChar = {
  14. 0x00,
  15. 0x00,
  16. 0x00,
  17. 0x00,
  18. 0x00,
  19. 0x00,
  20. 0x00,
  21. 0x00
  22. };
  23. /// Store character data in CGRAM registers by index.
  24. public static void SetCgram(byte[] data, int index) {
  25. if (data == null || data.Length != 8) return;
  26. if (index < 0 || index > 7) return;
  27. cgram[index] = data;
  28. }
  29. /// Get CGRAM character data by index.
  30. public static byte[] GetCgram(int index) {
  31. if (index < 0 || index > 7) return emptyChar;
  32. return cgram[index];
  33. }
  34. // 256x8 bytes (1024 bytes) characters
  35. static readonly byte[][] charset = {
  36. // 0000 0000
  37. new byte[] {
  38. 0x00,
  39. 0x00,
  40. 0x00,
  41. 0x00,
  42. 0x00,
  43. 0x00,
  44. 0x00,
  45. 0x00
  46. },
  47. // 0000 0001
  48. new byte[] {
  49. 0x00,
  50. 0x00,
  51. 0x00,
  52. 0x00,
  53. 0x00,
  54. 0x00,
  55. 0x00,
  56. 0x00
  57. },
  58. // ...

Now all the data is prepared.

Paint A Character

The characters renderer is inside the DotMatrixCharacter control.

  1. void drawBlocks(Graphics g) {
  2. byte[] charData;
  3. // check source of char to display for CGRAM support
  4. switch (charSource) {
  5. case DisplaySource.CGRAM:
  6. if (cgramData == null || cgramData.Length != DOT_ROWS)
  7. // invalid data, draw empty
  8. // all 0x00
  9. charData = new byte[DOT_ROWS];
  10. else charData = cgramData;
  11. break;
  12. case DisplaySource.DDRAM:
  13. default:
  14. charData = CharacterGenerator.GetDdram(ddramAddress);
  15. break;
  16. }
  17. // ready to draw
  18. byte mask;
  19. for (int i = 0; i < DOT_ROWS; i++) {
  20. // if use mask = 0x01 (right to left)
  21. // the output will be vertical mirrored
  22. mask = 0x01 << (DOT_COLS - 1);
  23. for (int j = 0; j < DOT_COLS; j++) {
  24. if ((mask & charData[i]) == 0) {
  25. // 0 - empty
  26. if (circleBlock) g.FillEllipse(inactiveBrush, j * (blockSize.Width + spacing), i * (blockSize.Height + spacing), blockSize.Width, blockSize.Height);
  27. else g.FillRectangle(inactiveBrush, j * (blockSize.Width + spacing), i * (blockSize.Height + spacing), blockSize.Width, blockSize.Height);
  28. } else {
  29. // 1 - fill
  30. if (circleBlock) g.FillEllipse(activeBrush, j * (blockSize.Width + spacing), i * (blockSize.Height + spacing), blockSize.Width, blockSize.Height);
  31. else g.FillRectangle(activeBrush, j * (blockSize.Width + spacing), i * (blockSize.Height + spacing), blockSize.Width, blockSize.Height);
  32. }
  33. // next bit
  34. //mask <<= 1;
  35. // msb to lsb
  36. mask >>= 1;
  37. }
  38. }
  39. }

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

    <a href="#"></a>点击浏览器会跳转地址栏加了#:<a href=""></a>点击会打开当前网页所 ...

  2. LED服务总结

    简单的程序总结 一个简单的用于控制LED屏幕的小程序,用到的一个常识 LED服务开发总结 系统运行截图   系统功能说明: 1.ServerStrack服务,提供前台访问. 2.动态库调用,用于信息转 ...

  3. MyCat 启蒙:分布式系统的数据库架构演变

    文章首发于[博客园-陈树义],点击跳转到原文<MyCat 启蒙:分布式系统的数据库架构演变> 单数据库架构 一个项目在初期的时候,为了尽可能快地验证市场,其对业务系统的最大要求是快速实现. ...

  4. python3 第八章 - 完善九九乘法表

    前面我们在第四章的时候挖了个坑:怎么用优雅的方式来打印九九乘法表.这一章我们就来填上这个坑. 首先,我们再来看下九九乘法表是什么样子的 1 x 1 = 1 1 x 2 = 2 2 x 2 = 4 1 ...

  5. background:url() 背景图不显示

    奇怪的问题: .box-3 { width: 100%; height: 500px; border: solid 2px red; margin-top: 70px; padding: 0 0 0 ...

  6. 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。

    /** * 创建md5摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名. */ private function createSign($parameters,$key) { $signP ...

  7. 用powershell实现:“倩女幽魂姥姥”版《语音报警系统》

    ------[第一章 前言]------ win7,及以上版本中,是自带语音库的,系统自带一套女声中文库,一套女声英文库.用powershell调用,从而发音,制作报警系统.是一件太简单的事情,只需要 ...

  8. spring的jar各包作用

    http://yjwen337.blog.163.com/blog/static/3625847820106132949858/[转]spring.jar是包含有完整发布的单个jar 包,spring ...

  9. 01-Go命令与基础

    什么是Go? Go是一门并发支持.垃圾回收的编译型系统编程语言,旨在创造一门具有在静态编译语言的高性能和动态的高效开之间拥有良好平衡点的一门编程语言. Go的主要特点有哪些? 类型安全和内存安全 以非 ...

  10. Node.js--安装express以及创建第一个express项目(windows)

    1.根据新版的express出现了安装器的概念,安装express需要两个步骤(命令行找到nodejs目录全局安装): (1)npm install -g express@4.15.0   (也可省略 ...