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

polishing: No double negations #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions E131.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ const byte E131::ACN_ID[12] = { 0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31,

/* Constructor */
E131::E131() {
#ifdef NO_DOUBLE_BUFFER
memset(pbuff1.raw, 0, sizeof(pbuff1.raw));
packet = &pbuff1;
pwbuff = packet;
#else
memset(pbuff1.raw, 0, sizeof(pbuff1.raw));
#ifdef DOUBLE_BUFFER
memset(pbuff2.raw, 0, sizeof(pbuff2.raw));
packet = &pbuff1;
pwbuff = &pbuff2;
#else
pwbuff = packet;
#endif

stats.num_packets = 0;
Expand Down
6 changes: 3 additions & 3 deletions E131.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
# define _UDP WiFiUDP
# define INT_ESP8266
# define INT_WIFI
# define DOUBLE_BUFFER
#elif defined (ARDUINO_ARCH_AVR)
# include <Ethernet.h>
# include <EthernetUdp.h>
# include <avr/pgmspace.h>
# include <utility/util.h>
# define _UDP EthernetUDP
# define INT_ETHERNET
# define NO_DOUBLE_BUFFER
#endif

/* Defaults */
Expand Down Expand Up @@ -139,7 +139,7 @@ class E131 {
static const uint8_t VECTOR_DMP = 2;

e131_packet_t pbuff1; /* Packet buffer */
#ifndef NO_DOUBLE_BUFFER
#ifdef DOUBLE_BUFFER
e131_packet_t pbuff2; /* Double buffer */
#endif
e131_packet_t *pwbuff; /* Pointer to working packet buffer */
Expand Down Expand Up @@ -211,7 +211,7 @@ class E131 {
udp.readBytes(pwbuff->raw, size);
error = validate();
if (!error) {
#ifndef NO_DOUBLE_BUFFER
#ifdef DOUBLE_BUFFER
e131_packet_t *swap = packet;
packet = pwbuff;
pwbuff = swap;
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This library is to simplify the validation and handling of E1.31 sACN (DMX over
### API / Usage
#### Notes
- Double-buffering of packet data is disabled on AVR architectures due to memory constraints. Make sure to check the return value of ```parsePacket()``` as your buffer may be trashed if a bad packet made its way in.
- Other architectures (i.e. ESP8266) double buffer the packets, so ```e131.data``` can always be considered pristine. Double buffering can be disabled by defining ```NO_DOUBLE_BUFFER``` in ```E131.h```.
- Other architectures (i.e. ESP8266) double buffer the packets, so ```e131.data``` can always be considered pristine. Double buffering can be disabled by removing the ```DOUBLE_BUFFER``` #define-ition in ```E131.h```.
- WiFi connection attempts will timeout after 10 seconds if a successful connection has not been established. ```WIFI_CONNECT_TIMEOUT``` can be changed in ```E131.h```.

#### Initializers
Expand Down Expand Up @@ -43,4 +43,4 @@ These are non-blocking handlers to be used in the ```loop()``` function of your

### Resources:
- Latest code: http://github.com/forkineye/E131
- Other Stuff: http://forkineye.com
- Other Stuff: http://forkineye.com