Add feature that switches to mode IDLE when duty of both motors did not
change over certain time.
control.cpp/hpp:
- add private function that handles timeout
- add public function that resets timeout
- add slow loop with timeout handle inside control handle loop
- 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
- control.cpp: Add feature to HTTP mode, that turns motors off when at least one motor is still on
but no data was received for more than 3 seconds (e.g. wifi connection
lost)
- change queue size from 20 to 1 - no need to store multiple joystick
data since only the latest one is relevant
- add "preset command" to control.hpp to set both motors to IDLE
- Create http.cpp and http.hpp
- functions for initializing a http server
- function for URL api/joystick
- receive joystick data from http post request
- parse json, define joystick position (function from joystick.hpp)
- send data to control task via queue
- control.hpp/cpp:
- add HTTP mode to handle loop
- receive joystick commands from queue, generate commands, send to
motorctl
- upgrade changeMode function with ability to run functions at switch
FROM and TO certain modes
- add code to start/stop wifi and webserver when switching to/from
HTTP mode
- change toggleModes and toggleIdle to use the changeMode function
- main.cpp:
- add several sections with code for testing new functions (commented
out)
- add http loglevel
- buzzer.cpp:
- add command (press 4 times) to toggle between HTTP and JOYSTICK mode
FIXME: moved initialization of wifi to main.cpp at startup because of an
error -> resolve this and place wifi start and stop functions into
mode-change as intended
currently works best in accesspoint mode with laptop connected using the
react-webapp
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
- 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
Add control.hpp and control.cpp
- task that repeatedly generates motor commands depending on the current mode
- function to change to a specified control mode
Add button.hpp and button.cpp
- class which runs commands depending on the count a button was pressed
Update main.cpp
- create button task
- create control task
- comment out previous testing code
- remove unnecessary includes (already included in config.hpp)
Add control.cpp and button.cpp to CMakeLists
Notes: Tested this state on the armchair: All currently implemented features
work. You can switch between IDLE and JOYSTICK by pressing the button 2
or 3 times. Also driving works well (limited to 60% duty, with no fans
yet).