Micro:bit I/O腳位控制


Microbit_Io_Pin component lets users configure the BBC micro:bit's analog pins for input and output, and to read, write, and request notifications for the I/O pin states.


屬性

  • BluetoothDevice – 連接至micro:bit 裝置之BluetoothLE元件。

get Microbit_Io_Pin1 BluetoothDevice

set Microbit_Io_Pin1 BluetoothDevice  to


方法

  • ReadPinADConfiguration – 讀取micro:bit的腳位設定狀態,讀取結果根據該腳位是設定為數位或類比而異specifically whether each pin is configured as digital (0 or 1) or analog (0 to 255)。成功讀取之後會自動呼叫PinADConfigurationReceived事件。

call Microbit_Io_Pin1 ReadPinADConfiguration

  • ReadPinData – 讀取一次micro:bit的腳位狀態。成功讀取之後會自動呼叫PinDataReceived事件。在讀取之前,該腳位要先使用WritePinIOConfiguration方法設定為輸入

call Microbit_Io_Pin1 ReadPinData

  • ReadPinIOConfiguration – 讀取micro:bit腳位當下的輸入/輸出設定。成功讀取之後會自動呼叫PinIOConfigurationReceived事件。

call Microbit_Io_Pin1 ReadPinIOConfiguration

  • RequestPinDataUpdates – 要求任一個已設定為輸入的micro:bit腳位更新。After requesting updates, the PinDataReceived will be run whenever the micro:bit reports changes to its input pins.

call Microbit_Io_Pin1 RequestPinDataUpdates

  • StopPinDataUpdates – 停止接收來自micro:bit的I/O腳位狀態更新。Note that there may be pending updates that have not been processed that will result in additional PinDataReceived events.

call Microbit_Io_Pin1 StopPinDataUpdates

  • WritePWMControl – 對micro:bit的PWM控制參數。PWM control field是一個長度可變動的陣列 of one or two instances of a data structure containing a 1-byte pin field (range 0-19), a 2-byte value field (range 0-1024), and a 4-byte period field (in milliseconds).

    參數:

    • PWM_Control_Field (清單) — PWM控制數值。

call Microbit_Io_Pin1 WritePWMControlPWM_Control_Field

  • WritePinADConfiguration – 本方法是用於設定指定micro:bit的腳位模式為類比或數位。Pin_AD_Config_Value是由19個位元所組成,長度為3個位元組,每一個位元分別代表micro:bit的一個腳位。位元0代表數位腳位,1則代表類比腳位。成功寫入新的腳位設定之後會自動呼叫WrotePinADConfiguration事件。

    參數:

    • Pin_AD_Config_Value (清單) — 長度19位元的位元清單,每一個位元分別代表micro:bit的一個腳位。

call Microbit_Io_Pin1 WritePinADConfigurationPin_AD_Config_Value

  • WritePinData – 本方法可設定micro:bit腳位的輸出數值,但該腳位需要先用WritePinIOConfiguration方法設定為輸出。成功寫入腳位之後會自動呼叫WrotePinData事件。

    參數:

    • IO_Pin_Data (清單) — 用於設定micro:bit腳位的數值清單,清單最多可包含19個數值,範圍0-255。

call Microbit_Io_Pin1 WritePinDataIO_Pin_Data

  • WritePinIOConfiguration – 本方法是用於設定指定micro:bit的腳位為輸入或輸出。Pin_IO_Config_Value參數為三個元素的清單,每個元素為0~255之間的數字,長度共19個位元。位元0代表輸出,1則代表輸入。

    參數:

    • Pin_IO_Config_Value (清單) — 長度19位元的位元清單,每一個位元分別代表micro:bit的一個腳位。

call Microbit_Io_Pin1 WritePinIOConfigurationPin_IO_Config_Value


事件

  • PinADConfigurationReceived – 成功執行ReadPinADConfiguration方法之後就會自動呼叫本事件。

    參數:

    • Pin_AD_Config_Value (清單) — 代表micro:bit腳位為類比(1)/數位(0)的位元清單。

when Microbit_Io_Pin1 PinADConfigurationReceived Pin_AD_Config_Value do

  • PinDataReceived – 成功接收到micro:bit的輸入腳位狀態之後就會自動呼叫本事件。這通常是跟在ReadPinDataRequestPinData方法之後所執行。

    參數:

    • IO_Pin_Data (清單) — 代表micro:bit的輸入腳位狀態的位元清單。未設定為輸入的腳位數值皆為0。

when Microbit_Io_Pin1 PinDataReceived IO_Pin_Data do

  • PinIOConfigurationReceived – 成功讀取micro:bit腳位的輸入/輸出設定之後就會自動呼叫本事件。Pin_IO_Config_Value will be a list of three bytes valued from 0-255 composing a 19-bit mask indicating the input or output state of each of the 19 pins provided by the micro:bit. A 0 bit indicates output and a 1 bit indicates input.

    參數:

    • Pin_IO_Config_Value (清單) — 長度19位元的位元清單,每一個位元分別代表micro:bit的一個腳位。

when Microbit_Io_Pin1 PinIOConfigurationReceived Pin_IO_Config_Value do

  • WrotePWMControl – The WrotePWMControl event is run after a successful write to the micro:bit's pulse-width modulation control service. The value of the control field that was written will be passed as the PWM_Control_Field.

    參數:

    • PWM_Control_Field (清單) — 要寫入micro:bit的控制資訊。

when Microbit_Io_Pin1 WrotePWMControl PWM_Control_Field do

  • WrotePinADConfiguration – 成功設定micro:bit指定腳位為類比或數位模式,就會自動呼叫本事件。Pin_AD_Config_Value 事件變數是一個位元清單 were written as part of the last call to the service.

    參數:

    • Pin_AD_Config_Value (清單) — 長度19位元的位元清單,每一個位元分別代表micro:bit的一個腳位。

when Microbit_Io_Pin1 WrotePinADConfiguration Pin_AD_Config_Value do

  • WrotePinData – The WrotePinData event will be run after the micro:bit's output pins are successfully written by a call to the WritePinData method.

    參數:

    • IO_Pin_Data (清單) — A list of up to 19 values from 0-255 that were written to the micro:bit's 腳位 from the last call to WritePinData.

when Microbit_Io_Pin1 WrotePinData IO_Pin_Data do

  • WrotePinIOConfiguration – 成功更新micro:bit的腳位設定之後就會自動呼叫本事件。Pin_IO_Config_Value that was sent to the device will be passed as a parameter to the event.

    參數:

    • Pin_IO_Config_Value (清單) — 長度19位元的位元清單,每一個位元分別代表micro:bit的一個腳位。

when Microbit_Io_Pin1 WrotePinIOConfiguration Pin_IO_Config_Value do

Comments