I am currently using SAMD21 with Round display by XIAO for my initial work.
The code below allows me to switch between 3 bitmap, however, I am expecting that the for loop will follow 0-2, but at times when the screen is touched, its staying at the same picture or it goes in reverse. Also, below is the serial monitor showing its not going as expected.
What could have gone wrong? Should I be calibrating the screen first + doing a debounce?
#include <TFT_eSPI.h>
#include <SPI.h>
#define USE_TFT_ESPI_LIBRARY
#include "lv_xiao_round_screen.h"
#include "images.h"
const uint16_t imageWidth = 160;
const uint16_t imageHeight = 160;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(TOUCH_INT, INPUT_PULLUP);
Wire.begin();
// Initialise the screen
tft.init();
//Set the orientation of screen
tft.setRotation(0);
//Fill screen with BLACK
tft.fillScreen(TFT_BLACK);
tft.setSwapBytes(true);
//Set initial image upon turn-on/load
tft.pushImage(40, 40, imageWidth, imageHeight, epd_bitmap_Asset_16_10x);
}
void loop() {
for(int i=0; i<3; i++){
if(chsc6x_is_pressed()){
Serial.print("Current Image is ");
Serial.println(i);
tft.pushImage(40, 40, imageWidth, imageHeight, epd_bitmap_allArray[i]);
}
delay(100);
}
}
Current Image is 0
Dislay is touched.
Current Image is 2
Dislay is touched.
Current Image is 1
Dislay is touched.
Current Image is 1
Dislay is touched.