readpixel and drawpixel.. diferent colours #951
-
Hi Bodmer. from the spiffs I draw an image on the screen. Until there, everything ok. Thanks for your time. uint16_t zzxx[400]; for (int a = 0; a <= 480; a++) for (int i = 0; i <= 320; i++) |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
Not all displays can be read successfully. Post a link to the (exactly the same) display you are using. |
Beta Was this translation helpful? Give feedback.
-
Here is a simple sketch to test. You should end up with a single red line 320 pixels long:
Note that in your sketch you should use < for the for loop, not <= because row/coumns 320 and 480 do not exist. Then you can minimise the array size to uint16_t zzxx[320]; since clearly the array index can only be 0-319 otherwise the processor will crash. You can change TFT_RED in that sketch to TFT_GREEN and then TFT_BLUE to check the R,G and B colour pixels are being read, if correct then all other colours should be OK too. |
Beta Was this translation helpful? Give feedback.
-
Hi, This is the display I am using: http://www.lcdwiki.com/3.5inch_SPI_Module_ILI9488_SKU:MSP3520 This is the result: after reading the original with readpixel and repainting it with drawpixel: the error is very evident in the monkey's left eye and in the mouse. |
Beta Was this translation helpful? Give feedback.
-
Did you run the sketch I posted? What are you findings? |
Beta Was this translation helpful? Give feedback.
-
Yes, I ran the sketch and everything was fine. The problem is that when the original color for example is red, when he repaints it is not the same red but an orange. The same goes for other colors. In the photo the monkey and the mouse can be seen clearly. |
Beta Was this translation helpful? Give feedback.
-
What SPI clock rate are you using for read and write? |
Beta Was this translation helpful? Give feedback.
-
// #define SPI_FREQUENCY 20000000 // Optional reduced SPI frequency for reading TFT |
Beta Was this translation helpful? Give feedback.
-
The read frequency is too high, this cause "bit smearing" where a single 1 bit becomes 2. Change it back to the default 16MHz. Note that the data sheet limit is 6.7MHz for read frequency and 20MHz for write frequency. Displays typically can be overclocked, but 16MHz is likely to be the limit for ILI9488 reads. Here is a simple walking 1 test, to test for read errors, run it, then reduce the frequency to 16MHz and it should run without error.
|
Beta Was this translation helpful? Give feedback.
-
Already solved. The problem was effectively as you said in the SPI read frequency. I had to lower it to 12mhz for it to work without errors. Again thanks for your time and for your fantastic library. |
Beta Was this translation helpful? Give feedback.
The read frequency is too high, this cause "bit smearing" where a single 1 bit becomes 2. Change it back to the default 16MHz. Note that the data sheet limit is 6.7MHz for read frequency and 20MHz for write frequency. Displays typically can be overclocked, but 16MHz is likely to be the limit for ILI9488 reads.
Here is a simple walking 1 test, to test for read errors, run it, then reduce the frequency to 16MHz and it should run without error.