Files
MeshCore-Solo/tools
Jakub 37432491dd fix(screenshot/eink): handle portrait and landscape rotations in decoder
The previous decoder always applied the rotation=1 (landscape) transform,
which caused three visible artefacts on a portrait (rotation=0) device:
  - Content rotated 90°     — wrong phys_x/phys_y mapping
  - Content doubled/skewed  — stride = buffer/log_width = 4000/122 = 32
                               instead of buffer/HEIGHT  = 4000/250 = 16

Fix: infer rotation from aspect ratio (portrait: log_height > log_width).
  portrait  → direct mapping: phys_x=lx, phys_y=ly
  landscape → rotation-1 map: phys_x=log_height-1-ly, phys_y=lx

Derive phys_stride from buffer_size // max(log_w, log_h) — the physical
HEIGHT is always the longer axis regardless of rotation, giving 16 bytes/row
for GxEPD2_213_B74 in both orientations.

No panel-specific constants remain; works for any GxEPD2 panel/rotation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-28 07:54:45 +02:00
..

Display Screenshot Tool

⚠️ Note: The screenshot feature requires the ENABLE_SCREENSHOT build flag to be enabled. Add -D ENABLE_SCREENSHOT to your PlatformIO build flags, then recompile and flash the firmware.

The firmware supports capturing the current display contents and transmitting it over USB serial. This is useful for debugging, remote monitoring, or creating documentation.

Important: When the device is connected to the companion app, the USB serial port is not available for communication. To use the screenshot tool, ensure the device is not connected to the companion app.

Usage:

  1. Build and flash firmware with -D ENABLE_SCREENSHOT build flag enabled

Example for the OLED dual firmware:

PLATFORMIO_BUILD_FLAGS="-D ENABLE_SCREENSHOT" pio run -e WioTrackerL1_companion_dual -t upload
  1. Connect the device to your computer via USB (ensure no companion app connection)

  2. Install dependencies and run the screenshot tool. To manage python and python dependencies, use uv: https://docs.astral.sh/uv/

    cd tools
    uv run tools/screenshot.py
    

    Options:

    • --port PORT — Serial port to use (default: auto-detect)
    • --scale SCALE — Upscale factor for the output image (1=no upscale, 2=2x, 3=3x, 4=4x, etc.; default: 1)
  3. In the tool's interactive menu, press S to capture a screenshot

  4. The tool will save the screenshot as a PNG file in tools/pngs/ with a timestamp-based filename

How it works:

  • The tool sends the CMD_GET_SCREENSHOT command (66) to the device
  • The device responds with RESP_CODE_SCREENSHOT (29) containing the framebuffer data
  • The framebuffer is transmitted in chunks (128×64 display = 1024 bytes, split across multiple frames)
  • The tool reassembles the chunks and converts them to a PNG image