/* strobe_esp32.h Part of WiFlash_esp32 Copyright (c) 2020 Kevin Matz (kevin.matz@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef STROBE_ESP32_H_ #define STROBE_ESP32_H_ #include "sacn.h" inline uint32_t hz_to_micros(uint8_t dmx) __attribute__((always_inline)); inline uint32_t dr_to_micros(uint8_t dmx) __attribute__((always_inline)); typedef enum { STROBE_INACTIVE, STROBE_ACTIVE_ON, STROBE_ACTIVE_OFF } strState; class Strobe { public: Strobe(e131_listen_t type, uint16_t universe = 1, uint16_t address = 1); bool begin(uint8_t pin, uint8_t pwm); // call in setup() void update(void *args = NULL); // update task const uint8_t profile = 4; // DMX profile length private: e131_listen_t m_type; // IP Unicast/Multicast uint16_t m_universe; // sACN universe uint16_t m_address; // DMX address uint16_t m_int; // state machine intensity uint8_t m_dur; // state machine durration uint8_t m_rat; // state machine rate strState m_state; // state machine cycle state uint16_t m_level; // state machine LED level uint8_t m_pwm; // LEDc PWM channel 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)); }; #endif // STROBE_ESP32_H_