- add currentsensor class
- add current limit to motorctl handle function
- add config options for curring limit for each motor
- update connection plan with more detailed driver-box overview
- remove second fan instance since both fans are controlled via one pin
now
- more config options so fans turn on less at short movements
=> less noise and less relay cycles
the joystick object is now available in the button class/task
thus can be used to trigger commands with certain combinations of
joystick and button
- not used yet -
auto.cpp:
apply fadeAccel and fadeDecel from commands to motors
main.cpp:
double stack size of button task (crashed controller every time)
button.cpp:
Modify test command to actually eject armchair leg support
control.cpp:
apply generated motor commands to motors
rename some variables:
typo: fadeAccel
more specific: auto_instruction_t
- Create class automatedArmchair in new files auto.hpp and auto.cpp
This class currently makes it possible to queue up and run commands
(motorstate, duty for certaion duration),
- add new file to cmakelists
- create automatedArmchair instance 'armchair' in config.cpp
- add loglevel configuration to main.cpp
- add AUTO mode to control.cpp (no way to change to mode yet)
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
- add 3 functions to controlledMotor class in motorctl.cpp/hpp
- setFade: set specific msFade duration for acceleration or
deceleration
- setFade: disable or set to default ramp for acceleration or
deceleration
- toggleFade: toggle between fading enabled or disables for
acceleration or deceleration
- button.cpp
- add controlledMotor objects to constructor
- add new command 8x press which now toggles fade-deceleration of both
motors
- config.cpp
- slightly decrease fading durations
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
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
- 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
Create functions in wifi.c and wifi.h:
- an wifi accesspoint can be created
- connect to an existing wifi anf disconnect
Add code for testing to main.cpp:
repeatedly connects, disconnects and switches between AP and connecting
to BKA-network every run
New functions
//init components (run in main function once)
void wifi_initNvs_initNetif();
//function to start an access point
void wifi_init_ap(void);
//function to disable/deinit access point
void wifi_deinit_ap(void);
//function to connect to existing wifi network
void wifi_init_client(void);
//function to disable/deinit client
void wifi_deinit_client(void);
- 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
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).
- 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
- 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
- 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.
- create class 'single100a' in motordrivers.hpp and motordrivers.cpp
- add code for testing the driver in main.cpp (test with led was successful)
- update cmakelists, to also compile the new .cpp file