diff --git a/esp8266_deauther/DisplayUI.cpp b/esp8266_deauther/DisplayUI.cpp index 9a73d50..4525074 100644 --- a/esp8266_deauther/DisplayUI.cpp +++ b/esp8266_deauther/DisplayUI.cpp @@ -504,6 +504,7 @@ void DisplayUI::setupButtons() { // === BUTTON UP === // up->setOnClicked([this]() { scrollCounter = 0; + scrollTime = currentTime; buttonTime = currentTime; if (!tempOff) { @@ -520,6 +521,7 @@ void DisplayUI::setupButtons() { up->setOnHolding([this]() { scrollCounter = 0; + scrollTime = currentTime; buttonTime = currentTime; if (!tempOff) { if (mode == DISPLAY_MODE::MENU) { // when in menu, go up or down with cursor @@ -536,6 +538,7 @@ void DisplayUI::setupButtons() { // === BUTTON DOWN === // down->setOnClicked([this]() { scrollCounter = 0; + scrollTime = currentTime; buttonTime = currentTime; if (!tempOff) { if (mode == DISPLAY_MODE::MENU) { // when in menu, go up or down with cursor @@ -551,6 +554,7 @@ void DisplayUI::setupButtons() { down->setOnHolding([this]() { scrollCounter = 0; + scrollTime = currentTime; buttonTime = currentTime; if (!tempOff) { if (mode == DISPLAY_MODE::MENU) { // when in menu, go up or down with cursor @@ -569,6 +573,7 @@ void DisplayUI::setupButtons() { // === BUTTON A === // a->setOnClicked([this]() { scrollCounter = 0; + scrollTime = currentTime; buttonTime = currentTime; if (!tempOff) { switch (mode) { @@ -596,6 +601,7 @@ void DisplayUI::setupButtons() { a->setOnHolding([this]() { scrollCounter = 0; + scrollTime = currentTime; buttonTime = currentTime; if (!tempOff) { if (mode == DISPLAY_MODE::MENU) { @@ -609,6 +615,7 @@ void DisplayUI::setupButtons() { // === BUTTON B === // b->setOnClicked([this]() { scrollCounter = 0; + scrollTime = currentTime; buttonTime = currentTime; if (!tempOff) { switch (mode) { @@ -704,11 +711,16 @@ void DisplayUI::drawMenu() { tmpLen = tmp.length(); // horizontal scrolling - if ((currentMenu->selected == i) && (tmpLen > maxLen - 1)) { - tmp = tmp.substring(scrollCounter / scrollSpeed); - scrollCounter++; - - if (scrollCounter / scrollSpeed > tmpLen - maxLen - 1) scrollCounter = 0; + if ((currentMenu->selected == i) && (tmpLen >= maxLen)) { + tmp = tmp + tmp; + tmp = tmp.substring(scrollCounter, scrollCounter + maxLen - 1); + + if ((scrollCounter > 0 && scrollTime < currentTime - scrollSpeed) || (scrollCounter == 0 && scrollTime < currentTime - scrollSpeed * 4)){ + scrollTime = currentTime; + scrollCounter++; + } + + if (scrollCounter > tmpLen) scrollCounter = 0; } tmp = (currentMenu->selected == i ? CURSOR : SPACE) + tmp; diff --git a/esp8266_deauther/DisplayUI.h b/esp8266_deauther/DisplayUI.h index 5f23864..e5b4cbe 100644 --- a/esp8266_deauther/DisplayUI.h +++ b/esp8266_deauther/DisplayUI.h @@ -81,7 +81,7 @@ class DisplayUI { const uint8_t maxLen = 18; const uint8_t lineHeight = 12; - const uint8_t scrollSpeed = 5; + const uint8_t scrollSpeed = 500; const uint8_t buttonDelay = 250; const uint8_t drawInterval = 100; // 100ms = 10 FPS const uint16_t screenIntroTime = 2500; @@ -112,7 +112,9 @@ class DisplayUI { private: int16_t selectedID = 0; // i.e. access point ID to draw the apMenu - uint16_t scrollCounter = 0; // for horizontal scrolling + uint8_t scrollCounter = 0; // for horizontal scrolling + + uint32_t scrollTime = 0; // last time a character was moved uint32_t drawTime = 0; // last time a frame was drawn uint32_t startTime = 0; // when the screen was enabled uint32_t buttonTime = 0; // last time a button was pressed