Ameba Arduino: [RTL8195] LCD12864 – 显示所画的图形

材料准备

  • Ameba x 1
  • LCD12864 Module x 1

范例说明

本范例使用LCD12864模组能在模组上显示范例所画的图形,分别是画出字形"012"及画出圆形,我们需要以下library:
https://github.com/Ameba8195/Arduino/raw/master/libraries/LCD12864.zip

关于LCD12864更多资讯请参考:
http://playground.arduino.cc/Code/LCD12864

安装library的方式请参考Arduino官方网站的教学文章将zip档的library加入Ameba:
https://www.arduino.cc/en/Guide/Libraries#toc4

接着打开范例 “File” -> “Examples” -> “AmebaLCD12864” -> “drawsketch”
并接线如下图:
1

程式码说明

此范例在LCD12864面板上,画出”0 1 2”的字及圆形
Render() 在呼叫Initialise()之后执行,开始产生图形描绘程序

LCDA.Render()

DrawCircle(int x0, int y0, int radius) method功能为画圆形,参数x0为开始圆形的x座标位置,参数y0为为开始圆形的y座标位置,参数radius为圆形的半径

LCDA.DrawCircle(30,135,5);

RenderScreenBuffer(int screen) method功能为指定绘制的screen (分为上半部和下半部,1 = 萤幕上半部, 2 = 萤幕下半部)

LCDA.RenderScreenBuffer(2);

Draw(bool t, int x, int y) method功能为切换graphics mode
(参数t为true = graphics mode, x和y参数可以为任一数字)
(参数t为false = ASCII mode, x 为字元放置的位置0~23, ranging from 0 to 23, y参数则不会产生任何作用)

LCDA.Draw(false,4,0);

setPins(int tRS, int tRW, int tD7, int tD6, int tD5, int tD4, int tD3, int tD2, int tD1, int tD0) method为直接通过参数指定来绘制LCD萤幕
tRS: Register Set
tRW: Read/Write
tD7: Data line 7
tD6: Data line 6
tD5: Data line 5
tD4: Data line 4
tD3: Data line 3
tD2: Data line 2
tD1: Data line 1
tD0: Data line 0

LCDA.setPins(1,0,0,0,1,1,0,0,0,0); //0
LCDA.setPins(1,0,0,0,1,1,0,0,0,1); //1
LCDA.setPins(1,0,0,0,1,1,0,0,1,0); //2