fusion_hat.device モジュール

Fusion Hat デバイス関連の関数

サンプル

device モジュールをインポートします

>>> from fusion_hat import device

スピーカーを有効にします

>>> device.enable_speaker()
>>> device.get_speaker_state()
True

スピーカーを無効にします

>>> device.disable_speaker()
>>> device.get_speaker_state()
False

ユーザーボタンの状態を取得します

>>> device.get_usr_btn()
False

シャットダウン要求の状態を取得します

>>> device.get_shutdown_request()
0

ユーザー LED を切り替えます

>>> device.set_user_led(True)
>>> device.set_user_led(False)
>>> device.set_user_led(1)
>>> device.set_user_led(0)

ファームウェアのバージョンを取得します

>>> device.get_firmware_version()
'1.1.4'

音量を設定します

>>> device.set_volume(50)

バッテリー電圧を取得します

>>> device.get_battery_voltage()
8.4
fusion_hat.device.NAME = 'Fusion Hat'

ボード名

fusion_hat.device.ID = 'fusion_hat'

ボード ID

fusion_hat.device.UUID = '9daeea78-0000-0774-000a-582369ac3e02'

ボードの UUID

fusion_hat.device.PRODUCT_ID = 1908

ボードの製品 ID

fusion_hat.device.PRODUCT_VER = 10

ボードの製品バージョン

fusion_hat.device.VENDOR = 'SunFounder'

ボードのベンダー

fusion_hat.device.is_detected() bool[ソース]

Check if the driver sysfs interface exists (driver loaded).

戻り値:

True if /sys/class/fusion_hat/ exists

戻り値の型:

bool

fusion_hat.device.is_driver_loaded() bool[ソース]

Check if Fusion Hat driver is loaded

This function checks if the Fusion Hat driver module is loaded by verifying the existence of /sys/class/fusion_hat/ directory.

戻り値:

True if driver is loaded, False otherwise

戻り値の型:

bool

fusion_hat.device.doctor() dict[ソース]

Live hardware health check — prints results as each check runs.

Sections:

Driver — sysfs, module, I2C MCU, dtoverlay, module file Audio — sound card, capture device (with dependency deep-dive)

戻り値:

overall, driver_ok, audio_ok, results (per-check dict)

戻り値の型:

dict with keys

fusion_hat.device.is_installed() bool[ソース]

Fusion Hat ボードがインストールされているかを確認します

バージョン Use で非推奨: is_detected() instead. This function will be removed in a future version.

戻り値:

インストールされている場合は True、そうでない場合は False

戻り値の型:

bool

fusion_hat.device.is_connected()[ソース]

Check if Fusion HAT is connected

バージョン Use で非推奨: is_driver_loaded() instead. This function will be removed in a future version.

戻り値:

True if connected

戻り値の型:

bool

fusion_hat.device.enable_speaker(*arg, **kwargs)[ソース]
fusion_hat.device.disable_speaker(*arg, **kwargs)[ソース]
fusion_hat.device.get_speaker_state(*arg, **kwargs)[ソース]
fusion_hat.device.get_usr_btn(*arg, **kwargs)[ソース]
fusion_hat.device.set_led(*arg, **kwargs)[ソース]
fusion_hat.device.get_firmware_version(*arg, **kwargs)[ソース]
fusion_hat.device.set_volume(value: int) None[ソース]

音量を設定します

パラメータ:

value (int) -- 音量(0~100)

fusion_hat.device._add_dtoverlay() bool[ソース]

Ensure dtoverlay=sunfounder-fusionhat is active in config.txt.

  • Already active → no-op

  • Commented out → uncomment

  • Not present → append

戻り値:

True if the line is active after the call

戻り値の型:

bool

fusion_hat.device._check_capture_device() tuple[ソース]

Check Fusion HAT mic via ALSA.

fusion_hat.device._check_sound_card() tuple[ソース]

Check Fusion HAT sound card (speaker) via ALSA.

fusion_hat.device._find_config_txt() str[ソース]

Locate the active Raspberry Pi config.txt file.

戻り値:

path to config.txt (may not exist)

戻り値の型:

str

fusion_hat.device._find_driver_src() str[ソース]

Find the Fusion Hat driver source directory.

fusion_hat.device._has_dtoverlay() bool[ソース]

Check if dtoverlay=sunfounder-fusionhat is already in config.txt.

戻り値:

True if the uncommented dtoverlay line exists

戻り値の型:

bool

fusion_hat.device._print_check(name: str, ok: bool, detail: str = '', indent: int = 2)[ソース]

Print a single check result inline, clearing previous spinner.

fusion_hat.device._remove_dtoverlay() bool[ソース]

Remove dtoverlay=sunfounder-fusionhat from config.txt.

Uses sudo sed since the file requires root.

戻り値:

True if the line was removed or not present

戻り値の型:

bool