Network variables, Digital actuator example – Echelon Mini EVK User Manual

Page 53

Advertising
background image

static SNVT_temp_p lastTemperature;
char temperatureString[15];

temperature = GetTemperature();
if (temperature != lastTemperature) {
lastTemperature = temperature;

// Convert temperature to a string and print
s32_from_slong(temperature / 100, &s32_temperature);
s32_to_ascii(&s32_temperature, temperatureString);
PrintConsole(temperatureString);
// Print new line
PrintConsole("\n\r");
}
}

Digital Actuator Example

The following example application toggles the state of the LEDs on a MiniGizmo

once a second. The timer code is highlighted in bold.

#pragma num_alias_table_entries 2
#pragma run_unconfigured

// Configure the I/O pins
IO_1 output bit ioLEDLd = 1;
IO_2 output bitshift numbits(8) ioLEDs;

// Set the MiniGizmo LEDs to all on or all off
void SetLED(const boolean state) {
// Shift out the LED value
io_out(ioLEDs, state ? 0 : 0xFF);

// Latch the new value
io_out(ioLEDLd, 0);
io_out(ioLEDLd, 1);
}

// Repeat every second
mtimer repeating updateTimer = 1000;

// Toggle the LEDs when the timer expires
when(timer_expires(updateTimer)) {
static boolean lastState;

}

SetLED(lastState = !lastState);

Network Variables

The ANSI/EIA/CEA-709.1 (EN14908-1) protocol employs a data-oriented

application layer that supports the sharing of data between devices, rather
than simply the sending of commands between devices. With this approach,

application data such as temperatures, pressures, states, and text strings can

be sent to multiple devices—each of which may have a different application
for each type of data. This results in smaller, simpler, and more

maintainable applications than traditional command-based systems.

Mini EVK User’s Guide

47

Advertising