Hi, I’m having trouble with my code. I have a condition where if I press a button ,that has its values in the int block , the button should either change its color to a different one or change back to the predefined one in int block. The Compiler compiles the project no problem but when I put it in the kit, there’s nothing happening.Drawing on the display still works (I put a spi.pixel(touch_x,touch_y,Blue); which makes pixel everytime it gets values from the touch) but anything after that the function does nothing.
void Button(){
int is_pressed = 0;
int block[] = {0,0,180,70,Blue};
while(1)
{
if (touch.DataAvailable())
{
if(touch.Read())
{
unsigned short int touch_y = touch.GetX();
unsigned short int touch_x = touch.GetY();
touch_x = touch_x - 10;
touch_y = touch_y + 10;
spi.pixel(touch_x,touch_y,Blue);
if ((touch_x >= block[0] && touch_x <= block[1])&&(touch_y >= block[2] && touch_y <= block[3]) && is_pressed == 1){
spi.fillrect( block[0], block[1], block[2], block[3], block[4]);
is_pressed = 0;
wait(0.3);
}else if ((touch_x >= pravy[0] && touch_x <= pravy[1])&&(touch_y >= pravy[2] && touch_y <= block[3])){
is_pressed = 1;
different_color(is_pressed);
wait(0.3);
}
}
}
}
}