General:
- Rename control mode MENU to MENU_SETTINGS
- Add new control mode MENU_MODE_SELECT
Button menu:
- change 'long press' to: 'switch to menu mode-select'
- move 'open settings menu' to 5x press
Display:
- display_task: outsource statusScreen to local function
- display_task: also handle MENU_MODE_SELECT control mode
- show display startup message for 2600ms instead of 2000ms
Menu:
- Add functions to handle modeSelect menu to select from a list of allowed modes
(similar to settings main menu)
As initially planned starting wifi only when needed, at change to HTTP mode.
Tested this on breakout board: ESP32 is not getting hot anymore!
Also optimized timeout: only notify "forgot to turn off" when battery is below certain
threshold (e.g. disable when charger is connected over night)
main:
- dont start wifi at startup anymore
- remove double-initialization of nvs
already initialized in wifi.c, thus removed some code
- optimize comments, logging
control:
- timeout "forgot to turn off": Add battery threshold
- start/stop wifi when switching to/from HTTP mode
wifi:
- split init function to separate functions for NVS and NETIF (more clear in main)
- optimize log output at nvs init (moved from main)
- rename start/stop functions, formatting
control:
- reset timeout on user input only
-> drop reset on changed motor duty
- add timeoutNotifyPowerStillOnMs
-> when forgotten to turn off the power the buzzer
beeps a few times every 30 minutes
- Add/fix JOYSTICK_LOG_IN_IDLE option
remove empty config.hpp
very experimental needs testing/debugging,
other control modes can currently be selected by editing the class definition in motorctl.hpp
menu/config
- add menu item to enable/disable traction control system
main: pass ptr to other motor to motor object
speedsensor: add method to get last update time
motorctl: handle loop:
- re-arrange some code sections
- add several methods to get current status (needed from other motor for tcs)
- add sketchy code for different control modes DUTY, CURRENT, SPEED (very basic implementation)
- add experimental code for traction control
motorctl, currentsensor:
- add config option for inverted current sensor
- adjust loglevels
config:
- Adjust gpio pins to actual wiring (not breakout board for testing)
- Add min pulse durations for speedsensors (measurements with scope)
- Adjust config to currently mounted encoders
control, buzzer:
- adjust beeping
- Add feature for optinal delay to buzzer class:
have some pause after beeps instead of immediately
continuing with next queued sequence
Major changes in motorctl and control to optimize performance
by freeing unnecessary cpu usage by motorctl task
Needs testing on actual hardware!
motorctl:
- slow down handle loop when duty is at target (wait for new command)
- create separate task for each motor
- setTarget method also accepts motorCommand directly now
control.cpp:
- redurce stress on motorctl by removing unnecessary commands
- set motors to idle at mode change only, instead of every iteration (IDLE, MENU, ADJUST)
- HTTP, JOYSTICK: only update motors when stick data actually changed
- simplify code
- add method for idling both motors
- use motorcommands directly in setTarget()
http:cpp:
- dont block control task with getData() method
- handle timeout independent of one queue event
- prevents unresponsive system for http-timeout when changing mode from HTTP
- menu:
- Add item joystick calibration wizzard
- Add item RESET (clear nvs and restart)
- Add configuration option to not show/change value. Instead only show confirm message
apply this to all items only running action
- Optimize formatting and comments
- main:
- pass nvsHandle to display task and joystick class
- joystick:
- Add methods to write and load calibration values (axis min/max adc value) from nvs
- Add method to get raw adc value
Changes in menu for accel/decel time are now persistent after
restarts
main: initialize nvs and pass pointer to motorctl task
motorctl:
- add method to get default configured value
- add name to config -> adjust logging
- add methods to read and write msFadeAccel and msFadeDecel from nvs
Even though the object was created in STACK using alloca
apparently the method call via pointer in lambda function still
takes quite long since the encoder in MENU started to lag again
It gets initialized before main() now this fixed the lag
- outsource configuration of display and encoder from source/header file
to config.cpp and pass it to init function or task from main()
- optimize logging in several init functions
- speedsensor:
- fix startup error: initialize ISR only once
- create instances at initialization instead of first method call
- ssd1306 display library:
- modify library to pass offsetX to init function instead of using macro
While testing the ADJUST_CHAIR mode on actual hardware fixed the
following issues:
- main.cpp: Uninitialized pointer for leg/back-rest were passed to
control task thus as when a method was called the controller crashed
- chairAdjust.cpp: the state was never reset to REST_OFF when below
stick threshold
- outsource task_fans and task_buzzer from main.cpp to their source files
- use task parameters to pass necessary configs and objects
- adjust task priorities (display was too low)
Since moving all objects to heap encoder started to lag
interrupt not recognizing some single events in MENU
fast executen of motordriver setTarget caused the lag,
initialize it in STACK while still using a pointer now
- All files:
Modify almost all files to adjust functions and classes to
work with pointers to objects passed at task creation
instead of global variables from config.hpp
- Remove/clear config.hpp to get rid of all global variables
- main.cpp
- Create pointer to all shared (used in multiple tasks) objects in main
- remove evaluatedSwitch button object,
since joystick library is used to get switch events
- changes HTTP-mode
- always init http-server (do not enable/disable at mode change)
- pass url-handle function to init-htpp function
- add lambda function to pass method of instance for thatMajor Rework all files - Remove global variables, pass pointers to tasks
- All files:
Modify almost all files to adjust functions and classes to
work with pointers to objects passed at task creation
instead of global variables from config.hpp
- Remove/clear config.hpp to get rid of all global variables
- main.cpp
- Create pointer to all shared (used in multiple tasks) objects in main
- remove evaluatedSwitch button object,
since joystick library is used to get switch events
- changes HTTP-mode
- always init http-server (do not enable/disable at mode change)
- pass url-handle function to init-htpp function
- add lambda function to pass method of instance for that
NOTES: - tested on breakoutboard only
- known issue that slow encoder events are not recognized
(especially in menu) - slowing down motorctl helps
Armchair functions as before (all tasks enabled).
Note: probably wrong encoder pin set in encoder.hpp
Old button menu works as usual (opimized code).
You can switch to new MENU state with 1x long press
and exit the menu with 1x long press
button.cpp: - use encoder queue instead of evaluated switch
- simplify code, rework actions
control.cpp: Add MENU state/mode
-> control task: turns motors off and idles
-> button task idles (button menu disabled)
-> display task switches state to handle menu
control.cpp: Optimize structure:
Add methods to freeze stick and toggle stick mapping
display.cpp: show status screen or handle menu depending on mode, simpilfy task
main.cpp: re-enable button task, disable buzzer logging
menu.cpp: Change events, Add menu exit condition
Added functional menu using display and encoder:
- a menu item is defined in one struct
- scroll in a list of defined items
- select option
- modify value
- save value, return to list
Currently only menu is run (button and status display disabled)
- Add menu.cpp/hpp
- Add encoder.cpp/hpp mostly from previous test in board-control
- display.cpp: only run new handleMenu() function
- main.cpp: initialize encoder at startup, disable button task for testing
- complete rework of chairAdjust.cpp/.hpp
created a class cControlledRest which is more readable
and saves a lot of duplicate code
- joystick.cpp: move chair control via joystick to
chairAdjust.cpp (prevents dependency loop)
- button.cpp: fix bug instant idle when changing to ADJUST_CHAIR
Note: briefly tested this state on a breakout board:
Mode change and call of new class methods works.
slightly rework hacked display test
- new code structure
- split code in several functions
- add task for display instead of running it in main()
- functions to convert voltage to battery percent charged
- show percentage and voltage on display
Successfull test drive with new driver
- set max duty from 90 to 100
- config adjust fading, calibrate joystick, disable deadtime
- disable 1x button cmd
- 8x sport mode: toggle accel not decel
- make motorctl compatible with different drivers
- pass set function instead of specific motor object
- add lambda function in config.cpp
- update config to use one new sabertooth driver instead of two single100a
- main test controlled motor
New controller will be run with single controller at first...
get single board version from V2.0 and create new folder
(two boards version is kept)
-> copied firmware from e6e586e5855d81ee726bb9a0fbe8ab12def5eeef