#author("2017-03-23T13:56:07+09:00","default:qua","qua") * 2.8インチ液晶ディスプレイ+タッチパネル [#b831ee8b] #ref(http://www.ist.aichi-pu.ac.jp/lab/qua/~qua/pbl/img/ili9341.jpg,242x177) [[メーカーWebページ:https://www.adafruit.com/products/1651]] **配線 [#mbee6d5e] Arduino本体と重ねて接続する。両側のピンのほかにUSB端子と逆側の中央付近のピンにも差し込むようになっているので、注意深く差し込む。すべてのピンを挿すようになっているが、実際には、デジタルピンの4と9から13を使用している(もちろん、電源5VとGNDも使っている)。 #ref(http://www.ist.aichi-pu.ac.jp/lab/qua/~qua/pbl/img/lcd_arduino.jpg,240x180) すべてのアナログピン、およびデジタルピンの2, 3, 5, 6, 7, 8は他の用途に利用可能である。これらのピンを使う場合には、ピンだけの基盤を間に挟む。ピンが足りないが、気にしなくてよい。 #ref(http://www.ist.aichi-pu.ac.jp/lab/qua/~qua/pbl/img/lcd_on_arduino.jpg,240x180) **プログラミング [#x72a1a5e] -ライブラリ -- グラフィックスライブラリ[[AdafruitGFX.zip:http://www.ist.aichi-pu.ac.jp/lab/qua/~qua/pbl/lib/AdafruitGFX.zip]] -- LCDライブラリ[[ILI9341.zip:http://www.ist.aichi-pu.ac.jp/lab/qua/~qua/pbl/lib/ILI9341.zip]] -- タッチパネルライブラリ[[STMPE610.zip:http://www.ist.aichi-pu.ac.jp/lab/qua/~qua/pbl/lib/STMPE610.zip]] -グラフィックスライブラリの使用例 --「外側」に書くこと #include "SPI.h" #include "Adafruit_GFX.h" #include "Adafruit_ILI9341.h" #define TFT_DC 9 #define TFT_CS 10 Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC); --ライブラリ使用準備 setup()内に書く tft.begin(); --描画 ---色について~ tft.color565( r, b, g ); で指定する。r, g, bはそれぞれ0から255の数。 ---画面の方向設定 tft.setRotation( angle ); angleは0=縦・USB端子上、1=横・USB端子左、2=縦・USB端子下、左3=横・USB端子右 ---画面のサイズ取得 tft.width() tft.height(); ---画面消去 tft.fillScreen( color ); ---描画~ 直線 tft.drawLine( x1, y1, x2, y2, color ); 横線 tft.drawFastHLine( x1, y, x2, color ); 縦線 tft.drawFastVLine( x, y1, y2, color ); 長方形 tft.drawRect( x, y, w, h, color ); 長方形塗りつぶし tft.fillRect( x, y, w, h, color ); 角丸長方形 tft.drawRoundRect( x, y, w, h, r, color ); 角丸長方形塗りつぶし tft.fillRoundRect( x, y, w, h, r, color ); 円 tft.drawCircle( x, y, r, color ); 円塗りつぶし tft.fillCircle( x, y, r, color ); 三角形 tft.drawTriangle( x, y, r, color ); 三角形塗りつぶし tft.fillTriangle( x, y, r, color ); ---文字の描画~ 文字サイズの設定 文字のサイズは(8×size)ピクセル tft.setTextSize( size ); 文字色の設定 tft.setTextColor( color ); tft.setTextColor( color, background ); 描画位置の指定 tft.setCursor( x, y ); 文字の描画 tft.println( string ); #author("2019-04-21T23:35:01+09:00","default:qua","qua")