-- Serial port trigger output script -- VoteChanged() is called with two arguments: -- 1. Sum of votes, an integer -- 2. Table (array) of active triggers -- Each entry in the array is itself a table with: -- ["time"] = trigger time as time_t -- ["time_nsec"] = trigger time, nanoseconds part -- ["weight"] = vote weight -- ["description"] = JSON describing trigger itself -- This function should return a string, which will be -- output onto the serial port. local IsOn = false function VoteChanged(voteSum, votes) -- this example prints a "1" when the sum of votes -- equals or exceeds 1000; it then prints a "0" when -- it falls below again if voteSum >= 1000 then if IsOn then return "" end IsOn = true return "1\r\n" end if IsOn then IsOn = false return "0\r\n" end return "" end -- SerialRead() is an optional function. If provided -- it is called with one argument: a string of data -- that was received on the serial port. Note it will -- likely be received in small (even 1-character) -- chunks, not altogether as one block of input. local LastSerialData function SerialRead(data) LastSerialData = data end -- vim: ts=2:sw=2:et