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.