Files
2026-06-30 15:09:05 +02:00

110 lines
3.1 KiB
Markdown

# MP90-Panel
Weather and clock display for the built-in screen on the Blackview MP90 N100 Mini PC.
![MP90 built-in weather panel](docs/mp90-panel.jpg)
## What It Does
`mp90_panel.py` drives the MP90 front display over USB HID and continuously renders a portrait dashboard:
- current time in the `Europe/Berlin` timezone
- current date
- tomorrow's Mannheim forecast for 09:00 and 17:00
- temperature, weather condition, and precipitation probability
Weather data comes from the Open-Meteo forecast API for Mannheim. The script refreshes weather every 15 minutes, redraws the display once per minute, and sends a heartbeat packet to the panel between redraws.
## Hardware
The code targets the MP90 front TFT exposed as a Holtek USB HID display.
Current local device path:
```text
1-8:1.1
```
The display is treated as a `320x170` RGB565 framebuffer. The script switches the panel to portrait mode and sends framebuffer chunks using the panel's HID command protocol.
## Requirements
- Linux with access to the MP90 HID device
- Python 3.14 as installed by Linuxbrew at `/home/linuxbrew/.linuxbrew/bin/python3`
- Python packages:
- `hid`
- `Pillow`
- `requests`
- DejaVu fonts:
- `/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf`
- `/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf`
The included systemd unit currently runs as `root`, which avoids HID permission setup. For a non-root deployment, add a udev rule for the Holtek HID device and adjust the service user.
## Run Once
From this directory:
```bash
/home/linuxbrew/.linuxbrew/bin/python3 ./mp90_panel.py --once
```
This fetches the forecast, draws one frame, sends it to the panel, and exits.
## Run Continuously
```bash
/home/linuxbrew/.linuxbrew/bin/python3 ./mp90_panel.py
```
The script reconnects after HID or network failures and keeps retrying until stopped.
## Deploy With Systemd
Copy or link the service file:
```bash
sudo cp mp90-panel.service /etc/systemd/system/mp90-panel.service
sudo systemctl daemon-reload
sudo systemctl enable --now mp90-panel.service
```
Check logs:
```bash
journalctl -u mp90-panel.service -f
```
Restart after code changes:
```bash
sudo systemctl restart mp90-panel.service
```
## Service Notes
`mp90-panel.service` expects this checkout at:
```text
/home/acidburns/.openclaw/workspace/mp90-panel
```
It also sets `PYTHONPATH` to the local Python 3.14 package directories used on the MP90 host. Update the unit if the checkout or Python environment moves.
## Configuration
Most settings are constants near the top of `mp90_panel.py`:
- `HID_PATH`: USB HID interface path
- `MANNHEIM`: latitude/longitude for weather lookup
- `TZ`: display timezone
- `OPEN_METEO_URL`: forecast API endpoint
- `FONT_REGULAR` / `FONT_BOLD`: font paths
## Troubleshooting
- `OSError` on HID open: confirm the panel path with `lsusb`, `hid.enumerate()`, or `/sys/bus/hid/devices`, then update `HID_PATH`.
- Blank or stale panel: restart the service and check `journalctl -u mp90-panel.service`.
- Weather fetch failures: confirm network access and Open-Meteo availability.
- Text rendering errors: install DejaVu fonts or update the font constants.