QiaoTuCodes / MicroPython-_ILI9488

MicroPython Library for the ILI9488 TFT controller for 4-6 wire SPI
12 stars 3 forks source link

Fixes for Waveshare Pico-ResTouch-LCD-3.5 (#1) #2

Open ptb99 opened 1 year ago

ptb99 commented 1 year ago

I am working with this display board and the Raspberry Pi Pico: https://www.waveshare.com/wiki/Pico-ResTouch-LCD-3.5

I tried your driver from the main branch in Github, but it didn't work for me. The main problem was that writing command parameters with SPI.write() only works if I write a single byte per write() call. I don't have a clear explanation for this, but looping one write() call per byte seems to be a safe workaround.

In addition, I found a bunch of opcodes that carried over from the source driver for ILI93xx chips but do not appear in the ILI9488 data sheet. I updated these codes based on the data sheet (although I didn't include everything in the data sheet). Similarly, the initialization code contained commands or parameters that didn't make sense based on the ILI9488 data sheet. I reduced these to a fairly minimal set that works OK for me.

Finally, I found that the code for draw_text8x8() had a bug with foreground and background colors. It turns out that any code using Micropython's FrameBuffer and the block() method to copy the FB's backing buffer to the ILI9488 is problematic. This is because FrameBuffers store the 16-bit colors in native byte-order (which is little-endian) while the ILI9488 expects colors to be big-endian. I couldn't find any code or hooks in FrameBuffer to deal with this, so I added code to the driver for byte-swapping and then flip the color value before writing into the FrameBuffer.

I don't know how much you are actively maintaining/supporting your driver, but I might as well send you these fixes if you want to use them. I'm fine with using my private version for my purposes, so no urgency to merge this from my end.

Thanks,

Tom Pavel

QiaoTuCodes commented 10 months ago

I am working with this display board and the Raspberry Pi Pico: https://www.waveshare.com/wiki/Pico-ResTouch-LCD-3.5

I tried your driver from the main branch in Github, but it didn't work for me. The main problem was that writing command parameters with SPI.write() only works if I write a single byte per write() call. I don't have a clear explanation for this, but looping one write() call per byte seems to be a safe workaround.

In addition, I found a bunch of opcodes that carried over from the source driver for ILI93xx chips but do not appear in the ILI9488 data sheet. I updated these codes based on the data sheet (although I didn't include everything in the data sheet). Similarly, the initialization code contained commands or parameters that didn't make sense based on the ILI9488 data sheet. I reduced these to a fairly minimal set that works OK for me.

Finally, I found that the code for draw_text8x8() had a bug with foreground and background colors. It turns out that any code using Micropython's FrameBuffer and the block() method to copy the FB's backing buffer to the ILI9488 is problematic. This is because FrameBuffers store the 16-bit colors in native byte-order (which is little-endian) while the ILI9488 expects colors to be big-endian. I couldn't find any code or hooks in FrameBuffer to deal with this, so I added code to the driver for byte-swapping and then flip the color value before writing into the FrameBuffer.

I don't know how much you are actively maintaining/supporting your driver, but I might as well send you these fixes if you want to use them. I'm fine with using my private version for my purposes, so no urgency to merge this from my end.

Thanks,

Tom Pavel

Thank you very much for your testing and updates. Indeed, this ILI9488 driver for MicroPython was my initial attempt at a test version, inspired by the integration and modifications from the ILI9341 driver. I didn't remove the relevant constant definitions from the original ILI9341 copy at that time. The idea was to eventually integrate multiple display drivers such as ILI93xx, ILI94xx, etc., into a super comprehensive library, so I kept the original constants for future integration. Due to recent minor family issues that have clearly constrained my ability to update and maintain my personal community and related technical discussions, I have briefly reviewed your post and code corrections. I appreciate your outstanding contributions; they look quite promising! A merge could be considered.

Thanks!,

Isaac.WeiRan