diff --git a/lib/I18n/translations/german.yaml b/lib/I18n/translations/german.yaml index 0a6080de..1144d938 100644 --- a/lib/I18n/translations/german.yaml +++ b/lib/I18n/translations/german.yaml @@ -242,10 +242,10 @@ STR_DIR_DOWN: "Runter" STR_OK_BUTTON: "OK" STR_SLEEP_COVER_FILTER: "Standby-Coverfilter" STR_FILTER_CONTRAST: "Kontrast" -STR_TILT_PAGE_TURN: "Seitenblaettern durch Neigen" +STR_TILT_PAGE_TURN: "Seitenblättern durch Neigen" STR_TILT_STABILIZATION: "Neigungsmodus" STR_TILT_MODE_RAW: "Rohbeschleunigung" -STR_TILT_MODE_SMOOTH: "Geglaettete Beschleunigung" +STR_TILT_MODE_SMOOTH: "Geglättete Beschleunigung" STR_TILT_MODE_KALMAN: "Gyro-/Beschleunigungsfusion" STR_CUSTOMISE_STATUS_BAR: "Statusleiste anpassen" STR_CHAPTER_PAGE_COUNT: "Kapitel-Seitenanzahl" diff --git a/lib/hal/HalTiltSensor.cpp b/lib/hal/HalTiltSensor.cpp index b744d27d..09214d2c 100644 --- a/lib/hal/HalTiltSensor.cpp +++ b/lib/hal/HalTiltSensor.cpp @@ -88,7 +88,7 @@ void HalTiltSensor::begin() { _i2cAddr = TILT_I2C_ADDR; if (!readReg(REG_WHO_AM_I, &whoami) || whoami != TILT_WHO_AM_I_VALUE) { _i2cAddr = TILT_I2C_ADDR_ALT; - if (!readReg(REG_WHO_AM_I, &whoami) || whoami != QMI8658_WHO_AM_I_VALUE) { + if (!readReg(REG_WHO_AM_I, &whoami) || whoami != TILT_WHO_AM_I_VALUE) { LOG_INF("TILT", "QMI8658 IMU not found"); _available = false; return; diff --git a/src/activities/reader/ReaderUtils.h b/src/activities/reader/ReaderUtils.h index d50eb97e..27877f15 100644 --- a/src/activities/reader/ReaderUtils.h +++ b/src/activities/reader/ReaderUtils.h @@ -113,18 +113,21 @@ inline PageTurnResult detectPageTurn(const MappedInputManager& input) { if (tiltNegative) { applyTiltAction(SETTINGS.tiltNegativeAction); } - const bool prev = tiltPrev || ((SETTINGS.btnShortPageBack == BA::BTN_DEFAULT && - !globalButtonEvents().hasDoubleAction(MappedInputManager::Button::PageBack) && - input.wasReleased(MappedInputManager::Button::PageBack)) || - (SETTINGS.btnShortLeft == BA::BTN_DEFAULT && - !globalButtonEvents().hasDoubleAction(MappedInputManager::Button::Left) && - input.wasReleased(MappedInputManager::Button::Left))); - const bool next = tiltNext || ((SETTINGS.btnShortPageForward == BA::BTN_DEFAULT && - !globalButtonEvents().hasDoubleAction(MappedInputManager::Button::PageForward) && - input.wasReleased(MappedInputManager::Button::PageForward)) || - (SETTINGS.btnShortRight == BA::BTN_DEFAULT && - !globalButtonEvents().hasDoubleAction(MappedInputManager::Button::Right) && - input.wasReleased(MappedInputManager::Button::Right))); + const bool prevButtonReleased = (SETTINGS.btnShortPageBack == BA::BTN_DEFAULT && + !globalButtonEvents().hasDoubleAction(MappedInputManager::Button::PageBack) && + input.wasReleased(MappedInputManager::Button::PageBack)) || + (SETTINGS.btnShortLeft == BA::BTN_DEFAULT && + !globalButtonEvents().hasDoubleAction(MappedInputManager::Button::Left) && + input.wasReleased(MappedInputManager::Button::Left)); + const bool nextButtonReleased = (SETTINGS.btnShortPageForward == BA::BTN_DEFAULT && + !globalButtonEvents().hasDoubleAction(MappedInputManager::Button::PageForward) && + input.wasReleased(MappedInputManager::Button::PageForward)) || + (SETTINGS.btnShortRight == BA::BTN_DEFAULT && + !globalButtonEvents().hasDoubleAction(MappedInputManager::Button::Right) && + input.wasReleased(MappedInputManager::Button::Right)); + + const bool prev = tiltPrev || prevButtonReleased; + const bool next = tiltNext || nextButtonReleased; return {prev, next}; } diff --git a/src/activities/reader/TxtReaderActivity.cpp b/src/activities/reader/TxtReaderActivity.cpp index 3cc1abb5..54c4bdf0 100644 --- a/src/activities/reader/TxtReaderActivity.cpp +++ b/src/activities/reader/TxtReaderActivity.cpp @@ -140,7 +140,13 @@ void TxtReaderActivity::onExit() { } void TxtReaderActivity::loop() { - if (inputDrainGuard.shouldDrain(mappedInput)) { + const bool drainActive = inputDrainGuard.shouldDrain(mappedInput); + if (!drainActive && drainWasActive) { + halTiltSensor.clearPendingEvents(); + } + drainWasActive = drainActive; + + if (drainActive) { buttonEvents.drain(); return; } diff --git a/src/activities/reader/TxtReaderActivity.h b/src/activities/reader/TxtReaderActivity.h index 60615e7a..4230a75f 100644 --- a/src/activities/reader/TxtReaderActivity.h +++ b/src/activities/reader/TxtReaderActivity.h @@ -16,6 +16,7 @@ class TxtReaderActivity final : public Activity { int totalPages = 1; int pagesUntilFullRefresh = 0; ReaderUtils::InputDrainGuard inputDrainGuard; + bool drainWasActive = false; // Bookmarks (starred pages) BookmarkStore bookmarkStore; diff --git a/src/activities/settings/ButtonActionsOverviewActivity.cpp b/src/activities/settings/ButtonActionsOverviewActivity.cpp index 8ecb6331..0c514f69 100644 --- a/src/activities/settings/ButtonActionsOverviewActivity.cpp +++ b/src/activities/settings/ButtonActionsOverviewActivity.cpp @@ -30,12 +30,11 @@ constexpr std::array kButtonRows = {{ }}; // Find the SettingInfo for a given (button submenu, press kind) pair in the shared settings list. -std::string cellValue(StrId submenu, StrId pressKind) { - const auto list = getSettingsList(); - auto it = std::find_if(list.begin(), list.end(), [submenu, pressKind](const SettingInfo& s) { +std::string cellValue(const std::vector& settings, StrId submenu, StrId pressKind) { + auto it = std::find_if(settings.begin(), settings.end(), [submenu, pressKind](const SettingInfo& s) { return s.submenu == submenu && s.nameId == pressKind && s.category == StrId::STR_CAT_CONTROLS; }); - if (it == list.end()) return {}; + if (it == settings.end()) return {}; return it->getDisplayValue(); } @@ -124,15 +123,17 @@ void ButtonActionsOverviewActivity::render(RenderLock&&) { renderer.fillPolygon(underlineX, underlineY, 4, true); y += 4; + const auto settings = getSettingsList(); + // Data rows for (const auto& row : kButtonRows) { const std::string label = I18N.get(row.labelStrId); const std::string clippedLabel = renderer.truncatedText(fontId, label.c_str(), colW[0], EpdFontFamily::BOLD); renderer.drawText(fontId, colX[0], y, clippedLabel.c_str(), true, EpdFontFamily::BOLD); - const std::string vShort = cellValue(row.submenu, StrId::STR_BTN_SHORT_PRESS); - const std::string vDouble = cellValue(row.submenu, StrId::STR_BTN_DOUBLE_PRESS); - const std::string vLong = cellValue(row.submenu, StrId::STR_BTN_LONG_PRESS); + const std::string vShort = cellValue(settings, row.submenu, StrId::STR_BTN_SHORT_PRESS); + const std::string vDouble = cellValue(settings, row.submenu, StrId::STR_BTN_DOUBLE_PRESS); + const std::string vLong = cellValue(settings, row.submenu, StrId::STR_BTN_LONG_PRESS); renderer.drawText(fontId, colX[1], y, renderer.truncatedText(fontId, vShort.c_str(), colW[1]).c_str()); renderer.drawText(fontId, colX[2], y, renderer.truncatedText(fontId, vDouble.c_str(), colW[2]).c_str()); diff --git a/src/main.cpp b/src/main.cpp index aacae41c..5be9d546 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -210,6 +210,7 @@ void setup() { if (wakeupReason == HalGPIO::WakeupReason::AfterUSBPower) { // If USB power caused a cold boot, go back to sleep immediately without initializing subsystems LOG_DBG("MAIN", "Wakeup reason: After USB Power => Deep sleep"); + halTiltSensor.deepSleep(); powerManager.startDeepSleep(gpio); return; }