- add more debug output in joystick getData function
- update joystick config with new min/max values while testing
=> fixed bugged movement (joystick unusable) after winter
- bump esp-idf version since successfully compiled with 4.4.4
- slightly decrease msFadeDecel by 100ms
- different approach in button.cpp for case last button press was long
e.g. reworked commands:
- 1x long press = restart
- 1x short press = center stick, freeze
- 1x short 1x long = run new auto commands
- 2x short = toggle idle
- change default minOnMs / minOffMs for evaulated switch class -> fix
button presses sometimes not recognized
- Create class automatedArmchair in new files auto.hpp and auto.cpp
This class currently makes it possible to queue up and run commands
(motorstate, duty for certaion duration),
- add new file to cmakelists
- create automatedArmchair instance 'armchair' in config.cpp
- add loglevel configuration to main.cpp
- add AUTO mode to control.cpp (no way to change to mode yet)
- add 3 functions to controlledMotor class in motorctl.cpp/hpp
- setFade: set specific msFade duration for acceleration or
deceleration
- setFade: disable or set to default ramp for acceleration or
deceleration
- toggleFade: toggle between fading enabled or disables for
acceleration or deceleration
- button.cpp
- add controlledMotor objects to constructor
- add new command 8x press which now toggles fade-deceleration of both
motors
- config.cpp
- slightly decrease fading durations
- Fix bug where case duty=0 was not handled in fading if structure thus no
incrementing action happened anymore (stuck at duty = 0)
- Set fade duration (acceleration, deceleration) to realistic value in
config
- Change fading algorithm to handle Acceleration and Deceleration for
forward and reverse separately (4 different cases)
- rename variables to make fading direction more obvious
e.g. msFadeUp -> msFadeAccel or dutyIncrementDon -> dutyIncrementDecel
TODO: fading needs optimization
- Fix bug where downfade did not work when driving forward
- Add BRAKE command functionality to motorctl (untested, since not used anywhere atm)
- Cleanup: Optimize code, add comments
!!!TODO: there is a fault in the current concept/logic:
fading up/down generally works, however when accelerating
REVERSE fade-down is utilized instead of fade-up.
=> Fix that bug, fade down should only be used when decelerating.
With this changes the motors are faded down (same as already existing fading up)
when the target duty suddenly decreases.
It can be configured or disabled with setting msFadeDown to 0 in config struct of
motorctl object.
- Add new config parameter msFadeDown
- Change msFade to msFadeDown
- Add fade down functionality to motorctl instead of just setting the
duty to lower value
!!!TODO: fix major BUG when motor direction changes suddenly (before fade got to
0) the motor immediately starts in other direction with previous duty
(no/less fading up happening)
Use reference to joystick object in control class instead of accessing
the global evaluatedJoystick object
control.hpp:
- add joystick reference to constructor
- add local joystick pointer variable
control.cpp:
- constructor: copy pointer to joystick object
- use methods of joystick reference instead of global object
- update log output of timeout check
config.cpp:
- add joystick object to control object construction
- joystick.hpp/cpp
- add function joystick_scaleCoordinatesLinear(joystickData_t * data, float pointX, float pointY)
that scales the coordinates with 2 different slopes before and
after certain point
- control.cpp
- scale coordinates linear with new function instead of exponential in JOYSTICK mode
- scale coordinates linear with new function instead of exponential in HTTP mode
- config.cpp
- adjust / decrease http joystick tolerances
Note: tested the armchair in http and joystick mode briefly and
optimized the scaling point slightly
- joystick.hpp/cpp
- add function joystick_scaleCoordinatesExp(joystickData_t * data, float exponent)
which updates joystick data with its scaled coordinates and
re-calculated radius
- control.cpp
- scale coordinates exponential (pow 2) in JOYSTICK mode
- scale coordinates exponential (pow 2) in HTTP mode
- config.cpp
- fixed swapped x/y zero tolerances for hardware joystick
Note: tested armchair with scaling exponents 1.5; 2; 3 and noticed that
2 works best
As already did for http joystick:
- Add different config options tolerance zero for X and Y axis for
normal/actual joystick.
This makes it possible to set Y tolerance to a lower value resulting in
a more responsive turning action, with still having a large range around
X axis for turning mode
Fix several bugs noticed while testing the preceding commits in dev
branch:
- Fix bug in function scaleCoordinate
- scaling was wrong resulting in negative/inverted values at start of axis
- Adjust timeout value from 30s to 5min
- Fix http joystick behaivor
- calculate angle, radius and evaluate position AFTER the coordinates
have been scaled in control.cpp (bug introduced when switching applying tolerance
on controller instead of in the app)
- Add independent toleranceZero for X and Y axis -> unnecessary to have
large tolerance for x axis... makes turning more sensitive
- Fix stack overflow in control task
- controller crashed repeatedly when logging output was enabled in
control task
- -> doubled stack size at task creation in main.cpp
currently works, position hast to be evaluated AFTER coordinate scaling
- create new struct control_config_t with several variables previously
hardcoded in control.cpp
- modified constructor: add config parameter
- add definition of config struct in config.cpp
typedef struct control_config_t {
controlMode_t defaultMode; //default mode after startup and toggling IDLE
//--- timeout ---
uint32_t timeoutMs; //time of inactivity after which the mode gets switched to IDLE
float timeoutTolerancePer; //percentage the duty can vary between timeout checks considered still inactive
//--- http mode ---
float http_toleranceZeroPer;//percentage around joystick axis the coordinate snaps to 0
float http_toleranceEndPer; //percentage before joystick end the coordinate snaps to 1/-1
uint32_t http_timeoutMs; //time no new data was received before the motors get turned off
- joystick.cpp/hpp:
- move method scaleCoordinate from joystick class to public function
- modify scaleCoordinate function to accept float values instead of
ADC pin, change tolerance parameters to percent instead of absolute
number
- change method getData to use the public function now
- control.cpp:
- use scaleCoordinate function in http mode
- calculate radius in http mode
- config.cpp
- adjust tolerance thresholds for joystick to percent
- App.js
- disable "snap to zero" feature -> just scale joystick output to
value of -1 to 1
- Add class for controlling fans for cooling the motor drivers
- Add configuration for left and right fan to config.cpp
- Create fan task in main.cpp
- Add getStatus function to controlledMotor class
- Move all separately declared functions in control.hpp to a new class
'controlledArmchair'
- now passing other objects only one time with constructor instead
of accessing them globally
- Create control instance in config.hpp, and passing objects in
config.cpp
- Add functions to new control class
- toggleIdle(): toggle between last mode and idle
- toggleModes(mode1, mode2): toggle between two modes
- Add commands to button.cpp
- 2x button press: call toggleIdle()
- 6x button press: toggleModes MASSAGE -> JOYSTICK
- Define control task in main.cpp
- Adjust button files and main.cpp to use the new command object instead
of the previus functions
- Copy buzzer function from gate project
this makes it possible to easily trigger and queue up buzzing events
without having to worry about delaying the program
- Add instance buzzer to config
- Add code for testing the buzzer to main.cpp
Copy gpio component from gate project
Add instance of evaluatedswitch for button next to joystick to config
Add code for testing the button to main.cpp
- Create class 'evaluatedJoystick'
- evaluates a joystick with 2 analog signals
- scales the adc input to coordinates with detailed tolerances
- calculates angle and radius
- defines an enum with position information
- Add joystick configuration and class instance to config.cpp
- Add code for testing the new class to main.cpp
- Add joystick.cpp to cmakelists
now function `joystick.getData` can be used globally to obtain a struct with
current position data of the joystick
- Create class 'controlledMotor':
- handles 'fading / ramp' of the pwm duty
- handles current limit **not implemented yet**
- has .handle function that is intended to be run very fast in another task
commands are sent via queue
- Create config.hpp
- Globally available instance motorLeft of controlledMotor class
- Create config.cpp
- Configuration of motordriver and control parameters for motorLeft
- Add config.cpp and motorctl.cpp to cmakelists
- main.cpp:
- create 'task_motorctl' which repeatedly runs motorLeft.handle()
- modify testing code for testing the new class
- comments
The fading/ramp capability of the new class was tested successfully
using a breakoutboard with an led.