2020-07-03 18:35:02 +02:00
|
|
|
/*
|
|
|
|
* © 2020, Chris Harlow. All rights reserved.
|
|
|
|
*
|
2020-09-06 21:24:18 +02:00
|
|
|
* This is a basic, no frills CVreader example of a DCC++ compatible setup.
|
|
|
|
* There are more advanced examples in the examples folder i
|
2020-07-03 18:35:02 +02:00
|
|
|
*/
|
|
|
|
|
2020-09-06 21:24:18 +02:00
|
|
|
#include "DCCEX.h"
|
2020-07-03 18:35:02 +02:00
|
|
|
|
2020-09-06 21:24:18 +02:00
|
|
|
// Create parser for <> commands coming from keyboard or JMRI on thr USB connection.
|
2020-06-11 14:35:16 +02:00
|
|
|
DCCEXParser serialParser;
|
2020-06-10 18:31:26 +02:00
|
|
|
|
2020-05-24 00:02:54 +02:00
|
|
|
void setup() {
|
2020-06-28 11:21:27 +02:00
|
|
|
|
2020-09-06 21:24:18 +02:00
|
|
|
// Responsibility 1: Start the usb connection for diagnostics and possible JMRI input
|
|
|
|
Serial.begin(115200);
|
2020-08-17 16:30:25 +02:00
|
|
|
|
2020-09-06 21:24:18 +02:00
|
|
|
// Responsibility 2: Start the DCC engine with information about your Motor Shield.
|
|
|
|
// STANDARD_MOTOR_SHIELD, POLOLU_MOTOR_SHIELD, FIREBOX_MK1, FIREBOX_MK1S are pre defined in MotorDriverss.h
|
|
|
|
DCC::begin(STANDARD_MOTOR_SHIELD);
|
2020-05-24 00:02:54 +02:00
|
|
|
}
|
|
|
|
|
2020-06-11 14:35:16 +02:00
|
|
|
void loop() {
|
2020-09-06 21:24:18 +02:00
|
|
|
// Responsibility 1: Handle DCC background processes (loco reminders and power checks)
|
2020-06-28 11:21:27 +02:00
|
|
|
DCC::loop();
|
2020-05-26 13:44:02 +02:00
|
|
|
|
2020-06-28 11:21:27 +02:00
|
|
|
// Responsibility 2: handle any incoming commands on USB connection
|
2020-09-06 21:24:18 +02:00
|
|
|
serialParser.loop(Serial);
|
2020-05-26 00:03:11 +02:00
|
|
|
}
|