I'm actually out today, but I'll try and look at this tomorrow - I might be able to detect the framing error in software and pass it to JS. Assuming you're happy playing around with resistors and capacitor values, you could try and detect the start of frame electrically though. You'd be trying to set it up so that when the DMX signal went low for a long period of time, the input on that other pin went low, but it didn't go low for normal serial data.
So something like:
Connect a diode with the non-marked end on the DMX RX pin
Connect a capacitor (1uF?) between GND and the other end of the diode
Put a resistor (1k?) across the capacitor
Connect the capacitor to a pin on Espruino
You'd really need an oscilloscope, and then a play around with the capacitor/resistor values until you saw the voltage on the pin drop below 1v only at the start of frame.
Once that happens you can do something like:
function dmxFrame(data) {
}
var dmx = new Uint8Array(512);
var dmxIdx = 0;
Serial2.setup(250000);
Serial2.on('data', function(d) { dmx.set(d, dmxIdx); dmxIdx += d.length; });
setWatch(function() {
dmxFrame(dmx);
dmxIdx = 0;
, DMX_SOF_PIN, { repeat: true, edge:"falling"});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
You mean the one about listing files?
I'm actually out today, but I'll try and look at this tomorrow - I might be able to detect the framing error in software and pass it to JS. Assuming you're happy playing around with resistors and capacitor values, you could try and detect the start of frame electrically though. You'd be trying to set it up so that when the DMX signal went low for a long period of time, the input on that other pin went low, but it didn't go low for normal serial data.
So something like:
You'd really need an oscilloscope, and then a play around with the capacitor/resistor values until you saw the voltage on the pin drop below 1v only at the start of frame.
Once that happens you can do something like: