Skip to content

Commit

Permalink
Small code cleaning in UserInterfaceManager class #refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
spaceAngel committed Sep 7, 2022
1 parent 7cccc27 commit b47a4a5
Showing 1 changed file with 18 additions and 29 deletions.
47 changes: 18 additions & 29 deletions src/UserInterface/UserInterfaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ bool UserInterfaceManager::handleTouch() {
this->swipeWasHandled = false;
this->touchFromInactivity = InactivityWatcher::getInstance()->isInactive();

}

if (
TTGOClass::getWatch()->getTouch(x, y)
&& ((x != 257) && (y != 2)) //some kind of HW error in my LILLYGO T-Watch (short circuit?)
) {
} else {
this->lastTouchX = x;
this->lastTouchY = y;
if (this->touchReleased == true) {
Expand Down Expand Up @@ -91,20 +86,17 @@ void UserInterfaceManager::handleSwipeHorizontal(uint x) {
this->swipeVectorHorizontal = VECTOR_LEFT;
}
}
} else if (
(
(this->swipeVectorHorizontal == VECTOR_RIGHT) && (this->swipeLastX < (x - CROSS_SWIPE_TOLERANCE))
) || (
(this->swipeVectorHorizontal == VECTOR_LEFT) && (this->swipeLastX > (x + CROSS_SWIPE_TOLERANCE))
)
) {
this->swipeCounterHorizontal++;
this->stopSwipeHandlerVertical();
} else {

if (
(
(this->swipeVectorHorizontal == VECTOR_RIGHT) && (this->swipeLastX < (x - CROSS_SWIPE_TOLERANCE))
) || (
(this->swipeVectorHorizontal == VECTOR_LEFT) && (this->swipeLastX > (x + CROSS_SWIPE_TOLERANCE))
)
) {
this->swipeCounterHorizontal++;
this->stopSwipeHandlerVertical();
} else {
this->stopSwipeHandlerHorizontal();
}
this->stopSwipeHandlerHorizontal();
}
if ((int32_t)this->swipeCounterHorizontal == 3) {
MainScreen::getInstance()->handleSwipeHorizontal(
Expand Down Expand Up @@ -137,17 +129,14 @@ void UserInterfaceManager::handleSwipeVertical(uint y) {
this->swipeVectorVertical = VECTOR_UP;
}
}
} else if (
(((int32_t)this->swipeVectorVertical == VECTOR_UP) && (this->swipeLastY > y))
|| (((int32_t)this->swipeVectorVertical == VECTOR_DOWN) && (this->swipeLastY < y))
) {
this->swipeCounterVertical++;
this->stopSwipeHandlerHorizontal();
} else {

if (
(((int32_t)this->swipeVectorVertical == VECTOR_UP) && (this->swipeLastY > y))
|| (((int32_t)this->swipeVectorVertical == VECTOR_DOWN) && (this->swipeLastY < y))
) {
this->swipeCounterVertical++;
this->stopSwipeHandlerHorizontal();
} else {
this->stopSwipeHandlerVertical();
}
this->stopSwipeHandlerVertical();
}
if ((int32_t)this->swipeCounterVertical == 3) {
MainScreen::getInstance()->handleSwipeVertical(
Expand Down

0 comments on commit b47a4a5

Please sign in to comment.