Add menu item Set Max Duty
Add nvs to control.cpp
This commit is contained in:
@@ -304,7 +304,7 @@ joystickPos_t joystick_evaluatePosition(float x, float y){
|
||||
//========= joystick_CommandsDriving =========
|
||||
//============================================
|
||||
//function that generates commands for both motors from the joystick data
|
||||
motorCommands_t joystick_generateCommandsDriving(joystickData_t data, bool altStickMapping){
|
||||
motorCommands_t joystick_generateCommandsDriving(joystickData_t data, joystickGenerateCommands_config_t * config){
|
||||
|
||||
//struct with current data of the joystick
|
||||
//typedef struct joystickData_t {
|
||||
@@ -317,10 +317,8 @@ motorCommands_t joystick_generateCommandsDriving(joystickData_t data, bool altSt
|
||||
|
||||
//--- variables ---
|
||||
motorCommands_t commands;
|
||||
float dutyMax = 100; //TODO add this to config, make changeable during runtime
|
||||
|
||||
float dutyOffset = 5; //immediately starts with this duty, TODO add this to config
|
||||
float dutyRange = dutyMax - dutyOffset;
|
||||
float dutyRange = config->maxDuty - config->dutyOffset;
|
||||
float ratio = fabs(data.angle) / 90; //90degree = x=0 || 0degree = y=0
|
||||
|
||||
//--- snap ratio to max at angle threshold ---
|
||||
@@ -334,7 +332,7 @@ motorCommands_t joystick_generateCommandsDriving(joystickData_t data, bool altSt
|
||||
*/
|
||||
|
||||
//--- experimental alternative control mode ---
|
||||
if (altStickMapping == true){
|
||||
if (config->altStickMapping == true){
|
||||
//swap BOTTOM_LEFT and BOTTOM_RIGHT
|
||||
if (data.position == joystickPos_t::BOTTOM_LEFT){
|
||||
data.position = joystickPos_t::BOTTOM_RIGHT;
|
||||
|
||||
@@ -10,6 +10,7 @@ extern "C"
|
||||
#include "esp_err.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
#include <stdbool.h>
|
||||
}
|
||||
|
||||
#include <cmath>
|
||||
@@ -69,6 +70,13 @@ typedef struct joystickData_t {
|
||||
} joystickData_t;
|
||||
|
||||
|
||||
// struct with parameters provided to joystick_GenerateCommandsDriving()
|
||||
typedef struct joystickGenerateCommands_config_t {
|
||||
float maxDuty;
|
||||
float dutyOffset;
|
||||
bool altStickMapping;
|
||||
} joystickGenerateCommands_config_t;
|
||||
|
||||
|
||||
//------------------------------------
|
||||
//----- evaluatedJoystick class -----
|
||||
@@ -120,7 +128,7 @@ private:
|
||||
//============================================
|
||||
//function that generates commands for both motors from the joystick data
|
||||
//motorCommands_t joystick_generateCommandsDriving(evaluatedJoystick joystick);
|
||||
motorCommands_t joystick_generateCommandsDriving(joystickData_t data, bool altStickMapping = false);
|
||||
motorCommands_t joystick_generateCommandsDriving(joystickData_t data, joystickGenerateCommands_config_t * config);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user