24 Commits

Author SHA1 Message Date
jonny_l480
25cc72c5e6 Optimize encoder-rest control, Invert back-rest direction
Less unintended menu jumping when controlling rest
Less ignored ticks when recently used
2024-09-08 12:23:13 +02:00
jonny_l480
c48b162d1f Add logging, mutex + Fixes - works well with MIN-On/Off time now 2024-09-06 15:27:09 +02:00
jonny_l480
c19d053867 Minor fixes + optimizations - test success 2024-09-05 10:47:37 +02:00
jonny
71460bbf87 Button: ignore first ticks, prevent long press when PRESS+ROTATE 2024-09-05 09:22:40 +02:00
jonny
23cf6e6f3e Add Display-notification, default position, Push+scroll 2024-09-04 23:04:54 +02:00
jonny_l480
43cc3ce3e0 Fix position tracking, stick mode - test success 2024-09-04 20:08:28 +02:00
jonny
2a2678b734 Add chairAdjust task, pos tracking, move with encoder 2024-09-04 18:27:24 +02:00
jonny_l480
ff98d3f5eb Change status-screen-scroll to require 2 clicks
to prevent confusion, made it harder to switch page
accidentially and easier to return to overview

- 2 rotate-clicks necessary for status page to switch
- if only one received within timeout it gets switched to default screen
2024-08-31 20:19:11 +02:00
jonny_l480
b1c010bf15 Fix menu immediately exiting, Optimize mode-select
Tested newly implemented menu on armchair and made several Fixes:

- reduce long delay when changing to menu modes (control handle)
- add unused line to mode select menu, also drop "click to confirm"
- fix and optimize getNextSelectableModeIndex function to get n next (recursive, offset)

- button: clear encoder queue before changing to menu mode
- fix menu immediately exiting on x5 press (missing break)
2024-05-30 09:05:29 +02:00
jonny
c58c6b9b35 Add Mode-Select-Menu (1x long), (settings is 5x now)
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)
2024-05-28 21:20:20 +02:00
jonny_l480
bff6175fb0 Button: Scroll through status screens with rotating encoder
In any mode except MENU the encoder rotateion selects status screens

Add functions to rotate through available status screens
Aandle rotate encoder event in button menu
2024-05-20 17:00:46 +02:00
jonny
c1d34237ee Fix unintended encoder doubleclick, Reduce long-press time
sdkconfig:
- increase encoder dead-time to fix bug where encoder triggered multiple
  short pressed events at one press.
  E.g. instantly submitted value when entering a menu page sometimes

button:
- decrease input-timeout (long press time) to 500ms same as encoder long-press
- empty encoder queue when changing to MENU

- re-enable or increase joystick scaling to have more resolution at
  slower speeds
2024-03-11 23:45:44 +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
3aa6bcc403 Adjust button commands (dont toggle modes)
Adjust button actions to match the current README
2024-02-29 23:50:12 +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_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
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
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_l480
d9deddf923 Display: show battery voltage, Button longPress=calibrate 2023-09-09 18:03:54 +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
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