Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
- source-path: ./
- name: ArxContainer
- name: ArxTypeTraits
- name: PollingTimer
- name: WiFi
- name: FastLED
verbose: true
Expand Down Expand Up @@ -122,6 +123,7 @@ jobs:
- source-path: ./
- name: ArxContainer
- name: ArxTypeTraits
- name: PollingTimer
- name: WiFiNINA
- name: VidorPeripherals
- name: FastLED
Expand Down Expand Up @@ -161,6 +163,7 @@ jobs:
- source-path: ./
- name: ArxContainer
- name: ArxTypeTraits
- name: PollingTimer
verbose: true

build-ethernet:
Expand Down Expand Up @@ -251,6 +254,7 @@ jobs:
- source-path: ./
- name: ArxContainer
- name: ArxTypeTraits
- name: PollingTimer
- name: Ethernet
- name: FastLED
verbose: true
Expand Down Expand Up @@ -295,6 +299,7 @@ jobs:
- source-path: ./
- name: ArxContainer
- name: ArxTypeTraits
- name: PollingTimer
- name: FastLED
verbose: true

Expand Down Expand Up @@ -382,6 +387,7 @@ jobs:
- source-path: ./
- name: ArxContainer
- name: ArxTypeTraits
- name: PollingTimer
- name: FastLED
- source-url: https://github.com/JAndrassy/EthernetENC.git
verbose: true
Expand Down Expand Up @@ -431,6 +437,7 @@ jobs:
- source-path: ./
- name: ArxContainer
- name: ArxTypeTraits
- name: PollingTimer
- name: WiFi
- name: Ethernet
verbose: true
2 changes: 1 addition & 1 deletion Artnet/ArtDmx.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using CallbackType = std::function<void(const uint8_t *data, uint16_t size, cons
#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11
using CallbackMap = std::map<uint16_t, CallbackType>;
#else
using CallbackMap = arx::stdx::map<uint16_t, CallbackType>;
using CallbackMap = arx::stdx::map<uint16_t, CallbackType, FIXED_CONTAINER_CAPACITY>;
#endif

inline Metadata generateMetadataFrom(const uint8_t *packet)
Expand Down
2 changes: 1 addition & 1 deletion Artnet/ArtNzs.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using CallbackType = std::function<void(const uint8_t *data, uint16_t size, cons
#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11
using CallbackMap = std::map<uint16_t, CallbackType>;
#else
using CallbackMap = arx::stdx::map<uint16_t, CallbackType>;
using CallbackMap = arx::stdx::map<uint16_t, CallbackType, FIXED_CONTAINER_CAPACITY>;
#endif

inline Metadata generateMetadataFrom(const uint8_t *packet)
Expand Down
9 changes: 5 additions & 4 deletions Artnet/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ constexpr uint16_t PROTOCOL_VER {14}; // 0x000E
constexpr uint8_t ID_LENGTH {8};
constexpr char ARTNET_ID[ID_LENGTH] {"Art-Net"};
constexpr float DEFAULT_FPS {40.};
constexpr uint32_t DEFAULT_INTERVAL_MS {(uint32_t)(1000. / DEFAULT_FPS)};
constexpr double DEFAULT_INTERVAL_MS {1000. / (double)DEFAULT_FPS};

// ArtDmx, ArtTrigger has same structure
constexpr uint16_t HEADER_SIZE {18};
Expand All @@ -67,6 +67,7 @@ constexpr uint16_t PACKET_SIZE {530};
template <uint16_t SIZE, typename T = uint8_t>
using Array = std::array<T, SIZE>;
#else
constexpr size_t FIXED_CONTAINER_CAPACITY = 3;
template <uint16_t SIZE, typename T = uint8_t>
using Array = arx::stdx::vector<T, SIZE>;
#endif
Expand Down Expand Up @@ -122,12 +123,12 @@ inline bool operator==(const Destination &rhs, const Destination &lhs)

#if ARX_HAVE_LIBSTDCPLUSPLUS >= 201103L // Have libstdc++11
// sender
using LastSendTimeMsMap = std::map<Destination, uint32_t>;
using LastSendTimeMsMap = std::map<Destination, double>;
using SequenceMap = std::map<Destination, uint8_t>;
#else
// sender
using LastSendTimeMsMap = arx::stdx::map<Destination, uint32_t>;
using SequenceMap = arx::stdx::map<Destination, uint8_t>;
using LastSendTimeMsMap = arx::stdx::map<Destination, double, FIXED_CONTAINER_CAPACITY>;
using SequenceMap = arx::stdx::map<Destination, uint8_t, FIXED_CONTAINER_CAPACITY>;
#endif

} // namespace art_net
Expand Down
11 changes: 7 additions & 4 deletions Artnet/Sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "ArtTrigger.h"
#include "ArtSync.h"
#include "SenderTraits.h"
#include <PollingTimer.h>

namespace art_net {

Expand All @@ -20,6 +21,7 @@ class Sender_
{
S* stream;
Array<PACKET_SIZE> packet;
PollingTimer timer;
LastSendTimeMsMap last_send_times;
SequenceMap dmx_sequences;
SequenceMap nzs_sequences;
Expand All @@ -30,6 +32,7 @@ class Sender_
Sender_()
{
this->packet.resize(PACKET_SIZE);
this->timer.start();
}
#endif

Expand Down Expand Up @@ -57,9 +60,9 @@ class Sender_
void streamArtDmxTo(const String& ip, uint8_t net, uint8_t subnet, uint8_t universe, uint8_t physical)
{
Destination dest {ip, net, subnet, universe};
uint32_t now = millis();
double now = timer.msec();
if (this->last_send_times.find(dest) == this->last_send_times.end()) {
this->last_send_times.insert(std::make_pair(dest, uint32_t(0)));
this->last_send_times.insert(std::make_pair(dest, 0.0));
}
if (now >= this->last_send_times[dest] + DEFAULT_INTERVAL_MS) {
this->sendArxDmxInternal(dest, physical);
Expand Down Expand Up @@ -91,9 +94,9 @@ class Sender_
void streamArtNzsTo(const String& ip, uint8_t net, uint8_t subnet, uint8_t universe, uint8_t start_code)
{
Destination dest {ip, net, subnet, universe};
uint32_t now = millis();
double now = timer.msec();
if (this->last_send_times.find(dest) == this->last_send_times.end()) {
this->last_send_times.insert(std::make_pair(dest, uint32_t(0)));
this->last_send_times.insert(std::make_pair(dest, 0.0));
}
if (now >= this->last_send_times[dest] + DEFAULT_INTERVAL_MS) {
this->sendArxNzsInternal(dest, start_code);
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,8 @@ void setLogger(Print*);

Some boards without enough memory (e.g. Uno, Nano, etc.) may not be able to use integrated sender/receiver because of the lack of enough memory. Please consider to use more powerful board or to use only sender OR receiver.

In addition, those boards have limitation of the number of callbacks and destinations (see `FIXED_CONTAINER_CAPACITY`) because of the lack of memory. Please consider to reduce the number of callbacks/destinations or to use more powerful board.

## Reference

- [Spec (Art-Net 4)](http://artisticlicence.com/WebSiteMaster/User%20Guides/art-net.pdf)
Expand Down
3 changes: 2 additions & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"platforms": "*",
"dependencies": {
"hideakitai/ArxContainer": ">=0.6.0",
"hideakitai/ArxTypeTraits": ">=0.3.2"
"hideakitai/ArxTypeTraits": ">=0.3.2",
"hideakitai/PollingTimer": "*"
}
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ paragraph=Art-Net Sender/Receiver for Arduino (Ethernet, WiFi)
category=Communication
url=https://github.com/hideakitai/ArtNet
architectures=*
depends=ArxContainer (>=0.6.0), ArxTypeTraits (>=0.3.2)
depends=ArxContainer (>=0.6.0), ArxTypeTraits (>=0.3.2), PollingTimer
Loading