Triggering functions

Sometimes, exchanging the data is not enough. In more complex projects there are events that occurs from both sides, especially triggering some event in arduino from html button. It's great to know that Involt cares about simplicity of such events.

Triggering from app to device

For example, use HTML element to send its value and trigger some event in Arduino sketch:

<button class="ard button P6 value-255 fn-involt">Click me</button>
...

void loop(){

involtReceive();


if(fname == "involt"){

doSomething...

};


fname = ""; //clear the name to prevent from repeating the function each time

}
...

For sending only the function use button-cta.

<div class="button-cta" fn="involt">Click me</div>

JQuery method to send function:

$(this).sendFn("involt");

Pure JS solution:

involt.sendFunction("involt");

Triggering from device to app

Adding this function to sketch will send name of function to app.

involtSendFunction("involt");

This one is tricky. Unlike previous versions and listening for changes in interval, now it's done with declaring the function in involtFunction JS object. Include the custom script in new file and attach it to end of HTML head section.

involtFunction.involt = function(){

//do something when function "involt" was triggered from device...

};

Listen for received pin value

Use it to trigger function each time when app receives value from certain pin. The index, value are related to received pin data.

involtListenForPin[0] = function(index, value){

//do something when received value from pin A0...

};

Be aware of using it for real time update, especially when manipulating the DOM. Instead use interval based update.