/* 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 "dmx_universe.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 union { uint8_t dmx[4]; struct { uint16_t intensity; uint8_t duration; uint8_t rate; } __attribute__((packed)); } profile_t; typedef enum { STROBE_INACTIVE, STROBE_ACTIVE_ON, STROBE_ACTIVE_OFF } strState; class Strobe { public: Strobe(uint16_t address = 1); bool begin(uint8_t pin, uint8_t pwm); // call in setup() static void update(void * param); // update task void recvData(Universe *); // data recieved callback private: uint16_t address_; // DMX address profile_t profile_; // DMX data strState state_; // state machine cycle state uint8_t pwm_; // LEDc PWM channel inline void setLevel(uint16_t level) __attribute__((always_inline)); }; #endif // STROBE_ESP32_H_