Skip to content

Optimize display rendering pipeline and introduce PWM_DEPTH config#551

Merged
JanPetterMG merged 3 commits intomainfrom
feat/pwm-depth
Apr 27, 2026
Merged

Optimize display rendering pipeline and introduce PWM_DEPTH config#551
JanPetterMG merged 3 commits intomainfrom
feat/pwm-depth

Conversation

@JanPetterMG
Copy link
Copy Markdown
Collaborator

@JanPetterMG JanPetterMG commented Apr 26, 2026

This PR introduces a configurable PWM_DEPTH setting and significantly optimizes the display rendering pipeline by shifting to a bitplane-based approach. These changes reduce the computational overhead during high-frequency hardware interrupts, resulting in smoother rendering and more efficient CPU usage.

Key Changes

  • Configurable PWM Depth: Added PWM_DEPTH support to config/secrets.h and config/services.h, allowing developers to manually dictate the PWM bit depth rather than relying strictly on automatic calculations.
  • Bitplane Rendering Pipeline: Refactored DisplayService::onTimer() and flush() to pre-calculate and process display frames into bitplanes (planes[plane]). This allows the high-frequency timer interrupt to simply push pre-formatted bytes via SPI.
  • Hardware Timer & SPI Adjustments: Updated the SPI speed and timer alarm configurations in DisplayService.cpp to dynamically align with the newly established PWM_DEPTH and frame rate variables.
  • Code Cleanup: Standardized array iteration logic (e.g., swapping pixel for idx) and minor refactoring across the core display and extension services.

Impact

  • Performance: Extracting the heavy bitwise brightness thresholding logic from onTimer() severely reduces the time spent inside the interrupt service routine (ISR).
  • Customization: Users can now tailor the balance between visual depth and performance based on their specific hardware capabilities by adjusting PWM_DEPTH.

@JanPetterMG JanPetterMG added the documentation Improvements or additions to documentation label Apr 26, 2026
@JanPetterMG JanPetterMG added this to the v2.4.0 milestone Apr 26, 2026
@JanPetterMG JanPetterMG added enhancement New feature or request firmware C++ related labels Apr 26, 2026
@JanPetterMG JanPetterMG changed the title Add PWM_DEPTH config option and refine rendering pipeline Optimize display rendering pipeline and introduce PWM_DEPTH config Apr 26, 2026
@JanPetterMG JanPetterMG marked this pull request as ready for review April 27, 2026 14:21
@JanPetterMG JanPetterMG added this pull request to the merge queue Apr 27, 2026
Merged via the queue into main with commit d2106af Apr 27, 2026
157 of 166 checks passed
@JanPetterMG JanPetterMG deleted the feat/pwm-depth branch April 27, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request firmware C++ related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant