Modul fusion_hat.device
Gerätebezogene Funktionen des Fusion Hat
Beispiel
Gerätemodul importieren
>>> from fusion_hat import device
Lautsprecher aktivieren
>>> device.enable_speaker()
>>> device.get_speaker_state()
True
Lautsprecher deaktivieren
>>> device.disable_speaker()
>>> device.get_speaker_state()
False
Status der Benutzertaste abrufen
>>> device.get_usr_btn()
False
Status der Herunterfahranforderung abrufen
>>> device.get_shutdown_request()
0
Benutzer-LED umschalten
>>> device.set_user_led(True)
>>> device.set_user_led(False)
>>> device.set_user_led(1)
>>> device.set_user_led(0)
Firmware-Version abrufen
>>> device.get_firmware_version()
'1.1.4'
Lautstärke einstellen
>>> device.set_volume(50)
Batteriespannung abrufen
>>> device.get_battery_voltage()
8.4
- fusion_hat.device.NAME = 'Fusion Hat'
Name der Platine
- fusion_hat.device.ID = 'fusion_hat'
ID der Platine
- fusion_hat.device.UUID = '9daeea78-0000-0774-000a-582369ac3e02'
UUID der Platine
- fusion_hat.device.PRODUCT_ID = 1908
Produkt-ID der Platine
- fusion_hat.device.PRODUCT_VER = 10
Produktversion der Platine
- fusion_hat.device.VENDOR = 'SunFounder'
Hersteller der Platine
- fusion_hat.device.is_detected() bool[Quellcode]
Check if the driver sysfs interface exists (driver loaded).
- Rückgabe:
True if /sys/class/fusion_hat/ exists
- Rückgabetyp:
bool
- fusion_hat.device.is_driver_loaded() bool[Quellcode]
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.
- Rückgabe:
True if driver is loaded, False otherwise
- Rückgabetyp:
bool
- fusion_hat.device.doctor() dict[Quellcode]
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)
- Rückgabe:
overall, driver_ok, audio_ok, results (per-check dict)
- Rückgabetyp:
dict with keys
- fusion_hat.device.is_installed() bool[Quellcode]
Prüfen, ob eine Fusion-Hat-Platine installiert ist
Veraltet ab Version Use:
is_detected()instead. This function will be removed in a future version.- Rückgabe:
True, wenn installiert, sonst False
- Rückgabetyp:
bool
- fusion_hat.device.is_connected()[Quellcode]
Check if Fusion HAT is connected
Veraltet ab Version Use:
is_driver_loaded()instead. This function will be removed in a future version.- Rückgabe:
True if connected
- Rückgabetyp:
bool
- fusion_hat.device.enable_speaker(*arg, **kwargs)[Quellcode]
- fusion_hat.device.disable_speaker(*arg, **kwargs)[Quellcode]
- fusion_hat.device.get_speaker_state(*arg, **kwargs)[Quellcode]
- fusion_hat.device.get_usr_btn(*arg, **kwargs)[Quellcode]
- fusion_hat.device.set_led(*arg, **kwargs)[Quellcode]
- fusion_hat.device.get_firmware_version(*arg, **kwargs)[Quellcode]
- fusion_hat.device.set_volume(value: int) None[Quellcode]
Lautstärke einstellen
- Parameter:
value (int) – Lautstärke (0~100)
- fusion_hat.device._add_dtoverlay() bool[Quellcode]
Ensure dtoverlay=sunfounder-fusionhat is active in config.txt.
Already active → no-op
Commented out → uncomment
Not present → append
- Rückgabe:
True if the line is active after the call
- Rückgabetyp:
bool
- fusion_hat.device._check_capture_device() tuple[Quellcode]
Check Fusion HAT mic via ALSA.
- fusion_hat.device._check_sound_card() tuple[Quellcode]
Check Fusion HAT sound card (speaker) via ALSA.
- fusion_hat.device._find_config_txt() str[Quellcode]
Locate the active Raspberry Pi config.txt file.
- Rückgabe:
path to config.txt (may not exist)
- Rückgabetyp:
str
- fusion_hat.device._find_driver_src() str[Quellcode]
Find the Fusion Hat driver source directory.
- fusion_hat.device._has_dtoverlay() bool[Quellcode]
Check if dtoverlay=sunfounder-fusionhat is already in config.txt.
- Rückgabe:
True if the uncommented dtoverlay line exists
- Rückgabetyp:
bool
- fusion_hat.device._print_check(name: str, ok: bool, detail: str = '', indent: int = 2)[Quellcode]
Print a single check result inline, clearing previous spinner.
- fusion_hat.device._remove_dtoverlay() bool[Quellcode]
Remove dtoverlay=sunfounder-fusionhat from config.txt.
Uses sudo sed since the file requires root.
- Rückgabe:
True if the line was removed or not present
- Rückgabetyp:
bool