Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modules: add bitmask modifying to param module #1488

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joshanne
Copy link
Contributor

Adds ability to toggle, set and clear bitmask parameters.

@joshanne
Copy link
Contributor Author

joshanne commented Nov 18, 2024

I have found it inconvenient at times to modify bitmasks - I've added this to the param module to make twiddling bits in parameters simpler.

The one caveat is that this currently relies on the user having downloaded the parameters for the vehicle software. I'd be happy to remove that requirement but then it would allow for every parameter to be twiddled. I would potentially find that helpful for custom firmwares or development builds.

If I were to allow all parameters to be treated as a bitmask, I'd at least check that the type of the parameter is not a float (if at all possible).

Example output:

Listing Full Bitmask

RTL> param bitmask NTF_LED_TYPES
NTF_LED_TYPES: LED Driver Types
NTF_LED_TYPES    123079

Bitmask:
          0 [x] : Built-in LED
          1 [x] : Internal ToshibaLED
          2 [x] : External ToshibaLED
          3 [ ] : External PCA9685
          4 [ ] : Oreo LED
          5 [ ] : DroneCAN
          6 [x] : NCP5623 External
          7 [x] : NCP5623 Internal
          8 [ ] : NeoPixel
          9 [ ] : ProfiLED
         10 [ ] : Scripting
         11 [ ] : DShot
         12 [ ] : ProfiLED_SPI
         13 [x] : LP5562 External
         14 [x] :  LP5562 Internal
         15 [x] : IS31FL3195 External
         16 [x] :  IS31FL3195 Internal
         17 [ ] :  DiscreteRGB
         18 [ ] :  NeoPixelRGB
bit index is not specified

Listing Individual Bitmask Fields

RTL> param bitmask NTF_LED_TYPES 10
NTF_LED_TYPES: LED Driver Types
NTF_LED_TYPES    123079

Bitmask:
         10 [ ] : Scripting
action is not specified - use toggle, set or clear

Toggle/Set/Clear Bitmask Index

RTL> param bitmask NTF_LED_TYPES 10 toggle
RTL> param bitmask NTF_LED_TYPES 10 clear
RTL> param bitmask NTF_LED_TYPES 10 set

@joshanne
Copy link
Contributor Author

joshanne commented Nov 18, 2024

The latest update adds autocompletion for bitmask

@peterbarker
Copy link
Contributor

Perhaps "setbit" and "unsetbit" which takes a bit offset?

Not sure about the ordering on the command-line; trend for recent years has been to have the command before the arguments on command-lines. So param bitmask set PARAM MASK

@joshanne
Copy link
Contributor Author

Perhaps "setbit" and "unsetbit" which takes a bit offset?

Happy to change the ordering. I wanted to be able to diagnose bits separately from the action, but if I reorder it I'd be happy to use param bitmask setbit the same way as param set - if no mask is specified then print out the bitmask decoding.

What I don't want is to accidentally trigger param set when param bitmask set is intended.

Adds ability to toggle, set and clear bitmask fields in parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants