Tiny Screen

jmontoya

  • Newbie
  • *
    • Posts: 1
    • View Profile
I have to change the color of the screen and the code below works:

if(x < 120){
          display.drawRect(0,0,96,64,TSRectangleFilled,TS_8b_Yellow);   
        }else{
          display.drawRect(0,0,96,64,TSRectangleFilled,TS_8b_Red);   
        }

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

display.setCursor(48,32);
if (display.Color!=TS_8b_Yellow)
  display.drawRect(0,0,96,64,TSRectangleFilled,TS_8b_Yellow);   

Thanks in advance


HunterHykes

  • Administrator
  • Full Member
  • *****
    • Posts: 19
    • View Profile
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;   
}else{
     color = TS_8b_Red;   
}

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

if (color != TS_8b_Yellow)
  display.drawRect(0,0,96,64,TSRectangleFilled,TS_8b_Yellow);

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

-Hunter


 

SMF spam blocked by CleanTalk