Guy-Chan / utas-helper

Utas machine setup helper
0 stars 0 forks source link

sense-hat on win #3

Open Guy-Chan opened 4 months ago

Guy-Chan commented 4 months ago

Install within msys2

# Install dependencies
pacman -S --needed --noconfirm vim \
   mingw-w64-ucrt-x86_64-python-pillow \
   mingw-w64-ucrt-x86_64-python-numpy \
   mingw-w64-ucrt-x86_64-cninja \
   mingw-w64-ucrt-x86_64-python-pip \
   mingw-w64-ucrt-x86_64-python3-gobject mingw-w64-ucrt-x86_64-gtk3 \
   mingw-w64-ucrt-x86_64-python-cairo \
   mingw-w64-ucrt-x86_64-gobject-introspection \
   base-devel mingw-w64-ucrt-x86_64-toolchain git \
   mingw-w64-ucrt-x86_64-python \
   mingw-w64-ucrt-x86_64-libffi

# Add ucrt64 bin to PATH for easy access
echo 'export PATH=/ucrt64/bin:$PATH' >> ~/.profile
source ~/.profile

# Install sense-emu from source with dependencies installed via package manager
pip3 install --force-reinstall --no-deps sense-emu
# Install requests
pip3 install requests

# Apply patch to stick.py for Windows API compatibility
echo "413c413
<         if family == socket.AF_UNIX:
---
>         if not sys.platform.startswith('win'):
455c455
<         if family == socket.AF_UNIX:
---
>         if not sys.platform.startswith('win'):" | patch /ucrt64/lib/python3.11/site-packages/sense_emu/stick.py

IDE integration

Execute the following within msys2:

start ${vscode executable}
Guy-Chan commented 4 months ago

For testing:

from sense_emu import SenseHat
import time

s=SenseHat()

while True:
    s.set_pixel(0,0,255,255,0)
    time.sleep(1)
    s.set_pixel(0,0,0,0,0)
    time.sleep(1)
mslfh commented 4 months ago

Executable:

/ucrt64/bin/sense_emu_gui.exe

Start Code within msys2:

start ${vscode executable}