mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
e0c76a9dc4
In prep for Wifi siolution, all output functions changed to expect Print class instead of Stream... Can still pass Serial1 etc because Stream extends Print, but this allows for an output-only class extending Print to collect a response buffer for Wifi sending with AT commands.
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
#include "DCC.h"
|
|
#include "DIAG.h"
|
|
#include "DCCEXParser.h"
|
|
#include "WifiInterface.h"
|
|
|
|
/* this code is here to test the waveform 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.
|
|
|
|
Once started, it continues to operate as a DCC++ compaitible command parser
|
|
Important... Config.h contains hardware specific confioguration settings
|
|
that you will need to check.
|
|
|
|
*/
|
|
|
|
void myCallback(int result) {
|
|
DIAG(F("\n getting Loco Id callback result=%d"),result);
|
|
}
|
|
|
|
DCCEXParser serialParser;
|
|
DCCEXParser wifiParser;
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
DCC::begin();
|
|
if (WIFI_PORT>0) WifiInterface::setup();
|
|
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"));
|
|
DIAG(F("\nReady for JMRI commands\n"));
|
|
}
|
|
|
|
void loop() {
|
|
DCC::loop(); // required to keep locos running and check powwer
|
|
|
|
// This line passes input on Serial to the DCCEXParser
|
|
serialParser.loop(Serial);
|
|
if (WIFI_PORT>0) WifiInterface::loop(wifiParser);
|
|
}
|