0 votes
in Touch Interface by (510 points)

I was having problems with the touch portion of the screen.  Whenever I touched the screen anywhere, the time would change from 12 ( which i selected in settings file) to 24 hr time.  No other screens would be displayed.  After some study about the touch driver I stumbled upon some code around line 168:

 if (!isCalibrationAvailable) { and there was some code following that looked backwards.  The if seemes to check if  calibration was not available, but it do a calibration test?

So I changed the if to:

if (isCalibrationAvailable) {   // removed the NOT

recompiled it and ran the program.  It came up this time asking me to calibrate the screen.  1 dot at the Top left, I pushed it, then another dot appeared at the bottom right, I pushed it and the program again took off working.  This time when I touched the screen (anywhere) the other screens came up.  Seemed to work as the sample video indicated.

Don't know if this is happening to anyone else but it fixed a problem i was having.  WAYYY.

in the new screens, on the final page SQUIX data about the ESP8266 chip

at the bottom:

Last Reset:

FatalException:0 flag:6

(EXT_SYS_RST)

epcf:0x00000000

When I reset it, the time came up as 12 hr time.

with the same error message as above, but it seems to be working OK for now.

BUT, there is always a BUT.. every time it restarts, the calibration program runs.again.

There is another statement down a little in the same routine at line 183:

touchController.saveCalibration();

That seems to save it somewhere, so I 

I reset the NOT flag, comile and ran it, it seems to work now and doesn't ask about calibration again.  Seems like this has to be done once for the screen ti find itself.  the results must be saved off in EEROM so could you check and if no value at that location, run the setup once, then the s/w would check and if there was a value in EEROM, then it didn't need to run again.  just saying.

1 Answer

0 votes
by (10.0k points)

I have a suspicion that the ESP's SPIFFS (file system) has never been formated. Can you please check if this code fixes the problem:

ts.begin();

  bool isFSMounted = SPIFFS.begin();
  if (!isFSMounted) {
    Serial.println("Formating FS");
    SPIFFS.format();
  }
  //SPIFFS.remove("/calibration.txt");
  boolean isCalibrationAvailable = touchController.loadCalibration();
  if (!isCalibrationAvailable) {
    Serial.println("Calibration not available");
    touchController.startCalibration(&calibration);
    while (!touchController.isCalibrationFinished()) {
      gfx.fillBuffer(0);
      gfx.setColor(MINI_YELLOW);
      gfx.setTextAlignment(TEXT_ALIGN_CENTER);
      gfx.drawString(120, 160, "Please calibrate\ntouch screen by\ntouch point");
      touchController.continueCalibration();
      gfx.commit();
      yield();
    }
    touchController.saveCalibration();
  }

Note: I also applied this change to github. So you can also just update from there

by (510 points)
This new change seems to correct the problem.  But the code in the next area seems to be backwards.
" if (!isCalibrationAvailable) {"

the code seems to say that calibration is NOT available, then it runs thru the calibration process.  I don't understand the "isCalibrationAvailable ()" routine or what a 'false' return means.  Unless it is a double negative!
Do we need to calibrate the TFT the First Time?

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.

https://thingpulse.com

...