9 Commits

Author SHA1 Message Date
jonny_ji7
b2b12fe5de Add hysteresis to joystick position X-Axis [WIP]
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
2022-07-08 19:38:29 +02:00
jonny_ji7
b460a52181 Add linear scaling of stick coordinates
- 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
2022-07-06 17:23:54 +02:00
jonny_l480
1c6586c29e Add exponential scaling of stick coordinates
- 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
2022-07-05 18:38:08 +02:00
jonny_ji7
9db5736f77 Create shake mode (basic functionality)
- 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)
2022-06-25 21:52:49 +02:00
jonny_ji7
1da03e9429 Add different tolerances for X and Y coordinate
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
2022-06-24 09:06:26 +02:00
jonny_ji7
20873b4175 Move coordinate scaling from app to controller
- 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
2022-06-19 15:37:42 +02:00
jonny_ji7
cc5226647b Move joystick pos-definition to separate function
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
2022-06-17 10:43:00 +02:00
jonny_ji7
f7ce61c666 Add function 'joystick_generateCommandsDriving'
- 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
2022-06-09 21:42:01 +02:00
jonny_ji7
4eb1c5d43a Create class 'evaluatedJoystick'
- 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
2022-06-08 19:50:17 +02:00