即使一個簡單的『模擬器』︰
打開了範例之後︰
不知道眉角,恐不會『跑』哩!
略作摸索試誤,發現 【Run】選單裡的
Run Module F5
是所求呦☺
【模擬器畫面變化】
而後驗之以『命令列』
pi@raspberrypi:~ python3 humidity-2018-12-05-15-56-20.py /usr/lib/python3/dist-packages/sense_emu/sense_hat.py:91: Warning: No emulator detected; spawning sense_emu_gui warnings.warn(Warning('No emulator detected; spawning sense_emu_gui')) Traceback (most recent call last): File "humidity-2018-12-05-15-56-20.py", line 12, in <module> humidity = sense.humidity File "/usr/lib/python3/dist-packages/sense_emu/sense_hat.py", line 630, in humidity return self.get_humidity() File "/usr/lib/python3/dist-packages/sense_emu/sense_hat.py", line 621, in get_humidity self._init_humidity() # Ensure humidity sensor is initialised File "/usr/lib/python3/dist-packages/sense_emu/sense_hat.py", line 604, in _init_humidity raise OSError('Humidity Init Failed') OSError: Humidity Init Failed
可以開始讀讀 Sense-Emu 文件,玩玩範例了◎
Examples
Introduction
The Sense HAT emulator exactly mirrors the official Sense HAT API. The only difference (required because both the emulator and actual library can be installed simultaneously on a Pi) is the name:sense_emu
instead of sense_hat
. It is recommended to import the library in the following manner at the top of your code:
from sense_emu import SenseHat
from sense_hat import SenseHat
Several example scripts, with varying degrees of difficulty, are available from the menu within the emulator. Selecting an example from this menu will open it in Python’s IDLE environment.
Note
The example will be opened directly from the installation. To edit the example for your own purposes, use /home/pi
). in IDLE to save the file under your home directory (e.g.