Skip to content

Instantly share code, notes, and snippets.

@ojisan
Last active January 31, 2017 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ojisan/89bf912bed37ed82d27f6c4da1ad66ce to your computer and use it in GitHub Desktop.
Save ojisan/89bf912bed37ed82d27f6c4da1ad66ce to your computer and use it in GitHub Desktop.
TEST_TFT.rb
#!mruby
#GR-CITRUS Version 2.28
#ここには全体で使用する変数を定義しています
@Usb = Serial.new(0,115200)
@WHITE = 0xFFFF
@BLACK = 0x0000
@GREY = 0xF7DE
@LGRAY = 0xC618
@DGRAY = 0x7BEF
@DGREEN = 0x03E0
@DCYAN = 0x03EF
@MAROON = 0x7800
@PURPLE = 0x780F
@OLIVE = 0x7BE0
@BLUE = 0x001F
@BLUE2 = 0x051F
@NAVY = 0x000F
@RED = 0xF800
@MAGENTA = 0xF81F
@GREEN = 0x07E0
@CYAN = 0x7FFF
@YELLOW = 0xFFE0
#//TFTが使えるかどうかチェック
if( System.useTFT() == 0)then
Usb.println "TFT can't use."
System.exit()
end
#//現在は下記7メソッドが使えます
TFT.clear(@DGREEN) #//全面緑色でクリア
TFT.fillRect( 0, 0, 100, 100, @BLUE)#//原点からx,y100ピクセル範囲を青色
TFT.drawPixel(220,220, @BLACK)#//x,y220ピクセルの位置に黒点
TFT.drawLine(100,100, 150, 150, @RED)#//x,Y100ピクセルからx,y150ピクセルに赤色線
TFT.drawVLine(10, 10, 100, @BLACK)#//x,y10ピクセルからy方向に100ピクセル黒線
TFT.drawHLine(10, 10, 100, @BLACK)#//x,y10ピクセルからx方向に100ピクセル黒線
TFT.puts(50,150, "1234567890abcdefghijkA", @RED, @BLACK,1)#//x50,y150ピクセル位置から文字色赤色、背景黒色文字種1(小字)で文字列表示
TFT.puts(50,200, "1234567890abcdefghijkA", @RED, @BLACK,2)#//x50,y150ピクセル位置から文字色赤色、背景黒色文字種2(大字)で文字列表示
sw = 1
50.times do
led(sw)
sw = 1 - sw
delay(50)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment