Skip to content

feat: rework CrossPointSettings#510

Open
borisfaure wants to merge 1 commit intocrosspoint-reader:masterfrom
borisfaure:feat/rework-settings-data-structure
Open

feat: rework CrossPointSettings#510
borisfaure wants to merge 1 commit intocrosspoint-reader:masterfrom
borisfaure:feat/rework-settings-data-structure

Conversation

@borisfaure
Copy link
Contributor

@borisfaure borisfaure commented Jan 23, 2026

Summary

Multiple goals are achieved with this change:

  • make descriptions of settings close to their definitions: the labels are in the same file as the configuration declarations
  • settings validation on loading with reset to default in case of bad value
  • (de)serialization is based on a single list of descriptors: single point of truth
  • possibly to have default values for the String configuration type
  • more constexpr to reduce RAM usage
  • less hardcoded values
  • more maintainable

RAM Usage:

From

RAM:   [===       ]  32.5% (used 106516 bytes from 327680 bytes)
Flash: [========= ]  94.9% (used 6217240 bytes from 6553600 bytes)

To

RAM:   [===       ]  32.3% (used 105844 bytes from 327680 bytes)
Flash: [========= ]  94.8% (used 6213636 bytes from 6553600 bytes)

Boot config validation:

[1186] [SD] SD card detected
[1192] [CPS] Invalid value for Status Bar, resetting to default [1192] [CPS] Settings loaded from file

AI Usage

While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it
helps set the right context for reviewers.

Did you use AI tools to help write this code? PARTIALLY

@borisfaure
Copy link
Contributor Author

This fixes #487

@Eloren1
Copy link
Contributor

Eloren1 commented Jan 23, 2026

  • settings validation on loading with reset to default in case of bad value

#492

@Eloren1
Copy link
Contributor

Eloren1 commented Jan 23, 2026

  • less hardcoded values

What does it mean?

@Eloren1
Copy link
Contributor

Eloren1 commented Jan 23, 2026

  • make descriptions of settings close to their definitions

What descriptions changed exactly?

@borisfaure borisfaure marked this pull request as draft January 23, 2026 14:30
@borisfaure borisfaure force-pushed the feat/rework-settings-data-structure branch 2 times, most recently from d16fda2 to 3e516a9 Compare January 23, 2026 22:44
@borisfaure
Copy link
Contributor Author

  • make descriptions of settings close to their definitions

What descriptions changed exactly?

No description changed. The settings labels are in the same file as their declarations.

@borisfaure borisfaure force-pushed the feat/rework-settings-data-structure branch from 3e516a9 to 329c897 Compare January 23, 2026 22:53
@borisfaure borisfaure marked this pull request as ready for review January 23, 2026 22:56
@KasyanDiGris
Copy link
Contributor

Maybe make settings (de)serialization autogenerated in a way protobuf does?

For example:

  uint8_t sleepScreen = DARK; // = 1
  uint8_t sleepScreenCoverMode = FIT; // = 2
  // settings:reserved uint8_t = 3
  uint8_t statusBar = FULL; // = 4

And make a script that generate loadFromFile and saveToFile functions to avoid breaking back compatibility.

@borisfaure
Copy link
Contributor Author

Maybe make settings (de)serialization autogenerated in a way protobuf does?

For example:

  uint8_t sleepScreen = DARK; // = 1
  uint8_t sleepScreenCoverMode = FIT; // = 2
  // settings:reserved uint8_t = 3
  uint8_t statusBar = FULL; // = 4

And make a script that generate loadFromFile and saveToFile functions to avoid breaking back compatibility.

I agree the whole serialization/deserialization can be greatly improved but should be done in a further PR.

@borisfaure borisfaure marked this pull request as draft January 27, 2026 21:33
@borisfaure borisfaure force-pushed the feat/rework-settings-data-structure branch from 329c897 to 89aa47e Compare January 27, 2026 22:35
@borisfaure borisfaure marked this pull request as ready for review January 27, 2026 22:35
@borisfaure borisfaure marked this pull request as draft January 28, 2026 11:24
@borisfaure borisfaure force-pushed the feat/rework-settings-data-structure branch 2 times, most recently from d1769e6 to 4ee4b26 Compare January 28, 2026 14:44
Multiple goals are achieved with this change:
- make descriptions of settings close to their definitions
- settings validation on loading with reset to default in case of bad
  value
- do not boot-loop on bad string values
- (de)serialization is based on a single list of descriptors: single point
  of truth
- possibly to have default values for the String configuration type
- more constexpr to reduce RAM usage
- less hardcoded values
- more maintainable

RAM Usage:
 From
RAM:   [===       ]  32.5% (used 106516 bytes from 327680 bytes)
Flash: [========= ]  94.9% (used 6217240 bytes from 6553600 bytes)
 To
RAM:   [===       ]  32.3% (used 105844 bytes from 327680 bytes)
Flash: [========= ]  94.8% (used 6213378 bytes from 6553600 bytes)

Boot config validation with a test where the status bar config is wrong:
[1256] [SD] SD card detected
[1256] [CPS] Loading settings from file
[1265] [CPS] Invalid value (0x3) for Status Bar, resetting to default
[1265] [CPS] Settings loaded from file
@borisfaure borisfaure force-pushed the feat/rework-settings-data-structure branch from 4ee4b26 to 5ae10a7 Compare January 28, 2026 15:13
@borisfaure borisfaure marked this pull request as ready for review January 28, 2026 20:36
@daveallie
Copy link
Member

I've moved forward with #920, however there are some nice small improvements in this PR which we can still merge if you're happy to rebase on top of master

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.

4 participants