ThingPulse / esp8266-weather-station-color

ESP8266 Weather Station in Color using ILI9341 TFT 240x320 display
https://thingpulse.com/product/esp8266-wifi-color-display-kit-2-4/
MIT License
565 stars 221 forks source link

LCD touch detection/calibration issue #148

Closed blankana closed 2 years ago

blankana commented 2 years ago

There seems to have been an issue with the calibration of my lcd and I'm unsure how to force a new calibration, the monitor shows only "Touch point detected at -1/-1" and "-1/0." where 90% of the screen is detected as -1/-1. The only thing I can do by touching the screen is switch between 12hr and 24hr time, naturally I'd like to use the other screens I'm seeing in videos demonstrating the weather station.

TiVoHomeUser commented 2 years ago

You need to re-flash select "erase all flash contents" or to keep most of the saved data modify the setup() function after

drawProgress(100, "Formatting done");

insert

if(ts.touched()){
  if(SPIFFS.exists("/calibration.txt")) SPIFFS.remove("/calibration.txt");
  while(ts.touched()){
    gfx.fillBuffer(MINI_BLACK); gfx.commit();
    delay(15); yield();
    gfx.fillBuffer(MINI_YELLOW); gfx.commit();
  }
}

Then if you press the screen and hold while booting the calibration data will be deleted forcing the touch screen to re-calibrate.

blankana commented 2 years ago

You need to re-flash select "erase all flash contents" or to keep most of the saved data modify the setup() function after drawProgress(100, "Formatting done"); insert if(ts.touched()){ if(SPIFFS.exists("/calibration.txt")) SPIFFS.remove("/calibration.txt"); while(ts.touched()){ gfx.fillBuffer(MINI_BLACK); gfx.commit(); delay(15); yield(); gfx.fillBuffer(MINI_YELLOW); gfx.commit(); } } Then if you press the screen and hold while booting the calibration data will be deleted forcing the touch screen to re-calibrate.

This did the trick, much obliged. I will note for anyone else doing this that you have to hold a touch on the screen after the splash screen starts not before which causes a 'fatal error' manifesting as a locked black screen.

marcelstoer commented 2 years ago

@TiVoHomeUser thanks for sharing this interesting idea! What was the initial motivation for this "feature"? Was your device misbehaving in some way or did you just think it would be useful to have a non-invasive way to reset the touch calibration?

TiVoHomeUser commented 2 years ago

It was a quick rough fix to this issue opened by blankana who could not change screens due to a bad touch screen calibration. I do think it would be useful to be able to force a touch screen re-calibration without having to connect to a computer to wipe the memory. I need to test a better way would be to just set the isCalibrationAvailable boolean instead of deleting the file.

boolean isCalibrationAvailable = false
if(ts.touched()){
 /*  if(SPIFFS.exists("/calibration.txt")) SPIFFS.remove("/calibration.txt"); */
  while(ts.touched()){
    gfx.fillBuffer(MINI_BLACK); gfx.commit();
    delay(15); yield();
    gfx.fillBuffer(MINI_YELLOW); gfx.commit();
  }
} else {
  isCalibrationAvailable = touchController.loadCalibration();
}
/* boolean isCalibrationAvailable = touchController.loadCalibration();*/

Also working on Add a couple of seconds with a display screen instructing the press and hold and a confirmation release screen. Move the connectWifi() to after the screen calibration not sure what that would break however.

marcelstoer commented 2 years ago

I do think it would be useful to be able to force a touch screen re-calibration without having to connect to a computer to wipe the memory.

👍 I fully agree and I like your ideas. Is this something you'll pursue and plan on raising a PR for? Would be awesome.

blankana commented 2 years ago

👍 I fully agree and I like your ideas. Is this something you'll pursue and plan on raising a PR for? Would be awesome.

I'd have to agree, it was very easy for me to foul up the calibration because as far as I was aware I touched the dots exactly in the center with the stylus and despite a few hours and re-flashing multiple times I couldn't get a new calibration prompt to trigger. I would imagine a bad calibration could be an issue for others in the future.

TiVoHomeUser commented 2 years ago

Created a new pull request "Allow user to force a screen re-calibration"

Unfamiliar with the new GitHub desktop I hope the request is correct.

TiVoHomeUser commented 2 years ago

Added screen navigation Divided the screen into 4 sections.

A touch in section: