remove unnecessary tracking of time of the lastDMX packet and remove unnecessary comments

This commit is contained in:
RaffaelW 2025-04-15 22:02:16 +02:00
parent 7c1a9e5c4d
commit 85b692e931

View file

@ -469,21 +469,11 @@ void loop()
dmx_packet_t dmx1_packet; dmx_packet_t dmx1_packet;
dmx_packet_t dmx2_packet; dmx_packet_t dmx2_packet;
/* And now we wait! The DMX standard defines the amount of time until DMX // check if there's a new DMX packet
officially times out. That amount of time is converted into ESP32 clock
ticks using the constant `DMX_TIMEOUT_TICK`. If it takes longer than that
amount of time to receive data, this if statement will evaluate to false. */
if (direction1 == Input && dmx_receive(dmx1, &dmx1_packet, 0)) if (direction1 == Input && dmx_receive(dmx1, &dmx1_packet, 0))
{ {
// Serial.println("Recv DMX1");
/* If this code gets called, it means we've received DMX data! */
dmx_read_offset(dmx1, 1, dmx1_data, 512); dmx_read_offset(dmx1, 1, dmx1_data, 512);
artnet.sendArtDmx(broadcastIp, universe1, dmx1_data, 512); artnet.sendArtDmx(broadcastIp, universe1, dmx1_data, 512);
/* Get the current time since boot in milliseconds so that we can find out
how long it has been since we last updated data and printed to the Serial
Monitor. */
unsigned long now = millis();
/* We should check to make sure that there weren't any DMX errors. */ /* We should check to make sure that there weren't any DMX errors. */
if (!dmx1_packet.err) if (!dmx1_packet.err)
@ -493,13 +483,6 @@ void loop()
/*dmx_read_offset(dmx1, 1, dmx1_data, dmx1_packet.size); /*dmx_read_offset(dmx1, 1, dmx1_data, dmx1_packet.size);
artnet.sendArtDmx(broadcastIp, universe1, dmx1_data, 512);*/ artnet.sendArtDmx(broadcastIp, universe1, dmx1_data, 512);*/
if (now - dmx1_lastUpdate > 1000)
{
/* Print the received start code - it's usually 0. */
// Serial.printf("Start code is 0x%02X and slot 1 is 0x%02X\n", dmx1_data[0], dmx1_data[1]);
dmx1_lastUpdate = now;
}
} }
else else
{ {
@ -513,17 +496,9 @@ void loop()
if (direction2 == Input && dmx_receive(dmx2, &dmx2_packet, 0)) if (direction2 == Input && dmx_receive(dmx2, &dmx2_packet, 0))
{ {
// Serial.println("Recv DMX2");
/* If this code gets called, it means we've received DMX data! */
dmx_read_offset(dmx2, 1, dmx2_data, 512); dmx_read_offset(dmx2, 1, dmx2_data, 512);
artnet.sendArtDmx(broadcastIp, universe2, dmx2_data, 512); artnet.sendArtDmx(broadcastIp, universe2, dmx2_data, 512);
/* Get the current time since boot in milliseconds so that we can find out
how long it has been since we last updated data and printed to the Serial
Monitor. */
unsigned long now = millis();
/* We should check to make sure that there weren't any DMX errors. */ /* We should check to make sure that there weren't any DMX errors. */
if (!dmx2_packet.err) if (!dmx2_packet.err)
{ {
@ -532,13 +507,6 @@ void loop()
/*dmx_read_offset(dmx2, 1, dmx2_data, dmx2_packet.size); /*dmx_read_offset(dmx2, 1, dmx2_data, dmx2_packet.size);
artnet.sendArtDmx(broadcastIp, universe2, dmx2_data, 512);*/ artnet.sendArtDmx(broadcastIp, universe2, dmx2_data, 512);*/
if (now - dmx2_lastUpdate > 1000)
{
/* Print the received start code - it's usually 0. */
// Serial.printf("Start code is 0x%02X and slot 1 is 0x%02X\n", dmx2_data[0], dmx2_data[1]);
dmx2_lastUpdate = now;
}
} }
else else
{ {