# MicroPython Max7219 8x8 LED Matrix
![PyPI](https://img.shields.io/pypi/v/micropython-max7219)
![PyPI - Implementation](https://img.shields.io/pypi/implementation/micropython-max7219)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/micropython-max7219)
![PyPI - License](https://img.shields.io/pypi/l/micropython-max7219)
![PyPI - Downloads](https://img.shields.io/pypi/dm/micropython-max7219)
A MicroPython library for the MAX7219 8x8 LED matrix driver using the SPI interface. Supporting custom fonts and cascading matrices.
## Features
- Cascading matrices together
- Custom font support
- Extends the [FrameBuffer](http://docs.micropython.org/en/latest/pyboard/library/framebuf.html) class
- Removes the need to specify offset for text method
- Extendable
## Examples
### Raspberry Pi Pico
| Pico | max7219 |
| :-------- | :------ |
| 40 (VBUS) | VCC 5V |
| 38 (GND) | GND |
| 5 (GP3) | DIN |
| 7 (GP5) | CS |
| 4 (GP2) | CLK |
```python
from machine import Pin, SPI
from max7219 import Matrix8x8
spi = SPI(0, baudrate=10000000, polarity=1, phase=0, sck=Pin(2), mosi=Pin(3))
ss = Pin(5, Pin.OUT)
display = Matrix8x8(spi, ss, 4)
# change brightness 1-15
display.brightness(5)
# clear display
display.zero()
display.show()
# show text using FrameBuffer's font
display.text("CODE")
display.show()
```
## Docs
- For any change to the `FrameBuffer` to appear, call the `.show()` method
- You may have to add delays when calling methods, these are documented in the datasheet
- Tested on 1.19.1
### Display Text
```python
display = Matrix8x8(...)
display.zero()
display.text("HI!")
display.show()
```
### Custom Fonts
Custom fonts (glyphs) can be provided, each glyph must be 8x8. Missing characters will use default characters from `FrameBuffer`.
```python
GLYPHS = {
"X": [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 0, 0],
[0, 0, 1, 0, 0, 1, 0, 0],
[0, 1, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
],
}
display = Matrix8x8(...)
display.text_from_glyph("X", GLYPHS)
```
### Shutdown / Wake
Shutting down and waking up the display is supported. This should allow a device to consume just 150μA when it's not needed. When the display is woken from shutdown the previous display should appear.
```python
# shutdown display
display.shutdown()
# wake from shutdown
display.wake()
```
### Test Mode
Test mode will enable all pixels, shutdown mode has no effect when testing mode is enabled.
```python
# enable test mode
display.test()
# disable test mode
display.test(False)
```
### Extending
#### Scrolling Text
Although not built-in you could add scrolling text like shown in the following example:
```python
from utime import sleep_ms
from max7219 import Matrix8x8
class Matrix8x8Ext(Matrix8x8):
def scroll_text(self, s, ms_delay=100):
s_width = len(s) * 8
n_pixels = self.num * 8
while True:
for x in range(n_pixels, -s_width, -1):
self.zero()
self.text(s, x)
self.show()
sleep_ms(ms_delay)
return s_width
```
## Attribution
- Original code by [@mcauser](https://github.com/mcauser/micropython-max7219)
- [Data-Sheet](https://www.analog.com/media/en/technical-documentation/data-sheets/max7219-max7221.pdf)
## License
Licensed under the [MIT License](http://opensource.org/licenses/MIT), found in `LICENSE.txt`.
Raw data
{
"_id": null,
"home_page": "https://github.com/enchant97/micropython-max7219",
"name": "micropython-max7219",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "micropython,max7219",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/bd/8f/c2dc9f5ae8dd1b7b695498bb4ca8cb5e2871dc4263435c5d9237fa7ffe5c/micropython-max7219-0.2.0.tar.gz",
"platform": null,
"description": "# MicroPython Max7219 8x8 LED Matrix\n![PyPI](https://img.shields.io/pypi/v/micropython-max7219)\n![PyPI - Implementation](https://img.shields.io/pypi/implementation/micropython-max7219)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/micropython-max7219)\n![PyPI - License](https://img.shields.io/pypi/l/micropython-max7219)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/micropython-max7219)\n\nA MicroPython library for the MAX7219 8x8 LED matrix driver using the SPI interface. Supporting custom fonts and cascading matrices.\n\n## Features\n- Cascading matrices together\n- Custom font support\n- Extends the [FrameBuffer](http://docs.micropython.org/en/latest/pyboard/library/framebuf.html) class\n- Removes the need to specify offset for text method\n- Extendable\n\n\n## Examples\n### Raspberry Pi Pico\n\n| Pico | max7219 |\n| :-------- | :------ |\n| 40 (VBUS) | VCC 5V |\n| 38 (GND) | GND |\n| 5 (GP3) | DIN |\n| 7 (GP5) | CS |\n| 4 (GP2) | CLK |\n\n```python\nfrom machine import Pin, SPI\nfrom max7219 import Matrix8x8\n\nspi = SPI(0, baudrate=10000000, polarity=1, phase=0, sck=Pin(2), mosi=Pin(3))\nss = Pin(5, Pin.OUT)\n\ndisplay = Matrix8x8(spi, ss, 4)\n\n# change brightness 1-15\ndisplay.brightness(5)\n\n# clear display\ndisplay.zero()\ndisplay.show()\n\n# show text using FrameBuffer's font\ndisplay.text(\"CODE\")\ndisplay.show()\n```\n\n\n## Docs\n- For any change to the `FrameBuffer` to appear, call the `.show()` method\n- You may have to add delays when calling methods, these are documented in the datasheet\n- Tested on 1.19.1\n\n### Display Text\n\n```python\ndisplay = Matrix8x8(...)\n\ndisplay.zero()\ndisplay.text(\"HI!\")\ndisplay.show()\n```\n\n### Custom Fonts\nCustom fonts (glyphs) can be provided, each glyph must be 8x8. Missing characters will use default characters from `FrameBuffer`.\n\n```python\nGLYPHS = {\n \"X\": [\n [0, 0, 0, 0, 0, 0, 0, 0],\n [0, 1, 0, 0, 0, 0, 1, 0],\n [0, 0, 1, 0, 0, 1, 0, 0],\n [0, 0, 0, 1, 1, 0, 0, 0],\n [0, 0, 0, 1, 1, 0, 0, 0],\n [0, 0, 1, 0, 0, 1, 0, 0],\n [0, 1, 0, 0, 0, 0, 1, 0],\n [0, 0, 0, 0, 0, 0, 0, 0],\n ],\n}\n\ndisplay = Matrix8x8(...)\ndisplay.text_from_glyph(\"X\", GLYPHS)\n```\n\n### Shutdown / Wake\nShutting down and waking up the display is supported. This should allow a device to consume just 150\u03bcA when it's not needed. When the display is woken from shutdown the previous display should appear.\n\n```python\n# shutdown display\ndisplay.shutdown()\n\n# wake from shutdown\ndisplay.wake()\n```\n\n### Test Mode\nTest mode will enable all pixels, shutdown mode has no effect when testing mode is enabled.\n\n```python\n# enable test mode\ndisplay.test()\n# disable test mode\ndisplay.test(False)\n```\n\n### Extending\n#### Scrolling Text\nAlthough not built-in you could add scrolling text like shown in the following example:\n\n```python\nfrom utime import sleep_ms\n\nfrom max7219 import Matrix8x8\n\nclass Matrix8x8Ext(Matrix8x8):\n def scroll_text(self, s, ms_delay=100):\n s_width = len(s) * 8\n n_pixels = self.num * 8\n while True:\n for x in range(n_pixels, -s_width, -1):\n self.zero()\n self.text(s, x)\n self.show()\n sleep_ms(ms_delay)\n return s_width\n```\n\n\n## Attribution\n- Original code by [@mcauser](https://github.com/mcauser/micropython-max7219)\n- [Data-Sheet](https://www.analog.com/media/en/technical-documentation/data-sheets/max7219-max7221.pdf)\n\n\n## License\nLicensed under the [MIT License](http://opensource.org/licenses/MIT), found in `LICENSE.txt`.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A MicroPython library for the Max7219 8x8 LED matrix driver",
"version": "0.2.0",
"split_keywords": [
"micropython",
"max7219"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "9c78d6faefe2c5953c66b2166decf71b",
"sha256": "d70b0c3ebf1485ef5d678a3ccfa8df7090003765d48771e9cbaffa2fa61889ab"
},
"downloads": -1,
"filename": "micropython_max7219-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9c78d6faefe2c5953c66b2166decf71b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4689,
"upload_time": "2022-12-13T20:31:06",
"upload_time_iso_8601": "2022-12-13T20:31:06.036822Z",
"url": "https://files.pythonhosted.org/packages/e0/42/8c0686f4bc4eee3467326f89d07e97b89cc0211bb4c3c4b857acff9a5d20/micropython_max7219-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "e6019dcd2dd07d61daeeaa6c0f96da8d",
"sha256": "1a55ccca514df51a05f19ff47667ab5a5bec21f15901e9eaa991e642b8930fdd"
},
"downloads": -1,
"filename": "micropython-max7219-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "e6019dcd2dd07d61daeeaa6c0f96da8d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4245,
"upload_time": "2022-12-13T20:31:07",
"upload_time_iso_8601": "2022-12-13T20:31:07.102272Z",
"url": "https://files.pythonhosted.org/packages/bd/8f/c2dc9f5ae8dd1b7b695498bb4ca8cb5e2871dc4263435c5d9237fa7ffe5c/micropython-max7219-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-13 20:31:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "enchant97",
"github_project": "micropython-max7219",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "micropython-max7219"
}