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 ​

設定指定位置的 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 ​

關閉指定位置的 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')