{"id":14967247,"url":"https://github.com/timhanewich/micropython-ssd1306","last_synced_at":"2025-10-25T17:31:41.715Z","repository":{"id":242588671,"uuid":"807786244","full_name":"TimHanewich/MicroPython-SSD1306","owner":"TimHanewich","description":"Creating and displaying bitmap graphics on an SSD-1306 OLED display using MicroPython","archived":false,"fork":false,"pushed_at":"2024-06-13T17:57:22.000Z","size":327,"stargazers_count":12,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T10:01:43.352Z","etag":null,"topics":["micropython","pico","raspberry-pi-pico","ssd1306","ssd1306-oled"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TimHanewich.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-05-29T19:11:28.000Z","updated_at":"2025-01-24T17:53:13.000Z","dependencies_parsed_at":"2024-06-13T20:54:38.741Z","dependency_job_id":null,"html_url":"https://github.com/TimHanewich/MicroPython-SSD1306","commit_stats":null,"previous_names":["timhanewich/micropython-ssd1306"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FMicroPython-SSD1306","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FMicroPython-SSD1306/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FMicroPython-SSD1306/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2FMicroPython-SSD1306/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimHanewich","download_url":"https://codeload.github.com/TimHanewich/MicroPython-SSD1306/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238191499,"owners_count":19431436,"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":["micropython","pico","raspberry-pi-pico","ssd1306","ssd1306-oled"],"created_at":"2024-09-24T13:37:41.817Z","updated_at":"2025-10-25T17:31:41.006Z","avatar_url":"https://github.com/TimHanewich.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Displaying Images on the SSD-1306 OLED Display with MicroPython\nThe **SSD-1306** is a popular driver chip used in small monochrome OLED displays. It is widely used in various electronic projects and consumer electronics due to its simplicity and effectiveness in driving OLED panels. The SSD-1306 commonly comes in resolutions of 128x64 pixels (128 wide, 64 high).\n\n**MicroPython** is an implementation of the Python 3 programming language designed to run on microcontrollers and other resource-constrained environments. It provides a subset of the Python standard library, tailored to the requirements of microcontroller hardware.\n\nI developed a developed a system for converting any bitmap image (JPG, PNG, etc.) to a format that can be displayed on the SSD-1306. This repo contains both the code to this system so you can use it yourself, and an explanation as to how it works with the SSD-1306.\n\n## Getting Up and Running: Basic SSD-1306 Interfacing\nThe [`ssd1306.py` module](./src/ssd1306.py) provides an excellent class for interfacing with the SSD1306 via I2C. I did not write this code; in fact, I do not know who did as the file itself does not credit a developer. I found this file in [this video](https://www.youtube.com/watch?v=oaM80GyVIwA) but also in other areas online. I am unsure of the author.\n\nWith that loaded onto your MicroPython board (I am using a Raspberry Pi Pico, RP2040), you can display on the SSD-1306 OLED display like this:\n\n```\nimport machine\nimport ssd1306\nimport time\n\n# create I2C interface\ni2c = machine.I2C(1, sda=machine.Pin(14), scl=machine.Pin(15)) # I have my display hooked up to pins 14 and 15 (for I2C)\nprint(i2c.scan()) # 0x3c is the I2C address of the SSD1306. As an integer, 60.\n\n# create SSD1306 interface\ndisplay_width:int = 128\ndisplay_height:int = 64\noled = ssd1306.SSD1306_I2C(128, 64, i2c)\n\n# turn on all pixels\noled.fill(1) # make the change\noled.show() # show the update\ntime.sleep(1)\n\n# turn off all pixels (blank display)\noled.fill(0)\noled.show()\ntime.sleep(1)\n\n# fill in a single pixel\noled.pixel(0, 0, 1) # turn on pixel at (0, 0) (top left)\noled.pixel(64, 0, 1) # turn on pixel at (64, 0), middle top\noled.pixel(127, 63, 1) # turn on pixel at (127, 63) (absolute bottom right on my 128x64 display)\noled.show() # show the update\ntime.sleep(1)\n\n# turn off all pixels again\noled.fill(0)\noled.show()\ntime.sleep(1)\n\n# display text\noled.text(\"Hello, world!\", 0, 0) # print text \"Hello, world!\" at position (0, 0) (top left)\noled.show()\ntime.sleep(1)\n\n# turn off all pixels again\noled.fill(0)\noled.show()\ntime.sleep(1)\n```\n\nThe above example demonstrates basic manipulation of the OLED display. The example below demonstrates (just add this to the bottom of the file below) how to display an image (represented as a bytearray, but that is explained later):\n\n```\nimport framebuf\n\n# Load smiley face image and display\n# The below bytearray is a buffer representation of a 32x32 smiley face image. This is explained in this documentation below - continue reading!\nsmiley = bytearray(b'\\x00?\\xfc\\x00\\x00\\xff\\xff\\x00\\x03\\xff\\xff\\xc0\\x07\\xe0\\x07\\xe0\\x0f\\x80\\x01\\xf0\\x1f\\x00\\x00\\xf8\u003e\\x00\\x00|\u003c\\x00\\x00\u003cx\\x00\\x00\\x1epx\\x1e\\x0e\\xf0x\\x1e\\x0f\\xe0x\\x1e\\x07\\xe0x\\x1e\\x07\\xe0\\x00\\x00\\x07\\xe0\\x00\\x00\\x07\\xe0\\x00\\x00\\x07\\xe1\\xc0\\x03\\x87\\xe1\\xc0\\x03\\x87\\xe1\\xc0\\x03\\x87\\xe1\\xe0\\x07\\x87\\xe0\\xf0\\x0f\\x07\\xf0\\xf8\\x1f\\x0fp\\x7f\\xfe\\x0ex?\\xfc\\x1e\u003c\\x0f\\xf0\u003c\u003e\\x00\\x00|\\x1f\\x00\\x00\\xf8\\x0f\\x80\\x01\\xf0\\x07\\xe0\\x07\\xe0\\x03\\xff\\xff\\xc0\\x00\\xff\\xff\\x00\\x00?\\xfc\\x00')\nfb = framebuf.FrameBuffer(smiley, 32, 32, framebuf.MONO_HLSB) # load the 32x32 image binary data in to a FrameBuffer\noled.blit(fb, 0, 0) # project or \"copy\" the loaded smiley image FrameBuffer into the OLED display at position 0,0 (the top left of the smiley will touch the top left corner of the display)\noled.show()\n```\n\n## How does displaying an image on the SSD-1306 work?\nWhen it comes down to it, the basic OLED display represents each pixel of the display as either a **0** or a **1**. A **0** means that the pixel is off while a **1** means that a pixel is on. Consider the following 8x8 image of an \"X\", for example: \n\n![8x8](https://i.imgur.com/xxWlOUD.png)\n\nYou can see that in this image of 64 pixels (8 pixels wide, 8 pixels high), the dark pixels (filled in) are represented by a 1 while the light pixels (not filled in) are represented by a 0.\n\nAs you probably know, a **byte** is a sequence of **eight bits** (8 zeros and ones). Observing the image above, we can see that, from left to right, top to bottom, we can \"chunk\" this image into **eight** bytes, each consisting of **eight bits**. For example, the first byte fits cleanly across the top row!\n\n![first row](https://i.imgur.com/swr5YJR.png)\n\nEach subsequent row of 8 bits can also be converted to a single byte form:\n\n![all rows](https://i.imgur.com/3p5lhCr.png)\n\nThus, the entire 8x8 image above can be represented as a sequence of 8 bytes (from top to bottom):\n\n```\n129,66,36,24,24,36,66,129\n```\n\nIn python, added to a `bytearray`, that will print into a `str` that looks like this:\n```\nb'\\x81B$\\x18\\x18$B\\x81'\n```\n\nWe an extrapolate this understanding to broader examples. In the above simple example, the image neatly translated into 8 rows of 8 bits, each row representing a byte. For images with widths in multiples of 8 (i.e. 16, 32, 64, etc.), this holds true, just with multiple bytes per row! For image sizes where the width is not a multiple of 8, padding is required (a more complicated process, not supported by the code in this repo).\n\n### So how can I convert a JPG/PNG image I have to buffer representation?\nI wrote code for doing that! You can find that code as the `image_to_buffer` *def* in the [`convert.py` file](./src/convert.py). This code:\n1. Uses [**pillow**](https://pypi.org/project/pillow/) to open an image.\n2. Loops through each RGB value of the image and decides if the pixel should be considered \"on\" or \"off\" based on a threshold.\n3. Assembles a list of bits representing each pixel.\n4. Chunks these bits into groups of 8.\n5. Converts each group of 8 bits into a byte.\n6. Collects these converted bytes and returns them to you - ready to be shown on the SSD-1306 display!\n\nFor example, I made a simple 128x64 (128 pixels wide, 64 pixels high) JPG image in Paint [here](./graphics/hello_world.jpg):\n\n![hello world](./graphics/hello_world.jpg)\n\nTo convert this to a buffer representation that can be loaded into the SSD-1306:\n\n```\n\u003e\u003e\u003e import convert\n\u003e\u003e\u003e converted = convert.image_to_buffer(r\"C:\\Users\\timh\\Downloads\\oled\\hello_world.jpg\")\n\u003e\u003e\u003e buffer = converted[0]\n\u003e\u003e\u003e buffer\nb'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00|\\x03\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xfe\\x0f\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00@\\x00\\x00\\x00\\x00\\x01\\xff?\\xc0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\\x00\\x00\\x00\\x00\\x01\\xe7\\xff\\xc0\\x00\\x00\\x00\\x04\\x00\\x00\\x00\\xe0\\x00\\x00\\x00\\x00\\x01\\xc7\\xf9\\xc0\\x00\\x00\\x10\\x0e\\x00\\x00\\x00\\xe0\\x00\\x00\\x00\\x00\\x01\\xc7\\xe1\\xc0\\x00\\x008\\x0e\\x00\\x00\\x00\\xe1\\x00\\x00\\x00\\x00\\x01\\xc3\\xc1\\xc0\\x00\\x008\\x0e\\x00\\x00\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xc0\\x01\\xc0\\x00\\x008\\x0e\\x00\\x00\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xc0\\x03\\xc0\\x00\\x00x\\x0e\\x00\\x00\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xc0\\x03\\x80\\x00\\x00p\\x0e\\x00\\x00\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xc0\\x07\\x80\\x00\\x00p\\x0e\\x01\\xfc\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xe0\\x0f\\x80\\x00\\x00p\\x0f\\xc3\\xfe\\x00\\xe3\\x80\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\xf7\\xff\\xe7\\xfe\\x00\\xe3\\x80\\x07\\x00\\x00\\x00\\x7f\\xfe\\x00\\x00\\x00\\xef\\xff\\xef\\x8e\\x00\\xe3\\x80\\x0f\\x80\\x00\\x00?\\xfc\\x00\\x00\\x00\\xe7\\xfe\\x0f\\x0e\\x00\\xe3\\x80\\x1f\\x80\\x00\\x00\\x1f\\xf0\\x00\\x00\\x00\\xe0\\x1c\\x1e\\x1e\\x00\\xe3\\x80?\\x80\\x00\\x00\\x0f\\x00\\x00\\x00\\x00\\xe0\\x1c\\x1f\\xfe\\x00\\xe3\\x80\\x7f\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\u003c\\x1f\\xfc\\x00\\xe3\\x80\\xf3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xe08\\x1f\\xf8\\x00\\xe3\\x81\\xe3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc08\\x0f\\x00\\x00\\xe3\\x81\\xe3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc08\\x07\\xe0\\x00\\xe3\\x81\\xc3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc08\\x03\\xfc@\\xe3\\x81\\xc3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc08\\x01\\xff\\xe0c\\x81\\xc7\\x80\\x00 \\x00\\x00\\x00\\x00\\x01\\xc0x\\x00?\\xe0\\x01\\x81\\xcf\\x00\\x00p\\x00\\x00\\x00\\x00\\x01\\xc0x\\x00\\x07\\xe0\\x00\\x01\\xff\\x00\\x00p\\x00\\x00\\x00\\x00\\x00\\xc00\\x00\\x00\\x00\\x00\\x01\\xff\\x00\\x00\\xf0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf8\\x00\\x00\\xf0\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00@\\x00\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xe0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x04\\x01\\xc0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x04\\x00\\x00\\x00\\x0e\\x01\\xc0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x0e\\x00\\x00\\x00\\x1e\\x01\\xc0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x0c\\x0e\\x00\\x0c\\x00\\x1e\\x01\\xc0\\x03\\xf0\\x03\\x80\\x00\\x00\\x18\\x00\\x1e\\x1e\\x00\\x1f\\x00\\xfc\\x01\\xc0\\x03\\xf0\\x03\\x80\\x00\\x00\u003c\\x00\u003e\\x1c\\x00\\x7f\\x81\\xf8\\x01\\xc0\\x03\\xf0\\x03\\x80\\x00\\x00\\x1c\\x00~\u003c\\x00\\xff\\x83\\xf8\\x01\\xc0\\x03\\xf0\\x03\\x80\\x00\\x00\\x1e\\x00~8\\x01\\xfb\\x83\\xe0\\x01\\xc0\\x07\\xe0\\x03\\x80\\x00\\x00\\x0e\\x00~8\\x03\\xe3\\x83\\xc0\\x01\\xc0\\x1f\\xe0\\x03\\x80\\x00\\x00\\x0f\\x00\\xfex\\x07\\xc3\\x83\\xc0\\x01\\xc0?\\xe0\\x03\\x80\\x00\\x00\\x07\\x00\\xefp\\x0f\\x03\\x83\\x80\\x01\\xc0\\x7f\\xe0\\x03\\x80\\x00\\x00\\x07\\x81\\xe7\\xf0\\x0f\\x03\\x87\\x80\\x01\\xc0\\xff\\xe0\\x03\\x80\\x00\\x00\\x03\\x83\\xc7\\xe0\\x0e\\x07\\x87\\x00\\x01\\xc1\\xef\\xe0\\x03\\x80\\x00\\x00\\x03\\xc3\\xc7\\xe0\\x1e\\x07\\x07\\x00\\x01\\xc3\\xee\\xe0\\x01\\x80\\x00\\x00\\x01\\xe7\\x87\\xc0\\x1c\\x0f\\x07\\x00\\x01\\xc3\\xce\\xe0\\x00\\x00\\x00\\x00\\x01\\xef\\x87\\xc0\\x1c\\x0f\\x07\\x00\\x01\\xc3\\x8e\\xe0\\x00\\x00\\x00\\x00\\x00\\xfe\\x07\\xc0\\x1c\\x1e\\x07\\x00\\x01\\xc7\\x8e\\xe0\\x00\\x00\\x00\\x00\\x00~\\x03\\x80\\x1e\u003e\\x07\\x00\\x01\\xc7\\x1e\\xe0\\x00\\x00\\x00\\x00\\x00\u003e\\x00\\x00\\x0f\\xfc\\x07\\x00\\x01\\xc7\u003c\\xe0\\x00\\x00\\x00\\x00\\x00\\x1c\\x00\\x00\\x0f\\xf8\\x03\\x00\\x01\\xc7|`\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x07\\xf0\\x00\\x00\\x01\\xc7\\xf8\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xc7\\xf0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\xc0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00'\n```\n\nThe `image_to_buffer` def above opens the bitmap image and translates it to a buffer representation that can be displayed on the SSD-1306. The `image_to_buffer` function returns three values as a tuple - firstly, the buffer, then the width and height of the image. Technically, these aren't necessarily needed if you already know the dimensions of your image, but they are returned here as well for convience purposes as these two values will be required to load the buffered image into memory in MicroPython.\n\n### Load to the device!\nLike in the example earlier in this document, that buffer can now be loaded into memory in the device controlling the SSD-1306 via MicroPython:\n\n```\n# load buffer\nhello_world_buf = bytearray(b'\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00|\\x03\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xfe\\x0f\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00@\\x00\\x00\\x00\\x00\\x01\\xff?\\xc0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\\x00\\x00\\x00\\x00\\x01\\xe7\\xff\\xc0\\x00\\x00\\x00\\x04\\x00\\x00\\x00\\xe0\\x00\\x00\\x00\\x00\\x01\\xc7\\xf9\\xc0\\x00\\x00\\x10\\x0e\\x00\\x00\\x00\\xe0\\x00\\x00\\x00\\x00\\x01\\xc7\\xe1\\xc0\\x00\\x008\\x0e\\x00\\x00\\x00\\xe1\\x00\\x00\\x00\\x00\\x01\\xc3\\xc1\\xc0\\x00\\x008\\x0e\\x00\\x00\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xc0\\x01\\xc0\\x00\\x008\\x0e\\x00\\x00\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xc0\\x03\\xc0\\x00\\x00x\\x0e\\x00\\x00\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xc0\\x03\\x80\\x00\\x00p\\x0e\\x00\\x00\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xc0\\x07\\x80\\x00\\x00p\\x0e\\x01\\xfc\\x00\\xe3\\x80\\x00\\x00\\x00\\x01\\xe0\\x0f\\x80\\x00\\x00p\\x0f\\xc3\\xfe\\x00\\xe3\\x80\\x00\\x00\\x00\\x00\\xf0?\\x00\\x00\\x00\\xf7\\xff\\xe7\\xfe\\x00\\xe3\\x80\\x07\\x00\\x00\\x00\\x7f\\xfe\\x00\\x00\\x00\\xef\\xff\\xef\\x8e\\x00\\xe3\\x80\\x0f\\x80\\x00\\x00?\\xfc\\x00\\x00\\x00\\xe7\\xfe\\x0f\\x0e\\x00\\xe3\\x80\\x1f\\x80\\x00\\x00\\x1f\\xf0\\x00\\x00\\x00\\xe0\\x1c\\x1e\\x1e\\x00\\xe3\\x80?\\x80\\x00\\x00\\x0f\\x00\\x00\\x00\\x00\\xe0\\x1c\\x1f\\xfe\\x00\\xe3\\x80\\x7f\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\u003c\\x1f\\xfc\\x00\\xe3\\x80\\xf3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xe08\\x1f\\xf8\\x00\\xe3\\x81\\xe3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc08\\x0f\\x00\\x00\\xe3\\x81\\xe3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc08\\x07\\xe0\\x00\\xe3\\x81\\xc3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc08\\x03\\xfc@\\xe3\\x81\\xc3\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc08\\x01\\xff\\xe0c\\x81\\xc7\\x80\\x00 \\x00\\x00\\x00\\x00\\x01\\xc0x\\x00?\\xe0\\x01\\x81\\xcf\\x00\\x00p\\x00\\x00\\x00\\x00\\x01\\xc0x\\x00\\x07\\xe0\\x00\\x01\\xff\\x00\\x00p\\x00\\x00\\x00\\x00\\x00\\xc00\\x00\\x00\\x00\\x00\\x01\\xff\\x00\\x00\\xf0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf8\\x00\\x00\\xf0\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00@\\x00\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xe0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xe0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x01\\xc0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x04\\x01\\xc0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x04\\x00\\x00\\x00\\x0e\\x01\\xc0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x00\\x0e\\x00\\x00\\x00\\x1e\\x01\\xc0\\x01\\xf0\\x03\\x80\\x00\\x00\\x00\\x00\\x0c\\x0e\\x00\\x0c\\x00\\x1e\\x01\\xc0\\x03\\xf0\\x03\\x80\\x00\\x00\\x18\\x00\\x1e\\x1e\\x00\\x1f\\x00\\xfc\\x01\\xc0\\x03\\xf0\\x03\\x80\\x00\\x00\u003c\\x00\u003e\\x1c\\x00\\x7f\\x81\\xf8\\x01\\xc0\\x03\\xf0\\x03\\x80\\x00\\x00\\x1c\\x00~\u003c\\x00\\xff\\x83\\xf8\\x01\\xc0\\x03\\xf0\\x03\\x80\\x00\\x00\\x1e\\x00~8\\x01\\xfb\\x83\\xe0\\x01\\xc0\\x07\\xe0\\x03\\x80\\x00\\x00\\x0e\\x00~8\\x03\\xe3\\x83\\xc0\\x01\\xc0\\x1f\\xe0\\x03\\x80\\x00\\x00\\x0f\\x00\\xfex\\x07\\xc3\\x83\\xc0\\x01\\xc0?\\xe0\\x03\\x80\\x00\\x00\\x07\\x00\\xefp\\x0f\\x03\\x83\\x80\\x01\\xc0\\x7f\\xe0\\x03\\x80\\x00\\x00\\x07\\x81\\xe7\\xf0\\x0f\\x03\\x87\\x80\\x01\\xc0\\xff\\xe0\\x03\\x80\\x00\\x00\\x03\\x83\\xc7\\xe0\\x0e\\x07\\x87\\x00\\x01\\xc1\\xef\\xe0\\x03\\x80\\x00\\x00\\x03\\xc3\\xc7\\xe0\\x1e\\x07\\x07\\x00\\x01\\xc3\\xee\\xe0\\x01\\x80\\x00\\x00\\x01\\xe7\\x87\\xc0\\x1c\\x0f\\x07\\x00\\x01\\xc3\\xce\\xe0\\x00\\x00\\x00\\x00\\x01\\xef\\x87\\xc0\\x1c\\x0f\\x07\\x00\\x01\\xc3\\x8e\\xe0\\x00\\x00\\x00\\x00\\x00\\xfe\\x07\\xc0\\x1c\\x1e\\x07\\x00\\x01\\xc7\\x8e\\xe0\\x00\\x00\\x00\\x00\\x00~\\x03\\x80\\x1e\u003e\\x07\\x00\\x01\\xc7\\x1e\\xe0\\x00\\x00\\x00\\x00\\x00\u003e\\x00\\x00\\x0f\\xfc\\x07\\x00\\x01\\xc7\u003c\\xe0\\x00\\x00\\x00\\x00\\x00\\x1c\\x00\\x00\\x0f\\xf8\\x03\\x00\\x01\\xc7|`\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x07\\xf0\\x00\\x00\\x01\\xc7\\xf8\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\xc7\\xf0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x03\\xc0\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00')\n\nimport framebuf\nhello_world_img = framebuf.FrameBuffer(hello_world_buf, 128, 64, framebuf.MONO_HLSB) # load as an image 128 pixels wide, 64 pixels high\noled.blit(hello_world_img, 0, 0) # write the 128x64 image to the SSD-1306 display, positioned in the top left corner\noled.show() # show on the display\n```\n\nAnd the [hello world image](./hello_world.jpg) is displayed!\n\n![hello world](https://i.imgur.com/51eorVj.png)\n\nThe buffer is \"hard coded\" within the code above. However, the binary data itself can just as easily be stored in file form on-device!\n\n## Graphic Collections\nIn this repo I am also providing pre-converted graphics that can be loaded directly into a `FrameBuffer` in MicroPython (to display on an SSD-1306). I am providing:\n- [A full alphanumeric set](./graphics/alphanumeric/bitmaps/) from [here](https://www.flaticon.com/packs/alphabet-and-numbers-11)\n    - [16x16](./graphics/alphanumeric/16x16/)\n    - [32x32](./graphics/alphanumeric/32x32/)\n    - [64x64](./graphics/alphanumeric/64x64/)\n\n### Creating your own graphics collection\nYou can use the `images_to_buffers` function of the [`convert.py` module](./src/convert.py). For example, to convert all bitmap images (i.e. PNG's) in the `bitmaps` folder to 64x64 buffer arrays in the `64x64` folder that can be loaded onto the SSD-1306:\n\n```\nimages_to_buffers(r\"C:\\Users\\timh\\Downloads\\oled\\graphics\\alphanumeric\\bitmaps\", r\"C:\\Users\\timh\\Downloads\\oled\\graphics\\alphanumeric\\64x64\", resize=(64,64))\n```\n\nThe example snippet above is what produced all of the 64x64 buffers [here in the alphanumeric collection](./graphics/alphanumeric/64x64/)!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimhanewich%2Fmicropython-ssd1306","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimhanewich%2Fmicropython-ssd1306","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimhanewich%2Fmicropython-ssd1306/lists"}