Add button commands; Update Readme
button.cpp: - Add command: reboot when long button press - Add command: switch to mode JOYSTICK with 3x press Readme: - rework table with switch functions - add new commands to table - add drink holder to planned features joystick.cpp: - fix bug: missing 'break;' for switch case in function joystick_CommandsShaking
This commit is contained in:
		
							parent
							
								
									3fa2f17a72
								
							
						
					
					
						commit
						1c3576206a
					
				
							
								
								
									
										23
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								README.md
									
									
									
									
									
								
							@ -92,21 +92,26 @@ A diagram which shows what components are connected to which terminals of the pc
 | 
				
			|||||||
- Anti slip regulation
 | 
					- Anti slip regulation
 | 
				
			||||||
- Self driving algorithm
 | 
					- Self driving algorithm
 | 
				
			||||||
- Lights
 | 
					- Lights
 | 
				
			||||||
 | 
					- drinks holder
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Usage
 | 
					# Usage
 | 
				
			||||||
## Switch functions
 | 
					## Switch functions
 | 
				
			||||||
**Currently implemented**
 | 
					**Currently implemented**
 | 
				
			||||||
| Count | Action |
 | 
					| Count | Type | Action | Description |
 | 
				
			||||||
| --- | ---|
 | 
					| --- | --- | --- | --- |
 | 
				
			||||||
| 1 | |
 | 
					| 1x | configure | [JOYSTICK] **calibrate stick** | when in joystick mode: set joystick center to current joystick pos |
 | 
				
			||||||
| 2 | toggle IDLE mode |
 | 
					| 1x | control | [MASSAGE] **freeze** input | when in massage mode: lock or unlock joystick input at current position |
 | 
				
			||||||
| 3 | |
 | 
					| 2x | toggle mode | **IDLE** <=> previous | enable/disable chair armchair e.g. enable after startup or timeout |
 | 
				
			||||||
| 4 | toggle between HTTP and JOYSTICK mode|
 | 
					| 3x | switch mode | **JOYSTICK** | switch to default mode JOYSTICK |
 | 
				
			||||||
| 5 | |
 | 
					| 4x | toggle mode | **HTTP** <=> JOYSTICK | switch to '**remote control** via web-app' or back to JOYSTICK mode |
 | 
				
			||||||
| 6 | toggle between MASSAGE and JOYSTICK mode |
 | 
					| 5x | | | |
 | 
				
			||||||
| 7 | |
 | 
					| 6x | toggle mode | **MASSAGE** <=> JOYSTICK | switch to MASSAGE mode or back to JOYSTICK mode |
 | 
				
			||||||
 | 
					| 7x | | | |
 | 
				
			||||||
 | 
					| 8x | toggle option | **deceleration limit** | disable/enable deceleration limit (default on) => more responsive |
 | 
				
			||||||
 | 
					| >1s | system | **restart** | Restart the controller when pressing the button longer than 1 second | 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**previous functions - not implemented**
 | 
					**previous functions - not implemented**
 | 
				
			||||||
 | 
				
			|||||||
@ -43,14 +43,20 @@ void buttonCommands::action (uint8_t count){
 | 
				
			|||||||
            buzzer->beep(3, 400, 100);
 | 
					            buzzer->beep(3, 400, 100);
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case 1:
 | 
					        case 0: //special case when last button press is longer than timeout (>1s)
 | 
				
			||||||
            //ESP_LOGW(TAG, "RESTART");
 | 
					            ESP_LOGW(TAG, "RESTART");
 | 
				
			||||||
            //buzzer->beep(1,1000,1);
 | 
					            buzzer->beep(1,1000,1);
 | 
				
			||||||
            //vTaskDelay(1000 / portTICK_PERIOD_MS);
 | 
					            vTaskDelay(1000 / portTICK_PERIOD_MS);
 | 
				
			||||||
            //esp_restart();
 | 
					            esp_restart();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case 1:
 | 
				
			||||||
            ESP_LOGW(TAG, "cmd %d: sending button event to control task", count);
 | 
					            ESP_LOGW(TAG, "cmd %d: sending button event to control task", count);
 | 
				
			||||||
            control->sendButtonEvent(count);
 | 
					            control->sendButtonEvent(count); //TODO: always send button event to control task (not just at count=1) -> control.cpp has to be changed
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        case 3:
 | 
				
			||||||
 | 
					            ESP_LOGW(TAG, "cmd %d: switch to JOYSTICK", count);
 | 
				
			||||||
 | 
					            control->changeMode(controlMode_t::JOYSTICK); //switch to JOYSTICK mode
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case 2:
 | 
					        case 2:
 | 
				
			||||||
@ -123,9 +129,16 @@ void buttonCommands::startHandleLoop() {
 | 
				
			|||||||
                    state = inputState_t::IDLE;
 | 
					                    state = inputState_t::IDLE;
 | 
				
			||||||
                    buzzer->beep(count, 50, 50);
 | 
					                    buzzer->beep(count, 50, 50);
 | 
				
			||||||
                    //TODO: add optional "bool wait" parameter to beep function to delay until finished beeping
 | 
					                    //TODO: add optional "bool wait" parameter to beep function to delay until finished beeping
 | 
				
			||||||
                    //run action function with current count of button presses
 | 
					 | 
				
			||||||
                    ESP_LOGI(TAG, "timeout - running action function for count=%d", count);
 | 
					                    ESP_LOGI(TAG, "timeout - running action function for count=%d", count);
 | 
				
			||||||
                    action(count);
 | 
					                    //--- run action function ---
 | 
				
			||||||
 | 
					                    //check if still pressed
 | 
				
			||||||
 | 
					                    if (button->state == true){
 | 
				
			||||||
 | 
					                        //run special case when last press was longer than timeout
 | 
				
			||||||
 | 
					                        action(0); 
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        //run action function with current count of button presses
 | 
				
			||||||
 | 
					                        action(count);
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
				
			|||||||
@ -456,6 +456,7 @@ motorCommands_t joystick_generateCommandsShaking(joystickData_t data){
 | 
				
			|||||||
                    stickQuadrant = joystickPos_t::BOTTOM_RIGHT;
 | 
					                    stickQuadrant = joystickPos_t::BOTTOM_RIGHT;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case joystickPos_t::X_AXIS:
 | 
					        case joystickPos_t::X_AXIS:
 | 
				
			||||||
            //when moving from center to axis initially start in a certain quadrant
 | 
					            //when moving from center to axis initially start in a certain quadrant
 | 
				
			||||||
@ -480,7 +481,7 @@ motorCommands_t joystick_generateCommandsShaking(joystickData_t data){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //--- handle different modes (joystich in any of 4 quadrants) ---
 | 
					    //--- handle different modes (joystick in any of 4 quadrants) ---
 | 
				
			||||||
    switch (stickQuadrant){
 | 
					    switch (stickQuadrant){
 | 
				
			||||||
        case joystickPos_t::CENTER:
 | 
					        case joystickPos_t::CENTER:
 | 
				
			||||||
        case joystickPos_t::X_AXIS: //never true
 | 
					        case joystickPos_t::X_AXIS: //never true
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user