GithubHelp home page GithubHelp logo

Comments (6)

arpschuino avatar arpschuino commented on May 25, 2024

In summary, this is what my main loop consists of:
If you receive DMX:
read it.
else if you receive artnet wifi:
read it.
perform other actions such as running stepper motors

thank you for your attention

from esp_dmx.

someweisguy avatar someweisguy commented on May 25, 2024

Yes, this is possible. The macro DMX_PACKET_TIMEOUT_TICK specifies how long to block code execution. If I recall correctly, it is 1.25 seconds.

If you replace the macro with zero (in other words, write xQueueReceive(queue, &packet, 0) the program will not block.

from esp_dmx.

arpschuino avatar arpschuino commented on May 25, 2024

OK perfect, thank you.
So if I understand correctly, it is better to set this value to Zero rather than not doing this check. And I will still be able to receive DMX correctly?

from esp_dmx.

someweisguy avatar someweisguy commented on May 25, 2024

In most cases, using xQueueReceive() is preferred.

As long as the mode is set to DMX_MODE_READ you will be able to receive data. Using xQueueReceive() allows you to get notified when a new packet has been received. This may be easier to explain with some example code:

// Example Code 1
uint8_t data[513] = {};
while (true) {
  if (xQueueReceive(queue, &packet, 0)) {
    dmx_read_packet(dmx_num, data, sizeof(data));

    // Process data...
    // Perhaps it takes a long time to process data!
  }
}

In this example, I process data every time I receive a new DMX packet. It takes a long time to process data, so I only want to process data when I receive a new packet.

And here's a different example, example 2:

// Example Code 2
uint8_t data[513] = {};
while (true) {
  dmx_read_packet(dmx_num, data, sizeof(data));

  // Process data...
}

In this example, I read data in every loop. This is acceptable too! The difference here is that I'm processing data even if I haven't received a new packet. This can be considered inefficient to some.

Hopefully this helps! Let me know if you have more questions! :)

from esp_dmx.

arpschuino avatar arpschuino commented on May 25, 2024

Thank you very much for this very precise and detailed answer, it is a pleasure to deal with people like you.

from esp_dmx.

someweisguy avatar someweisguy commented on May 25, 2024

Glad I could help! I'll close this for now. Feel free to reopen or open a new issue if you have any more questions!

from esp_dmx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.