seperate stobe class from sACN.
This commit is contained in:
parent
7821577523
commit
525970bbf9
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <WiFi.h>
|
|
||||||
#include "sacn.h"
|
#include "sacn.h"
|
||||||
|
|
||||||
// E1.17 ACN Packet Identifier
|
// E1.17 ACN Packet Identifier
|
||||||
|
@ -51,20 +51,16 @@ uint32_t dr_to_micros(uint8_t dmx) {
|
|||||||
/*
|
/*
|
||||||
Constructor
|
Constructor
|
||||||
*/
|
*/
|
||||||
Strobe::Strobe(e131_listen_t type, uint16_t universe, uint16_t address) {
|
Strobe::Strobe(uint16_t universe, uint16_t address) {
|
||||||
m_type = type;
|
|
||||||
m_universe = universe;
|
m_universe = universe;
|
||||||
m_address = address;
|
m_address = address;
|
||||||
m_e131 = new ESPAsyncE131(1);
|
|
||||||
m_e131->onPacket(std::bind(&Strobe::recvData, this,
|
|
||||||
std::placeholders::_1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
call durring setup()
|
call durring setup()
|
||||||
*/
|
*/
|
||||||
bool Strobe::begin(uint8_t pin, uint8_t pwm) {
|
bool Strobe::begin(uint8_t pin, uint8_t pwm) {
|
||||||
bool success = false;
|
bool success = true;
|
||||||
// set state
|
// set state
|
||||||
m_pwm = pwm;
|
m_pwm = pwm;
|
||||||
m_state = STROBE_INACTIVE;
|
m_state = STROBE_INACTIVE;
|
||||||
@ -75,14 +71,6 @@ bool Strobe::begin(uint8_t pin, uint8_t pwm) {
|
|||||||
ledcSetup(m_pwm, 2400, 15); // 2.4KHz PWM, 15 bit resolutio
|
ledcSetup(m_pwm, 2400, 15); // 2.4KHz PWM, 15 bit resolutio
|
||||||
ledcWrite(m_pwm, m_level); // LED to 0%
|
ledcWrite(m_pwm, m_level); // LED to 0%
|
||||||
|
|
||||||
// start sACN
|
|
||||||
if (!m_e131->begin(m_type, m_universe)) {
|
|
||||||
Serial.println("Failed to start E1.31");
|
|
||||||
} else {
|
|
||||||
Serial.println("Listening for sACN");
|
|
||||||
success = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,16 +41,17 @@ typedef enum {
|
|||||||
|
|
||||||
class Strobe {
|
class Strobe {
|
||||||
public:
|
public:
|
||||||
Strobe(e131_listen_t type, uint16_t universe = 1, uint16_t address = 1);
|
Strobe(uint16_t universe = 1, uint16_t address = 1);
|
||||||
|
|
||||||
bool begin(uint8_t pin, uint8_t pwm); // call in setup()
|
bool begin(uint8_t pin, uint8_t pwm); // call in setup()
|
||||||
|
|
||||||
void update(void *args = NULL); // update task
|
void update(void *args = NULL); // update task
|
||||||
|
|
||||||
const uint8_t profile = 4; // DMX profile length
|
const uint8_t profile = 4; // DMX profile length
|
||||||
|
|
||||||
|
void recvData(e131_packet_t *packet); // data recieved callback
|
||||||
|
|
||||||
private:
|
private:
|
||||||
e131_listen_t m_type; // IP Unicast/Multicast
|
|
||||||
uint16_t m_universe; // sACN universe
|
uint16_t m_universe; // sACN universe
|
||||||
uint16_t m_address; // DMX address
|
uint16_t m_address; // DMX address
|
||||||
|
|
||||||
@ -63,10 +64,6 @@ class Strobe {
|
|||||||
uint8_t m_pwm; // LEDc PWM channel
|
uint8_t m_pwm; // LEDc PWM channel
|
||||||
|
|
||||||
uint32_t m_time; // micros() of current cycle start
|
uint32_t m_time; // micros() of current cycle start
|
||||||
|
|
||||||
ESPAsyncE131 *m_e131; // ESPAsyncE131 instance
|
|
||||||
|
|
||||||
void recvData(e131_packet_t *packet); // data recieved callback
|
|
||||||
|
|
||||||
inline void setLevel(uint16_t level) __attribute__((always_inline));
|
inline void setLevel(uint16_t level) __attribute__((always_inline));
|
||||||
};
|
};
|
||||||
|
@ -61,7 +61,10 @@ const String released_value = "99.2";
|
|||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Configure E1.31 sACN
|
// Configure E1.31 sACN
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
Strobe strobe(E131_UNICAST, 1, 001); // (uni|multi)cast, sACN Universe, Address
|
const e131_listen_t sACN_mode = E131_UNICAST; // (uni|multi)cast
|
||||||
|
const uint16_t strobe_universe = 1;
|
||||||
|
const uint16_t strobe_address = 501;
|
||||||
|
|
||||||
/* DMX Value
|
/* DMX Value
|
||||||
* | chan | Command | range | range |
|
* | chan | Command | range | range |
|
||||||
* |------+-----------+-------+------------|
|
* |------+-----------+-------+------------|
|
||||||
@ -86,11 +89,14 @@ const int led = LED_BUILTIN; // IO13
|
|||||||
* Change nothing else unless you're really sure.
|
* Change nothing else unless you're really sure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//// device objects
|
||||||
|
Strobe *strobe = new Strobe(strobe_universe, strobe_address);
|
||||||
|
ESPAsyncE131 *e131 = new ESPAsyncE131();
|
||||||
|
|
||||||
//// Global button variables
|
//// Global button variables
|
||||||
bool pressed = false; // track button state
|
bool pressed = false; // track button state
|
||||||
uint32_t change_time; // time of button press (ms)
|
uint32_t change_time; // time of button press (ms)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Arduino powerup
|
* Arduino powerup
|
||||||
*/
|
*/
|
||||||
@ -113,12 +119,22 @@ void setup() {
|
|||||||
Serial.println("STA Failed to configure");
|
Serial.println("STA Failed to configure");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//// start sACN
|
||||||
|
if (!e131->begin(sACN_mode, strobe_universe)) {
|
||||||
|
Serial.println("Failed to start E1.31");
|
||||||
|
} else {
|
||||||
|
e131->onPacket(std::bind(&Strobe::recvData, strobe,
|
||||||
|
std::placeholders::_1));
|
||||||
|
Serial.println("Listening for sACN");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//// start fixtures hardware:
|
//// start fixtures hardware:
|
||||||
// button
|
// button
|
||||||
pinMode(button, INPUT_PULLUP);
|
pinMode(button, INPUT_PULLUP);
|
||||||
// led_trigPres_trigPress _trigPress _trigPress _trigPress s
|
// led_trigPres_trigPress _trigPress _trigPress _trigPress s
|
||||||
if (!strobe.begin(led, 0)) {
|
if (!strobe->begin(led, 0)) {
|
||||||
Serial.println("Strobe failed to configure.");
|
Serial.println("Strobe failed to configure.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +150,7 @@ void loop() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
strobe.update();
|
strobe->update();
|
||||||
|
|
||||||
// Be a remote trigger
|
// Be a remote trigger
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user