Digital sensor example – Echelon Mini EVK User Manual

Page 59

Advertising
background image

file that specifies the data encoding, scaling, units, default value, range, and

behavior for configuration properties based on the type. A rich variety of
standard configuration property types (SCPTs) are defined. SCPTs provide

standard type definitions for commonly used configuration properties such as
dead-bands, hysteresis thresholds, and message heartbeat rates. You can

also create your own user configuration property types (UCPTs) that are

defined in resource files that you create with the NodeBuilder Resource
Editor.

Digital Sensor Example

The following example application adds a configuration property that documents

the location of the digital sensor example application from the previous section.
This configuration property is used by network tools to document the location of a

device, and is not used by the application. The ignore_notused compiler
directive is used to prevent a symbol not used warning when compiling this

application. The configuration property code is highlighted in bold. A network

tool such as the LonMaker Integration Tool is required to test this application.

#pragma num_alias_table_entries 2
#pragma run_unconfigured

// Define the device interface
network input SCPTlocation cp cpLocation = {"Unknown"};
#pragma ignore_notused cpLocation
network output SNVT_switch nvoSwitch;

// Configure the I/O pins
IO_4 input bitshift numbits(8) clockedge(-) ioButtons;
IO_6 output bit ioButtonLd = 1;

// Read the MiniGizmo buttons
boolean GetButton(void) {
// Latch the button inputs
io_out(ioButtonLd, 0);
io_out(ioButtonLd, 1);

// Shift in and return TRUE if any buttons are pressed
return !((unsigned) io_in(ioButtons) == 0xFF);
}

// Repeat every 50 milliseconds
mtimer repeating scanTimer = 50;

// Read the buttons when the timer expires
when(timer_expires(scanTimer)) {
boolean button;
static boolean lastButton;

button = GetButton();
if (button != lastButton) {
lastButton = button;
nvoSwitch.value = button ? 200U : 0;
nvoSwitch.state = button ? 1 : 0;
}
}

Mini EVK User’s Guide

53

Advertising