Integrate menu into control, Rework prev. button menu
Armchair functions as before (all tasks enabled). Note: probably wrong encoder pin set in encoder.hpp Old button menu works as usual (opimized code). You can switch to new MENU state with 1x long press and exit the menu with 1x long press button.cpp: - use encoder queue instead of evaluated switch - simplify code, rework actions control.cpp: Add MENU state/mode -> control task: turns motors off and idles -> button task idles (button menu disabled) -> display task switches state to handle menu control.cpp: Optimize structure: Add methods to freeze stick and toggle stick mapping display.cpp: show status screen or handle menu depending on mode, simpilfy task main.cpp: re-enable button task, disable buzzer logging menu.cpp: Change events, Add menu exit condition
This commit is contained in:
parent
fc5aad0c14
commit
4f8c421168
@ -8,6 +8,7 @@ extern "C"
|
||||
}
|
||||
|
||||
#include "button.hpp"
|
||||
#include "encoder.hpp"
|
||||
|
||||
|
||||
|
||||
@ -37,46 +38,53 @@ buttonCommands::buttonCommands(gpio_evaluatedSwitch * button_f, evaluatedJoystic
|
||||
//----------------------------
|
||||
//function that runs commands depending on a count value
|
||||
void buttonCommands::action (uint8_t count, bool lastPressLong){
|
||||
//--- variable declarations ---
|
||||
//--- variables ---
|
||||
bool decelEnabled; //for different beeping when toggling
|
||||
commandSimple_t cmds[8]; //array for commands for automatedArmchair
|
||||
|
||||
//--- get joystick position ---
|
||||
//in case joystick is used for additional cases:
|
||||
//joystickData_t stickData = joystick->getData();
|
||||
|
||||
//--- actions based on count ---
|
||||
switch (count){
|
||||
//no such command
|
||||
default:
|
||||
ESP_LOGE(TAG, "no command for count=%d defined", count);
|
||||
buzzer->beep(3, 400, 100);
|
||||
break;
|
||||
//--- run actions based on count ---
|
||||
switch (count)
|
||||
{
|
||||
// ## no command ##
|
||||
default:
|
||||
ESP_LOGE(TAG, "no command for count=%d and long=%d defined", count, lastPressLong);
|
||||
buzzer->beep(3, 400, 100);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
//restart contoller when 1x long pressed
|
||||
if (lastPressLong){
|
||||
ESP_LOGW(TAG, "RESTART");
|
||||
buzzer->beep(1,1000,1);
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
//esp_restart();
|
||||
//-> define joystick center or toggle freeze input (executed in control task)
|
||||
control->sendButtonEvent(count); //TODO: always send button event to control task (not just at count=1) -> control.cpp has to be changed
|
||||
return;
|
||||
}
|
||||
//note: disabled joystick calibration due to accidential trigger
|
||||
//
|
||||
// ESP_LOGW(TAG, "cmd %d: sending button event to control task", count);
|
||||
// //-> define joystick center or toggle freeze input (executed in control task)
|
||||
// control->sendButtonEvent(count); //TODO: always send button event to control task (not just at count=1) -> control.cpp has to be changed
|
||||
break;
|
||||
case 2:
|
||||
//run automatic commands to lift leg support when pressed 1x short 1x long
|
||||
if (lastPressLong){
|
||||
case 1:
|
||||
// ## switch to MENU state ##
|
||||
if (lastPressLong)
|
||||
{
|
||||
control->changeMode(controlMode_t::MENU);
|
||||
ESP_LOGW(TAG, "1x long press -> change to menu mode");
|
||||
buzzer->beep(1, 1000, 1);
|
||||
vTaskDelay(500 / portTICK_PERIOD_MS);
|
||||
}
|
||||
// ## toggle joystick freeze ##
|
||||
else if (control->getCurrentMode() == controlMode_t::MASSAGE)
|
||||
{
|
||||
control->toggleFreezeInputMassage();
|
||||
}
|
||||
// ## define joystick center ##
|
||||
else
|
||||
{
|
||||
// note: disabled joystick calibration due to accidential trigger
|
||||
//joystick->defineCenter();
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// ## switch to ADJUST_CHAIR mode ##
|
||||
if (lastPressLong)
|
||||
{
|
||||
ESP_LOGW(TAG, "cmd %d: toggle ADJUST_CHAIR", count);
|
||||
control->toggleMode(controlMode_t::ADJUST_CHAIR);
|
||||
}
|
||||
|
||||
//toggle idle when 2x pressed
|
||||
// ## toggle IDLE ##
|
||||
else {
|
||||
ESP_LOGW(TAG, "cmd %d: toggle IDLE", count);
|
||||
control->toggleIdle(); //toggle between idle and previous/default mode
|
||||
@ -84,21 +92,25 @@ void buttonCommands::action (uint8_t count, bool lastPressLong){
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// ## switch to JOYSTICK mode ##
|
||||
ESP_LOGW(TAG, "cmd %d: switch to JOYSTICK", count);
|
||||
control->changeMode(controlMode_t::JOYSTICK); //switch to JOYSTICK mode
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// ## switch to HTTP mode ##
|
||||
ESP_LOGW(TAG, "cmd %d: toggle between HTTP and JOYSTICK", count);
|
||||
control->toggleModes(controlMode_t::HTTP, controlMode_t::JOYSTICK); //toggle between HTTP and JOYSTICK mode
|
||||
break;
|
||||
|
||||
case 6:
|
||||
// ## switch to MASSAGE mode ##
|
||||
ESP_LOGW(TAG, "cmd %d: toggle between MASSAGE and JOYSTICK", count);
|
||||
control->toggleModes(controlMode_t::MASSAGE, controlMode_t::JOYSTICK); //toggle between MASSAGE and JOYSTICK mode
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// ## toggle "sport-mode" ##
|
||||
//toggle deceleration fading between on and off
|
||||
//decelEnabled = motorLeft->toggleFade(fadeType_t::DECEL);
|
||||
//motorRight->toggleFade(fadeType_t::DECEL);
|
||||
@ -113,12 +125,10 @@ void buttonCommands::action (uint8_t count, bool lastPressLong){
|
||||
break;
|
||||
|
||||
case 12:
|
||||
ESP_LOGW(TAG, "cmd %d: sending button event to control task", count);
|
||||
//-> toggle altStickMapping (executed in control task)
|
||||
control->sendButtonEvent(count); //TODO: always send button event to control task (not just at count=1)?
|
||||
// ## toggle alternative stick mapping ##
|
||||
control->toggleAltStickMapping();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -127,56 +137,65 @@ void buttonCommands::action (uint8_t count, bool lastPressLong){
|
||||
//-----------------------------
|
||||
//------ startHandleLoop ------
|
||||
//-----------------------------
|
||||
//this function has to be started once in a separate task
|
||||
//repeatedly evaluates and processes button events then takes the corresponding action
|
||||
void buttonCommands::startHandleLoop() {
|
||||
// when not in MENU mode, repeatedly receives events from encoder button
|
||||
// and takes the corresponding action
|
||||
// this function has to be started once in a separate task
|
||||
#define INPUT_TIMEOUT 800 // duration of no button events, after which action is run (implicitly also is 'long-press' time)
|
||||
void buttonCommands::startHandleLoop()
|
||||
{
|
||||
//-- variables --
|
||||
bool isPressed = false;
|
||||
static rotary_encoder_event_t ev; // store event data
|
||||
// int count = 0; (from class)
|
||||
|
||||
while(1) {
|
||||
vTaskDelay(20 / portTICK_PERIOD_MS);
|
||||
//run handle function of evaluatedSwitch object
|
||||
button->handle();
|
||||
|
||||
//--- count button presses and run action ---
|
||||
switch(state) {
|
||||
case inputState_t::IDLE: //wait for initial button press
|
||||
if (button->risingEdge) {
|
||||
count = 1;
|
||||
buzzer->beep(1, 65, 0);
|
||||
timestamp_lastAction = esp_log_timestamp();
|
||||
state = inputState_t::WAIT_FOR_INPUT;
|
||||
ESP_LOGI(TAG, "first button press detected -> waiting for further events");
|
||||
}
|
||||
break;
|
||||
|
||||
case inputState_t::WAIT_FOR_INPUT: //wait for further presses
|
||||
//button pressed again
|
||||
if (button->risingEdge){
|
||||
count++;
|
||||
buzzer->beep(1, 65, 0);
|
||||
timestamp_lastAction = esp_log_timestamp();
|
||||
ESP_LOGI(TAG, "another press detected -> count=%d -> waiting for further events", count);
|
||||
}
|
||||
//timeout
|
||||
else if (esp_log_timestamp() - timestamp_lastAction > 1000) {
|
||||
state = inputState_t::IDLE;
|
||||
buzzer->beep(count, 50, 50);
|
||||
//TODO: add optional "bool wait" parameter to beep function to delay until finished beeping
|
||||
ESP_LOGI(TAG, "timeout - running action function for count=%d", count);
|
||||
//--- run action function ---
|
||||
//check if still pressed
|
||||
bool lastPressLong = false;
|
||||
if (button->state == true){
|
||||
//run special case when last press was longer than timeout
|
||||
lastPressLong = true;
|
||||
}
|
||||
//run action function with current count of button presses
|
||||
action(count, lastPressLong);
|
||||
}
|
||||
break;
|
||||
while (1)
|
||||
{
|
||||
//-- disable functionality when in menu mode --
|
||||
//(display task uses encoder in that mode)
|
||||
if (control->getCurrentMode() == controlMode_t::MENU)
|
||||
{
|
||||
//do nothing every loop cycle
|
||||
ESP_LOGD(TAG, "in MENU mode -> button commands disabled");
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-- get events from encoder --
|
||||
if (xQueueReceive(encoderQueue, &ev, INPUT_TIMEOUT / portTICK_PERIOD_MS))
|
||||
{
|
||||
switch (ev.type)
|
||||
{
|
||||
break;
|
||||
case RE_ET_BTN_PRESSED:
|
||||
ESP_LOGD(TAG, "Button pressed");
|
||||
buzzer->beep(1, 65, 0);
|
||||
isPressed = true;
|
||||
count++; // count each pressed event
|
||||
break;
|
||||
case RE_ET_BTN_RELEASED:
|
||||
ESP_LOGD(TAG, "Button released");
|
||||
isPressed = false; // rest stored state
|
||||
break;
|
||||
case RE_ET_BTN_LONG_PRESSED:
|
||||
case RE_ET_BTN_CLICKED:
|
||||
case RE_ET_CHANGED:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else // timeout (no event received within TIMEOUT)
|
||||
{
|
||||
if (count > 0)
|
||||
{
|
||||
//-- run action with count of presses --
|
||||
ESP_LOGI(TAG, "timeout: count=%d, lastPressLong=%d -> running action", count, isPressed);
|
||||
buzzer->beep(count, 50, 50);
|
||||
action(count, isPressed); // run action - if currently still on the last press is considered long
|
||||
count = 0; // reset count
|
||||
}
|
||||
else {
|
||||
ESP_LOGD(TAG, "no button event received in this cycle (count=0)");
|
||||
}
|
||||
} //end queue
|
||||
} //end while(1)
|
||||
} //end function
|
@ -20,7 +20,7 @@ extern "C"
|
||||
|
||||
//tag for logging
|
||||
static const char * TAG = "control";
|
||||
const char* controlModeStr[8] = {"IDLE", "JOYSTICK", "MASSAGE", "HTTP", "MQTT", "BLUETOOTH", "AUTO", "ADJUST_CHAIR"};
|
||||
const char* controlModeStr[9] = {"IDLE", "JOYSTICK", "MASSAGE", "HTTP", "MQTT", "BLUETOOTH", "AUTO", "ADJUST_CHAIR", "MENU"};
|
||||
|
||||
|
||||
//-----------------------------
|
||||
@ -183,46 +183,18 @@ void controlledArmchair::startHandleLoop() {
|
||||
break;
|
||||
|
||||
|
||||
case controlMode_t::MENU:
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
//nothing to do here, display task handles the menu
|
||||
//--- idle motors ---
|
||||
commands = cmds_bothMotorsIdle;
|
||||
motorRight->setTarget(commands.right.state, commands.right.duty);
|
||||
motorLeft->setTarget(commands.left.state, commands.left.duty);
|
||||
break;
|
||||
|
||||
//TODO: add other modes here
|
||||
}
|
||||
|
||||
|
||||
//--- run actions based on received button button event ---
|
||||
//note: buttonCount received by sendButtonEvent method called from button.cpp
|
||||
//TODO: what if variable gets set from other task during this code? -> mutex around this code
|
||||
switch (buttonCount) {
|
||||
case 1: //define joystick center or freeze input
|
||||
if (mode == controlMode_t::JOYSTICK){
|
||||
//joystick mode: calibrate joystick
|
||||
joystick_l->defineCenter();
|
||||
} else if (mode == controlMode_t::MASSAGE){
|
||||
//massage mode: toggle freeze of input (lock joystick at current values)
|
||||
freezeInput = !freezeInput;
|
||||
if (freezeInput){
|
||||
buzzer->beep(5, 40, 25);
|
||||
} else {
|
||||
buzzer->beep(1, 300, 100);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 12: //toggle alternative joystick mapping (reverse swapped)
|
||||
altStickMapping = !altStickMapping;
|
||||
if (altStickMapping){
|
||||
buzzer->beep(6, 70, 50);
|
||||
} else {
|
||||
buzzer->beep(1, 500, 100);
|
||||
}
|
||||
break;
|
||||
}
|
||||
//--- reset button event --- (only one action per run)
|
||||
if (buttonCount > 0){
|
||||
ESP_LOGI(TAG, "resetting button event/count");
|
||||
buttonCount = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------
|
||||
//------ slow loop ------
|
||||
//-----------------------
|
||||
@ -240,6 +212,60 @@ void controlledArmchair::startHandleLoop() {
|
||||
|
||||
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
//------ toggleFreezeInputMassage -------
|
||||
//---------------------------------------
|
||||
// releases or locks joystick in place when in massage mode
|
||||
bool controlledArmchair::toggleFreezeInputMassage()
|
||||
{
|
||||
if (mode == controlMode_t::MASSAGE)
|
||||
{
|
||||
// massage mode: toggle freeze of input (lock joystick at current values)
|
||||
freezeInput = !freezeInput;
|
||||
if (freezeInput)
|
||||
{
|
||||
buzzer->beep(5, 40, 25);
|
||||
ESP_LOGW(TAG, "joystick input is now locked in place");
|
||||
}
|
||||
else
|
||||
{
|
||||
buzzer->beep(1, 300, 100);
|
||||
ESP_LOGW(TAG, "joystick input gets updated again");
|
||||
}
|
||||
return freezeInput;
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "can not freeze/unfreeze joystick input - not in MASSAGE mode!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-------------------------------------
|
||||
//------- toggleAltStickMapping -------
|
||||
//-------------------------------------
|
||||
// toggle between normal and alternative stick mapping (joystick reverse position inverted)
|
||||
bool controlledArmchair::toggleAltStickMapping()
|
||||
{
|
||||
altStickMapping = !altStickMapping;
|
||||
if (altStickMapping)
|
||||
{
|
||||
buzzer->beep(6, 70, 50);
|
||||
ESP_LOGW(TAG, "changed to alternative stick mapping");
|
||||
}
|
||||
else
|
||||
{
|
||||
buzzer->beep(1, 500, 100);
|
||||
ESP_LOGW(TAG, "changed to default stick mapping");
|
||||
}
|
||||
return altStickMapping;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
//---------- resetTimeout -----------
|
||||
//-----------------------------------
|
||||
@ -250,17 +276,6 @@ void controlledArmchair::resetTimeout(){
|
||||
|
||||
|
||||
|
||||
//------------------------------------
|
||||
//--------- sendButtonEvent ----------
|
||||
//------------------------------------
|
||||
void controlledArmchair::sendButtonEvent(uint8_t count){
|
||||
//TODO mutex - if not replaced with queue
|
||||
ESP_LOGI(TAG, "setting button event");
|
||||
buttonCount = count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------
|
||||
//---------- handleTimeout -----------
|
||||
//------------------------------------
|
||||
|
@ -11,9 +11,9 @@
|
||||
//---- struct, enum, variable declarations ---
|
||||
//--------------------------------------------
|
||||
//enum that decides how the motors get controlled
|
||||
enum class controlMode_t {IDLE, JOYSTICK, MASSAGE, HTTP, MQTT, BLUETOOTH, AUTO, ADJUST_CHAIR};
|
||||
enum class controlMode_t {IDLE, JOYSTICK, MASSAGE, HTTP, MQTT, BLUETOOTH, AUTO, ADJUST_CHAIR, MENU};
|
||||
//string array representing the mode enum (for printing the state as string)
|
||||
extern const char* controlModeStr[8];
|
||||
extern const char* controlModeStr[9];
|
||||
|
||||
//--- control_config_t ---
|
||||
//struct with config parameters
|
||||
@ -63,13 +63,15 @@ class controlledArmchair {
|
||||
//function that restarts timer which initiates the automatic timeout (switch to IDLE) after certain time of inactivity
|
||||
void resetTimeout();
|
||||
|
||||
//function for sending a button event (e.g. from button task at event) to control task
|
||||
//TODO: use queue instead?
|
||||
void sendButtonEvent(uint8_t count);
|
||||
|
||||
//methods to get the current control mode
|
||||
controlMode_t getCurrentMode() const {return mode;};
|
||||
const char * getCurrentModeStr() const {return controlModeStr[(int)mode];};
|
||||
const char *getCurrentModeStr() const { return controlModeStr[(int)mode]; };
|
||||
|
||||
// releases or locks joystick in place when in massage mode, returns true when input is frozen
|
||||
bool toggleFreezeInputMassage();
|
||||
|
||||
// toggle between normal and alternative stick mapping (joystick reverse position inverted), returns true when alt mapping is active
|
||||
bool toggleAltStickMapping();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -200,53 +200,33 @@ void showStartupMsg(){
|
||||
//============================
|
||||
//======= display task =======
|
||||
//============================
|
||||
#define VERY_SLOW_LOOP_INTERVAL 60000
|
||||
#define SLOW_LOOP_INTERVAL 5000
|
||||
#define FAST_LOOP_INTERVAL 200
|
||||
//TODO: separate task for each loop?
|
||||
#define STATUS_SCREEN_UPDATE_INTERVAL 500
|
||||
// TODO: separate task for each loop?
|
||||
|
||||
void display_task( void * pvParameters ){
|
||||
//variables
|
||||
int countFastloop = 0;
|
||||
int countSlowLoop = 0;
|
||||
|
||||
//initialize display
|
||||
void display_task(void *pvParameters)
|
||||
{
|
||||
// initialize display
|
||||
display_init();
|
||||
//TODO check if successfully initialized
|
||||
// TODO check if successfully initialized
|
||||
|
||||
//show startup message
|
||||
// show startup message
|
||||
showStartupMsg();
|
||||
vTaskDelay(STARTUP_MSG_TIMEOUT / portTICK_PERIOD_MS);
|
||||
|
||||
// repeatedly update display with content
|
||||
while (1)
|
||||
{
|
||||
|
||||
//currently only showing menu:
|
||||
handleMenu(&dev);
|
||||
|
||||
|
||||
//status screen currently disabled:
|
||||
// //--- fast loop ---
|
||||
// showScreen1();
|
||||
|
||||
// if (countFastloop >= SLOW_LOOP_INTERVAL / FAST_LOOP_INTERVAL)
|
||||
// {
|
||||
// //--- slow loop ---
|
||||
|
||||
// if (countSlowLoop >= VERY_SLOW_LOOP_INTERVAL / SLOW_LOOP_INTERVAL)
|
||||
// {
|
||||
// //--- very slow loop ---
|
||||
// // clear display - workaround for bugged line order after a few minutes
|
||||
// countSlowLoop = 0;
|
||||
// ssd1306_clear_screen(&dev, false);
|
||||
// }
|
||||
// countFastloop = 0;
|
||||
// countSlowLoop++;
|
||||
// }
|
||||
// countFastloop++;
|
||||
// vTaskDelay(FAST_LOOP_INTERVAL / portTICK_PERIOD_MS);
|
||||
// // TODO add pages and menus
|
||||
if (control.getCurrentMode() == controlMode_t::MENU)
|
||||
{
|
||||
//uses encoder events to control menu and updates display
|
||||
handleMenu(&dev);
|
||||
}
|
||||
else //show status screen in any other mode
|
||||
{
|
||||
showScreen1();
|
||||
vTaskDelay(STATUS_SCREEN_UPDATE_INTERVAL / portTICK_PERIOD_MS);
|
||||
}
|
||||
// TODO add pages and menus
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ void setLoglevels(void){
|
||||
|
||||
//--- set loglevel for individual tags ---
|
||||
esp_log_level_set("main", ESP_LOG_INFO);
|
||||
//esp_log_level_set("buzzer", ESP_LOG_INFO);
|
||||
esp_log_level_set("buzzer", ESP_LOG_ERROR);
|
||||
//esp_log_level_set("motordriver", ESP_LOG_DEBUG);
|
||||
//esp_log_level_set("motor-control", ESP_LOG_INFO);
|
||||
//esp_log_level_set("evaluatedJoystick", ESP_LOG_DEBUG);
|
||||
@ -201,11 +201,7 @@ extern "C" void app_main(void) {
|
||||
//--- create task for button ---
|
||||
//------------------------------
|
||||
//task that evaluates and processes the button input and runs the configured commands
|
||||
#define MENU_TEST
|
||||
//currently disabled due to using button/encoder for testing the menu
|
||||
#ifndef MENU_TEST
|
||||
xTaskCreate(&task_button, "task_button", 4096, NULL, 4, NULL);
|
||||
#endif
|
||||
|
||||
//-----------------------------------
|
||||
//--- create task for fan control ---
|
||||
|
@ -155,7 +155,8 @@ void showItemList(SSD1306_t *display, int selectedItem)
|
||||
//---------------------------
|
||||
//----- showValueSelect -----
|
||||
//---------------------------
|
||||
//TODO show previous value in one line?
|
||||
// TODO show previous value in one line?
|
||||
// TODO update changed line only (value)
|
||||
void showValueSelect(SSD1306_t *display, int selectedItem)
|
||||
{
|
||||
//--- variables ---
|
||||
@ -248,7 +249,7 @@ void handleMenu(SSD1306_t *display)
|
||||
}
|
||||
break;
|
||||
|
||||
case RE_ET_BTN_PRESSED:
|
||||
case RE_ET_BTN_CLICKED:
|
||||
//--- switch to edit value page ---
|
||||
ESP_LOGI(TAG, "Button pressed - switching to state SET_VALUE");
|
||||
// change state (menu to set value)
|
||||
@ -259,10 +260,15 @@ void handleMenu(SSD1306_t *display)
|
||||
ssd1306_clear_screen(display, false);
|
||||
break;
|
||||
|
||||
case RE_ET_BTN_RELEASED:
|
||||
case RE_ET_BTN_CLICKED:
|
||||
//exit menu mode
|
||||
case RE_ET_BTN_LONG_PRESSED:
|
||||
control.changeMode(controlMode_t::IDLE);
|
||||
ssd1306_clear_screen(display, false);
|
||||
break;
|
||||
|
||||
case RE_ET_BTN_RELEASED:
|
||||
case RE_ET_BTN_PRESSED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -272,6 +278,8 @@ void handleMenu(SSD1306_t *display)
|
||||
//-------------------------
|
||||
case SET_VALUE:
|
||||
// wait for encoder event
|
||||
showValueSelect(display, selectedItem);
|
||||
|
||||
if (xQueueReceive(encoderQueue, &event, portMAX_DELAY))
|
||||
{
|
||||
switch (event.type)
|
||||
@ -289,19 +297,18 @@ void handleMenu(SSD1306_t *display)
|
||||
if (value < menuItems[selectedItem].valueMin)
|
||||
value = menuItems[selectedItem].valueMin;
|
||||
break;
|
||||
case RE_ET_BTN_PRESSED:
|
||||
case RE_ET_BTN_CLICKED:
|
||||
//-- apply value --
|
||||
ESP_LOGI(TAG, "Button pressed - running action function with value=%d for item '%s'", value, menuItems[selectedItem].title);
|
||||
menuItems[selectedItem].action(value);
|
||||
menuState = MAIN_MENU;
|
||||
break;
|
||||
case RE_ET_BTN_PRESSED:
|
||||
case RE_ET_BTN_RELEASED:
|
||||
case RE_ET_BTN_CLICKED:
|
||||
case RE_ET_BTN_LONG_PRESSED:
|
||||
break;
|
||||
}
|
||||
}
|
||||
showValueSelect(display, selectedItem);
|
||||
break;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user