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
Fix bug where armchair moved too long every once in a while (especially
at start).
Minor adjustments of parameters.
main.cpp:
- set individual task priorities for each task e.g. fan or buzzer task has very low priority (did not have any immediate effect though while testing)
- increase handle interval of motorctl
change from 20 to 10 (same frequency as generation of massage
commands)
-> this fixed the bug with unexpected movement (motorctl could not
process every command from massage mode)
control.cpp:
- decrease delay in massage mode for more detail/levels at joystick
radius (from 20 to 10ms)
- increase fading in massage mode (400ms to 500ms) for slightly less hard
shaking
joystick.cpp:
- reduce max shaking amount
- swap modes
- top left shake backward
- top right shake forward
- bottom left/right shake rotating
Modified function that generates commands in massage mode (joystick.cpp)
- define variable stickQuadrant with axis as hysteresis from actual joystick data/pos
- prepare switch case for implementation of 4 modes (each quadrant)
- add basic content to modes for testing (different motor directions)
TODO: remove old code with pulsing shake variable and implement actual modes
While testing this feature briefly that approach did not appear to be a good idea.
- noticed that the driving with joystick was a little unintuitive/unexpected (maybe just not used to it?)
- BUG that the state does not reset to center when previous state was
X-AXIS? Resulting in the armchair to slightly shake randomly at
joystick center
-> this has to be fixed if this approach is tested again.
This reverts commit b2b12fe5de1e16ea2f25dfa4b0c3ac6845024c71.
modified function
joystickPos_t joystick_evaluatePosition(float x, float y, joystickPos_t* prevPos)
because prevPos has to be stored http.cpp/hpp and joystick.cpp/hpp had
to be updated as well
TODO: add function without hysteresis again?
WIP this has to be tested
- 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
- add function joystick_generateCommandsShaking that generates motor
commands from joystick data
- pulses motors:
- intervals depend on joystick radius
- direction depends on joystick position (currently only on-x-axis and on-y-axis
supported)
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
- 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
Move section that defines joystick position enum to a separate function
(outside of joystick class), this makes it usable for other inputs as
well
- create new function joystick_evaluatePosition
- call the new function in joystickgetData (where code was initially)
- change function joystick_generateCommandsDriving to accept joystick
data struct instead of joystick object as parameter -> makes the
function usable with other input than hardware joystick too
- add new function to joystick.hpp/cpp
- reads data from joystick and generates commands for driving in
"joystick" mode
- returns struct with commands for both motors
- main.cpp
- add code for testing the new function
- enable 5v regulator (needed for pullups AB left motor)
- add newly created motorRight to handle function
- add new struct with two motorcommands to motorctl.hpp
- 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