Skip to content

Ant and PacMan effects #4536

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

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

BobLoeffler68
Copy link

@BobLoeffler68 BobLoeffler68 commented Feb 3, 2025

I added two new effects: Ant and PacMan Please take a look at them and test them and make any suggestions. I'm a noob at this, so I will probably code these in the most inefficient manner. :-) I don't know if the speeds are going to be good on other esp chips (e.g. ESP8266). I've only tested on an ESP32 WROOM 32D so far. Both effects are pretty rough right now and experts could make them so much better, I would think. I want to add at least another feature to reverse the direction of the PacMan effect.

Summary by CodeRabbit

  • New Features
    • Added new LED animation modes “Ants” and “Pac-Man” for enhanced visual effects.
    • Updated the Rolling Balls effect while removing an outdated effect.
  • Chores
    • Streamlined the configuration by focusing on a single target environment.
    • Increased the upload speed for improved performance.

@blazoncek
Copy link
Collaborator

Thanks.
You'll need to revert changes in platformio.ini and package-lock.json

@DedeHai DedeHai added the effect label Feb 3, 2025
@DedeHai
Copy link
Collaborator

DedeHai commented Feb 3, 2025

I like the general idea of this effect and the animation is well done.
Suggestions:

  • you should return FRAMETIME as anything else is legacy and leads to problems with transitions and overlay
  • IMHO it should be more versatile by user-selectable number of yellow dots, selectable overall-speed and maybe white-dot spacing

maybe I have some more points after testing :)

@BobLoeffler68
Copy link
Author

Thanks. You'll need to revert changes in platformio.ini and package-lock.json

How do I revert changes to those two files in Github Desktop?

@BobLoeffler68
Copy link
Author

I like the general idea of this effect and the animation is well done. Suggestions:

Thanks!

  • you should return FRAMETIME as anything else is legacy and leads to problems with transitions and overlay

Yes, I knew changing the FRAMETIME would be ugly because it slows down the FPS rate, but I couldn't figure out how to do it any other way. Do you have a suggestion of how to do it after looking at the code?

  • IMHO it should be more versatile by user-selectable number of yellow dots, selectable overall-speed and maybe white-dot spacing

Ah, good idea with the user-selectable yellow dots.

The speed is selectable with that first slider, but that is doing it by changing the FRAMETIME. I need a suggestion for a better way to do it. :-(

Yes, white dot spacing would be good to make it more obvious that PacMan is eating the dots.

maybe I have some more points after testing :)

That would be awesome! I am planning on changing the direction that they start moving. Right now they move from LED 0 to SEGLEN, so I will add an option checkbox to start them moving from SEGLEN to 0.

Thanks!

@DedeHai
Copy link
Collaborator

DedeHai commented Feb 4, 2025

Yes, I knew changing the FRAMETIME would be ugly because it slows down the FPS rate, but I couldn't figure out how to do it any other way. Do you have a suggestion of how to do it after looking at the code?

you need to render every frame, meaning rendering the same frame again if time has not advanced enough between calls.

That would be awesome! I am planning on changing the direction that they start moving. Right now they move from LED 0 to SEGLEN, so I will add an option checkbox to start them moving from SEGLEN to 0.

that can be done by selecting "reverse" on the segment as well

@BobLoeffler68
Copy link
Author

you need to render every frame, meaning rendering the same frame again if time has not advanced enough between calls.

Rendering every frame is still a new concept to me. :-) Thanks.

that can be done by selecting "reverse" on the segment as well

Oh, that's right! I won't worry about that one and will check that off of my list. :-)

@DedeHai
Copy link
Collaborator

DedeHai commented Feb 4, 2025

I tested the two effects, I found this:

  • first run of pacman does not clear / initialize correctly
  • ants sometimes randomly disappear (or shrink?) for a brief moment

@BobLoeffler68
Copy link
Author

I tested the two effects, I found this:

Thanks for testing!

  • first run of pacman does not clear / initialize correctly

It should work if you set the Transition to 0.

  • ants sometimes randomly disappear (or shrink?) for a brief moment

An ant can "merge" with another ant of the same color, so it looks like it disappears, but it's just using the same LEDs as another ant. That is probably what you are seeing. I haven't seen any actually disappear or shrink.

@blazoncek
Copy link
Collaborator

It should work if you set the Transition to 0.

Do not assume such approach. The effect has to handle everything.

@BobLoeffler68
Copy link
Author

It should work if you set the Transition to 0.

Do not assume such approach. The effect has to handle everything.

Good point. Is there a way to set the transition to 0 in the code?

@DedeHai
Copy link
Collaborator

DedeHai commented Feb 5, 2025

It should work if you set the Transition to 0.

Do not assume such approach. The effect has to handle everything.

Good point. Is there a way to set the transition to 0 in the code?

no, you need to handle transitions in the FX.

@blazoncek
Copy link
Collaborator

Is there a way to set the transition to 0 in the code?

There is, but you don't do that from effect. You have to handle transitions (if needed at all).
@DedeHai has provided valuable information on how to do that.

@blazoncek
Copy link
Collaborator

How do I revert changes to those two files in Github Desktop?

I don't use Github Desktop app but here are some instructions for git:
https://git-scm.com/book/ms/v2/Git-Basics-Undoing-Things
https://stackoverflow.com/questions/2733873/how-can-i-revert-a-single-file-to-a-previous-version

Basically you check-out a file from previous commit. And then commit it again.

NEVER FORCE PUSH YOUR CHANGES!

@BobLoeffler68
Copy link
Author

How do I revert changes to those two files in Github Desktop?

I don't use Github Desktop app but here are some instructions for git: https://git-scm.com/book/ms/v2/Git-Basics-Undoing-Things https://stackoverflow.com/questions/2733873/how-can-i-revert-a-single-file-to-a-previous-version

Basically you check-out a file from previous commit. And then commit it again.

NEVER FORCE PUSH YOUR CHANGES!

I think I did the reverts correctly, but I can't tell from the messages that came back. WLED-AC is my working directory.
Here is what I performed:

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git status
On branch pr-ant-and-pacman-modes
Your branch is up to date with 'BobLoeffler68/pr-ant-and-pacman-modes'.
nothing to commit, working tree clean

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git checkout 34d0f17 -- package-lock.json

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git checkout 34d0f17 -- platformio.ini

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git status
On branch pr-ant-and-pacman-modes
Your branch is up to date with 'BobLoeffler68/pr-ant-and-pacman-modes'.
nothing to commit, working tree clean

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git commit -m "Reverted 2 files"
On branch pr-ant-and-pacman-modes
Your branch is up to date with 'BobLoeffler68/pr-ant-and-pacman-modes'.
nothing to commit, working tree clean

Does it look like I did it correctly? I also tried the full file path of the two files when the checkouts didn't give me any feedback:

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git checkout 34d0f17 -- C:\Users\boblo\Documents\GitHub\repos\WLED-AC\package-lock.json

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git checkout 34d0f17 -- C:\Users\boblo\Documents\GitHub\repos\WLED-AC\platformio.ini

I have not done a push yet after running the commands above.

@blazoncek
Copy link
Collaborator

git checkout <commit> -- path/to/filespec is the correct way to revert a file to a previous commit.

@BobLoeffler68
Copy link
Author

git checkout -- path/to/filespec is the correct way to revert a file to a previous commit.

So these should've worked, right?

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git checkout 34d0f17 -- C:\Users\boblo\Documents\GitHub\repos\WLED-AC\package-lock.json

C:\Users\boblo\Documents\GitHub\repos\WLED-AC>git checkout 34d0f17 -- C:\Users\boblo\Documents\GitHub\repos\WLED-AC\platformio.ini

I saw several websites that said that you can use just the filename of the file if you were running the command from the working directory. But I'll use the full file path from now on. Thanks.

@netmindz
Copy link
Member

netmindz commented Feb 9, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Feb 9, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Feb 9, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request updates the project configuration and LED effect implementations. In platformio.ini, the default environment is changed to esp32dev and the upload speed increased. In the WLED effect files, two new effect modes—"ants" and "pacman"—are added, the "rolling_balls" effect is modified, and "mode_racers" is removed. Additionally, the header file is updated to define new effect mode constants and adjust the total mode count.

Changes

Files Change Summary
platformio.ini Updated "default_envs" to "esp32dev" (commenting out multiple defaults) and increased "upload_speed" from 115200 to 921600.
wled00/FX.cpp, wled00/FX.h Added new LED effects (mode_ants, mode_pacman), modified rolling_balls function, commented out mode_racers, updated effect registration in setupEffectData, and revised mode constants with an increased MODE_COUNT (from 187 to 189).

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Controller as WLED Controller
    participant Data as Effect Data Setup
    participant LED as LED Strip

    User->>Controller: Select LED effect mode
    Controller->>Data: Load effect data (including new modes)
    alt "Ants" effect selected
        Controller->>Controller: Execute mode_ants()
    else "Pacman" effect selected
        Controller->>Controller: Execute mode_pacman()
    else Other effect selected
        Controller->>Controller: Execute existing effect
    end
    Controller->>LED: Update LED display
Loading

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 0

🧹 Nitpick comments (6)
wled00/FX.cpp (6)

3023-3024: Consider using a more descriptive struct name

The struct name RollingBall is being used for both rolling balls and ants effects. Consider renaming it to something more generic like MovingObject or creating separate structs for better code clarity.

-typedef struct RollingBall {                                          // used for rolling_balls and Ants modes
+typedef struct MovingObject {                                         // used for rolling_balls and Ants modes

3133-3136: Consider using constexpr for compile-time constants

The magic numbers used for array sizes and limits could be defined as constexpr values for better maintainability.

-  uint32_t bgcolor = BLACK;
-  uint8_t antSize = 1;
-  const uint16_t maxNumAnts = 32;                                 // 255/16 + 1 ( * 2 ?????)
-  uint16_t dataSize = sizeof(rball_t) * maxNumAnts;
+  static constexpr uint16_t MAX_ANTS = 32;                       // Maximum number of ants
+  static constexpr uint8_t DEFAULT_ANT_SIZE = 1;
+  uint32_t bgcolor = BLACK;
+  uint8_t antSize = DEFAULT_ANT_SIZE;
+  uint16_t dataSize = sizeof(rball_t) * MAX_ANTS;

3243-3247: Consider using bit fields to reduce memory usage

The PacManChars struct could use bit fields to reduce memory usage since some fields don't need full bytes.

typedef struct PacManChars {
-  uint16_t  pos;
-  uint8_t   size;
-  uint32_t  color;
+  uint16_t  pos;    // Position needs full range
+  uint8_t   size:4; // Size likely won't exceed 15
+  uint32_t  color;  // Color needs full 32 bits
} pacmancharacters_t;

3386-3388: Consider using a constant for timing value

The hardcoded timing value could be defined as a constant for better maintainability.

+  static constexpr uint16_t PACMAN_FRAME_TIME = 20;
-  return 20 + ((22 * (uint32_t)(255 - SEGMENT.speed)) / SEGLEN);                // FRAMETIME and FRAMETIME_FIXED were too fast
+  return PACMAN_FRAME_TIME + ((22 * (uint32_t)(255 - SEGMENT.speed)) / SEGLEN); // Custom timing for smooth animation

7944-7965: Consider adding bounds checking for effect IDs

The addEffect function could benefit from additional bounds checking and error handling.

uint8_t WS2812FX::addEffect(uint8_t id, mode_ptr mode_fn, const char *mode_name) {
+  if (mode_fn == nullptr || mode_name == nullptr) return 255; // Invalid parameters
+  
  if (id == 255) { // find empty slot
    for (size_t i=1; i<_mode.size(); i++) if (_modeData[i] == _data_RESERVED) { id = i; break; }
  }

7967-7975: Consider using std::vector::reserve for performance

Pre-allocating vector capacity could improve performance during initialization.

void WS2812FX::setupEffectData() {
+  _mode.reserve(_modeCount);     // Pre-allocate capacity
+  _modeData.reserve(_modeCount); // Pre-allocate capacity
  // Solid must be first! (assuming vector is empty upon call to setup)
  _mode.push_back(&mode_static);
  _modeData.push_back(_data_FX_MODE_STATIC);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b64cd36 and 34d0f17.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • platformio.ini (2 hunks)
  • wled00/FX.cpp (3 hunks)
  • wled00/FX.h (1 hunks)
🔇 Additional comments (4)
wled00/FX.h (2)

329-329: Mode count updated correctly.

The MODE_COUNT is correctly updated to 189 to account for the two new effect modes (FX_MODE_ANTS and FX_MODE_PACMAN).


325-327: New effect modes added.

The addition of FX_MODE_ANTS and FX_MODE_PACMAN effects aligns with the PR objectives. However, FX_MODE_RACERS is commented out, which suggests it was initially planned but removed.

Let's verify if there are any references to the commented-out mode:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Search for any references to FX_MODE_RACERS in the codebase
rg "FX_MODE_RACERS|mode_racers"

Length of output: 171


FX_MODE_RACERS confirmed as intentionally disabled.
The search results show that all references to FX_MODE_RACERS—both in wled00/FX.h and wled00/FX.cpp—are commented out. This indicates that the removal/replacement of FX_MODE_RACERS was deliberate. The addition of FX_MODE_ANTS and FX_MODE_PACMAN, along with the updated mode count, aligns well with the PR objectives.

platformio.ini (2)

13-14: Default Environment Configuration Change
The changes here narrow the default board selection to only esp32dev by commenting out the original multi-board list and then setting “default_envs = esp32dev.” Given the community feedback requesting a reversion of unintended configuration changes, please confirm if this restriction is intentional. Limiting the environments could reduce testing flexibility, especially as the effects were originally noted for potential issues on other ESP chips.

Also applies to: 21-21


130-130: Upload Speed Parameter Update
The upload_speed setting has been increased from 115200 to 921600. While a higher upload speed can accelerate firmware deployment on ESP32, it might introduce compatibility issues on other boards. Considering prior feedback about reverting some changes in platformio.ini, please verify whether this adjustment is needed solely for the new visual effects or if it should remain unchanged to support broader hardware compatibility.

Ants
----
- Made the number of ants more dynamically user-selectable.
- The size of ants can now be up to 20 pixels wide.
- Changed random() and random16() to hw_random() and hw_random16().
- Fixed a few suggestions by CodeRabbit

TODO:
- Foreground and background color selection needs to be improved.
  The current way of setting the background color is very clunky
  (with slider wled#4).

PacMan
------
- constexpr instead of const
- return mode_static() on short segments (15 or less pixels)
- made use of numGhosts intead of hard-coded integers
- now using aux0 for binary flags (DIRECTION_FLAG and GHOSTSBLUE_FLAG)
- now using aux1 for the timer tick count
- reworked timing to draw moving characters and power dot
- now returning FRAMETIME correctly

TODO:
- Speed adjustments?
- Transition from previous FX is not looking good. It is supposed to
  wipe out any pixels by making them black. Then draw whitish dots
  every other pixel if the White Dots checkbox is enabled. But there
  are usually colored pixels still displayed from the previous FX.
Copy link
Collaborator

@blazoncek blazoncek left a comment

Choose a reason for hiding this comment

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

I would like you to also remove changes to package-lock.json and reuse removed effects IDs (marked in the source) for new effects.

Otherwise the code is clean and readable, no comments there.

Copy link
Collaborator

@DedeHai DedeHai left a comment

Choose a reason for hiding this comment

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

this is good progress in general, but there is still a lot of redundant code that makes it hard to understand.

@BobLoeffler68
Copy link
Author

Hi @DedeHai I've cleaned up the PacMan code and it's looking much better, but I still have one big issue. I added the ability to select up to 5 power dots, but it's not working correctly. If I hard-code numPowerDots in line 3325, it works fine. But when I allow the user to select the number of power dots with the intensity slider (line 3324), it doesn't work correctly. No more than 3 power dots are displayed even if I select 4 or 5, and the power dots are not put in the correct LEDs. Can you take a look at it? I just pushed the latest code to my branch. Thanks.

@DedeHai
Copy link
Collaborator

DedeHai commented Apr 14, 2025

looks a lot cleaner, I think you are getting the hang of it. I can check whats up with the dots.

@BobLoeffler68
Copy link
Author

looks a lot cleaner, I think you are getting the hang of it. I can check whats up with the dots.

I really, really appreciate your help and guidance!

@DedeHai
Copy link
Collaborator

DedeHai commented Apr 14, 2025

fixed it. I did get a crash at one point when changing number of dots near the end of the animation, no idea why.
the powerdot spacing may need some fine-tuning, but using round() with floats is not a good way.

Copy link
Collaborator

@blazoncek blazoncek left a comment

Choose a reason for hiding this comment

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

I think this could do without floats and there are some other aspects I'd like to be reconsidered and probably changed.

I did not trace execution so can't say anything about behaviour.

@BobLoeffler68
Copy link
Author

fixed it. I did get a crash at one point when changing number of dots near the end of the animation, no idea why. the powerdot spacing may need some fine-tuning, but using round() with floats is not a good way.

Thanks! I did find a new bug with the dynamic setting of the number of power dots. After approximately half of the power dots are eaten while the setting is set at the default (50% of the slider), change it to 100% and you will see the new powerdots in the pixesl that have already been eaten. I can fix that by adding "&& character[i+5].pos > character[PACMAN].topPos" to line 3423:

// now draw the power dots in the segment only if they have not been eaten yet
for (int i = 0; i < numPowerDots; i++) {
if (!character[i+5].eaten && character[i+5].pos > character[PACMAN].topPos)
SEGMENT.setPixelColor(character[i+5].pos, character[i+5].color);
}

But PacMan will still start chasing the ghosts at that pixel because line 3407 is placing the powerdot there, even though we can't see it because of my change above. I tried doing the following, but then none of the powerdots are set/displayed (besides the last one). :-(

// update power dot positions: can change if user selects a different number of power dots
for (int i = 1; i < maxPowerDots; i++) {
if (character[i+5].pos > character[PACMAN].topPos)
character[i+5].pos = 10 + i * everyXLeds;
}

Any ideas? And do we want to use maxPowerDots in there? Or should it be numPowerDots? I played with both but it didn't seem to help with this bug.

@DedeHai
Copy link
Collaborator

DedeHai commented Apr 15, 2025

After approximately half of the power dots are eaten while the setting is set at the default (50% of the slider), change it to 100% and you will see the new powerdots in the pixesl that have already been eaten.

that is by design. if you want to fix it, there are two ways:

  • in the part that sets number of powerdots, add a loop to check all powerdots, set all to eaten that have x<maxpacmanposition
  • re-initialize the animation if the slider is moved

@BobLoeffler68
Copy link
Author

  • re-initialize the animation if the slider is moved

I think this is the cleanest and least confusing way to do it, so I'll do this for the next version. Thx.

@BobLoeffler68
Copy link
Author

Hi @DedeHai and @blazoncek I just pushed the latest version. I've fixed all of the bugs that I know about and looked at everything you have mentioned, except the floats. I see a lot of other effects with floats and I just did my effects the same as those, since I don't know how to not use floats. Thanks for all of your help! Both effects look really good now.

@BobLoeffler68
Copy link
Author

Hi @DedeHai and @blazoncek I just pushed the latest version. I had found a crashing issue in PacMan when using the White Dots option on a 2D matrix. It's fixed now. I think both effects are done now and we can merge this branch into the main WLED (I think that is the correct terminology). Please take a look when you have time. If you think it's good, let me know what I need to do. Thx!

@DedeHai
Copy link
Collaborator

DedeHai commented May 5, 2025

I need to look at it once more, I think the pacman effect is ok to merge, I am not too sure about the ants effect, I need to test it some more and check the code. As mentioned before, the ant effect may be better done using the PS: potentially shorter code, much more rendering options (colors, size of ants etc.)

@BobLoeffler68
Copy link
Author

I need to look at it once more, I think the pacman effect is ok to merge, I am not too sure about the ants effect, I need to test it some more and check the code. As mentioned before, the ant effect may be better done using the PS: potentially shorter code, much more rendering options (colors, size of ants etc.)

Ok, let me know about the Ants code after you've had time to review it. Thanks!

@BobLoeffler68
Copy link
Author

BobLoeffler68 commented May 7, 2025

unsigned everyXLeds = ((SEGLEN - 10) << 8) / numPowerDots;
for (int i = 1; i < maxPowerDots; i++) {
character[i+5].pos = 10 + (i * everyXLeds) >> 8;
}

The everyXLeds code is not looking right on my 141 LED strip, so I'm going to play around with it.

@DedeHai
Copy link
Collaborator

DedeHai commented May 7, 2025

The everyXLeds code is not looking right on my 141 LED strip, so I'm going to play around with it.

ups, there is a missing bracket: character[i+5].pos = 10 + ((i * everyXLeds) >> 8);

@BobLoeffler68
Copy link
Author

The everyXLeds code is not looking right on my 141 LED strip, so I'm going to play around with it.

ups, there is a missing bracket: character[i+5].pos = 10 + ((i * everyXLeds) >> 8);

Yes, that was it. Thx! New version pushed. Looks very optimized now.

@DedeHai
Copy link
Collaborator

DedeHai commented May 12, 2025

I tested the ant effect yesterday and while the effect itself looks ok, the code is a mess.
It also uses 1.5k of flash, which is a lot for a rather simple (and specific) effect. In its current state, I don't think it should be added as a default effect (you could still move it to the user-effects usermod which is in PR)

@BobLoeffler68
Copy link
Author

I tested the ant effect yesterday and while the effect itself looks ok, the code is a mess. It also uses 1.5k of flash, which is a lot for a rather simple (and specific) effect. In its current state, I don't think it should be added as a default effect (you could still move it to the user-effects usermod which is in PR)

I basically used the code from the rolling_balls FX and made modifications to it. Last night I started looking at your PS code, so maybe I will try to convert it. Not sure how that will go since I'm not a coding expert. If that doesn't go well, I'll move it to the user-effects usermod.

@DedeHai
Copy link
Collaborator

DedeHai commented May 13, 2025

you can start looking at mode_particleChase() it probably comes closest in how I would implement it: it does manipulate and place particles "manually" i.e. not using a source to emit particles. You can create the ants either using several particles with a defined spacing (one pixel in 1D particle space has a "length" of 32) or you can use a single particle and increase its size by setting PartSys->advPartProps[i].size up to 255. make sure to initialize the PS with advanced=true or advPartProps is not available and it will crash if you try to access it.

@BobLoeffler68
Copy link
Author

Ok, thx. I'll take a look at that soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants