From c7685ffc298325509f284f77eb3308304c14f2de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eckhard=20V=C3=B6llm?= Date: Tue, 26 Mar 2024 23:53:16 +0100 Subject: [PATCH] regard rotary counts in setup menu and select menu's as well --- main/SetupMenu.cpp | 11 +++++++---- main/SetupMenuSelect.cpp | 8 ++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/main/SetupMenu.cpp b/main/SetupMenu.cpp index 41e91b82a..4ae06122d 100644 --- a/main/SetupMenu.cpp +++ b/main/SetupMenu.cpp @@ -573,10 +573,11 @@ void SetupMenu::down(int count){ ucg->setColor(COLOR_BLACK); ucg->drawFrame( 1,(highlight+1)*25+3,238,25 ); ucg->setColor(COLOR_WHITE); - if( highlight > -1 ){ + while( (highlight > -1) && count ){ highlight --; + count--; } - else + if( highlight < -1 ) highlight = (int)(_childs.size() -1 ); ucg->drawFrame( 1,(highlight+1)*25+3,238,25 ); xSemaphoreGive(spiMutex ); @@ -617,11 +618,13 @@ void SetupMenu::up(int count){ ucg->setColor(COLOR_BLACK); ucg->drawFrame( 1,(highlight+1)*25+3,238,25 ); ucg->setColor(COLOR_WHITE); - if( highlight < (int)(_childs.size()-1) ){ + while( highlight < (int)(_childs.size()-1) && count ){ highlight ++; + count--; } - else + if( highlight > (int)(_childs.size()-1) ){ highlight = -1; + } ucg->drawFrame( 1,(highlight+1)*25+3,238,25 ); pressed = true; xSemaphoreGive(spiMutex ); diff --git a/main/SetupMenuSelect.cpp b/main/SetupMenuSelect.cpp index d0385bb13..897697b30 100644 --- a/main/SetupMenuSelect.cpp +++ b/main/SetupMenuSelect.cpp @@ -187,8 +187,10 @@ void SetupMenuSelect::down(int count){ ucg->setColor(COLOR_BLACK); ucg->drawFrame( 1,(_select+1)*25+3,238,25 ); // blank old frame ucg->setColor(COLOR_WHITE); - if( (_select) > 0 ) + while( (_select) > 0 && count){ (_select)--; + count--; + } ESP_LOGI(FNAME,"val down %d", _select ); ucg->drawFrame( 1,(_select+1)*25+3,238,25 ); // draw new frame xSemaphoreGive(spiMutex ); @@ -215,8 +217,10 @@ void SetupMenuSelect::up(int count){ ucg->setColor(COLOR_BLACK); ucg->drawFrame( 1,(_select+1)*25+3,238,25 ); // blank old frame ucg->setColor(COLOR_WHITE); - if ( (_select) < _numval-1 ) + while ( (_select) < _numval-1 && count ){ (_select)++; + count--; + } ESP_LOGI(FNAME,"val up %d", _select ); ucg->drawFrame( 1,(_select+1)*25+3,238,25 ); // draw new frame xSemaphoreGive(spiMutex );