technoblogy / ulisp-tdeck

A version of uLisp to convert the LilyGO T-Deck into a self-contained handheld Lisp computer.
15 stars 2 forks source link

Benchmarks run very slow #3

Closed technoblogy closed 10 months ago

technoblogy commented 10 months ago

The tak benchmark runs much slower than expected. I traced it to the current definition of testescape() which is checking for a keypress, and this takes a significant time on the I2C interface.

I suggest replacing the definition of testescape() with:

void testescape () {
#if defined serialmonitor
  if (Serial.available() && Serial.read() == '~') error2(PSTR("escape!"));
#endif
  if (digitalRead(0) == LOW) error2(PSTR("escape!")); // Trackball pushed
}

You can now escape from a running program by pressing in the trackball.

With this change (tak 18 12 6) runs in 2.4 s.

This will be changed in the next release.

technoblogy commented 10 months ago

With my previous suggestion the trackball sometimes seems to get stuck in the LOW state, in which case Escape is permanently pressed.

This definition of testescape() seems to be working reliably:

void testescape () {
#if defined serialmonitor
  if (Serial.available() && Serial.read() == '~') error2(PSTR("escape!"));
#endif
  if (digitalRead(0) == LOW) {
    pinMode(0, INPUT_PULLUP); 
    if (digitalRead(0) == LOW) error2(PSTR("escape!")); // Trackball pushed
  }
}