DCCpp
This is the library version of a program for Arduino to control railroading DCC devices.
Output Struct Reference

#include "Outputs.h"

Public Member Functions

void begin (int id, int pin, int iFlag)
 
void set (int id, int pin, int iFlag)
 
void activate (int s = 1)
 
bool isActivated ()
 

Static Public Member Functions

static Output * get (int id)
 
static void remove (int id)
 
static int count ()
 
static void load ()
 
static void store ()
 
static void parse (char *c)
 
static Output * create (int id, int pin, int iFlag)
 

Public Attributes

struct OutputData data
 
Output * nextOutput
 
int num
 

Static Public Attributes

static Output * firstOutput =NULL
 

Detailed Description

DCC++ BASE STATION supports optional OUTPUT control of any unused Arduino Pins for custom purposes. Pins can be activated or dis-activated. The default is to set ACTIVE pins HIGH and INACTIVE pins LOW. However, this default behavior can be inverted for any pin in which case ACTIVE=LOW and INACTIVE=HIGH.

Definitions and state (ACTIVE/INACTIVE) for pins are retained in EEPROM and restored on power-up. The default is to set each defined pin to active or inactive according to its restored state. However, the default behavior can be modified so that any pin can be forced to be either active or inactive upon power-up regardless of its previous state before power-down.

To have this sketch utilize one or more Arduino pins as custom outputs, first define/edit/delete output definitions using the following variation of the "Z" command.

When controlled as such, the Arduino updates and stores the direction of each output in EEPROM so that it is retained even without power. A list of the current states of each output in the form <Y ID STATE> is generated by this sketch whenever the <s> status command is invoked. This provides an efficient way of initializing the state of any outputs being monitored or controlled by a separate interface or GUI program.

Definition at line 130 of file Outputs.h.

Member Function Documentation

void begin ( int  id,
int  pin,
int  iFlag 
)

Initialize the output created by regular C++ instantiation.

Parameters
idThe numeric ID (0-32767) of the output.
pinThe arduino pin number to use for the output.
iFlagDefines the operational behavior of the output based on bits 0, 1, and 2 (see in class description for values).
Remarks
Should not be used in command line mode.

Definition at line 25 of file Outputs.cpp.

void set ( int  id,
int  pin,
int  iFlag 
)

Force the output values created by command line.

Parameters
idThe numeric ID (0-32767) of the output.
pinThe arduino pin number to use for the output.
iFlagDefines the operational behavior of the output based on bits 0, 1, and 2 (see in class description for values).
Remarks
Should not be used in C++ mode.

Definition at line 55 of file Outputs.cpp.

void activate ( int  s = 1)

Change the activation state of the output. The state of the pin is updated by this function.

Parameters
snew state : see iFlag description in class description..

Definition at line 75 of file Outputs.cpp.

bool isActivated ( )

Checks if the output is activated or not.

Returns
True if the output is activated. Otherwise false (of course...).

Definition at line 154 of file Outputs.h.

Output * get ( int  id)
static

Get a particular output.

Parameters
idThe numeric ID (0-32767) of the output.
Returns
The found output or NULL if not found.
Remarks
Only available when USE_EEPROM or USE_TEXTCOMMAND is defined.

Definition at line 102 of file Outputs.cpp.

void remove ( int  id)
static

Removes a particular output.

Parameters
idThe numeric ID (0-32767) of the output.
Remarks
Only available when USE_EEPROM or USE_TEXTCOMMAND is defined.

Definition at line 109 of file Outputs.cpp.

int count ( )
static

Get the total number of outputs.

Returns
Number of outputs.
Remarks
Only available when USE_EEPROM or USE_TEXTCOMMAND is defined.

Definition at line 141 of file Outputs.cpp.

void load ( )
static

Load the content of all outputs from EEPROM.

Remarks
Only available when USE_EEPROM is defined.

Definition at line 152 of file Outputs.cpp.

void store ( )
static

Store the content of all outputs in EEPROM.

Remarks
Only available when USE_EEPROM is defined.

Definition at line 190 of file Outputs.cpp.

void parse ( char *  c)
static

Do command according to the given command string.

Parameters
cstring to interpret... See syntax in class description.
Remarks
Only available when USE_TEXTCOMMAND is defined.

Definition at line 215 of file Outputs.cpp.

Output * create ( int  id,
int  pin,
int  iFlag 
)
static

Creates a new output in the list..

Parameters
idThe numeric ID (0-32767) of the output.
pinThe arduino pin number to use for the output.
iFlagDefines the operational behavior of the output based on bits 0, 1, and 2 (see in class description for values).
Remarks
Should not be used in C++ mode.
Only available when USE_TEXTCOMMAND is defined.

Definition at line 254 of file Outputs.cpp.

Member Data Documentation

struct OutputData data

Data associated to this output.

Definition at line 131 of file Outputs.h.

Output * firstOutput =NULL
static

Address of the first object of this class. NULL means empty list of outputs. Do not change it !

Definition at line 157 of file Outputs.h.

Output* nextOutput

Address of the next object of this class. NULL means end of the list of outputs. Do not change it !

Definition at line 158 of file Outputs.h.

int num

EEPROM starting address for this Output storage.

Definition at line 184 of file Outputs.h.