Skip to main content
Version: Next

Pulse S0

Pulse S0 Functions

This category contains functions specific to pulse S0 devices.

API NameBrief Description
api.S0readCounter(channel)Reports current value of S0 channel counter.
api.S0initializeCounter(channel, value)Sets the value of S0 channel counter in non-volatile memory.
api.S0setThreshold(channel, value)Defines a threshold for triggering the onThreshold() event.

api.S0readCounter(channel)


api.S0readCounter(3)

Reports current value of S0 channel counter.

Info: Calling this function updates the internal shadow variable for the channel counter, resetting the counter for the onThreshold() event.

Arguments

  • channel (integer): Number of the S0 channel, 1 to 4.

Return

  • value (integer): Value of the S0 counter.

Example

-- Read the value of S0 channel 3 and store to variable val
val = api.S0readCounter(3)

--------------------------------

function getS0Data()
s01 = api.S0readCounter(1)
print("S0-1: "..tostring(s01))
s02 = api.S0readCounter(2)
print("S0-2: "..tostring(s02))
s03 = api.S0readCounter(3)
print("S0-3: "..tostring(s03))
s04 = api.S0readCounter(4)
print("S0-4: "..tostring(s04)

api.S0initializeCounter(channel, value)


api.S0initializeCounter(1, 100)

Sets the value of S0 channel counter in non-volatile memory.

Note: This function is typically used on startup to restore the current value.

Arguments

  • channel (integer): Number of the S0 channel, 1 to 4.
  • value (integer): Value of the S0 counter.

Example

-- Set counter value for channel 1 to 100
api.S0initializeCounter(1, 100)

--------------------------------

api.S0initializeCounter(1, s01)
api.S0initializeCounter(2, s02)
api.S0initializeCounter(3, s03)
api.S0initializeCounter(4, s04)

api.S0setThreshold(channel, value)


api.S0setThreshold(2, 10000)

Defines a threshold between the current value of S0 channel counter and the last reported value.

Info: When the difference between these two values reaches the threshold, the onThreshold() event is triggered.

Arguments

  • channel (integer): Number of the S0 channel, 1 to 4.
  • value (integer): Threshold value:
    • 0 disables the threshold.
    • 0x01 or 1 to 0xFFFFFFFF or 4294967295 sets the threshold.

Example

-- Set threshold for channel 2 to 10000
api.S0setThreshold(2, 10000)

--------------------------------

function onStartup()
print("onStartup(), S0 persistent emulation - 4 channels ...")

--set to threshold
api.S0setThreshold(1, 0)
api.S0setThreshold(2, 0)
api.S0setThreshold(3, 0)
api.S0setThreshold(4, 0)