From 4bfc750a6a95cf52988c8f86d157cb92acc8fa6f Mon Sep 17 00:00:00 2001 From: Hideaki Tai Date: Mon, 29 Jun 2020 11:32:30 +0900 Subject: [PATCH] fix const --- Artnet.h | 30 ++++++++++++------------ README.md | 70 +++++++++++++++++++++++++++---------------------------- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Artnet.h b/Artnet.h index 268c4f2..367d72e 100644 --- a/Artnet.h +++ b/Artnet.h @@ -192,17 +192,17 @@ namespace arduino virtual ~Sender_() {} - void net(uint8_t n) { target_net = n & 0x7F; } - void subnet(uint8_t s) { target_subnet = s & 0x0F; } - void universe(uint8_t u) { target_universe = u & 0x0F; } - void universe15bit(uint8_t u) + void net(const uint8_t n) { target_net = n & 0x7F; } + void subnet(const uint8_t s) { target_subnet = s & 0x0F; } + void universe(const uint8_t u) { target_universe = u & 0x0F; } + void universe15bit(const uint8_t u) { net((u >> 8) & 0xFF); subnet((u >> 4) & 0x0F); universe((u >> 0) & 0x0F); } - void set(const uint8_t* const data, uint16_t size = 512) + void set(const uint8_t* const data, const uint16_t size = 512) { packet[IDX(Index::PHYSICAL)] = phy; packet[IDX(Index::NET)] = target_net; @@ -212,13 +212,13 @@ namespace arduino memcpy((&packet[IDX(Index::DATA)]), data, size); } - void set(const uint32_t universe_, const uint8_t* const data, uint16_t size = 512) + void set(const uint32_t universe_, const uint8_t* const data, const uint16_t size = 512) { universe15bit(universe_); set(data, size); } - void set(const uint8_t net_, const uint8_t subnet_, const uint8_t universe_, const uint8_t* const data, uint16_t size = 512) + void set(const uint8_t net_, const uint8_t subnet_, const uint8_t universe_, const uint8_t* const data, const uint16_t size = 512) { net(net_); subnet(subnet_); @@ -238,17 +238,17 @@ namespace arduino stream->write(packet.data(), packet.size()); stream->endPacket(); } - void send(const uint8_t* const data, uint16_t size = 512) + void send(const uint8_t* const data, const uint16_t size = 512) { set(data, size); send(); } - void send(const uint32_t universe_, const uint8_t* const data, uint16_t size = 512) + void send(const uint32_t universe_, const uint8_t* const data, const uint16_t size = 512) { set(universe_, data, size); send(); } - void send(const uint8_t net_, const uint8_t subnet_, const uint8_t universe_, const uint8_t* const data, uint16_t size = 512) + void send(const uint8_t net_, const uint8_t subnet_, const uint8_t universe_, const uint8_t* const data, const uint16_t size = 512) { set(net_, subnet_, universe_, data, size); send(); @@ -263,12 +263,12 @@ namespace arduino } } - void physical(uint8_t i) { phy = constrain(i, 0, 3); } + void physical(const uint8_t i) const { phy = constrain(i, 0, 3); } uint8_t sequence() const { return seq; } protected: - void attach(S& s, const char* user_ip, uint16_t user_port = DEFAULT_PORT) + void attach(S& s, const char* user_ip, const uint16_t user_port = DEFAULT_PORT) { stream = &s; ip = user_ip; @@ -420,7 +420,7 @@ namespace arduino { S stream; public: - void begin(const char* send_ip, uint32_t send_port = DEFAULT_PORT, uint32_t recv_port = DEFAULT_PORT) + void begin(const char* send_ip, const uint16_t send_port = DEFAULT_PORT, const uint16_t recv_port = DEFAULT_PORT) { stream.begin(recv_port); this->Sender_::attach(stream, send_ip, send_port); @@ -433,7 +433,7 @@ namespace arduino { S stream; public: - void begin(const char* ip, uint32_t port = DEFAULT_PORT) + void begin(const char* ip, const uint16_t port = DEFAULT_PORT) { this->Sender_::attach(stream, ip, port); } @@ -444,7 +444,7 @@ namespace arduino { S stream; public: - void begin(uint32_t port = DEFAULT_PORT) + void begin(const uint16_t port = DEFAULT_PORT) { stream.begin(port); this->Receiver_::attach(stream); diff --git a/README.md b/README.md index 4e00c7b..4ddfa7f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Art-Net Sender/Receiver for Arduino (Ethernet, WiFi) - support Art-Net with both Ethernet and WiFi - register multiple callbacks depending on universe - flexible net/subnet/universe setting -- etc. + ## Usage @@ -174,45 +174,45 @@ artnet.begin(ip, send_port, recv_port); // set your own ### ArtnetSender ```C++ -void net(uint8_t n) -void subnet(uint8_t s) -void universe(uint8_t u) -void universe15bit(uint8_t u) -void set(const uint8_t* const data, uint16_t size = 512) -void set(const uint32_t universe_, const uint8_t* const data, uint16_t size = 512) -void set(const uint8_t net_, const uint8_t subnet_, const uint8_t universe_, const uint8_t* const data, uint16_t size = 512) -void send() -void send(const uint8_t* const data, uint16_t size = 512) -void send(const uint32_t universe_, const uint8_t* const data, uint16_t size = 512) -void send(const uint8_t net_, const uint8_t subnet_, const uint8_t universe_, const uint8_t* const data, uint16_t size = 512) -void streaming() -void physical(uint8_t i) -uint8_t sequence() const +void net(const uint8_t n); +void subnet(const uint8_t s); +void universe(const uint8_t u); +void universe15bit(const uint8_t u); +void set(const uint8_t* const data, const uint16_t size = 512); +void set(const uint32_t universe_, const uint8_t* const data, const uint16_t size = 512); +void set(const uint8_t net_, const uint8_t subnet_, const uint8_t universe_, const uint8_t* const data, const uint16_t size = 512); +void send(); +void send(const uint8_t* const data, const uint16_t size = 512); +void send(const uint32_t universe_, const uint8_t* const data, const uint16_t size = 512); +void send(const uint8_t net_, const uint8_t subnet_, const uint8_t universe_, const uint8_t* const data, const uint16_t size = 512); +void streaming(); +void physical(const uint8_t i) const; +uint8_t sequence() const; ``` ### ArtnetReceiver ```C++ -bool parse() -inline const IPAddress& ip() const { return remote_ip; } -uint16_t port() const { return remote_port; } -String id() const -uint16_t opcode() const -uint16_t opcode(const uint8_t* p) const -uint16_t version() const -uint8_t sequence() const -uint8_t physical() const -uint8_t net() const -uint8_t subnet() const -uint8_t universe() const -uint16_t universe15bit() const -uint16_t length() const -uint16_t size() const -uint8_t* data() -uint8_t data(const uint16_t i) const -void subscribe(const uint32_t universe, const CallbackType& func) -void subscribe(const CallbackType& func) -void subscribe(const uint8_t net, const uint8_t subnet, const uint8_t universe, const CallbackType& func) +bool parse(); +inline const IPAddress& ip() const; +uint16_t port() const; +String id() const; +uint16_t opcode() const; +uint16_t opcode(const uint8_t* p) const; +uint16_t version() const; +uint8_t sequence() const; +uint8_t physical() const; +uint8_t net() const; +uint8_t subnet() const; +uint8_t universe() const; +uint16_t universe15bit() const; +uint16_t length() const; +uint16_t size() const; +uint8_t* data(); +uint8_t data(const uint16_t i) const; +void subscribe(const uint32_t universe, const CallbackType& func); +void subscribe(const CallbackType& func); +void subscribe(const uint8_t net, const uint8_t subnet, const uint8_t universe, const CallbackType& func); ``` ## Supported Platform