Skip to content

HAT-010 5x5マトリクス ​

インスタンスの宣言 ​

HAT-010 5x5マトリクス(HAT010) ブロックを作業領域に追加すると、Python コードには次のようなインスタンスの宣言が自動的に挿入されます:

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

パラメーター ​

名前区分説明範囲・種類デフォルト値
indexドロップダウンオプションインスタンス番号(0 から始まる)0 以上の整数0

開始 ​

5x5 マトリクスを使います。

start

パラメーター ​

(なし)

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.start()

LEDを1つ点灯する ​

指定した位置の LED の色を設定します。
LED の位置は x, y 座標で表します。

set_one

パラメーター ​

名前区分説明範囲・種類デフォルト値
x入力値(フィールド)横の座標0 ~ 4 の整数-
y入力値(フィールド)縦の座標0 ~ 4 の整数-
colorドロップダウンオプション色消灯(off), 赤(red), オレンジ(orange), 黄(yellow), 緑(green), シアン(cyan), 青(blue), 紫(violet), マゼンタ(magenta), 白(white)-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.set_one(2, 3, 'red')

図形を描く ​

指定した位置から始めて、設定したパターンどおりに LED を点灯します。
LED の位置は x, y 座標で表します。

draw_shape

パラメーター ​

名前区分説明範囲・種類デフォルト値
x入力値(フィールド)図形の左上の x整数-
y入力値(フィールド)図形の左上の y整数-
colorドロップダウンオプション色off, red, orange, yellow, green, cyan, blue, violet, magenta, white-
shapeドロップダウンオプション図形の名前rectangle, triangle, diamond, circle, x, like, dislike, angry, mouth_open, mouth_close, heart, star, up_arrow, down_arrow, left_arrow, right_arrow, walking, dog, butterfly, airplane, quarter_note, eighth_note-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.draw_shape(0, 0, 'red', 'heart')

数字を描く ​

指定した位置から始めて、設定したパターンどおりに LED を点灯します。
LED の位置は x, y 座標で表します。

draw_number

パラメーター ​

名前区分説明範囲・種類デフォルト値
x入力値(フィールド)数字の左上の x整数-
y入力値(フィールド)数字の左上の y整数-
colorドロップダウンオプション色off, red, orange, yellow, green, cyan, blue, violet, magenta, white-
numberドロップダウンオプション描く数字0, 1, 2, 3, 4, 5, 6, 7, 8, 9-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.draw_number(0, 0, 'red', 5)

パターンを描画 ​

指定した位置から始めて、設定したパターンどおりに LED を点灯します。
LED の位置は x, y 座標で表します。

draw_pattern

パラメーター ​

名前区分説明範囲・種類デフォルト値
x入力値(フィールド)左上の x整数-
y入力値(フィールド)左上の y整数-
colorドロップダウンオプション色off, red, orange, yellow, green, cyan, blue, violet, magenta, white-
matrix入力値(配列)25 マスのピクセル配列 (0/1)長さ 25 の整数の配列-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.draw_pattern(0, 0, 'red', [
   1, 0, 1, 0, 1, 
   0, 1, 0, 1, 0, 
   1, 0, 1, 0, 1, 
   0, 1, 0, 1, 0, 
   1, 0, 1, 0, 1
])

だけ移動 ​

指定した x, y の分だけ画面を移動します。
x の値が正なら画面が右に移動し、負なら左に移動します。
y の値が正なら画面が下に移動し、負なら上に移動します。

shift

パラメーター ​

名前区分説明範囲・種類デフォルト値
x入力値(フィールド)横の移動量整数-
y入力値(フィールド)縦の移動量整数-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.shift(1, 0)

LEDを1つ消灯する ​

指定した位置の LED を消します。
LED の位置は x, y 座標で表します。

turn_off_one

パラメーター ​

名前区分説明範囲・種類デフォルト値
x入力値(フィールド)横の座標0 ~ 4 の整数-
y入力値(フィールド)縦の座標0 ~ 4 の整数-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.turn_off_one(2, 3)

すべてのLEDを消灯 ​

画面に表示されている LED をすべて消します。

turn_off_all

パラメーター ​

(なし)

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.turn_off_all()

明るさを設定 ​

5x5 マトリクスの明るさを設定します。
選べる値の範囲は 0 ~ 100 です。

set_brightness

パラメーター ​

名前区分説明範囲・種類デフォルト値
value入力値(フィールド)明るさ0 ~ 100 の整数-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.set_brightness(50)

明るさを変える ​

5x5 マトリクスの明るさを変えます。
選べる値の範囲は -100 ~ 100 です。

change_brightness

パラメーター ​

名前区分説明範囲・種類デフォルト値
value入力値(フィールド)明るさの変化量整数-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.change_brightness(10)

ボタンの入力 ​

選んだボタンの入力の状態
ボタンが押されていれば 0、ボタンが押されていなければ 1 を出力します。

button_input

パラメーター ​

名前区分説明範囲・種類デフォルト値
unitドロップダウンオプションボタンの名前ボタン A ('A'), ボタン B ('B')-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.button_input('A')

ボタンがクリックされた? ​

選んだボタンがクリックされたかどうか
このブロックは、選んだボタンがクリックされた瞬間だけ true を返し、それ以外は false を返します。

button_click

パラメーター ​

名前区分説明範囲・種類デフォルト値
unitドロップダウンオプションボタンの名前ボタン A ('A'), ボタン B ('B')-

Python ​

python
cheesestick = CheeseStick(0)
hat010 = cheesestick.HAT010()

hat010.button_click('A')