From cdfb37c8b59d7c26a7db58267b068da9dc95e2bf Mon Sep 17 00:00:00 2001 From: David Cutting Date: Thu, 11 Jun 2020 13:24:00 -0600 Subject: [PATCH] Fix indentation and refactor for split class --- .vscode/settings.json | 12 +++++++++ src/main.cpp | 61 ++++++++++++++++++++----------------------- 2 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1301145 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "files.associations": { + "array": "cpp", + "deque": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "string_view": "cpp", + "initializer_list": "cpp", + "cstdint": "cpp" + } +} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 805105a..c7c10f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,66 +4,63 @@ #define DCC_IRQ_MICROSECONDS 29 -#if defined(ARDUINO_AVR_UNO) -#define NUM_LOCOS_MAIN 20 -#else -#define NUM_LOCOS_MAIN 50 -#endif +#define NUM_LOCOS 50 //////////////////////////////////////////////////////////////// // Motor driver selection: // Comment out all but the two lines that you want to use -// DCC* mainTrack = DCC::Create_WSM_SAMCommandStation_Main(NUM_LOCOS_MAIN); -// DCC* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(2); +// DCCMain* mainTrack = DCC::Create_WSM_SAMCommandStation_Main(NUM_LOCOS); +// DCCService* progTrack = DCC::Create_WSM_SAMCommandStation_Prog(); -DCC* mainTrack = DCC::Create_Arduino_L298Shield_Main(NUM_LOCOS_MAIN); -DCC* progTrack = DCC::Create_Arduino_L298Shield_Prog(2); - -// DCC* mainTrack = DCC::Create_Pololu_MC33926Shield_Main(NUM_LOCOS_MAIN); -// DCC* progTrack = DCC::Create_Pololu_MC33926Shield_Prog(2); +// DCCMain* mainTrack = DCC::Create_Arduino_L298Shield_Main(NUM_LOCOS); +// DCCService* progTrack = DCC::Create_Arduino_L298Shield_Prog(); + +DCCMain* mainTrack = DCCMain::Create_Pololu_MC33926Shield_Main(NUM_LOCOS); +DCCService* progTrack = DCCService::Create_Pololu_MC33926Shield_Prog(); //////////////////////////////////////////////////////////////// void waveform_IrqHandler() { - mainTrack->interruptHandler(); - progTrack->interruptHandler(); + mainTrack->interruptHandler(); + progTrack->interruptHandler(); } #if defined(ARDUINO_ARCH_SAMD) void SERCOM4_Handler() { - mainTrack->hdw.railcomSerial()->IrqHandler(); + mainTrack->railcom.getSerial()->IrqHandler(); } #endif void setup() { - mainTrack->hdw.setup(); - progTrack->hdw.setup(); + mainTrack->hdw.setup(); + mainTrack->railcom.setup(); + progTrack->hdw.setup(); - // TimerA is TCC0 on SAMD21, Timer1 on MEGA2560, and Timer1 on MEGA328 - // We will fire an interrupt every 29us to generate the signal on the track - TimerA.initialize(); - TimerA.setPeriod(DCC_IRQ_MICROSECONDS); - TimerA.attachInterrupt(waveform_IrqHandler); - TimerA.start(); + // TimerA is TCC0 on SAMD21, Timer1 on MEGA2560, and Timer1 on MEGA328 + // We will fire an interrupt every 29us to generate the signal on the track + TimerA.initialize(); + TimerA.setPeriod(DCC_IRQ_MICROSECONDS); + TimerA.attachInterrupt(waveform_IrqHandler); + TimerA.start(); #if defined (ARDUINO_ARCH_SAMD) - CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface - Wire.begin(); // Needed for EEPROM to work + CommManager::registerInterface(new USBInterface(SerialUSB)); // Register SerialUSB as an interface + Wire.begin(); // Needed for EEPROM to work #elif defined(ARDUINO_ARCH_AVR) - CommManager::registerInterface(new SerialInterface(Serial)); // Register Serial (USB port on mega/uno) as an interface + CommManager::registerInterface(new SerialInterface(Serial)); // Register Serial (USB port on mega/uno) as an interface #endif - EEStore::init(); + EEStore::init(); - DCCEXParser::init(mainTrack, progTrack); // Set up the string parser to accept commands from the interfaces - CommManager::showInitInfo(); + DCCEXParser::init(mainTrack, progTrack); // Set up the string parser to accept commands from the interfaces + CommManager::showInitInfo(); } void loop() { - CommManager::update(); - mainTrack->loop(); - progTrack->loop(); + CommManager::update(); + mainTrack->loop(); + progTrack->loop(); }