Add compressed JSON format for dac_controlset#498
Add compressed JSON format for dac_controlset#498Schlepptop wants to merge 2 commits intosle118:master-v4.3from
Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @Schlepptop, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request significantly optimizes the storage and parsing of DAC control sequences by introducing a new, highly compressed JSON array format. This change allows for more complex and longer control sequences to be stored within the limited memory constraints of embedded systems, while maintaining compatibility with the existing object-based JSON format. The core functionality now intelligently dispatches to the appropriate parser based on the structure of the provided control set.
Highlights
- New Compressed JSON Format: Introduced a space-efficient, flattened array JSON format for DAC control sequences. This new format supports direct register writes (
[reg, val]), burst writes ([reg, [val1, ..., valN]]), delays (["d", duration_ms]), and bitwise AND/OR operations (["&", reg, val]or["|", reg, val]). - Dual Format Support: The
i2c_json_executefunction has been enhanced to intelligently detect and process either the existing object-based JSON control sets or the newly introduced compressed array format, ensuring backward compatibility while enabling the new efficiency. - Memory Optimization: The primary motivation for this change is to significantly reduce the memory footprint of DAC control sets, which are often stored in Non-Volatile Storage (NVS) with limited capacity. The compressed format addresses the space inefficiency of the previous verbose JSON structure.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
|
Warning Gemini is unable to generate a review due to a potential policy violation. |
The current format for the dac_controlset JSON is very space-inefficient. NVS allows for 4000 characters, which is not a lot by itself. Setting a register with
{"reg":25,"val": 5}, which is even worsened by the escapes needed to store it (NVS writes{\"reg\":25,\"val\":5}) doesn't help, so I propose supporting this alternative format that uses a single flat array instead.Register write:
[reg, val]Writes a single byte value to a register.
Burst write:
[reg, [val1, val2, ..., valN]]Writes multiple bytes to a register in one burst. The second item must be a JSON array.
Delay:
["d", duration_ms]Pauses execution for the specified number of milliseconds.
Bitwise operations:
["&", reg, val]— Read-modify-write: AND value into register["|", reg, val]— Read-modify-write: OR value into registerNotes:
false.Example input:
This will:
This is obviously not as simple to write by hand, but easy enough to generate from header files that are supplied by manufacturers.