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

Integrate Fast and Efficient String Formatting Library #244

Merged
merged 6 commits into from
Oct 18, 2024

Conversation

forntoh
Copy link
Owner

@forntoh forntoh commented Oct 17, 2024

This PR introduces a trimmed-down version of the mpaland/printf library to handle string formatting on embedded systems. The integration of this library significantly enhances the performance and efficiency of string formatting operations.

Key changes include:

  • Addition of the mpaland/printf library to the project.
  • Refactoring string formatting in menu items to use a more efficient and flexible approach.

These changes ensure that our string formatting operations are optimized for embedded systems, leading to faster and more efficient code execution.


Checklist

General Requirements

  • I have kept this PR in draft until all the required tasks are completed.
  • I have reviewed the contributing guidelines for this project.
  • I have tagged this PR with breaking-change if it introduces a breaking change.
  • I have checked that this PR does not introduce any breaking changes unless explicitly stated.
  • I have checked that changes generate no new warnings.
  • I have performed a self-review of my own code
  • I have built and tested ALL the examples to ensure that I haven't broken anything.

Refactor/Enhancement

  • This PR is a code refactor.
  • I have tagged this PR with enhancement.
  • I have made changes to the code that improve readability/performance/maintainability.
  • I have added documentation for the changes if necessary.
  • I have generated and reviewed the documentation locally if necessary.

This PR introduces a trimmed-down version of the [mpaland/printf](https://github.com/mpaland/printf) library to handle string formatting on embedded systems. The integration of this library significantly enhances the performance and efficiency of string formatting operations.

Key changes include:

- Addition of the `mpaland/printf` library to the project.
- Refactoring string formatting in menu items to use a more efficient and flexible approach.

These changes ensure that our string formatting operations are optimized for embedded systems, leading to faster and more efficient code execution.
Prevent clang-format from formatting code in printf.c and printf.h by adding the directive "clang-format off" before includes.
@forntoh forntoh added the enhancement Improve readability/performance/maintainability label Oct 17, 2024
Added clang-format off directive to printf.c and printf.h files for consistent formatting.
Copy link
Contributor

Memory usage change @ 359e312

Board flash % RAM for global variables %
arduino:avr:uno 🔺 0 - +4604 0.0 - +14.27 🔺 0 - +64 0.0 - +3.12
Click for full report table
Board examples/Basic
flash
% examples/Basic
RAM for global variables
% examples/ButtonAdapter
flash
% examples/ButtonAdapter
RAM for global variables
% examples/ButtonWithRotaryAdapter
flash
% examples/ButtonWithRotaryAdapter
RAM for global variables
% examples/Callbacks
flash
% examples/Callbacks
RAM for global variables
% examples/CharsetInput
flash
% examples/CharsetInput
RAM for global variables
% examples/InputRotary
flash
% examples/InputRotary
RAM for global variables
% examples/IntFloatValues
flash
% examples/IntFloatValues
RAM for global variables
% examples/ItemBack
flash
% examples/ItemBack
RAM for global variables
% examples/KeyboardAdapter
flash
% examples/KeyboardAdapter
RAM for global variables
% examples/List
flash
% examples/List
RAM for global variables
% examples/MenuTimeout
flash
% examples/MenuTimeout
RAM for global variables
% examples/RTOS
flash
% examples/RTOS
RAM for global variables
% examples/SSD1803A_I2C
flash
% examples/SSD1803A_I2C
RAM for global variables
% examples/SimpleInput
flash
% examples/SimpleInput
RAM for global variables
% examples/SimpleRotary
flash
% examples/SimpleRotary
RAM for global variables
% examples/SubMenu
flash
% examples/SubMenu
RAM for global variables
% examples/ViewShifting
flash
% examples/ViewShifting
RAM for global variables
%
arduino:avr:uno 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 1516 4.7 64 3.12 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 4604 14.27 58 2.83 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/Basic<br>flash,%,examples/Basic<br>RAM for global variables,%,examples/ButtonAdapter<br>flash,%,examples/ButtonAdapter<br>RAM for global variables,%,examples/ButtonWithRotaryAdapter<br>flash,%,examples/ButtonWithRotaryAdapter<br>RAM for global variables,%,examples/Callbacks<br>flash,%,examples/Callbacks<br>RAM for global variables,%,examples/CharsetInput<br>flash,%,examples/CharsetInput<br>RAM for global variables,%,examples/InputRotary<br>flash,%,examples/InputRotary<br>RAM for global variables,%,examples/IntFloatValues<br>flash,%,examples/IntFloatValues<br>RAM for global variables,%,examples/ItemBack<br>flash,%,examples/ItemBack<br>RAM for global variables,%,examples/KeyboardAdapter<br>flash,%,examples/KeyboardAdapter<br>RAM for global variables,%,examples/List<br>flash,%,examples/List<br>RAM for global variables,%,examples/MenuTimeout<br>flash,%,examples/MenuTimeout<br>RAM for global variables,%,examples/RTOS<br>flash,%,examples/RTOS<br>RAM for global variables,%,examples/SSD1803A_I2C<br>flash,%,examples/SSD1803A_I2C<br>RAM for global variables,%,examples/SimpleInput<br>flash,%,examples/SimpleInput<br>RAM for global variables,%,examples/SimpleRotary<br>flash,%,examples/SimpleRotary<br>RAM for global variables,%,examples/SubMenu<br>flash,%,examples/SubMenu<br>RAM for global variables,%,examples/ViewShifting<br>flash,%,examples/ViewShifting<br>RAM for global variables,%
arduino:avr:uno,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,1516,4.7,64,3.12,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,4604,14.27,58,2.83,0,0.0,0,0.0,0,0.0,0,0.0

Copy link
Contributor

Memory usage change @ 43ba40d

Board flash % RAM for global variables %
arduino:avr:uno 🔺 0 - +1516 0.0 - +4.7 🔺 0 - +64 0.0 - +3.12
Click for full report table
Board examples/Basic
flash
% examples/Basic
RAM for global variables
% examples/ButtonAdapter
flash
% examples/ButtonAdapter
RAM for global variables
% examples/ButtonWithRotaryAdapter
flash
% examples/ButtonWithRotaryAdapter
RAM for global variables
% examples/Callbacks
flash
% examples/Callbacks
RAM for global variables
% examples/CharsetInput
flash
% examples/CharsetInput
RAM for global variables
% examples/InputRotary
flash
% examples/InputRotary
RAM for global variables
% examples/IntFloatValues
flash
% examples/IntFloatValues
RAM for global variables
% examples/ItemBack
flash
% examples/ItemBack
RAM for global variables
% examples/KeyboardAdapter
flash
% examples/KeyboardAdapter
RAM for global variables
% examples/List
flash
% examples/List
RAM for global variables
% examples/MenuTimeout
flash
% examples/MenuTimeout
RAM for global variables
% examples/RTOS
flash
% examples/RTOS
RAM for global variables
% examples/SSD1803A_I2C
flash
% examples/SSD1803A_I2C
RAM for global variables
% examples/SimpleInput
flash
% examples/SimpleInput
RAM for global variables
% examples/SimpleRotary
flash
% examples/SimpleRotary
RAM for global variables
% examples/SubMenu
flash
% examples/SubMenu
RAM for global variables
% examples/ViewShifting
flash
% examples/ViewShifting
RAM for global variables
%
arduino:avr:uno 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 1516 4.7 64 3.12 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 0 0.0 1244 3.86 4 0.2 0 0.0 0 0.0 0 0.0 0 0.0
Click for full report CSV
Board,examples/Basic<br>flash,%,examples/Basic<br>RAM for global variables,%,examples/ButtonAdapter<br>flash,%,examples/ButtonAdapter<br>RAM for global variables,%,examples/ButtonWithRotaryAdapter<br>flash,%,examples/ButtonWithRotaryAdapter<br>RAM for global variables,%,examples/Callbacks<br>flash,%,examples/Callbacks<br>RAM for global variables,%,examples/CharsetInput<br>flash,%,examples/CharsetInput<br>RAM for global variables,%,examples/InputRotary<br>flash,%,examples/InputRotary<br>RAM for global variables,%,examples/IntFloatValues<br>flash,%,examples/IntFloatValues<br>RAM for global variables,%,examples/ItemBack<br>flash,%,examples/ItemBack<br>RAM for global variables,%,examples/KeyboardAdapter<br>flash,%,examples/KeyboardAdapter<br>RAM for global variables,%,examples/List<br>flash,%,examples/List<br>RAM for global variables,%,examples/MenuTimeout<br>flash,%,examples/MenuTimeout<br>RAM for global variables,%,examples/RTOS<br>flash,%,examples/RTOS<br>RAM for global variables,%,examples/SSD1803A_I2C<br>flash,%,examples/SSD1803A_I2C<br>RAM for global variables,%,examples/SimpleInput<br>flash,%,examples/SimpleInput<br>RAM for global variables,%,examples/SimpleRotary<br>flash,%,examples/SimpleRotary<br>RAM for global variables,%,examples/SubMenu<br>flash,%,examples/SubMenu<br>RAM for global variables,%,examples/ViewShifting<br>flash,%,examples/ViewShifting<br>RAM for global variables,%
arduino:avr:uno,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,1516,4.7,64,3.12,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,0,0.0,1244,3.86,4,0.2,0,0.0,0,0.0,0,0.0,0,0.0

@forntoh forntoh marked this pull request as ready for review October 17, 2024 14:58
@forntoh forntoh added this to the LcdMenu v5.3.0 milestone Oct 17, 2024
@forntoh forntoh merged commit 8e79749 into master Oct 18, 2024
16 checks passed
@forntoh forntoh deleted the feature/format-strings branch October 18, 2024 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve readability/performance/maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant