Metadata-Version: 2.3
Name: displaypad-driver
Version: 2.0.0
Summary: A Driver to communicate with the mountain displaypad.
License: MIT
Keywords: displaypad,mountain,driver,library,python,usb,hid
Author: AnnikenToGo
Author-email: anniken@annikentogo.de
Requires-Python: >=3.14
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: System :: Hardware :: Hardware Drivers
Classifier: Topic :: System :: Hardware :: Universal Serial Bus (USB) :: Human Interface Device (HID)
Requires-Dist: hidapi (>=0.14.0,<1.0.0)
Requires-Dist: pillow (>=12.1.0,<13.0.0)
Requires-Dist: pyusb (>=1.3.1,<2.0.0)
Project-URL: Bug Tracker, https://github.com/AnnikenYT/oss-mountain-displaypad/issues
Project-URL: Documentation, https://github.com/annikenyt/oss-mountain-displaypad/wiki
Project-URL: Homepage, https://annikentogo.de
Project-URL: Repository, https://github.com/AnnikenYT/oss-mountain-displaypad
Description-Content-Type: text/markdown

# displaypad-driver

USB driver for the Mountain DisplayPad. Handles device connection, image uploads, key polling, and brightness control. Used internally by `displaypad-lib`; use that unless you need direct hardware access.

## Modules

- **`device.py`** — `DisplayPad` driver class.
  - `DisplayPad(vendor_id, product_id, auto_connect=True)` — opens USB interfaces on init unless `auto_connect=False`.
  - `try_connect()` → `bool` — connect without raising on failure.
  - `connect()` / `close()` — open and release USB interfaces.
  - `upload_button(key_index, bgr_pixels)` — upload a 102×102 BGR image to one key slot (0–11).
  - `upload_panel(tiles_bgr)` — upload all 12 key slots at once.
  - `poll_key(timeout)` → `{'pressed', 'released', 'current'}` — read key state.
  - `set_brightness(percent)` — set backlight 0–100%.
  - `close()` — release interfaces.
- **`transport.py`** — opens Interface 1 (bulk pixel data via PyUSB) and Interface 3 (HID commands/events via hidapi). Not intended for direct use.
- **`hotplug.py`** — `USBHotplugMonitor` and `is_device_present()` for detecting plug/unplug events.
- **`protocol.py`** — VID/PID constants, packet templates, and `get_pressed_keys()`.
- **`image.py`** — image conversion utilities: `image_to_bgr102`, `split_image_to_tiles`, `load_gif_frames`, `split_gif_to_tiles`, `make_label_icon`, `make_folder_icon`.

For a usage example, see [driver_example.py](https://github.com/AnnikenYT/oss-mountain-displaypad/blob/main/examples/driver_example.py).

## Acknowledgments
Performance optimizations, dual-interface transport handling, initialization handshakes, and input report interleaving were built with inspiration from [ramisotti13-eng/BaseCamp-Linux](https://github.com/ramisotti13-eng/BaseCamp-Linux).

