{"id":15540351,"url":"https://github.com/rm-hull/luma.examples","last_synced_at":"2025-05-15T15:09:06.196Z","repository":{"id":15794819,"uuid":"78778717","full_name":"rm-hull/luma.examples","owner":"rm-hull","description":"Companion repo for running examples against the luma.oled, luma.lcd, luma.led_matrix and luma.emulator display drivers.","archived":false,"fork":false,"pushed_at":"2024-11-02T23:37:48.000Z","size":5749,"stargazers_count":399,"open_issues_count":25,"forks_count":151,"subscribers_count":26,"default_branch":"main","last_synced_at":"2025-03-31T20:06:50.204Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rm-hull.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE.rst","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-12T19:20:20.000Z","updated_at":"2025-03-30T19:50:16.000Z","dependencies_parsed_at":"2023-01-13T20:30:16.853Z","dependency_job_id":"2abee573-5bbe-46bb-b6f0-0635f6516ba4","html_url":"https://github.com/rm-hull/luma.examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rm-hull%2Fluma.examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rm-hull%2Fluma.examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rm-hull%2Fluma.examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rm-hull%2Fluma.examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rm-hull","download_url":"https://codeload.github.com/rm-hull/luma.examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730068,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-02T12:13:35.687Z","updated_at":"2025-04-07T21:11:13.818Z","avatar_url":"https://github.com/rm-hull.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"`luma.core \u003chttps://github.com/rm-hull/luma.core\u003e`__ **|**\n`luma.docs \u003chttps://github.com/rm-hull/luma.docs\u003e`__ **|**\n`luma.emulator \u003chttps://github.com/rm-hull/luma.emulator\u003e`__ **|**\nluma.examples **|**\n`luma.lcd \u003chttps://github.com/rm-hull/luma.lcd\u003e`__ **|**\n`luma.led_matrix \u003chttps://github.com/rm-hull/luma.led_matrix\u003e`__ **|**\n`luma.oled \u003chttps://github.com/rm-hull/luma.oled\u003e`__\n\nLuma.Examples\n=============\n\n.. image:: https://github.com/rm-hull/luma.examples/workflows/luma.examples/badge.svg?branch=master\n   :target: https://github.com/rm-hull/luma.examples/actions?workflow=luma.examples\n\nThis is the companion repo for running examples against the `luma.emulator \u003chttps://github.com/rm-hull/luma.emulator\u003e`_,\n`luma.oled \u003chttps://github.com/rm-hull/luma.oled\u003e`_, `luma.lcd \u003chttps://github.com/rm-hull/luma.lcd\u003e`_ and\n`luma.led_matrix \u003chttps://github.com/rm-hull/luma.led_matrix\u003e`_ display drivers.\n\nInstallation instructions\n-------------------------\nAssuming you are using a Raspberry Pi (running Debian Jessie or newer), follow the pre-requisites \u0026\ninstructions in the above repositories to wire up your display, then from a command-line::\n\n  $ sudo usermod -a -G i2c,spi,gpio pi\n  $ sudo apt install python3-dev python3-pip python3-numpy libfreetype6-dev libjpeg-dev build-essential\n  $ sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev\n\nLog out and in again and clone this repository::\n\n  $ git clone https://github.com/rm-hull/luma.examples.git\n  $ cd luma.examples\n\nFinally, install the luma libraries using::\n\n  $ sudo -H pip install -e .\n\n\nRunning the examples\n--------------------\nAfter cloning the repository, enter the ``examples`` directory and try running\none of the following examples listed below. For example::\n\n  cd examples\n  python3 3d_box.py\n\n========================= ================================================================\nExample                   Description\n========================= ================================================================\n3d_box.py                 Rotating 3D box wireframe \u0026 color dithering\nanimated_gif.py           Renders an animated GIF\nbitstamp_ticker.py        Display the Bitcoin price at Bitstamp\nbitstamp_realtime.py      Displays the latest Bitcoin trades in realtime at Bitstamp\nbounce.py                 Display a bouncing ball animation and frames per second\ncarousel.py               Showcase viewport and hotspot functionality\nchroma.py                 Trippy color rendering demo\nclock.py                  An analog clockface with date \u0026 time\ncolors.py                 Color rendering demo\ncrawl.py                  A vertical scrolling demo, which should be familiar\ndemo.py                   Use misc draw commands to create a simple image\ndotmatrixtool.py          Simple demo showing how to integrate output from http://dotmatrixtool.com\nfont_awesome.py           A meander through some awesome fonts\ngame_of_life.py           Conway's game of life\ngreyscale.py              Greyscale rendering demo\nimage_composition.py      Displays different song titles and scrolls them back and forth\ninvaders.py               Space Invaders demo\njetset_willy.py           Sprite animation framework demo\nlarson_hue.py             Alpha blending color demo\nmatrix.py                 The Matrix\nmaze.py                   Maze generator\nperfloop.py               Simple benchmarking utility to measure performance\npicamera_photo.py         Capture photo with picamera and display it on a screen\npicamera_video.py         Capture continuous video stream and display it on a screen\npi_logo.py                Display the Raspberry Pi logo (loads image as .png)\nrunner.py                 Sprite animation framework demo\nsavepoint.py              Example of savepoint/restore functionality\nscrolling_pixelart.py     Image dithering and viewport scrolling\nsprite_animation.py       Using sprite maps for animation effects\nstarfield.py              3D starfield simulation\nsys_histogram.py          Display system information including a rolling histogram\nsys_info.py               Display basic system information\nsys_info_extended.py      Display detailed system information in graph format\nterminal.py               Simple println capabilities\ntv_snow.py                Example image-blitting\ntweet_scroll.py           Using Twitter's Streaming API to display scrolling notifications\nvideo.py                  Display a video clip\nweather.py                3-day weather forecasts from the BBC\nwelcome.py                Unicode font rendering \u0026 scrolling\n========================= ================================================================\n\nBy default, all the examples will asume I2C port 1, address ``0x3C`` and the\n``ssd1306`` driver.  If you need to use a different setting, these can be\nspecified on the command line – each program can be invoked with a ``--help``\nflag to show the options::\n\n    $ python3 examples/demo.py --help\n    usage: demo.py [-h] [--config CONFIG] [--display DISPLAY] [--width WIDTH]\n                    [--height HEIGHT] [--rotate ROTATION] [--interface INTERFACE]\n                    [--i2c-port I2C_PORT] [--i2c-address I2C_ADDRESS]\n                    [--spi-port SPI_PORT] [--spi-device SPI_DEVICE]\n                    [--spi-bus-speed SPI_BUS_SPEED]\n                    [--spi-transfer-size SPI_TRANSFER_SIZE]\n                    [--spi-cs-high SPI_CS_HIGH] [--ftdi-device FTDI_DEVICE]\n                    [--framebuffer-device FRAMEBUFFER_DEVICE] [--gpio GPIO]\n                    [--gpio-mode GPIO_MODE]\n                    [--gpio-data-command GPIO_DATA_COMMAND]\n                    [--gpio-chip-select GPIO_CHIP_SELECT]\n                    [--gpio-reset GPIO_RESET] [--gpio-backlight GPIO_BACKLIGHT]\n                    [--gpio-reset-hold-time GPIO_RESET_HOLD_TIME]\n                    [--gpio-reset-release-time GPIO_RESET_RELEASE_TIME]\n                    [--block-orientation ORIENTATION] [--mode MODE]\n                    [--framebuffer FRAMEBUFFER] [--num-segments NUM_SEGMENTS]\n                    [--bgr] [--inverse] [--h-offset H_OFFSET]\n                    [--v-offset V_OFFSET] [--backlight-active VALUE] [--debug]\n                    [--transform TRANSFORM] [--scale SCALE] [--duration DURATION]\n                    [--loop LOOP] [--max-frames MAX_FRAMES]\n\n    luma.examples arguments\n\n    options:\n      -h, --help            show this help message and exit\n\n    General:\n      --config CONFIG, -f CONFIG\n                            Load configuration settings from a file (default:\n                            None)\n      --display DISPLAY, -d DISPLAY\n                            Display type, supports real devices or emulators.\n                            Allowed values are: ssd1306, ssd1309, ssd1322,\n                            ssd1362, ssd1322_nhd, ssd1325, ssd1327, ssd1331,\n                            ssd1351, sh1106, sh1107, ws0010, winstar_weh, pcd8544,\n                            st7735, st7789, ht1621, uc1701x, st7567, ili9341,\n                            ili9486, ili9488, hd44780, max7219, ws2812, neopixel,\n                            neosegment, apa102, unicornhathd, capture, gifanim,\n                            pygame, asciiart, asciiblock, linux_framebuffer\n                            (default: ssd1306)\n      --width WIDTH         Width of the device in pixels (default: 128)\n      --height HEIGHT       Height of the device in pixels (default: 64)\n      --rotate ROTATION, -r ROTATION\n                            Rotation factor. Allowed values are: 0, 1, 2, 3\n                            (default: 0)\n      --interface INTERFACE, -i INTERFACE\n                            Interface type. Allowed values are: i2c, noop, spi,\n                            gpio_cs_spi, bitbang, ftdi_spi, ftdi_i2c, pcf8574,\n                            bitbang_6800 (default: i2c)\n\n    I2C:\n      --i2c-port I2C_PORT   I2C bus number (default: 1)\n      --i2c-address I2C_ADDRESS\n                            I2C display address (default: 0x3C)\n\n    SPI:\n      --spi-port SPI_PORT   SPI port number (default: 0)\n      --spi-device SPI_DEVICE\n                            SPI device (default: 0)\n      --spi-bus-speed SPI_BUS_SPEED\n                            SPI max bus speed (Hz) (default: 8000000)\n      --spi-transfer-size SPI_TRANSFER_SIZE\n                            SPI bus max transfer unit (bytes) (default: 4096)\n      --spi-cs-high SPI_CS_HIGH\n                            SPI chip select is high (gpio_cs_spi driver only)\n                            (default: False)\n\n    FTDI:\n      --ftdi-device FTDI_DEVICE\n                            FTDI device (default: ftdi://::/1)\n\n    Linux framebuffer:\n      --framebuffer-device FRAMEBUFFER_DEVICE\n                            Linux framebuffer device (default: /dev/fd0)\n\n    GPIO:\n      --gpio GPIO           Alternative RPi.GPIO compatible implementation (SPI\n                            interface only) (default: None)\n      --gpio-mode GPIO_MODE\n                            Alternative pin mapping mode (SPI interface only)\n                            (default: None)\n      --gpio-data-command GPIO_DATA_COMMAND\n                            GPIO pin for D/C RESET (SPI interface only) (default:\n                            24)\n      --gpio-chip-select GPIO_CHIP_SELECT\n                            GPIO pin for Chip select (GPIO_CS_SPI interface only)\n                            (default: 24)\n      --gpio-reset GPIO_RESET\n                            GPIO pin for RESET (SPI interface only) (default: 25)\n      --gpio-backlight GPIO_BACKLIGHT\n                            GPIO pin for backlight (PCD8544, ST7735 devices only)\n                            (default: 18)\n      --gpio-reset-hold-time GPIO_RESET_HOLD_TIME\n                            Duration to hold reset line active on startup\n                            (seconds) (SPI interface only) (default: 0)\n      --gpio-reset-release-time GPIO_RESET_RELEASE_TIME\n                            Duration to pause for after reset line was made active\n                            on startup (seconds) (SPI interface only) (default: 0)\n\n    Misc:\n      --block-orientation ORIENTATION\n                            Fix 90° phase error (MAX7219 LED matrix only). Allowed\n                            values are: 0, 90, -90, 180 (default: 0)\n      --mode MODE           Colour mode (SSD1322, SSD1325 and emulator only).\n                            Allowed values are: 1, RGB, RGBA (default: RGB)\n      --framebuffer FRAMEBUFFER\n                            Framebuffer implementation (SSD1331, SSD1322, ST7735,\n                            ILI9341 displays only). Allowed values are:\n                            diff_to_previous, full_frame (default:\n                            diff_to_previous)\n      --num-segments NUM_SEGMENTS\n                            Sets the number of segments to when using the diff-to-\n                            previous framebuffer implementation. (default: 4)\n      --bgr                 Set if LCD pixels laid out in BGR (ST7735 displays\n                            only). (default: False)\n      --inverse             Set if LCD has swapped black and white (ST7735\n                            displays only). (default: False)\n      --h-offset H_OFFSET   Horizontal offset (in pixels) of screen to display\n                            memory (ST7735 displays only). (default: 0)\n      --v-offset V_OFFSET   Vertical offset (in pixels) of screen to display\n                            memory (ST7735 displays only). (default: 0)\n      --backlight-active VALUE\n                            Set to \"low\" if LCD backlight is active low, else\n                            \"high\" otherwise (PCD8544, ST7735 displays only).\n                            Allowed values are: low, high (default: low)\n      --debug               Set to enable debugging. (default: False)\n\n    Emulator:\n      --transform TRANSFORM\n                            Scaling transform to apply (emulator only). Allowed\n                            values are: identity, led_matrix, none, scale2x,\n                            seven_segment, smoothscale (default: scale2x)\n      --scale SCALE         Scaling factor to apply (emulator only) (default: 2)\n      --duration DURATION   Animation frame duration (gifanim emulator only)\n                            (default: 0.01)\n      --loop LOOP           Repeat loop, zero=forever (gifanim emulator only)\n                            (default: 0)\n      --max-frames MAX_FRAMES\n                            Maximum frames to record (gifanim emulator only)\n                            (default: None)\n\n.. note::\n   #. ``python3-dev`` (apt-get) and ``psutil`` (pip/pip3) are required to run the ``sys_info.py``\n      example. See `install instructions \u003chttps://github.com/rm-hull/luma.examples/blob/master/examples/sys_info.py#L10-L13\u003e`_ for the exact commands to use.\n   #. At runtime, ``luma.core`` enumerates which display drivers are present and dynamically constructs the list of ``--display`` options, therefore (for example) the ``capture``/``gifanim``/``pygame`` options will not show unless `luma.emulator` is installed\n\nEmulators\n^^^^^^^^^\nThere are various display emulators available for running code against, for debugging\nand screen capture functionality:\n\n* The `luma.emulator.device.capture` device will persist a numbered PNG file to\n  disk every time its ``display`` method is called.\n\n* The `luma.emulator.device.gifanim` device will record every image when its ``display``\n  method is called, and on program exit (or Ctrl-C), will assemble the images into an\n  animated GIF.\n\n* The `luma.emulator.device.pygame` device uses the `pygame` library to\n  render the displayed image to a pygame display surface.\n\nAfter `installing luma.emulator \u003chttps://luma-emulator.readthedocs.io/en/latest/install.html\u003e`_\nyou can invoke the demos with::\n\n  $ python3 examples/clock.py --display pygame\n\nor::\n\n  $ python3 examples/clock.py --display gifanim\n\n  $ python3 examples/starfield.py --display capture\n\nDocumentation\n-------------\nFull documentation with installation instructions can be found in:\n\n* https://luma-oled.readthedocs.io\n* https://luma-lcd.readthedocs.io\n* https://luma-led-matrix.readthedocs.io\n* https://luma-core.readthedocs.io\n* https://luma-emulator.readthedocs.io\n\nLicense\n-------\nThe MIT License (MIT)\n\nCopyright (c) 2017-2023 Richard Hull \u0026 Contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frm-hull%2Fluma.examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frm-hull%2Fluma.examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frm-hull%2Fluma.examples/lists"}