From ae2869ba8df07a8c38527eb285bf09cb295879d7 Mon Sep 17 00:00:00 2001 From: FrightRisk <37218136+FrightRisk@users.noreply.github.com> Date: Fri, 18 Sep 2020 19:40:18 -0400 Subject: [PATCH] Rename .ino to match folder name and make changes for WiFi --- .gitignore | 15 ++-- CommandStation-EX.ino | 74 +++++++++++++++++++ .../{CVReader.ino => CommandStation-EX.ino} | 2 +- .../{CVReader.ino => CommandStation-EX.ino} | 2 +- .../{CVReader.ino => CommandStation-EX.ino} | 1 + objdump.bat | 8 +- 6 files changed, 89 insertions(+), 13 deletions(-) create mode 100644 CommandStation-EX.ino rename examples/advanced/{CVReader.ino => CommandStation-EX.ino} (98%) rename examples/basic/{CVReader.ino => CommandStation-EX.ino} (91%) rename examples/basicWifi/{CVReader.ino => CommandStation-EX.ino} (99%) diff --git a/.gitignore b/.gitignore index f3b5252..f49f28f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -.vscode/* -!.vscode/settings.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ +Release/* +.ino.cpp +.pioenvs +.piolibdeps +.clang_complete +.gcc-flags.json +.pio/ +.vscode/ diff --git a/CommandStation-EX.ino b/CommandStation-EX.ino new file mode 100644 index 0000000..e3d7cac --- /dev/null +++ b/CommandStation-EX.ino @@ -0,0 +1,74 @@ +/* + * © 2020, Chris Harlow. All rights reserved. + * + * This file is a demonstattion of setting up a DCC-EX + * Command station to support direct connection of WiThrottle devices + * such as "Engine Driver". If you contriol your layout through JMRI + * then DON'T connect throttles to this wifi, connect them to JMRI. + * + * This is just 3 statements longer than the basic setup. + * + * THIS SETUP DOES NOT APPLY TO ARDUINO UNO WITH ONLY A SINGLE SERIAL PORT. + * REFER TO SEPARATE EXAMPLE. + */ + +#include "DCCEX.h" + +#ifdef ARDUINO_AVR_UNO + #include + SoftwareSerial Serial1(15,16); // YOU must get these pins correct to use Wifi on a UNO + #define WIFI_BAUD 9600 +#else + #define WIFI_BAUD 115200 +#endif + +// Create a serial command parser... Enables certain diagnostics and commands +// to be issued from the USB serial console +// This is NOT intended for JMRI.... + +DCCEXParser serialParser; + +void setup() { + + // The main sketch has responsibilities during setup() + + // Responsibility 1: Start the usb connection for diagnostics + // This is normally Serial but uses SerialUSB on a SAMD processor + Serial.begin(115200); + + // Start the WiFi interface on a MEGA, Uno cannot currently handle WiFi + // NOTE: References to Serial1 are for the serial port used to connect + // your wifi chip/shield. + + Serial1.begin(WIFI_BAUD); + WifiInterface::setup(Serial1, F("Your network name"), F("your network password"),F("DCCEX"),3532); + + // Responsibility 3: Start the DCC engine. + // Note: this provides DCC with two motor drivers, main and prog, which handle the motor shield(s) + // Standard supported devices have pre-configured macros but custome hardware installations require + // detailed pin mappings and may also require modified subclasses of the MotorDriver to implement specialist logic. + + // STANDARD_MOTOR_SHIELD, POLOLU_MOTOR_SHIELD, FIREBOX_MK1, FIREBOX_MK1S are pre defined in MotorShields.h + + // Optionally a Timer number (1..4) may be passed to DCC::begin to override the default Timer1 used for the + // waveform generation. e.g. DCC::begin(STANDARD_MOTOR_SHIELD,2); to use timer 2 + + DCC::begin(STANDARD_MOTOR_SHIELD); + +} + +void loop() { + // The main sketch has responsibilities during loop() + + // Responsibility 1: Handle DCC background processes + // (loco reminders and power checks) + DCC::loop(); + + // Responsibility 2: handle any incoming commands on USB connection + serialParser.loop(Serial); + + // Responsibility 3: Optionally handle any incoming WiFi traffic + WifiInterface::loop(); + + +} diff --git a/examples/advanced/CVReader.ino b/examples/advanced/CommandStation-EX.ino similarity index 98% rename from examples/advanced/CVReader.ino rename to examples/advanced/CommandStation-EX.ino index 33724fc..b7d10c0 100644 --- a/examples/advanced/CVReader.ino +++ b/examples/advanced/CommandStation-EX.ino @@ -115,7 +115,7 @@ void setup() { WifiInterface::setHTTPCallback(myHttpFilter); // This is just for demonstration purposes - DIAG(F("\n===== CVReader demonstrating DCC::getLocoId() call ==========\n")); + DIAG(F("\n===== DCCEX demonstrating DCC::getLocoId() call ==========\n")); DCC::getLocoId(myCallback); // myCallback will be called with the result DIAG(F("\n===== DCC::getLocoId has returned, but the callback wont be executed until we are in loop() ======\n")); diff --git a/examples/basic/CVReader.ino b/examples/basic/CommandStation-EX.ino similarity index 91% rename from examples/basic/CVReader.ino rename to examples/basic/CommandStation-EX.ino index 681bb27..e0a4509 100644 --- a/examples/basic/CVReader.ino +++ b/examples/basic/CommandStation-EX.ino @@ -1,7 +1,7 @@ /* * © 2020, Chris Harlow. All rights reserved. * - * This is a basic, no frills CVreader example of a DCC++ compatible setup. + * This is a basic, no frills DCC-EX example of a DCC++ compatible setup. * There are more advanced examples in the examples folder i */ diff --git a/examples/basicWifi/CVReader.ino b/examples/basicWifi/CommandStation-EX.ino similarity index 99% rename from examples/basicWifi/CVReader.ino rename to examples/basicWifi/CommandStation-EX.ino index 797088f..f4a091e 100644 --- a/examples/basicWifi/CVReader.ino +++ b/examples/basicWifi/CommandStation-EX.ino @@ -15,6 +15,7 @@ #include "DCCEX.h" + // Create a serial command parser... Enables certain diagnostics and commands // to be issued from the USB serial console // This is NOT intended for JMRI.... diff --git a/objdump.bat b/objdump.bat index fc9ab9e..bee2d0f 100644 --- a/objdump.bat +++ b/objdump.bat @@ -1,12 +1,12 @@ ECHO ON FOR /F "delims=" %%i IN ('dir %TMP%\arduino_build_* /b /ad-h /t:c /od') DO SET a=%%i echo Most recent subfolder: %a% >%TMP%\OBJDUMP_%a%.txt -avr-objdump --private=mem-usage %TMP%\%a%\CVReader.ino.elf >>%TMP%\OBJDUMP_%a%.txt +avr-objdump --private=mem-usage %TMP%\%a%\DCCEX.ino.elf >>%TMP%\OBJDUMP_%a%.txt ECHO ++++++++++++++++++++++++++++++++++ >>%TMP%\OBJDUMP_%a%.txt -avr-objdump -x -C %TMP%\%a%\CVReader.ino.elf | find ".text" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt +avr-objdump -x -C %TMP%\%a%\DCCEX.ino.elf | find ".text" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt ECHO ++++++++++++++++++++++++++++++++++ >>%TMP%\OBJDUMP_%a%.txt -avr-objdump -x -C %TMP%\%a%\CVReader.ino.elf | find ".data" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt +avr-objdump -x -C %TMP%\%a%\DCCEX.ino.elf | find ".data" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt ECHO ++++++++++++++++++++++++++++++++++ >>%TMP%\OBJDUMP_%a%.txt -avr-objdump -x -C %TMP%\%a%\CVReader.ino.elf | find ".bss" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt +avr-objdump -x -C %TMP%\%a%\DCC.ino.elf | find ".bss" | sort /+25 /R >>%TMP%\OBJDUMP_%a%.txt notepad %TMP%\OBJDUMP_%a%.txt EXIT