LCD12864 - 顯示所畫的圖形

材料準備

  • Ameba x 1
  • LCD12864 Module x 1

範例說明

本範例使用LCD12864模組能在模組上顯示範例所畫的圖形,分別是畫出字形"012"及畫出圓形,我們需要以下library:
https://github.com/ambiot/amb1_arduino/raw/master/Arduino_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
Please confirm that QQ communication software is installed
請先確認已安裝QQ通訊軟體