30 Commits

Author SHA1 Message Date
jonny_jr9
cef2a841c8 Add menu item Set Max Duty
Add nvs to control.cpp
2024-02-22 23:59:13 +01:00
jonny_l480
0672d08cb8 Adjust beeping
Tested on actual hardware.
- adjust count and duration of beeps
2024-02-21 14:23:07 +01:00
jonny_jr9
cdfa64fbc0 Add joystick-calibration wizzard (store in nvs), Optimize Menu
- 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
2024-02-21 11:30:36 +01:00
jonny_jr9
c9c371a742 Add default-value to Menu, Optimize value-screen, Add Beeping
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
2024-02-20 17:33:54 +01:00
jonny_jr9
268018832d Add nvs in motorctl: Store and Load accel/decel conf
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
2024-02-20 16:34:42 +01:00
jonny_jr9
021a3660e1 Outsource display, encoder cfg to config.cpp, Optimize speedsensor
- 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
2024-02-20 12:24:41 +01:00
jonny_l480
b7288b442e Fix Motor jump at startup / always on - all modes tested
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
2024-02-20 09:41:34 +01:00
jonny_l480
8de4dbbe27 Fix crash in ADJUST_CHAIR mode, Fix Rest not stopping
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
2024-02-20 09:34:33 +01:00
jonny_jr9
26761f4a80 Oursource task_fans and task_buzzer
- 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)
2024-02-19 13:54:22 +01:00
jonny_jr9
6e9b3d96d9 Initialize motorDriver in STACK instead of HEAP, pointer
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
2024-02-19 11:54:32 +01:00
jonny_jr9
2fcf17feda Major Rework all files - Pass pointers to tasks, Remove gloabl variables
- 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
2024-02-18 10:00:34 +01:00
jonny_jr9
fe0e0093d0 Add functional menu items (accel/decel), Add menu-timeout
menu.cpp:
    - add item center-Joystick (functional)
    - add item accel-Limit (functional)
    - add item decel-Limit (functional)
    - fix display freeze on timeout
    - add menu timeout
    - switch to previous mode on exit instead of always idle

motorctl.cpp:
    - add getFade method, to get currently configured values
    - add log output on fade change
2024-02-14 23:56:52 +01:00
jonny_jr9
f16b96c100 Optimize Display: show current mode, git-tag...
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
2024-02-12 23:00:31 +01:00
jonny_jr9
a1bb808b62 Rework/simplify chairAdjust - now using a class
- 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.
2024-02-11 23:22:33 +01:00
jonny_jr9
30e9411a2e Add GPIO initialization, logging 2023-10-11 20:02:02 +02:00
jonny_jr9
9dfe1bddb2 Add chairAdjust driver, Add joystick control
- Add functions that control the relays for adjusting the armchair
  position
- Add function that controls the chair using joystick input
2023-10-08 14:19:04 +02:00
jonny_jr9
0037f4a836 Fix bug right motor always on; Optimize comments
Bug was fixed in previous commit already
Only changed code slightly (better readable) work with duty instead of data

Optimize comments in motordriver
2023-09-13 13:49:52 +02:00
jonny_jr9
5f54681bbf Sabertooth: Add uart-mutex; Add both-off serial command
- 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"
2023-09-13 12:15:35 +02:00
jonny_l480
69a421a924 Outsource speedsensor, Display: show speed
- 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
2023-09-12 16:00:20 +02:00
jonny_l480
3449bb7f34 Config optimizations (Test-drive)
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
2023-09-09 16:10:18 +02:00
jonny_jr9
8e0441b27c Fix stack-overflow, Adjust logging, test-ready
enable all tasks in main for full function test with new driver
2023-09-09 09:38:42 +02:00
jonny_jr9
71b63ebbd3 Make drivers interchangeable, Switch to sabertooth driver
- 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
2023-09-08 12:09:52 +02:00
jonny_jr9
98956e2bf8 Create class sabertooth2x60a - new driver functional
currently repeatedly sends test commands from main using a created
instance of that new class
2023-09-07 16:37:14 +02:00
jonny_jr9
a30ec01818 Simple driver test - works
test controlling driver via uart (in main function)
2023-09-07 14:02:48 +02:00
jonny_jr9
f76db1d9bc Outsource http, joystick to common/ and react-app to root
Same reason as before commit
Note: some changes to http were necessary due to global object
- untested!

Also remove unneded duplicate components folder
2023-09-07 12:59:15 +02:00
jonny_jr9
13b896accb Outsource currentsensor, motorctl, motordrivers to common/
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
2023-09-07 12:30:22 +02:00
jonny_jr9
446c246f43 Add message framing (start, end, escape bytes) to UART
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
2023-08-30 18:17:20 +02:00
jonny_jr9
1e544613ee send, receive, apply motorCommands works (proof of concept); add timeout
- 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
2023-08-30 09:01:44 +02:00
jonny_jr9
3722b0af74 Add uart templates, send and receive tasks with templates work
both boards compile and send/receive example data using new templates in
common uart code
common/uart_common.hpp
2023-08-30 09:01:31 +02:00
jonny_jr9
76e8bac113 2 boards: split code, outsource common, remove duplicate files
- 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
2023-08-30 09:01:13 +02:00