display.cpp:
Optimize battery voltage measurement
While calibrating noticed it is very non-linear
- outsource function to scale using lookup table
- add lookup table to batvoltage measurement
inserted many values to lookup table while testing
currentsensors:
Fix current value jumping around between 0 and 0.2 on display
while standstill
- add parameter snapToZeroThreshold
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
Tested and debugged speed measurement on actual hardware.
Speed measurement is very stable now (reliable direction)
- fix direction inverted no effect
- fix direction detection
- remove "invalid directions" since every combination is valid
- trigger on rising edge only
- ignore too short pulses - possible noise (config option)
- ignore invalid pulse orders
- debug log count of ignored sequences
- config, chairAdjust:
- disable reset-pin of display (not connected, random pin was assigned)
same pin was used for chair adjust resulting in on state after startup
- fix chairAdjust not stopping in OFF state
- display
- add functionality to show different status screens (content when not in MENU)
- add status screen 'Speed' (to show speed and debug speedsensors)
- menu
- fix item joystick define center not working
- add item to select status screen
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
menu:
- optimize set-value page: send static content only once
so only update value -> significant performance boost
- formatting
- reset control timeout to prevent unintended exit and bugged display
- menu item: add option to show a default value (function ptr)
- add default value to adjust fading
- add beeping
motorctl:
- dont write to nvs when value is unchanged
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
- 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 new commits on actual hardware noticed
the motors always beeing on at full power.
-> This was due to uninitialized value. It had to fade down from
duty 81236182734612738 which takes forever.
-> This also fixes the old issue where left motor jumped for a
second after startup
Also tested JOYSTICK, HTTP, ADJUST_CHAIR modes and encoder+menu
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
Currently testing with breakoutboard and larger
1.3'' display (OFFSETX needed)
- display.cpp:
- change structure (outsource in page functions)
- add git and compile info to startup screen
- add armchair mode and motor current to status screen
- control.hpp: Add methods to get current armchair control mode (string)
- motorctl.hpp: Add method to get motor current
- 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.
- add mutex around mutex send instruction
- add minimum delay between sent messages
- detect situation where both motors are off and send special both motor
stop command. This might fix issue "right motor stay always on"
- move speedsensor files from motorctl pcb to common
- single pcb create and configure global speedsensor objects
- display: create fast slow veryslow loop
- clear display every 30s
- show speed in rpm and km/h
NOTE: speedsensor needs fix, direction unreliable
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
Same reason as before commit
Note: some changes to http were necessary due to global object
- untested!
Also remove unneded duplicate components folder
since board_single uses mostly the same code as board_control and
board_motorctl several files are outsorced to common folder to prevent
dupliate code and different versions
Same functionality as previous commit. But way more stable and clean.
Previous proof of concept approach had issues with random partial or
too large messages due to time based method
Rework send and receive functions to work more stable
- send: encode data with frame (start, end byte)
- receive: read each byte one after the other, assemble message,
handle actual data in handle function
- add semaphore to write operation to prevent parallel write of
different data when called from other tasks
- board_control successfully sends motor commands to board_motorctl
- board_motorctl receives and applies motor commands
note: control pcb currently switches to HTTP mode after startup for testing
with data from ui
- partially commented in code that has to be reworked
- control: send commands via uart instead of to motor objects
- board motorctl handled motor: add timeout when no target data
received (e.g. control pcb offline / uart bugged)
- board motorctl uart: receive motorCommands_t struct and apply data to
target state of handled motors
- types: fix issue with global motorstateStr variable
- outsoruce common files and separate common types from source files (new
common/types.hpp)
- split source files to 2 board folders (relevant only, no duplicate)
- currently boards compile successfull but not functional at all
- comment out currently incompatible code