2020-05-24 17:07:16 +02:00
|
|
|
#include "DCC.h"
|
2020-05-24 00:02:54 +02:00
|
|
|
#include "DIAG.h"
|
2020-06-04 21:55:18 +02:00
|
|
|
#include "DCCEXParser.h"
|
2020-06-11 14:35:16 +02:00
|
|
|
#include "WifiInterface.h"
|
2020-05-24 00:22:12 +02:00
|
|
|
|
2020-06-07 17:29:53 +02:00
|
|
|
/* this code is here to test the waveform generator and reveal the issues involved in programming track operations.
|
2020-05-24 00:22:12 +02:00
|
|
|
|
2020-05-26 13:44:02 +02:00
|
|
|
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.
|
2020-05-24 00:22:12 +02:00
|
|
|
|
2020-06-07 17:29:53 +02:00
|
|
|
Once started, it continues to operate as a DCC++ compaitible command parser
|
2020-05-26 13:44:02 +02:00
|
|
|
Important... Config.h contains hardware specific confioguration settings
|
|
|
|
that you will need to check.
|
2020-05-24 17:07:16 +02:00
|
|
|
|
2020-05-26 13:44:02 +02:00
|
|
|
*/
|
|
|
|
|
2020-06-07 17:29:53 +02:00
|
|
|
void myCallback(int result) {
|
2020-06-08 14:04:47 +02:00
|
|
|
DIAG(F("\n getting Loco Id callback result=%d"),result);
|
2020-06-07 17:29:53 +02:00
|
|
|
}
|
2020-05-24 00:02:54 +02:00
|
|
|
|
2020-06-11 14:35:16 +02:00
|
|
|
DCCEXParser serialParser;
|
|
|
|
DCCEXParser wifiParser;
|
2020-06-10 18:31:26 +02:00
|
|
|
|
2020-05-24 00:02:54 +02:00
|
|
|
void setup() {
|
|
|
|
Serial.begin(115200);
|
2020-06-11 14:35:16 +02:00
|
|
|
DCC::begin();
|
|
|
|
// if (WIFI_PORT>0) WifiInterface::setup();
|
2020-06-08 14:04:47 +02:00
|
|
|
DIAG(F("\n===== CVReader demonstrating DCC::getLocoId() call ==========\n"));
|
|
|
|
DCC::getLocoId(myCallback); // myCallback will be called with the result
|
|
|
|
DIAG(F("\n===== DCC::getLocoId has returned, but wont be executed until we are in loop() ======\n"));
|
2020-06-07 17:29:53 +02:00
|
|
|
DIAG(F("\nReady for JMRI commands\n"));
|
2020-05-24 00:02:54 +02:00
|
|
|
}
|
|
|
|
|
2020-06-11 14:35:16 +02:00
|
|
|
void loop() {
|
|
|
|
DCC::loop(); // required to keep locos running and check powwer
|
2020-05-26 13:44:02 +02:00
|
|
|
|
2020-06-04 21:55:18 +02:00
|
|
|
// This line passes input on Serial to the DCCEXParser
|
2020-06-11 14:35:16 +02:00
|
|
|
serialParser.loop(Serial);
|
|
|
|
|
|
|
|
if (WIFI_PORT>0) {
|
|
|
|
// wifiParser=WifiInterface::getSingleClient(wifiParser);
|
|
|
|
// if (wifiParser) wifiParser->loop();
|
|
|
|
}
|
2020-05-26 00:03:11 +02:00
|
|
|
}
|