App:Library:FabGL:FabGL Specific Terminal Sequences

提供: robot-jp wiki
ナビゲーションに移動検索に移動

FabGL Specific Terminal Sequences

これは、FabGL固有のターミナルシーケンスのリストです。 これらは、標準のエスケープシーケンスでは利用できないグラフィックス/オーディオなどの機能にアクセスするために使用されます。

特定のシーケンスは、どの端末エミュレーションが設定されているかわからず、既知のエスケープシーケンスを使用して画面を制御したい場合にも役立ちます。

特定のシーケンスは、ESC(ASCII 27h、0x1B)とアンダースコア( "_"、ASCII 90h、0x5f)で始まります。 1文字で構成される実際のコマンドに従います。

コマンド文字の後に、セミコロン( ";")で区切ったパラメーター(必要な場合)を指定できます。 終了ドル記号($、ASCII 36h、0x24)は、エスケープシーケンスを終了します。

一部のコマンドは応答シーケンスを返します。これは固定長で、ドル記号($)で始まります。


アナログ-デジタルコンバーター(ADC)のセットアップ

Sequence:

  ESC "_A" resolution ";" attenuation ";" gpio "$"


パラメータ:

  resolution:

      "9", "10", "11", "12"

  attenuation:

      "0" = 0dB   (reduced to 1/1), full-scale voltage 1.1 V, accurate between 100 and 950 mV

      "1" = 2.5dB (reduced to 1/1.34), full-scale voltage 1.5 V, accurate between 100 and 1250 mV

      "2" = 6dB   (reduced to 1/2), full-scale voltage 2.2 V, accurate between 150 to 1750 mV

      "3" = 11dB  (reduced to 1/3.6), full-scale voltage 3.9 V (maximum volatage is still 3.3V!!), accurate between 150 to 2450 mV

  gpio:

      "32"..."39"


使用例:

  // setup GPIO number 36 as analog input, 11dB attenuation (3) and 12 bit resolution

  Terminal.write("\e_A12;3;36$");

指定されたgpioからアナログ入力(ADC)を読取

Sequence:

  ESC "_C" gpio "$"


パラメータ:

  gpio:

      "32"..."39"


Returns:

  "$"

  hex value (3 characters)


使用例:

  // Request to read ADC from GPIO number 36

  Terminal.write("\e_C36$");  // will return something like "$1A5" (value 421)

入力または出力用のデジタルピンを設定

Sequence:

  ESC "_D" mode gpio "$"


パラメータ:

  mode:

      "-" = disable input/output

      "I" = input only

      "O" = output only

      "D" = output only with open-drain

      "E" = output and input with open-drain

      "X" = output and input

  gpio:

      "0"..."39" (not all usable!)


使用例:

  // Setup gpio number 12 as output (O)

  Terminal.write("\e_DO12$");

デジタル出力ピンの状態を設定

Sequence:

  ESC "_W" value gpio "$"


パラメータ:

  value:

      0 or '0' or 'L' = low (and others)

      1 or '1' or 'H' = high

  gpio:

      "0"..."39" (not all usable!)


使用例:

  // Set gpio 12 to High

  Terminal.write("\e_WH12$");

  // Set gpio 12 to Low

  Terminal.write("\e_WL12$");

デジタル入力ピンの状態を読取

Sequence:

  ESC "_R" gpio "$"


パラメータ:

  gpio:

      "0"..."39" (not all usable!)


Returns:

  "$"

  '0' = low, '1' = high


使用例:

  // Read state of gpio 12

  Terminal.write("\e_R12$");  // you will get "$0" or "$1"

背景色でターミナルエリアをクリア

Sequence:

  ESC "_B" "$"


使用例:

  // Clear terminal area

  Terminal.write("\e_B$");

カーソルの有効化・無効化

Sequence:

  ESC "_E" state "$"


パラメータ:

  state:

      "0" = disable cursor

      "1" = enable cursor


使用例:

  // Disable cursor

  Terminal.write("\e_E0$");

カーソル位置の設定

Sequence:

  ESC "_F" column ";" row "$"


パラメータ:

  column:

      column (1 = first column)

  row:

      row (1 = first row)


使用例:

  // Print "Hello" at column 1 of row 10

  Terminal.write("\e_F1;10$");

  Terminal.write("Hello");

マウスの有効化/無効化

Sequence:

  ESC "_H" value "$"


パラメータ:

  value:

      '0' (and others) = enable mouse

      '1' = disable mouse


使用例:

  // Enable mouse

  Terminal.write("\e_H1$");

マウス位置の取得

Sequence:

  ESC "_M" "$"


Returns:

  "$"

  X position: 3 hex digits

  ";"

  Y position: 3 hex digits

  ";"

  Scroll wheel delta: 1 hex digit (0..F)

  ";"

  Pressed buttons: 1 hex digit, composed as follow:

      bit 1 = left button

      bit 2 = middle button

      bit 3 = right button


使用例:

  // Get mouse status

  Terminal.write("\e_M$"); // you will get something like "$1AB;08A;0;1"

ミリ秒単位のDelay

Sequence:

  ESC "_Y" value "$"


パラメータ:

  value:

      number (milliseconds)


Returns:

  "$": returns the dollar sign after specified number of milliseconds


使用例:

  // Get mouse status

  Terminal.write("\e_Y500$"); // you will get "$" after 500 milliseconds

音を出す

Sequence:

  ESC "_S" waveform ";" frequency ";" duration ";" volume "$"


パラメータ:

  waveform:

      "0" = SINE

      "1" = SQUARE

      "2" = TRIANGLE

      "3" = SAWTOOTH

      "4" = NOISE

      "5" = VIC NOISE

  frequency:

      frequency in Hertz

  duration:

      duration in milliseconds

  volume:

      volume (min is 0, max is 127)


使用例:

  // play Sine waveform at 800 Hz, for 1000ms at volume 100

  Terminal.write("\e_S0;800;1000;100$");

グラフィック画面を背景色でクリアし、スクロール領域をリセット

Sequence:

  ESC "_GCLEAR" "$"


例:

  // clear graphics screen, filling with dark blue

  Terminal.write("\e_GBRUSH0;0;128$");

  Terminal.write("\e_GCLEAR$");

グラフィックのブラシの色を設定

Sequence:

  ESC "_GBRUSH" red ";" green ";" blue "$"


パラメータ:

  red:   '0'..'255'

  green: '0'..'255'

  blue:  '0'..'255'


使用例:

  // set pure red (255,0,0) as background color for graphics

  Terminal.write("\e_GBRUSH255;0;0$");

グラフィックのペン色の設定

Sequence:

  ESC "_GPEN" red ";" green ";" blue "$"


パラメータ:

  red:   '0'..'255'

  green: '0'..'255'

  blue:  '0'..'255'


使用例:

  // set yellow (255,255,0) as pen color for graphics

  Terminal.write("\e_GPEN255;255;0$");

ペン幅の設定

Sequence:

  ESC "_GPENW" width "$"


パラメータ:

  width: pen width (from 1)


使用例:

  // set pen width to 2

  Terminal.write("\e_GPENW2$");

ペンの色を使用して指定されたピクセルを設定

Sequence:

  ESC "_GPIXEL" X ";" Y "$"


パラメータ:

  X: horizontal coordinate

  Y: vertical coordinate


使用例:

  // set pixel at 89, 31 to blue

  Terminal.write("\e_GPEN0;0;255$"); // pen = blue

  Terminal.write("\e_GPIXEL89;31$"); // draw pixel

ペンの色を使用して線を描画

Sequence:

  ESC "_GLINE" X1 ";" Y1 ";" X2 ";" Y2 "$"


パラメータ:

  X1: starting horizontal coordinate

  Y1: starting vertical coordinate

  X2: ending horizontal coordinate

  Y2: ending vertical coordinate


使用例:

  // draw a red line from 10, 10 to 150,150

  Terminal.write("\e_GPEN255;0;0$");        // pen = red

  Terminal.write("\e_GLINE10;10;150;150$"); // draw line

ペンの色を使用して長方形を描画

Sequence:

  ESC "_GRECT" X1 ";" Y1 ";" X2 ";" Y2 "$"


パラメータ:

  X1: starting horizontal coordinate

  Y1: starting vertical coordinate

  X2: ending horizontal coordinate

  Y2: ending vertical coordinate


使用例:

  // draw a white rectangle from 10, 10 to 150,150

  Terminal.write("\e_GPEN255;255;255$");    // pen = white

  Terminal.write("\e_GRECT10;10;150;150$"); // draw rectangle

ブラシの色を使用して長方形を塗りつぶす

Sequence:

  ESC "_GFILLRECT" X1 ";" Y1 ";" X2 ";" Y2 "$"


パラメータ:

  X1: starting horizontal coordinate

  Y1: starting vertical coordinate

  X2: ending horizontal coordinate

  Y2: ending vertical coordinate


使用例:

  // fill a yellow rectangle from 10, 10 to 150,150

  Terminal.write("\e_GBRUSH255;255;0$");         // brush = yellow

  Terminal.write("\e_GFILLRECT10;10;150;150$");  // fill rectangle

ペンの色を使用して楕円を描画

Sequence:

  ESC "_GELLIPSE" X ";" Y ";" width ";" height "$"


パラメータ:

  X:      horizontal coordinate of ellipse center

  Y:      vertical coordinate of ellipse center

  with:   ellipse width

  height: ellipse height


使用例:

  // draw a green ellipse at 100,120 with 50 horizontal size and 80 vertical size

  Terminal.write("\e_GPEN0;255;0$");            // pen = green

  Terminal.write("\e_GELLIPSE100;120;50;80$");  // draw ellipse

ブラシの色で楕円を塗りつぶす

Sequence:

  ESC "_GFILLELLIPSE" X ";" Y ";" width ";" height "$"


パラメータ:

  X:      horizontal coordinate of ellipse center

  Y:      vertical coordinate of ellipse center

  with:   ellipse width

  height: ellipse height


使用例:

  // fill a red ellipse at 100,120 with 50 horizontal size and 80 vertical size

  Terminal.write("\e_GBRUSH255;0;0$");              // brush = red

  Terminal.write("\e_GFILLELLIPSE100;120;50;80$");  // fill ellipse

ペンの色を使用してポリゴン(パス)を描画

Sequence:

  ESC "_GPATH" X1 ";" Y1 ";" X2 ";" Y2 [";" Xn ";" Yn...] "$"


パラメータ:

  X1: first horizontal coordinate

  Y1: first vertical coordinate

  X2: second horizontal coordinate

  Y2: second vertical coordinate

  Xn: optional "n" horizontal coordinate

  Yn: optional "n" vertical coordinate


注:

  Maximum number of points is 32 (configurable in terminal.h)


使用例:

  // draw a red triangle at (5,5)-(12,18)-(6,16)

  Terminal.write("\e_GPEN255;0;0$");                // pen = red

  Terminal.write("\e_GPATH5;5;12;18;6;16$");        // draw path

ブラシの色でポリゴン(パス)を塗りつぶす

Sequence:

  ESC "_GFILLPATH" X1 ";" Y1 ";" X2 ";" Y2 [";" Xn ";" Yn...] "$"


パラメータ:

  X1: first horizontal coordinate

  Y1: first vertical coordinate

  X2: second horizontal coordinate

  Y2: second vertical coordinate

[Xn]: optional "n" horizontal coordinate

[Yn]: optional "n" vertical coordinate

Notes:

  Maximum number of points is 32 (configurable in terminal.h)


使用例:

  // fill a green triangle at (5,5)-(12,18)-(6,16)

  Terminal.write("\e_GBRUSH0;255;0$");              // brush = green

  Terminal.write("\e_GFILLPATH5;5;12;18;6;16$");    // fill path

割り当てるスプライトの数を設定

Sequence:

  ESC "_GSPRITECOUNT" count "$"


パラメータ:

  count: number of sprites that will be defined by "_GSPRITEDEF"


使用例:

  // allocates two sprites

  Terminal.write("\e_GSPRITECOUNT2$");

割り当てられたスプライトにビットマップを追加

Sequence:

  ESC "_GSPRITEDEF" spriteIndex ";" width ";" height ";" format ";" [R ";" G ";" B ";"] data... "$"


パラメータ:

  spriteIndex: sprite index (0...)

  width:       bitmap width

  height:      bitmap height

  format:

      "M" = bitmap format is monochrome (1 bit per pixel)

      "2" = bitmap format is 64 colors (6 bits per pixel, 2 bits per channel with transparency)

      "8" = bitmap format is true color (32 bits per pixel, 8 bits per channel with transparency)

[R]:          red channel when bitmap format is monochrome

[G]:          green channel when bitmap format is monochrome

[B]:          blue channel when bitmap format is monochrome

  data:        bitmap data data as a sequence of 2 digits hex numbers (ie 002A3BFF2C...).

               each bitmap row is always byte aligned


使用例:

  // allocates one sprite and assign a 8x4 monochrome bitmap, colored with red

  Terminal.write("\e_GSPRITECOUNT1$");

  Terminal.write("\e_GSPRITEDEF0;8;4;M;255;0;0;AABBCCDD$");

スプライトの可視性、位置、現在のフレーム(ビットマップ)の設定

Sequence:

  ESC "_GSPRITESET" spriteIndex ";" visible ";" frameIndex ";" X ";" Y "$"


パラメータ:

  spriteIndex: sprite index (0...)

  visible:     "H" = hidden, "V" = visible

  frameIndex:  current frame (bitmap) to show (0...)

  X:           horizontal position

  Y:           vertical position


使用例:

  // make sprite 0 visible at position 50,120 with first added bitmap

  Terminal.write("\e_GSPRITESET0;V;0;50;120$");

ピクセル単位で画面をスクロール

Sequence:

  ESC "_GSCROLL" offsetX ";" offsetY "$"


パラメータ:

  offsetX: number of pixels to scroll (<0 = scroll left, >0 scroll right)

  offsetY: nunber of pixels to scroll (<0 = scroll up, >0 scroll down)


使用例:

  // scroll left by 8 pixels

  Terminal.write("\e_GSCROLL-8;0$");



戻る