General Category => General Discussion => Topic started by: jmontoya on January 06, 2019, 01:40:44 AM

Title: Tiny Screen
Post by: jmontoya on January 06, 2019, 01:40:44 AM
I have to change the color of the screen and the code below works:

if(x < 120){

I want to set the cursor to the middle of the screen and check the color of the screen in that position. Something like this

if (display.Color!=TS_8b_Yellow)

Thanks in advance
Title: Re: Tiny Screen
Post by: HunterHykes on January 07, 2019, 01:29:43 PM
Hi jmontoya,

Due to the hardware setup of the TinyScreen and TinyScreen+, it is not possible to read data from the registers in the Graphic Display Data RAM via SPI. The only way to read a specific pixel's color would rely on the use of a buffer array and reference the specific index corresponding to the desired coordinate.

However, if you just chose the pixel on the center of the screen to detect the color of the entire screen, here's something you could do.

uint16_t color;

if(x < 120){
     color = TS_8b_Yellow;   
     color = TS_8b_Red;   

display.drawRect(0, 0, 96, 64, TSRectangleFilled, color);

if (color != TS_8b_Yellow)

I more or less made an assumption of what you were trying to do, but I hope this helps!