A couple of fixes
This commit is contained in:
@@ -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};
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -30,12 +30,11 @@ constexpr std::array<ButtonRow, 7> 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<SettingInfo>& 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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user