#include "DCCpp.hpp"
|
static void | begin () |
|
static void | beginMain (uint8_t inOptionalDirectionMotor, uint8_t inSignalPin, uint8_t inSignalEnablePin, uint8_t inCurrentMonitor) |
|
static void | beginProg (uint8_t inOptionalDirectionMotor, uint8_t inSignalPin, uint8_t inSignalEnablePin, uint8_t inCurrentMonitor) |
|
static void | beginMainMotorShield () |
|
static void | beginProgMotorShield () |
|
static void | beginMainPololu () |
|
static void | beginProgPololu () |
|
static bool | IsMainTrack (volatile RegisterList *apRegs) |
|
static void | loop () |
|
static void | panicStop (bool inStop) |
|
static void | powerOn (bool inMain = true, bool inProg = true) |
|
static void | powerOff (bool inMain = true, bool inProg = true) |
|
static void | setCurrentSampleMaxMain (float inMax) |
|
static void | setCurrentSampleMaxProg (float inMax) |
|
static float | getCurrentMain () |
|
static float | getCurrentProg () |
|
static bool | setSpeedMain (int nReg, int inLocoId, int inStepsNumber, int inNewSpeed, bool inForward) |
|
static int | identifyLocoIdMain () |
|
static int | readCvMain (int inCvId, int callBack = 100, int callBackSub = 200) |
|
static void | writeCvMain (int inCvId, byte inValue, int callBack = 100, int callBackSub = 200) |
|
static void | setFunctionsMain (int nReg, int inLocoId, FunctionsState &inStates) |
|
static bool | setSpeedProg (int nReg, int inLocoId, int inStepsNumber, int inNewSpeed, bool inForward) |
|
static int | identifyLocoIdProg () |
|
static int | readCvProg (int inCvId, int callBack = 100, int callBackSub = 200) |
|
static void | writeCvProg (int inCvId, byte inValue, int callBack = 100, int callBackSub = 200) |
|
static void | setFunctionsProg (int nReg, int inLocoId, FunctionsState &inStates) |
|
static void | setAccessory (int inAddress, byte inSubAddress, byte inActivate) |
|
|
static volatile RegisterList | mainRegs |
|
static volatile RegisterList | progRegs |
|
static CurrentMonitor | mainMonitor |
|
static CurrentMonitor | progMonitor |
|
This is the main class of the library. All data and functions are static. There is no needs to instantiate this class.
Definition at line 70 of file DCCpp.hpp.
Begins the DCCpp library.
Definition at line 293 of file DCCpp.cpp.
void DCCpp::beginMain |
( |
uint8_t |
inOptionalDirectionMotor, |
|
|
uint8_t |
inSignalPin, |
|
|
uint8_t |
inSignalEnablePin, |
|
|
uint8_t |
inCurrentMonitor |
|
) |
| |
|
static |
Initializes the main track.
- Parameters
-
inOptionalDirectionMotor | Pin for the rerouting of shields direction pin, set it to UNDEFINED_PIN if not used. |
inSignalPin | Pin for the signal pin, the one driven by an interruption, set it to UNDEFINED_PIN if not used (but the line will be always down...). |
inSignalEnablePin | Pin for the enable/PWM pin, set it to UNDEFINED_PIN if not used. |
inCurrentMonitor | Pin for the current monitor analog pin, set it to UNDEFINED_PIN if not used. |
Definition at line 117 of file DCCpp.cpp.
static void DCCpp::beginMainMotorShield |
( |
| ) |
|
|
inlinestatic |
Initializes the main track for an Arduino Motor Shield.
Definition at line 109 of file DCCpp.hpp.
static void DCCpp::beginMainPololu |
( |
| ) |
|
|
inlinestatic |
Initializes the main track for a Pololu MC33926 Motor Shield.
Definition at line 116 of file DCCpp.hpp.
void DCCpp::beginProg |
( |
uint8_t |
inOptionalDirectionMotor, |
|
|
uint8_t |
inSignalPin, |
|
|
uint8_t |
inSignalEnablePin, |
|
|
uint8_t |
inCurrentMonitor |
|
) |
| |
|
static |
Initializes the programming track.
- Parameters
-
inOptionalDirectionMotor | Pin for the rerouting of shields direction pin, set it to UNDEFINED_PIN if not used. |
inSignalPin | Pin for the signal pin, the one driven by an interruption, set it to UNDEFINED_PIN if not used (but the line will be always down...). |
inSignalEnablePin | Pin for the enable/PWM pin, set it to UNDEFINED_PIN if not used. |
inCurrentMonitor | Pin for the current monitor analog pin, set it to UNDEFINED_PIN if not used. |
Definition at line 182 of file DCCpp.cpp.
static void DCCpp::beginProgMotorShield |
( |
| ) |
|
|
inlinestatic |
Initializes the programming track for an Arduino Motor Shield.
Definition at line 112 of file DCCpp.hpp.
static void DCCpp::beginProgPololu |
( |
| ) |
|
|
inlinestatic |
Initializes the programming track for a Pololu MC33926 Motor Shield.
Definition at line 119 of file DCCpp.hpp.
static float DCCpp::getCurrentMain |
( |
| ) |
|
|
inlinestatic |
Get the actual analog level for the current detection pin for the main track.
- Returns
- Current value between 0 and 1023 using an exponential smoother...
Definition at line 171 of file DCCpp.hpp.
static float DCCpp::getCurrentProg |
( |
| ) |
|
|
inlinestatic |
Get the actual analog level for the current detection pin for the programming track.
- Returns
- Current value between 0 and 1023.
Definition at line 176 of file DCCpp.hpp.
static int DCCpp::identifyLocoIdMain |
( |
| ) |
|
|
inlinestatic |
Try to identify the address of a decoder on the main track. Be sure there is only one loco on the track to call this function !
- Returns
- CV 1 value: the loco decoder Id or -1 if no decoder identified.
Definition at line 192 of file DCCpp.hpp.
static int DCCpp::identifyLocoIdProg |
( |
| ) |
|
|
inlinestatic |
Try to identify the address of a decoder on the programming track. Be sure there is only one loco on the track to call this function !
- Returns
- CV 1 value: the loco decoder Id or -1 if no decoder identified.
Definition at line 233 of file DCCpp.hpp.
static bool DCCpp::IsMainTrack |
( |
volatile RegisterList * |
apRegs | ) |
|
|
inlinestatic |
Checks if the given RegisterList is from the main track or not.
- Parameters
-
apRegs | RegisterList to check. |
- Returns
- true if the RegisterList is mainRegs, the one from the main track.
Definition at line 135 of file DCCpp.hpp.
Main loop function of the library.
Definition at line 92 of file DCCpp.cpp.
void DCCpp::panicStop |
( |
bool |
inStop | ) |
|
|
static |
Stop/restore the power on all the tracks.
- Parameters
-
inStop | If true, stop the power, otherwise restore the power. |
Definition at line 531 of file DCCpp.cpp.
void DCCpp::powerOff |
( |
bool |
inMain = true , |
|
|
bool |
inProg = true |
|
) |
| |
|
static |
Stop the power on all the tracks by default, or on the chosen track according .
- Parameters
-
inMain | If true, power off the main track. |
inProg | If true, power off the programmation track. |
Definition at line 561 of file DCCpp.cpp.
void DCCpp::powerOn |
( |
bool |
inMain = true , |
|
|
bool |
inProg = true |
|
) |
| |
|
static |
Set the power on all the tracks by default, or on the chosen track according .
- Parameters
-
inMain | If true, power on the main track. |
inProg | If true, power on the programmation track. |
Definition at line 548 of file DCCpp.cpp.
static int DCCpp::readCvMain |
( |
int |
inCvId, |
|
|
int |
callBack = 100 , |
|
|
int |
callBackSub = 200 |
|
) |
| |
|
inlinestatic |
Try to read a CV from a decoder on the main track. Be sure there is only one loco on the track before calling this function !
- Parameters
-
inCvId | CV id from 0 to 255. |
callBack | an arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs that call this function. Default 100. |
callBackSub | a second arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs (e.g. DCC++ Interface) that call this function. Default 200 |
- Returns
- CV value: the CV value if the value cannot be read.
Definition at line 201 of file DCCpp.hpp.
static int DCCpp::readCvProg |
( |
int |
inCvId, |
|
|
int |
callBack = 100 , |
|
|
int |
callBackSub = 200 |
|
) |
| |
|
inlinestatic |
Try to read a CV from a decoder on the programming track. Be sure there is only one loco on the track before calling this function !
- Parameters
-
inCvId | CV id from 0 to 255. |
callBack | an arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs that call this function. Default 100. |
callBackSub | a second arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs (e.g. DCC++ Interface) that call this function. Default 200 |
- Returns
- CV value: the CV value if the value cannot be read.
Definition at line 242 of file DCCpp.hpp.
void DCCpp::setAccessory |
( |
int |
inAddress, |
|
|
byte |
inSubAddress, |
|
|
byte |
inActivate |
|
) |
| |
|
static |
Activates or not the given accessory
- Parameters
-
inAddress | main address of the accessory decoder, from 0 to 511. |
inSubAddress | accessory number inside the decoder, from 0 to 3. |
inActivate | True to activate the accessory, false to deactivate. |
Definition at line 756 of file DCCpp.cpp.
static void DCCpp::setCurrentSampleMaxMain |
( |
float |
inMax | ) |
|
|
inlinestatic |
Set the maximum current value before an event 'too much current consumption detected !' for main track.
- Parameters
-
inMax | Maximum value between 0 and 1023. Default is 300. |
Definition at line 161 of file DCCpp.hpp.
static void DCCpp::setCurrentSampleMaxProg |
( |
float |
inMax | ) |
|
|
inlinestatic |
Set the maximum current value before an event 'too much current consumption detected !' for programming track.
- Parameters
-
inMax | Maximum value between 0 and 1023. Default is 300. |
Definition at line 166 of file DCCpp.hpp.
static void DCCpp::setFunctionsMain |
( |
int |
nReg, |
|
|
int |
inLocoId, |
|
|
FunctionsState & |
inStates |
|
) |
| |
|
inlinestatic |
Set the functions states of the given decoder on the main track.
- Parameters
-
nReg | Register number. Avoid register 0, used for one shot commands like accessories or CV programming. |
inLocoId | Decoder address in short or long format. |
inStates | FunctionsState class with the wanted new status. |
Definition at line 217 of file DCCpp.hpp.
static void DCCpp::setFunctionsProg |
( |
int |
nReg, |
|
|
int |
inLocoId, |
|
|
FunctionsState & |
inStates |
|
) |
| |
|
inlinestatic |
Set the functions states of the given decoder on the programming track.
- Parameters
-
nReg | Register number. Avoid register 0, used for one shot commands like accessories or CV programming. |
inLocoId | Decoder address in short or long format. |
inStates | FunctionsState class with the wanted new status. |
Definition at line 257 of file DCCpp.hpp.
static bool DCCpp::setSpeedMain |
( |
int |
nReg, |
|
|
int |
inLocoId, |
|
|
int |
inStepsNumber, |
|
|
int |
inNewSpeed, |
|
|
bool |
inForward |
|
) |
| |
|
inlinestatic |
For the given decoder id, set the speed and the direction on the main track.
- Parameters
-
nReg | Register number. Avoid register 0, used for one shot commands like accessories or CV programming. |
inLocoId | Decoder address in short or long format. |
inStepsNumber | According to the decoder configuration, set it to 14, 28 or 128 . |
inNewSpeed | Speed of the loco, between 2 and the steps number - 1 (13, 27 or 127). 0 means normal complete stop. 1 means emergency stop. |
inForward | True means forward move, false means backward. |
Definition at line 187 of file DCCpp.hpp.
static bool DCCpp::setSpeedProg |
( |
int |
nReg, |
|
|
int |
inLocoId, |
|
|
int |
inStepsNumber, |
|
|
int |
inNewSpeed, |
|
|
bool |
inForward |
|
) |
| |
|
inlinestatic |
For the given decoder id, set the speed and the direction on the programming track.
- Parameters
-
nReg | Register number. Avoid register 0, used for one shot commands like accessories or CV programming. |
inLocoId | Decoder address in short or long format. |
inStepsNumber | According to the decoder configuration, set it to 14, 28 or 128 . |
inNewSpeed | Speed of the loco, between 2 and the steps number - 1 (13, 27 or 127). 0 means normal complete stop. 1 means emergency stop. |
inForward | True means forward move, false means backward. |
Definition at line 228 of file DCCpp.hpp.
static void DCCpp::writeCvMain |
( |
int |
inCvId, |
|
|
byte |
inValue, |
|
|
int |
callBack = 100 , |
|
|
int |
callBackSub = 200 |
|
) |
| |
|
inlinestatic |
Write the given CV on the main track. Be sure there is only one loco on the track before calling this function !
- Parameters
-
inCvId | CV id from 0 to 255. |
inValue | CV new value from 0 to 255. |
callBack | an arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs that call this function. Default 100. |
callBackSub | a second arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs (e.g. DCC++ Interface) that call this function. Default 200 |
Definition at line 210 of file DCCpp.hpp.
static void DCCpp::writeCvProg |
( |
int |
inCvId, |
|
|
byte |
inValue, |
|
|
int |
callBack = 100 , |
|
|
int |
callBackSub = 200 |
|
) |
| |
|
inlinestatic |
Write the given CV on the programming track.
- Parameters
-
inCvId | CV id from 0 to 255. |
inValue | CV new value from 0 to 255. |
callBack | an arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs that call this function. Default 100. |
callBackSub | a second arbitrary integer (0-32767) that is ignored by the Base Station and is simply echoed back in the output - useful for external programs (e.g. DCC++ Interface) that call this function. Default 200 |
Definition at line 250 of file DCCpp.hpp.
The documentation for this class was generated from the following files:
- D:/Mes documents/Trusty/Arduino/Libraries/DCCpp/src/DCCpp.hpp
- D:/Mes documents/Trusty/Arduino/Libraries/DCCpp/src/DCCpp.cpp