Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(m5stack): sharing SPI bus with an SD card
The [m5stack][1] development boards share the same SPI bus bewtween their display (ili9341) and SD card interface. This leads to an SPI bus conflict when trying to use the display and SD card simultaneously, as previously reported by [others][2] using the same display. This commit intruduces 2 new build flags that modify the compilation of the modILI9341.c module: `LV_M5STACK`: When defined, adjust the screen rotation and color mapping to match the M5Stack modules. `LV_ILI9341_SHARE_SPI_BUS`: When defined, assume that the SPI bus has already been defined and simply add the display to the existing bus. Note that this also sets the display to use Full- Duplex mode. The following code provides a minimal example using LittlevGL with an SD card interface: ```python import machine import os import lvgl as lv import lvesp32 import ILI9341 os.mount(machine.SDCard(slot=3, sck=18, mosi=23, miso=19, cs=4), '/sd') lv.init() disp = ILI9341.display(spihost=1, miso=19, mosi=23, clk=18, cs=14, dc=27, rst=33, backlight=32, mhz=25) disp.init() disp_buf1 = lv.disp_buf_t() buf1_1 = bytearray(480*10) lv.disp_buf_init(disp_buf1,buf1_1, None, len(buf1_1)//4) disp_drv = lv.disp_drv_t() lv.disp_drv_init(disp_drv) disp_drv.buffer = disp_buf1 disp_drv.flush_cb = disp.flush disp_drv.hor_res = 320 disp_drv.ver_res = 240 disp_drv.rotated = 0 lv.disp_drv_register(disp_drv) scr = lv.obj() btn = lv.btn(scr) btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0) label = lv.label(btn) label.set_text("Button") lv.scr_load(scr) print(os.listdir('/sd')) ``` [1]: https://m5stack.com/collections/m5-core [2]: https://hackaday.io/project/162059-street-sense/log/170296-farewell-loboris-hello-littlevgl
- Loading branch information