{"id":18262061,"url":"https://github.com/de-dh/ESP32-Cheap-Yellow-Display-Micropython-LVGL","last_synced_at":"2025-04-04T20:30:34.887Z","repository":{"id":250914804,"uuid":"835839473","full_name":"de-dh/ESP32-Cheap-Yellow-Display-Micropython-LVGL","owner":"de-dh","description":"This repository is about running LVGL under Micropython firmware on the cheap yellow display. ","archived":false,"fork":false,"pushed_at":"2024-12-22T21:05:56.000Z","size":1372,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T18:53:58.498Z","etag":null,"topics":["cheap-yellow-display","cyd","cyd2usb","demo","esp32","esp32-2432s028","esp32-gui","esp32-wroom","firmware","ili9341","lvgl","lvgl8","micropython","thonny","xpt2046"],"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/de-dh.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-07-30T16:22:43.000Z","updated_at":"2025-03-06T08:21:34.000Z","dependencies_parsed_at":"2024-09-13T04:32:17.633Z","dependency_job_id":"5748c381-abdc-41da-a44d-65c845db0ef0","html_url":"https://github.com/de-dh/ESP32-Cheap-Yellow-Display-Micropython-LVGL","commit_stats":null,"previous_names":["de-dh/cyd2-mpy-lvgl","de-dh/esp32-cheap-yellow-display-micropython-lvgl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-dh%2FESP32-Cheap-Yellow-Display-Micropython-LVGL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-dh%2FESP32-Cheap-Yellow-Display-Micropython-LVGL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-dh%2FESP32-Cheap-Yellow-Display-Micropython-LVGL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/de-dh%2FESP32-Cheap-Yellow-Display-Micropython-LVGL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/de-dh","download_url":"https://codeload.github.com/de-dh/ESP32-Cheap-Yellow-Display-Micropython-LVGL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247246031,"owners_count":20907724,"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":["cheap-yellow-display","cyd","cyd2usb","demo","esp32","esp32-2432s028","esp32-gui","esp32-wroom","firmware","ili9341","lvgl","lvgl8","micropython","thonny","xpt2046"],"created_at":"2024-11-05T11:06:30.004Z","updated_at":"2025-04-04T20:30:34.879Z","avatar_url":"https://github.com/de-dh.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!NOTE]\n\u003e This repositry is meant to show you how to quickly get LVGL under Micropython on the Cheap-Yellow-Display working and save you some time and pain.\n\u003e Everyone is welcome to contribute to this repositry and share his / her knowledge.\n\n\u003e [!WARNING]\n\u003e All demo programs were tested with the pre-built firmware linked in this repositry using **LVGL version 8.3.6.** and **Micropython version 1.19.1.**\n\u003e The demo programs may be incompatible with other versions of LVGL / MPY.\n\n\n\n# CYD2-MPY-LVGL\n\n## Introduction\n\u003cimg align=\"right\"  src=\"doc/CYD1.jpg\" width=\"250\" height=\"auto\" /\u003e\n\nThe [Cheap Yellow Display](https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/tree/main) (CYD) aka ESP32-2432S028 is a low-cost device comprised of a ESP32-WROOM equipped with a\nILI9431 2.8' Display and a xpt2046 resistive touch pad and some more peripherals. It can be found on AliExpress for 7$ - 15$ depending on the seller and available promotions.\nIn my opinion, this combination is great for GUI development for small IOT projects.\n\n\nHowever, getting LVGL + MPY to work on the CYD(2) was very time-consuming and annoying. \nThis documentation might save you a lot of time which I wasted.\n\n**This repository is about running LVGL under Miropython firmware on the cheap yellow display.** \nThis setup enables the use of Thonny to create and debug programms easily.\nThe CYD is ideal for small IOT projects and LVGL provides a convenient solution to create user interfaces.\n\nThe demo programms demonstrate the following functions of lvgl on CYD(2):\n\n- simple demo with buttons and callback functions\n- using CYD2 in portrait mode\n- loading a png image\n- loading a custom text font\n- loading a custom icon font\n- advanced demo with multiple screens, a chart with data imported from a .csv file and asyncio usage\n\n[Two similar versions of CYD are available](https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/blob/main/cyd.md). \nThe first version has one USB port (i call this \"CYD\") and the second version features two USB ports (i call this \"CYD-2\"). \nAlthough the remaining components are identical, there is a difference in the display drivers color management.\n\n\u003cimg src=\"doc/CYD_Chart.jpg\" width=\"250\" height=\"auto\" /\u003e\n\n\n## CYD2 and LVGL + Micropython\n\n\u003e [!IMPORTANT]\n\u003e Summary of the steps needed to make the LVGL demo programms work on your CYD/CYD2:\n\u003e - Download the LVGL-MPY firmware from the link below and flash it to your CYD using esptool.py.\n\u003e - Upload the complete content of the `/demo-lvgl` folder to your CYD's root (not the folder itself).\n\u003e - Run demo programm (which most likely looks wrong at this point).\n\u003e - Open `demo_lvgl/lib/display_driver.py` and adjust display color mode and rotation settings (you have to test the different settings until you find the correct ones).\n\n\n### Drivers and Firmware\nAfter getting CYD2 to work with standard MPY firmware and the corresponding drivers,\nI figured that the display driver is slow and has very limited capabilities for use.\n\nA [prebuild version of the lvgl firmware 8.3.6. for CYD](https://stefan.box2code.de/2023/11/18/esp32-grafik-mit-lvgl-und-micropython/) is provided for download by Stefan Scholz in his awesome blog post.\nFurthermore, Stefan Scholz modified the xpt2046 driver used in his blog.\nI further modified the driver to support portrait mode (included in the `lvgl_demo/lib folder`).\n\nThe prebuild version of the MPY-LVGL firmware needs to be downloaded from the aforementioned site. \nI didn't upload them since I don't hold the copyright.\n\nHere are direct download links from Stefan's Blog for non-german users (use one of the first three versions for CYD/CYD2):\n\n- [Esp32WROOM](https://stefan.box2code.de/wp-content/uploads/2023/11/lv_micropython-WROOM.zip) \n- [Esp32WROOM + espnow](https://stefan.box2code.de/wp-content/uploads/2024/04/lv_micropython-WROOM_EspNow.zip)\n- [Esp32WROOM + async espnow](https://stefan.box2code.de/wp-content/uploads/2024/04/lv_micropython-WROOM_AOIEspNow.zip)\n- [Esp32WROVER](https://stefan.box2code.de/huge_files/lv_micropython-WROVER.zip)\n\nThe .zip archives already contain a `flash.sh` file for flashing with esptool.py under unix (i guess).\nYou might need to change `python` to `python3` and `-p /dev/ttyUSB0` to `--port COMXX` (XX = your COM address) if you use esptool.py with windows command line.\nOpen command line and navigate to the folder containing the source files (use the `cd` command, e. g. `cd Desktop/lv_micropython-WROOM`).\nThen run the esptool command.\nIn my case I had to use the following command:\n```\npython -m esptool --chip esp32 --port COM13 -b 460800 --before=default_reset --after=hard_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x1000 bootloader/bootloader.bin 0x10000 micropython.bin 0x8000 partition_table/partition-table.bin \n```\n\n### Adjusting the display settings for CYD2\n\nAlthough my CYD2's look all the same, some require adjustments for the initialization of the display driver (thanks to Stefan Scholz for the help).\nSome of my boards only needed the colormode to be changed, other also required different rotation settings.\nYou just have to figure it out by trying.\n\nOpen `demo_lvgl/lib/display_driver.py` and look for the display initialization command:\n\n```python\ndisp = ili9XXX.ili9341(clk=14, cs=15, dc=2, rst=12, power=23, miso=12, mosi=13, width = 320, height = 240,\nrot = 0xC0, colormode=ili9XXX.COLOR_MODE_RGB, double_buffer = False, factor = 16)\n```\n\nIf your colors are inverted, replace `colormode=ili9XXX.COLOR_MODE_RGB` with `colormode=ili9XXX.COLOR_MODE_BGR`.\nIf the rotation is wrong, change `rot = 0xC0` to `rot = 0xXX` according to the table below. \nTry the different values until you get the right one.\n\n```python\n# Excerpt from the ILI9341 driver MADCTL configurations for rotation and mirroring.\n# First value stands for mirroring, second value stands for rotation.\nMIRROR_ROTATE = {\n    (False, 0): 0x80, \n    (False, 90): 0xE0,\n    (False, 180): 0x40,\n    (False, 270): 0x20,\n    (True, 0): 0xC0,\n    (True, 90): 0x60,\n    (True, 180): 0x00,\n    (True, 270): 0xA0\n}\n```\n### Demo Programms\n\nSeveral demos can be found in the `/demo-lvgl` folder. Flash the prebuild firmware with esptool.py and **upload the complete content** of the `/demo-lvgl` folder to your CYD (not the folder itself).\nThe modified xpt2046 driver is included in the `lib` folder. Display and touchscreen are initialized in the `display_driver.py` file in the `lib` folder.\n\n\u003cimg align=\"right\"  src=\"doc/CYD_Simple.jpg\" width=\"300\" height=\"auto\" /\u003e\n\n\nThe demo programms demonstrate the following functions of lvgl on CYD(2):\n\n- simple demo with buttons and callback functions\n- using CYD2 in portrait mode\n- loading a png image\n- loading a custom text font\n- loading a custom icon font\n- advanced demo with multiple screens, a chart with data imported from a .csv file and asyncio usage\n\n## LVGL Tips\n\n### Font Converter for custom fonts\n\nThe prebuild firmwares only contain the `lv.font_montserrat_14` and `lv.font_montserrat_16` fonts.\nUse the [font converter](https://lvgl.io/tools/fontconverter) to compile custom fonts for LVGL. \nThe image shows the settings used to compile fonts and load them in the demo script (click to enlarge).\n\n\nI have tested several fonts and [Lexend](https://fonts.google.com/specimen/Lexend) is one of my favourites.\nIt's clearly readable on the CYD with medium or semi-bold font-weight.\nIt's provided under the Open Font License.\n\n\n\u003cimg src=\"doc/Font_Converter_Settings.jpg\" width=\"250\" height=\"auto\" /\u003e\n\n\n\n## CYD2 and MicroPython\n\n### Drivers and Firmware\n\nThe standard release of ESP32 MPY-Firmware can be installed on the CYD-2 as described [here](https://github.com/witnessmenow/ESP32-Cheap-Yellow-Display/blob/main/Examples/Micropython/Micropython.md).\nThe ILI9341 driver and the xpt2046 driver can be found in the `/demo_no_lvgl` folder. \n\n### Color Mode for CYD2\n\nDuring display initialization in pure Micropython, bgr-mode needs to be disabled:\n```python\nDisplay(self.spi_display, dc=Pin(2), cs=Pin(15), rst=Pin(15), width = 320, height = 240, bgr = False)\n```\n\nAnother solution can be disabling gamma-correction by passing `gamma = False` during Display initialization (see [#2](https://github.com/de-dh/ESP32-Cheap-Yellow-Display-Micropython-LVGL/issues/2#issuecomment-2558521839) )\n\n### Demo Programm\n\nA working demo and the drivers can be found in the `/demo_no_lvgl` folder. \nDraw functions can be used and touch actions can be assigned to multiple areas on screen in the demo programm.\n\n\u003cimg src=\"doc/CYD_MPY_Only.jpg\" width=\"300\" height=\"auto\" /\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fde-dh%2FESP32-Cheap-Yellow-Display-Micropython-LVGL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fde-dh%2FESP32-Cheap-Yellow-Display-Micropython-LVGL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fde-dh%2FESP32-Cheap-Yellow-Display-Micropython-LVGL/lists"}