2020-05-24 17:07:16 +02:00
|
|
|
#include "DCC.h"
|
2020-05-24 00:02:54 +02:00
|
|
|
#include "DIAG.h"
|
2020-05-24 00:22:12 +02:00
|
|
|
|
|
|
|
/* this code is here to test the waveforwe generator and reveal the issues involved in programming track operations.
|
|
|
|
*
|
|
|
|
* It tests the Waveform genartor and demonstrates how a DCC API function can be simply written
|
|
|
|
* to transmit and receive DCC data on the programming track.
|
|
|
|
*
|
|
|
|
* Important... DCCWaveform.h contains hardware specific confioguration settings
|
|
|
|
* that you will need to check.
|
|
|
|
*
|
|
|
|
* Notes: the waveform generator sends reset packets on progTrack when it has nothing better to do, this means that
|
|
|
|
* the decoder does not step out of service mode. (The main track sends idles).
|
|
|
|
* It also means that the API functions dont have to mess with reset packets.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-05-24 17:07:16 +02:00
|
|
|
|
2020-05-24 00:02:54 +02:00
|
|
|
const int cvnums[]={1,2,3,4,5,17,18,19,21,22,29};
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
Serial.begin(115200);
|
2020-05-24 17:07:16 +02:00
|
|
|
DCC::begin();
|
2020-05-24 00:22:12 +02:00
|
|
|
|
|
|
|
DIAG(F("\n===== CVReader begin ==============================\n"));
|
2020-05-24 00:02:54 +02:00
|
|
|
|
|
|
|
for (byte x=0;x<sizeof(cvnums)/sizeof(cvnums[0]);x++) {
|
2020-05-24 17:07:16 +02:00
|
|
|
int value=DCC::readCV(cvnums[x]);
|
2020-05-24 00:22:12 +02:00
|
|
|
DIAG(F("\nCV %d = %d 0x%x %s"),cvnums[x],value,value, value>=0?" VERIFIED OK":"FAILED VERIFICATION");
|
2020-05-24 00:02:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DIAG(F("\nProgram complete, press reset to retry"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
2020-05-24 17:07:16 +02:00
|
|
|
DCC::loop();
|
2020-05-24 00:22:12 +02:00
|
|
|
}
|