LX32DMX
IntroductionLX32DMX is a driver for sending or receiving DMX using an ESP32's UART2. LX32DMX output mode continuously sends DMX once its interrupts have been enabled using startOutput(). LX32DMX input mode receives DMX using the ESP32's UART2 RX pin (GPIO16) LX32DMX input requires replacing the uart hardware abstraction files to allow breaks to be converted LX32DMX is used with a single instance called ESP32DMX. Member Functions
clearSlotszero buffer including slot[0] which is start code public dmxDataprovides direct access to data array public Return Valuepointer to dmx array getSlotreads the value of a slot/address/channel public Return Valuelevel (0-255) DiscussionNOTE: Data is not double buffered. So a complete single frame is not guaranteed. The ISR continuously reads the next frame into the buffer receiveInterruptHandlerUART receive interrupt handler public setDataReceivedCallbackFunction called when DMX frame has been read public DiscussionSets a pointer to a function that is called on the break after a DMX frame has been received. Whatever happens in this function should be quick! Best used to set a flag that is polled outside of ISR for available data. setDirectionPinoptional utility sets the pin used to control driver chip's DE (data enable) line, HIGH for output, LOW for input. public ParameterssetMaxSlotsSets the number of slots (aka addresses or channels) sent per DMX frame. public ParametersDiscussiondefaults to 512 or DMX_MAX_SLOTS and should be no less DMX_MIN_SLOTS slots. The DMX standard specifies min break to break time no less than 1024 usecs. At 44 usecs per slot ~= 24 setSlotSets the output value of a slot Note:slot[0] is DMX start code! public ParametersstartInputstarts interrupt that continuously reads DMX data public Discussionsets up baud rate, bits and parity, sets globals accessed in ISR, enables transmission and tx interrupt startOutputstarts interrupt that continuously sends DMX output public DiscussionSets up baud rate, bits and parity, sets globals accessed in ISR, enables transmission and tx interrupt. stopdisables transmission and tx interrupt public txEmptyInterruptHandlerUART tx empty interrupt handler public Member Data
_current_slotnumber of dmx slots ~24 to 512 private _direction_pinpin used to control direction of output driver chip private _dmx_staterepresents phase of sending dmx packet data/break/etc used to change baud settings private _dmxDataArray of dmx data including start code private _idle_countcount of idle interrupts private _interrupt_statustrue when ISR is enabled private _receive_callbackPointer to receive callback function private _slotsnumber of dmx slots ~24 to 512 private |