atomic14 / diy-esp32-epub-reader

An ESP32 e-reader
MIT License
359 stars 48 forks source link

Touch thoughts #29

Closed cgreening closed 3 years ago

cgreening commented 3 years ago

I've done a bit of refactoring on the touch code - not sure if it's really correct yet.

A couple of thoughts I had.

It's quite hard to hit the buttons - we could:

When reading a book, go to the next page by tapping the right of the screen and go left by tapping the left of the screen. Get back to the main menu by tapping near the top of the screen.

When selecting books got up and down by tapping the top and bottom of the screen and select by tapping in the centre - not sure how intuitive that is though...

Is it possible with the touch library to detect a "touch up" ie the end of the touch interaction when the finger is removed from the screen? That would be a good point to kick off the interaction.

I need to pull a lot of the code out of the main function so that it's a bit easier to drive the UI from controls. I'll make a start on that next.

cgreening commented 3 years ago

Actually, for browsing the books a fairly large arrow at the top and bottom of the screen would let you page through the books nicely.

cgreening commented 3 years ago

I've increased the hit area and now it works nicely.

martinberlin commented 3 years ago

Nice job. There is an additional thing to do on my component side:

// Updating this in the L58Touch::processTouch to 50 millis instead of 150:
if (tapDetectionEnabled && _touchEndTime - _touchStartTime <= 50) {
        fireEvent(point, TEvent::Tap);
    }

Makes it much smoother and reduces the double click effect. I will convert that into a variable that can be set on class instantiation, setTapMillis or setTapThreshold so we can modify it.

This is an annoying error that didn't appear before

It happens when it goes to deep sleep in the ePub list mode and I'm getting this often since yesterday update. No idea if it's related or a casual problem with SPIFFS. I think I had it once before but not often like know, it's finding the buffer and don't giving decompress errors, but still says there is no data to restore.

I (526) main: Controls configured
I (526) Controls: ULP Wakeup
I (536) EPD: Hydrating EPD
I (686) EPD: Buffer compressed size: 40567
E (866) EPD: No data to restor
I (866) EPD: Hydrate EPD failed

Which results in the list being rendered blank. Did something changed in your last refactoring that can affect this? Because before I was not getting it. UPDATE: I think I know what it is. I deleted a book to leave more space in the SPIFFs and now it works. So the ideal thing will be to log an error when it tries to save and it's not successful because there is no sufficient free space.

Second error I'm seeing in the Serial, although seems not to affect anything is this:

I (127266) main: Entering deep sleep
E (127276) RTCIO: rtc_gpio_init(44): RTCIO number error
E (127276) RTCIO: rtc_gpio_set_direction(103): RTCIO number error
E (127286) RTCIO: rtc_gpio_pulldown_dis(153): RTCIO number error
E (127296) RTCIO: rtc_gpio_pullup_dis(133): RTCIO number error
E (127296) RTCIO: rtc_gpio_hold_dis(176): RTCIO number error
rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

Update: Touch class ready to be updated https://github.com/martinberlin/FT6X36-IDF/commit/b5e674ec78d69faf72434a6da31e6df4cff36a0e

Just do a $ git submodule update --remote Submodule path 'lib/touch': checked out 'b5e674ec78d69faf72434a6da31e6df4cff36a0e'

Seems to hold like expected last commit!

martinberlin commented 3 years ago

@cgreening when you have time check last commit and if you find it interesting then I make a second pull request. Note: To mark buttons pressed is a silly decoration visual aid but does a poor job to make it better. But it just looks cool since it's instant UX feedback. With that an a smaller hourglass things start looking promising ;)

cgreening commented 3 years ago

I think this is good enough now.

Your RTC error is due to using using GPIO_NUM_1 instead of GPIO_NUM_35 - make sure you've got the correct commit of epdiy in the submodule as the latest version fixes the always low problem.