Logicode

In addition to the peripherals which compose an IoT.Cafe project, some specific logic can be scripted along.
This script can, for example, establish some relation between the properties of the project, like link one property to another, or perform some mathematical operation. It can also do conditional and iterative operations and cover some simple algorithms.

The script is executed on a virtual processor, whose mode of operation and instruction set are covered by the OpenIoT specification.
In high-level, it can be implemented in any language that provides a compiler to the byte code. For the IoT.Cafe implementation, it's a language similar to C, which is then compiled to byte code that can run on IoT.Cafe devices.

A few examples

Suppose you have a project, which has an analog knob (potentiometer) and a dimmable LED and you want to control the LED intensity with the knob.
What you need to do is set the dimmable LED's value to the analog knob's value.
Like this:

            DimLED.value = Knob.value;
        

Ok, now let's suppose you have the same setup, but you want the LED intensity to be inversely proportional to the knob's value. You'd do:

            DimLED.value = 1 - Knob.value;
        

...or you want the LED to reach full illumination when the knob is at it's half:

            DimLED.value = Knob.value * 2;
        

...or have the LED light up only if the knob is turned between 40% and 60%:

            if (Knob.value >= 0.4 && Knob.value <= 0.6)
                DimLED.value = 1;
            else
                DimLED.value = 0;
        

you can also write this same thing as:

            DimLED.value = (Knob.value >= 0.4 && Knob.value <= 0.6) ? 1 : 0;
        

Convert values

Suppose you want to use the AirSensor peripheral to measure temperature and send it to a web service.
The AirSensor gives you the temperature in Celsius, but the web service requires temperature in Fahrenheit.

You can convert the value you have in Celsius to Fahrenheit and store it in a Paramter peripheral's value, which you can pass to the web service.
So, you'd add a Parameter peripheral, rename it to "Fahrenheit" (the name is not technically signifficant, but we'll rename it for clarity) and write the conversion code:
            Fahrenheit.value = AirSensor.temperature * 1.8 + 32;
        

Coming up

Writing manually in Logicode is planned to be superseded by an entirely visual point-and-click mode of construction.

This is part of our Smart development v2.0 vision for the next step in smart device engineering.
Logicode will then be composed rather than written, however underlying code will still be available for those, who wish to interact with it directly.


Concept, Smart development 2.0