14 Commits

Author SHA1 Message Date
jonny_l480
a6a630af44 Add boost outer tire, Add ratio-threshold, Fix motorctl timeout
Rework joystick command generation
Fix timeout no commands received in motorctl

Successfully tested this state on actual hardware:
turning behavior is significantly improved - does not get slower when turning anymore

joystick:
    - add boost of inner tire when turning
    - add threshold where ratio snaps to 1
    - optimize structure, logging

control:
    - rename maxDuty to maxDutyStraight to be more clear
    - add methods to change and get new variable RelativeBoostPer for menu item

menu:
    - add new item to set maxRelativeBoost config parameter

motorctl:
    - fix timeout not working:
    previously when not receiving commands for 15s the duty was set to 0 for 1 handle cycle only
2024-03-05 23:59:12 +01:00
jonny
77ba81e996 WiFi on in HTTP-mode only, Add batt-threshold to timeout
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
2024-03-03 22:04:27 +01:00
jonny
3514dd6bf2 Add Brightness reduction at inactive, Optimize timeout
display.cpp:
    - add timeout where display brightness gets reduced
    - rework display-task loop to handle timeouts
    - run commands when changing from/to status-page (toggle scrolling)
    - add BRIGHTNESS_TEST option

config: Add display timeouts to config.cpp

control:
    - dont reset timeout at mode change (happens not always at user input)
    - remove deprecated config option
2024-03-02 13:06:55 +01:00
jonny_l480
0d082a52d8 Add Screensaver, Fix timeout
Add screensaver status screen to prevent oled burn-in:
  Display task switches to screensaver status-screen
  when certain time of inactivity is exceeded
2024-03-01 23:59:00 +01:00
jonny
bc9504d4ab Add Timeout / Notification on "forgot to turn off"
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
2024-03-01 13:55:51 +01:00
jonny_l480
bf481ae8ea Adjust GPIO-pins and conf, Invert currentsensor, Buzzer
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
2024-02-26 22:57:22 +01:00
jonny_jr9
bc014befb7 Optimize motorctl: slow down task when target reached
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
2024-02-23 23:57:21 +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
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
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
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
95f2403163 Add control mode 'ADJUST_CHAIR' (btn 1 short, 1 long)
Add functional mode to control chair position via joystick
Switch to that mode using button 1x short 1x long (prev eject support)
2023-10-08 14:56:19 +02:00
jonny_jr9
ee5bad53ee Revert to V2.0 single board (additional folder)
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
2023-09-07 12:17:33 +02:00