pyb
--- pyboard 関連の関数¶
pyb
は puboard に固有の関数を提供します(訳注: 元々は pyboard 用ですが、似たアーキテクチャ、特に STM32 系の MCU を載せたボードではサポートされていることが多いです)。
その他の関数¶
-
pyb.
have_cdc
()¶ USB がシリアルデバイスとして接続されていれば True を、そうでなければ False を返します。
注釈
この関数は非推奨です。代わりに pyb.USB_VCP().isconnected() を使ってください。
-
pyb.
hid
((buttons, x, y, z))¶ 4項目のタプル(またはリスト)を取り、それを USB ホスト(PC)に送信して HID マウスモーションイベントを通知します。
注釈
この関数は非推奨です。代わりに
pyb.USB_HID.send()
を使ってください。
-
pyb.
info
([dump_alloc_table])¶ ボードについてのたくさんの情報を表示します。
-
pyb.
main
(filename)¶ boot.py が完了した後に実行するメインスクリプトのファイル名を設定します。この関数が呼び出されないと、デフォルトのファイル main.py が実行されます。
boot.py の中からこの関数を呼び出すことだけが理にかなっています。
-
pyb.
mount
(device, mountpoint, *, readonly=False, mkfs=False)¶ 注釈
この関数は非推奨です。デバイスのマウントとマウント解除には、代わりに
uos.mount()
とuos.umount()
を使ってください。ブロックデバイスをマウントしてファイルシステムの一部として利用できるようにします。
device
はブロックプロトコルを提供するオブジェクトでなければなりません。(以下も非推奨です。ブロックデバイスを作成する正しい方法についてはuos.AbstractBlockDev
を参照してください。)readblocks(self, blocknum, buf)
writeblocks(self, blocknum, buf)
(オプション)count(self)
sync(self)
(オプション)
readblocks
とwriteblocks
はbuf
とブロックデバイスの間でデータをコピーするもので、デバイスのブロック番号blocknum
から始まります。buf
は 512 の倍数の長さを持つ bytearray です。writeblocks
が定義されていなければ、デバイスは読み取り専用でマウントされます。これら2つの関数の戻り値は無視されます。count
はデバイスで利用可能なブロック数を返します。sync
が実装されている場合、この関数はデバイス上のデータを同期します。パラメータ
mountpoint
は、デバイスをマウントするためのファイルシステムのルート内の場所です。それはスラッシュ記号で始まらなければなりません。readonly
がTrue
であれば、デバイスは読み取り専用でマウントされ、それ以外の場合は、読み書きができるようマウントされます。mkfs
がTrue
である場合、ファイルシステムが存在しない場合は、新しいファイルシステムが作成されます。
-
pyb.
repl_uart
(uart)¶ REPL が繰り返される UART オブジェクトを取得または設定します。
-
pyb.
rng
()¶ 30ビットのハードウェア生成乱数を返します。
-
pyb.
sync
()¶ すべてのファイルシステムを同期します。
-
pyb.
unique_id
()¶ MCU の一意な ID である12バイト(96ビット)の文字列を返します。
-
pyb.
usb_mode
([modestr, ]port=-1, vid=0xf055, pid=-1, msc=(), hid=pyb.hid_mouse, high_speed=False)¶ 引数なしで呼び出された場合は、現在の USB モードを文字列として返します。
If called with modestr provided, attempts to configure the USB mode. The following values of modestr are understood:
None
: USB を無効化'VCP'
: VCP (仮想 COM ポート)インタフェースを有効化'MSC'
: MSC (マスストレージデバイスクラス)インタフェースを有効化'VCP+MSC'
: VCP と MSC を有効化'VCP+HID'
: VCP と HID (ヒューマンインタフェースデバイス)を有効化'VCP+MSC+HID'
: enabled with VCP, MSC and HID (only available on PYBD boards)
後方互換性のために、
'CDC'
は'VCP'
を意味すると解釈されます``'CDC+MSC'`` と'CDC+HID'
も同様です)。The port parameter should be an integer (0, 1, ...) and selects which USB port to use if the board supports multiple ports. A value of -1 uses the default or automatically selected port.
The vid and pid parameters allow you to specify the VID (vendor id) and PID (product id). A pid value of -1 will select a PID based on the value of modestr.
If enabling MSC mode, the msc parameter can be used to specify a list of SCSI LUNs to expose on the mass storage interface. For example
msc=(pyb.Flash(), pyb.SDCard())
.If enabling HID mode, you may also specify the HID details by passing the hid keyword parameter. It takes a tuple of (subclass, protocol, max packet length, polling interval, report descriptor). By default it will set appropriate values for a USB mouse. There is also a
pyb.hid_keyboard
constant, which is an appropriate tuple for a USB keyboard.The high_speed parameter, when set to
True
, enables USB HS mode if it is supported by the hardware.
クラス¶
- クラス Accel - 加速度センサー制御
- class ADC -- アナログ-デジタル変換
- class CAN -- controller area network communication bus
- class DAC -- digital to analog conversion
- class ExtInt -- configure I/O pins to interrupt on external events
- クラス I2C -- 2線式シリアルプロトコル
- class LCD -- LCD control for the LCD touch-sensor pyskin
- class LED -- LED object
- クラス Pin -- I/O ピンの制御
- class PinAF -- Pin Alternate Functions
- class RTC -- リアルタイムクロック
- class Servo -- 3-wire hobby servo driver
- class SPI -- a master-driven serial protocol
- class Switch -- switch object
- class Timer -- control internal timers
- class TimerChannel --- setup a channel for a timer
- class UART -- 二重シリアル通信バス
- class USB_HID -- USB Human Interface Device (HID)
- class USB_VCP -- USB virtual comm port