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

Add initial persistent parameter API #280

Merged
merged 20 commits into from Dec 3, 2021
Merged

Conversation

jonasdn
Copy link
Contributor

@jonasdn jonasdn commented Nov 11, 2021

A persistent parameter is one that can be stored to eeprom. The way to do this is to set a value to the parameter, using the regular parameter API, and then use CRTP to tell the firmware to store the value. A value can also be cleared from eeprom using CRTP.

In order to build nice UIs we want to be able to tell whether a persistent parameter is stored or not, and what the default value of the parameter is. This is done by asking the firmware about the state.

Also! Since we are taking the last bit in the parameter type to express that this is a persistent parameter we have now introduced the concept of extended type information. That we also fetch as part of the connection in the Crazyflie class.

Contains the following commit:

  • Param: fetch extended types at connection
  • Param: add persistent_get_state method
  • Param: add persistent_store method
  • Param: add persistent_clear method

@jonasdn jonasdn force-pushed the jonasdn/persistent_parameters branch 4 times, most recently from e34c79e to 8763d3e Compare November 12, 2021 06:28
Copy link
Contributor

@krichardsson krichardsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just had a quick look

cflib/crazyflie/param.py Outdated Show resolved Hide resolved
cflib/crazyflie/param.py Outdated Show resolved Hide resolved
@jonasdn jonasdn force-pushed the jonasdn/persistent_parameters branch from 8763d3e to b8ab6cc Compare November 12, 2021 08:04
@jonasdn
Copy link
Contributor Author

jonasdn commented Nov 22, 2021

I just had a quick look

Does it look better now?

Copy link
Contributor Author

@jonasdn jonasdn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Some comments below!

examples/parameters/persistent_params.py Outdated Show resolved Hide resolved
examples/parameters/persistent_params.py Outdated Show resolved Hide resolved
examples/parameters/persistent_params.py Outdated Show resolved Hide resolved
examples/parameters/persistent_params.py Outdated Show resolved Hide resolved
@jonasdn jonasdn force-pushed the jonasdn/persistent_parameters branch 2 times, most recently from fa33e95 to 9c2cf81 Compare November 25, 2021 14:28
jonasdn and others added 15 commits December 1, 2021 13:58
Get the state of the specified persistent parameter. The state will be
returned in the supplied callback. The state is represented as a
namedtuple with members: `is_stored`, `default_value` and
`stored_value`. The state is `None` if the parameter is not persistent
or if something goes wrong.

| Member            | Description                                     |
| ----------------- | ----------------------------------------------- |
| `is_stored`       | `True` if the value is stored to eeprom         |
| `default_value`   | The default value supplied by the firmware      |
| `stored_value`    | Value stored in eeprom, None if `not is_stored` |
Store the current value of the specified persistent parameter to
eeprom. The supplied callback will be called with `True` as an
argument on success, and with `False` as an argument on failure.
Clear the current value of the specified persistent parameter from
eeprom. The supplied callback will be called with `True` as an
argument on success, and with `False` as an argument on failure.
So that the same callback can multiplex for a lot of parameters.
When doing persitent param operations, check that the parameter is
persistent. Otherwise throw exception.
@jonasdn jonasdn merged commit 30fa266 into master Dec 3, 2021
@jonasdn jonasdn deleted the jonasdn/persistent_parameters branch December 3, 2021 08:27
@knmcguire knmcguire added this to the next-release milestone Dec 16, 2021
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.

None yet

3 participants