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

Fix: PUSH flag handling for exact multiples of 480 in DDP #833

Merged
merged 2 commits into from
Mar 17, 2024

Conversation

bigredfrog
Copy link
Contributor

@bigredfrog bigredfrog commented Mar 16, 2024

With the prior code with exact multiples of 480 pixels counts the PUSH flag would never be set

Treating it as a display now flag, although its definition is not quite definitive in this regard

http://www.3waylabs.com/ddp/

This addresses the issues discussed at

https://discord.com/channels/469985374052286474/1216471237090480259

Where a WLED setup with exactly 480 pixels would not update, although the WLED peek does work

Also tested on the Falcon Player Pro as a DDP endpoint, which does not care about the PUSH flag at all.

To gain most benefit from prior maturity, preserved prior expression of sending push flag on last packet of a frame, now also for if it is an exact multiple of 480 pixels.

Tested as not working / working on a 512 WLED endpoint with ledfx device set to 480 which could be seen to only work for Peek and not pixels prior to fix

Now shows full effect at all times.

Regression tested on 16K FPP as well.

Summary by CodeRabbit

  • Refactor
    • Improved packet sending mechanism for devices by introducing a parameter to identify the final packet, enhancing the construction of packet headers.

Copy link
Contributor

coderabbitai bot commented Mar 16, 2024

Walkthrough

The update introduces a modification to the send_packet method within the DDPDevice class of the ledfx/devices/ddp.py file. This change incorporates an additional parameter named last, which is utilized to ascertain whether the packet being sent is the final one. The inclusion of this parameter significantly influences how the packet header is constructed, tailoring it based on whether or not it is the concluding packet in the sequence.

Changes

File(s) Change Summary
ledfx/devices/ddp.py Modified the send_packet method in the DDPDevice class to include a last parameter, influencing the packet header construction based on its value.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

sentry-io bot commented Mar 16, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: ledfx/devices/ddp.py

Function Unhandled Issue
send_out OSError: [WinError 10051] A socket operation was attempted to an unreachable network ...
Event Count: 1
send_out OSError: [Errno 65] No route to host ledfx.device...
Event Count: 1

Did you find this useful? React with a 👍 or 👎

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 4dedba7 and 3c3d85b.
Files selected for processing (1)
  • ledfx/devices/ddp.py (1 hunks)
Additional comments: 2
ledfx/devices/ddp.py (2)
  • 98-98: The addition of the last parameter in the send_packet call within the send_out method is a crucial change. This parameter is used to determine if the current packet is the last in a sequence, which in turn decides whether the PUSH flag should be set. This logic is essential for ensuring that displays update correctly when the pixel count is an exact multiple of 480. The implementation appears to correctly handle the calculation of whether a packet is the last one by comparing the current packet index (i) with the total number of packets (packets). This is a well-thought-out approach to solving the issue at hand.
  • 102-107: The modification to the send_packet method to include the last parameter and use it to conditionally set the PUSH flag in the packet header is the key fix for the issue described. The logic to set the PUSH flag only on the last packet (DDPDevice.PUSH if last else 0) is correctly implemented. This change ensures that the display updates correctly for setups with exactly 480 pixels, addressing the previously identified problem. It's important to note that this approach maintains compatibility with existing behavior by preserving the logic that sets the PUSH flag on the last packet of a frame, extending this treatment to scenarios involving exact multiples of 480 pixels. The implementation is concise and directly addresses the problem without introducing unnecessary complexity.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 3c3d85b and ea64ac3.
Files selected for processing (1)
  • ledfx/devices/ddp.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ledfx/devices/ddp.py

@bigredfrog bigredfrog merged commit 8baa1a8 into LedFx:main Mar 17, 2024
20 checks passed
@bigredfrog bigredfrog deleted the ddp480 branch March 30, 2024 01:16
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.

1 participant