{
  "id": "mattytrentini/micropython-pixel-framebuf",
  "name": "micropython-pixel-framebuf",
  "prettyName": "micropython-pixel-framebuf",
  "description": "Use NeoPixels like a framebuf",
  "version": "",
  "author": "mattytrentini",
  "license": "MIT",
  "tags": [],
  "status": "VALID",
  "official": false,
  "source": "https://github.com/mattytrentini/micropython-pixel-framebuf",
  "updatedAt": "2026-11-22T07:00:42.903Z",
  "page": "https://checkmim.com/packages/mattytrentini+micropython-pixel-framebuf",
  "createdAt": "2026-11-21T21:32:21.045Z",
  "submittedBy": "Matt",
  "install": {
    "mpremote": "mpremote mip install github:mattytrentini/micropython-pixel-framebuf",
    "mip": "import mip; mip.install(\"github:mattytrentini/micropython-pixel-framebuf\")"
  },
  "readme": "# MicroPython Pixel Framebuf\n\n`pixel_framebuf` adapts MicroPython's [`framebuf`](https://docs.micropython.org/en/latest/library/framebuf.html) drawing primitives to NeoPixel, WS2812, and DotStar/APA102 LED matrices.\n\nIt stores pixels as RGB565, so `fill`, `line`, `rect`, `ellipse`, `text`, and the other standard `framebuf.FrameBuffer` operations work normally. Call `display()` once the frame is ready to copy it to the LEDs and transmit it.\n\n## Install\n\nAfter publishing this repository to `mattytrentini/micropython-pixel-framebuf`:\n\n```sh\nmpremote mip install github:mattytrentini/micropython-pixel-framebuf\n```\n\nThe package is self-hosted through `package.json`, so it is installable directly from GitHub and does not require publication to `micropython-lib`.\n\n## Usage\n\n```python\nfrom machine import Pin\nfrom neopixel import NeoPixel\nfrom pixel_framebuf import PixelFramebuffer, HORIZONTAL\n\nWIDTH = 10\nHEIGHT = 6\nleds = NeoPixel(Pin(2), WIDTH * HEIGHT)\nmatrix = PixelFramebuffer(leds, WIDTH, HEIGHT, HORIZONTAL, alternating=True)\n\nmatrix.fill(0)\nmatrix.rect(0, 0, WIDTH, HEIGHT, 0x001f)\nmatrix.line(0, 0, WIDTH - 1, HEIGHT - 1, 0xf800)\nmatrix.text(\"Hi\", 1, 0, 0x07e0)\nmatrix.display()\n```\n\nThe Seeed Studio RGB Matrix for XIAO has 60 WS2812 LEDs in a 10-by-6 grid. The example assumes its LEDs are wired row-by-row in a serpentine pattern; use `pixel_to_led(x, y)` and a one-pixel test pattern to confirm the orientation of a particular board.\n\n## Matrix layouts\n\n`PixelFramebuffer(pixels, width, height, orientation, alternating, reverse_x, reverse_y)` accepts these layout controls:\n\n- `HORIZONTAL` (default): consecutive LEDs travel across a row.\n- `VERTICAL`: consecutive LEDs travel down a column.\n- `alternating=True` (default): reverse every second row or column for serpentine matrices.\n- `reverse_x` / `reverse_y`: move the logical origin to the other horizontal or vertical edge.\n\nThe LED object needs indexed RGB assignment and `.write()` (as MicroPython `neopixel.NeoPixel` provides). A compatible DotStar driver can simply define `write = show`. Set `auto_write=False` when creating a DotStar object; otherwise every LED assignment during `display()` transmits a partial frame.\n\n## License\n\nMIT. See [LICENSE](LICENSE).\n"
}