4 Commits

Author SHA1 Message Date
jonny_l480
73325e08ce Fix bug in scaling, Fix http cmd gen, Fix overflow
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
2022-06-22 09:09:40 +02:00
jonny_ji7
a80502f95b Utilize SPIFFS for serving the app with web-server
With this commit the webserver of the controller can serve a folder (/react-app/build/), when the ip is accessed in a web-browser.

Currently the react app is successfully served and the armchair can be controlled when in HTTP mode and connected via AP.

- CMakeLists: Add command that creates and flashes the spiffs partition when running
  idf.py flash
- main.cpp: Add function to initialize spiffs
- http.cpp: uncomment handler for default URL (accesses spiffs)
- Add partitions.csv: needed for the creation of spiffs.bin during
  compilation
- Add sdkconfig: It was necessary to change the FLASH_SIZE from 2MB to
  4MB. To avoid having the same trouble on other devices the sdkconfig
  is now added to the repository
2022-06-17 22:33:29 +02:00
jonny_ji7
d0b3b6fb78 Add timeout to HTTP mode, Change Queue size
- 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
2022-06-17 21:10:20 +02:00
jonny_ji7
3cb5bc410b Create http server, Add HTTP mode
- 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
2022-06-17 18:24:11 +02:00