14 Commits

Author SHA1 Message Date
jonny_l480
5d1d17915d make control-modes and TCS work [proof of concept]
Tested new control modes on actual hardware.
Adjust new code so the modes kind of work now, as proof of concept.
Still needs major optimization and fixes though.

motorctl:
    - add config option to disable logging for particular instance
    - add some definitions to finetune control modes
    - rework current and speed mode, so they actually kind of work
    - fix TCS to not cause deadlock motors off

menu:
    - add item set motorControlMode (select DUTY, CURRENT, SPEED)
    - fix missing item maxDuty

speedsensor: fix return type
2024-02-28 23:00:38 +01:00
jonny_jr9
2abeefde07 Add Duty, Current, Speed control modes, Add traction-control [testing]
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
2024-02-28 10:21:53 +01:00
jonny_l480
aab30abb80 Display: Add Status screens 'Motors' and 'Joystick'
Add new status screens that can be selected in menu
(status screen = display content while not in MENU mode)

- display:
    - Motors screen: shows Power usage, duty, speed
    - Joystick screen: shows all stick data and current control mode (similar to 'debug joystick' menu option

- menu:
    - disable example menu items
    - add new status screens
2024-02-26 23:05:02 +01:00
jonny_jr9
ccef663c33 Fix chairAdjust, Add different status screens (Speed)
- 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
2024-02-24 12:25:45 +01:00
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
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
ffac657199 Add abstracted functions for display - simplify code
Simple functions for printing a line normal, large or centered
using format string directly instead of having to use both
snprintf first and then display function all the time
This makes the code more readable and compact

Applied this optimization where applicable in manu.cpp and display.cpp
2024-02-15 23:24:41 +01:00
jonny_jr9
a35fb7b6aa Add menu 'Debug Joystick'
- Add menu that continously shows/updates all Joystick
  data on display
- Add display pointer to action function
2024-02-15 16:37:54 +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
4f8c421168 Integrate menu into control, Rework prev. button menu
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
2024-02-14 13:40:46 +01:00
jonny_jr9
fc5aad0c14 Add menu (display + encoder) functional - wip
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
2024-02-13 19:36:06 +01:00