Closed NerdsCorp closed 3 weeks ago
this would make it so you could free up main buttons and have "config/tuning" in a different layer thus creating more advanced Projects using this.
I think i might have an idea of how to do this. What if each binding had an optional key called conditionals
or something, which can either be an event or a list of events. The binding's action is only executed if all of the conditional events resolve as true. I think each event would be resolved by the same logic as boolean-input actions (like BB_ACTION_SPEED_DOWN), where it is true
if the event value is greater than the halfway point between min and max. Because the main event and conditional events might have different ranges, I'll also add a conditional_min
(default=0) and conditional_max
(default=1).
For example, if you wanted to have speed control stuff gated behind the start button (like in your post) you could do something like this:
- action: BB_ACTION_SPEED_DOWN
event: BB_EVENT_DPAD_DOWN
conditionals: BB_EVENT_BTN_START
min: 0
max: 1
Another example, if you instead wanted to check that both analog sticks are pushed upwards (ie: Y axis > 0), you could do
- action: BB_ACTION_SPEED_DOWN
event: BB_EVENT_DPAD_DOWN
conditionals: [BB_EVENT_ANALOG_LY, BB_EVENT_ANALOG_RY]
min: 0
max: 1
conditional_min: 0
conditional_max: 511
At least I think this would work? What do you think?
I think that would make the code Clean and it would make it work. Using the conditionals would also allow for the feedback system that is in the #todo.md.
hi, i've added this feature, and a little bit of documentation. try it out and let me know if it works!
So i did some testing, I tried it a few different ways i thought it would work but nothing. I only changed one, the very last on my config.yml. The way i understand it this config should have two states on and off, its assigned to x but you have to hold the brake, am i right? Im just using an led on that output pin to test.
Also my questions are from reading the Documents are... Do you have to have conditional min and max for them to work or is it alway 1 or 0, its not very clear... and what are possible limitations with conditionals.
Side note, maybe in the future could we clean up the debug codes, its a little hard to follow.
Heres the output of my serial.
23:22:44.867 -> Bluepad32 (C) 2016-2024 Ricardo Quesada and contributors.
23:22:44.867 -> Version: v4.1.0
23:22:44.867 -> BTstack: Copyright (C) 2017 BlueKitchen GmbH.
23:22:45.495 -> BTstack up and running at B0:B2:1C:F8:73:AE
23:22:47.016 -> [32m[i] [0m[main]
23:22:47.016 -> === bbrx! ===
23:22:47.016 -> [32m[i] [0m[main] version: v1.1
23:22:47.016 -> [32m[i] [0m[main] build time: Sep 24 2024 23:04:39
23:22:47.016 -> [32m[i] [0m[main]
23:22:47.016 -> [32m[i] [0m[status] Setting up Status LED
23:22:47.016 -> [36m[d] [0m[status] [2m1 leds on pin 5, init brightness = 35[0m
23:22:47.049 -> [36m[d] [0m[status] [2mchanged state to 1[0m
23:22:47.049 -> [36m[d] [0m[status] [2msetting led to 0 128 0, pulse period = 1000, pulse delay = 4, divider = 7, brightness = 35[0m
23:22:47.049 -> [32m[i] [0m[config] Loading bbrx config file from LittleFS...
23:22:47.115 -> [36m[d] [0m[config] [2mloading deadzones...[0m
23:22:47.115 -> [36m[d] [0m[config] [2m- ly = 40[0m
23:22:47.115 -> [36m[d] [0m[config] [2m- lx = 40[0m
23:22:47.115 -> [36m[d] [0m[config] [2m- ry = 40[0m
23:22:47.115 -> [36m[d] [0m[config] [2m- rx = 40[0m
23:22:47.115 -> [36m[d] [0m[config] [2m- brake = 64[0m
23:22:47.115 -> [36m[d] [0m[config] [2m- throttle = 64[0m
23:22:47.148 -> [36m[d] [0m[config] [2m[0m
23:22:47.148 -> [36m[d] [0m[config] [2mloading beefzones...[0m
23:22:47.148 -> [36m[d] [0m[config] [2m- ly = 500[0m
23:22:47.148 -> [36m[d] [0m[config] [2m- lx = 500[0m
23:22:47.148 -> [36m[d] [0m[config] [2m- ry = 500[0m
23:22:47.148 -> [36m[d] [0m[config] [2m- rx = 500[0m
23:22:47.148 -> [36m[d] [0m[config] [2m- brake = 1000[0m
23:22:47.148 -> [36m[d] [0m[config] [2m- throttle = 1000[0m
23:22:47.148 -> [36m[d] [0m[config] [2m[0m
23:22:47.148 -> [36m[d] [0m[config] [2mparsing binding 0[0m
23:22:47.148 -> [36m[d] [0m[config] [2m- action string BB_ACTION_SERVO[0m
23:22:47.181 -> [36m[d] [0m[config] [2m- action int 2[0m
23:22:47.181 -> [36m[d] [0m[config] [2m- action enum 2[0m
23:22:47.181 -> [36m[d] [0m[config] [2m- event string BB_EVENT_ANALOG_LY[0m
23:22:47.181 -> [36m[d] [0m[config] [2m- event int 1[0m
23:22:47.181 -> [36m[d] [0m[config] [2m- event enum 1[0m
23:22:47.214 -> [36m[d] [0m[config] [2m- min int -512[0m
23:22:47.214 -> [36m[d] [0m[config] [2m- max int 511[0m
23:22:47.214 -> [36m[d] [0m[config] [2m- missing or invalid default_value key[0m
23:22:47.214 -> [36m[d] [0m[config] [2m- pin int 36[0m
23:22:47.214 -> [36m[d] [0m[config] [2m- missing or invalid exec_without_controller key[0m
23:22:47.214 -> [36m[d] [0m[config] [2m- missing or invalid ignore_claims key[0m
23:22:47.214 -> [36m[d] [0m[config] [2m- missing or invalid conditionals
Heres My Config.yml
deadzones: ly: 40 lx: 40 ry: 40 rx: 40 brake: 64 throttle: 64
beefzones: ly: 500 lx: 500 ry: 500 rx: 500 brake: 1000 throttle: 1000
bindings:
action: BB_ACTION_SERVO event: BB_EVENT_ANALOG_LY min: -512 max: 511 pin: 36
action: BB_ACTION_SERVO event: BB_EVENT_ANALOG_LX min: 511 max: -512 pin: 37
action: BB_ACTION_SERVO event: BB_EVENT_ANALOG_RY min: -512 max: 511 pin: 38
action: BB_ACTION_SERVO event: BB_EVENT_ANALOG_RX min: 511 max: -512 pin: 39
action: BB_ACTION_SERVO event: BB_EVENT_ANALOG_THROTTLE min: 1023 max: -1024 pin: 34
action: BB_ACTION_SERVO event: BB_EVENT_ANALOG_BRAKE min: 1023 max: -1024 pin: 35
action: BB_ACTION_GPIO event: BB_EVENT_BTN_B min: 0 max: 1 pin: 2
action: BB_ACTION_GPIO event: BB_EVENT_BTN_Y min: 0 max: 1 pin: 4
action: BB_ACTION_GPIO event: BB_EVENT_BTN_A min: 0 max: 1 pin: 17
action: BB_ACTION_GPIO event: BB_EVENT_BTN_X conditionals: BB_ACTION_BRAKE min: 0 max: 1 pin: 16
Never mind its not an issue, when i moved it from the brake to a different button it worked great. ( may put this in the Notes)= conditionals cannot be a analog option on the controller.
also I have verified "sticky Keys" does not work, and we should add a easy Is sticky in the config.yml like below. I think if its needed it can be turned on otherwise it off to eliminate Nooby Confusion.
action: BB_ACTION_GPIO event: BB_EVENT_BTN_A min: 0 max: 1 is_sticky: true or false pin: 17
thanks for trying it out!
conditional_min
is 0 by default and conditional_max
is 1 by default. they're designed for digital buttons by default. good point about it not being documented, i'll add a note in the docs.conditional_min
and conditional_max
to match the range of the input since 0 and 1 usually aren't appropriate for analog inputs. again i get that this isn't clear in the docs so i'll add this tooconditional_{min, max}
applies to all conditionals. note you can have a digital event
and analog conditionals
or vice versa, since event
and conditionals
have separate min and max settingsBB_EVENT_BTN_L2
. with BB_EVENT_ANALOG_BRAKE
you have to set conditonal_{min, max}
since it's an analog input, but with BB_EVENT_BTN_L2
you can use the default range since it's digitalregarding the funky debug logs, the �[36m
stuff is ANSI colour codes. so on terminals which support it parts of the output will render in colour. i do most of my development of bbrx in visual studio code, which looks like this:
I tried it on arduino ide v2 and it looks like it doesn't support colour codes :(
there's not really an ideal way to copy and paste the text without ansi codes from arduino ide, but you can disable ansi codes entirely by commenting out ANSI_ENABLE
in log.h
I hope this clears it up!
yes this explanation helps a lot! thanks!
I might be missing it or this might be a future thing, but is it possible to Hold one button down and then click another for the outcome to trigger?
I tried this below but I don't think its built in to the rest of the code. But it would be cool if this was added!