1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-26 17:46:14 +01:00

Rename .ino to match folder name and make changes for WiFi

This commit is contained in:
FrightRisk 2020-09-18 19:40:18 -04:00
parent 6eec133b24
commit ae2869ba8d
6 changed files with 89 additions and 13 deletions

15
.gitignore vendored
View File

@ -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/

74
CommandStation-EX.ino Normal file
View File

@ -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.h>
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();
}

View File

@ -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"));

View File

@ -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
*/

View File

@ -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....

View File

@ -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