1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 21:21:24 +01:00

First test on Uno

This commit is contained in:
Harald Barth 2020-07-03 00:19:59 +02:00
parent b0debd1fab
commit 3d7a9500cf
4 changed files with 18 additions and 10 deletions

View File

@ -22,10 +22,10 @@ void myFilter(Print & stream, byte & opcode, byte & paramCount, int p[]) {
DCC::setFn(p[0],p[1],p[2]==1); DCC::setFn(p[0],p[1],p[2]==1);
opcode=0; // tell parser to ignore this command opcode=0; // tell parser to ignore this command
break; break;
case '#': // Diagnose parser <#....> case '$': // Diagnose parser <$....>
DIAG(F("# paramCount=%d\n"),paramCount); DIAG(F("$ paramCount=%d\n"),paramCount);
for (int i=0;i<paramCount;i++) DIAG(F("p[%d]=%d (0x%x)\n"),i,p[i],p[i]); for (int i=0;i<paramCount;i++) DIAG(F("p[%d]=%d (0x%x)\n"),i,p[i],p[i]);
opcode=0; // Normal parser wont understand #, opcode=0; // Normal parser wont understand $,
break; break;
default: // drop through and parser will use the command unaltered. default: // drop through and parser will use the command unaltered.
break; break;
@ -50,7 +50,8 @@ DCCEXParser serialParser;
// Try monitoring the memory // Try monitoring the memory
#include "freeMemory.h" #include "freeMemory.h"
int minMemory=32767; //int minMemory=32767;
int minMemory=2048;
void setup() { void setup() {
@ -68,8 +69,10 @@ void setup() {
// and a 9600 baud rate. // and a 9600 baud rate.
// setup(serial, F(router name), F(password) , port) // setup(serial, F(router name), F(password) , port)
// //
#ifdef WIFI
Serial1.begin(115200); Serial1.begin(115200);
WifiInterface::setup(Serial1, F("BTHub5-M6PT"), F("49de8d4862"),3532); // (3532 is 0xDCC decimal... ) WifiInterface::setup(Serial1, F("BTHub5-M6PT"), F("49de8d4862"),3532); // (3532 is 0xDCC decimal... )
#endif
// This is just for demonstration purposes // This is just for demonstration purposes
DIAG(F("\n===== CVReader demonstrating DCC::getLocoId() call ==========\n")); DIAG(F("\n===== CVReader demonstrating DCC::getLocoId() call ==========\n"));
@ -95,7 +98,9 @@ void loop() {
serialParser.loop(Serial); serialParser.loop(Serial);
// Responsibility 3: Optionally handle any incoming WiFi traffic // Responsibility 3: Optionally handle any incoming WiFi traffic
#ifdef WIFI
WifiInterface::loop(Serial1); WifiInterface::loop(Serial1);
#endif
// Your additional code e.g. Report any decrease in memory // Your additional code e.g. Report any decrease in memory
int freeNow=freeMemory(); int freeNow=freeMemory();

View File

@ -7,16 +7,15 @@ const byte MAIN_POWER_PIN = 3;
const byte MAIN_SIGNAL_PIN = 12; const byte MAIN_SIGNAL_PIN = 12;
const byte MAIN_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins const byte MAIN_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins
const byte MAIN_SENSE_PIN = A0; const byte MAIN_SENSE_PIN = A0;
const byte MAIN_SENSE_FACTOR=1; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps
const byte MAIN_BRAKE_PIN = 9; const byte MAIN_BRAKE_PIN = 9;
const float MAIN_SENSE_FACTOR=1.717; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps
const byte PROG_POWER_PIN = 11; const byte PROG_POWER_PIN = 11;
const byte PROG_SIGNAL_PIN = 13; const byte PROG_SIGNAL_PIN = 13;
const byte PROG_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins const byte PROG_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins
const byte PROG_SENSE_PIN = A1; const byte PROG_SENSE_PIN = A1;
const byte PROG_BRAKE_PIN = 8; const byte PROG_BRAKE_PIN = 8;
const float PROG_SENSE_FACTOR=1.717; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps
const float PROG_SENSE_FACTOR=1; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps
// Allocations with memory implications..! // Allocations with memory implications..!
// Base system takes approx 900 bytes + 8 per loco. Turnouts, Sensors etc are dynamically created // Base system takes approx 900 bytes + 8 per loco. Turnouts, Sensors etc are dynamically created

View File

@ -232,6 +232,10 @@ void DCCEXParser::parse(Print & stream, const byte *com, bool banAsync) {
DCC::setDebug(p[0]==1); DCC::setDebug(p[0]==1);
DIAG(F("\nDCC DEBUG MODE %d"),p[0]==1); DIAG(F("\nDCC DEBUG MODE %d"),p[0]==1);
return; return;
case '#': // NUMBER OF LOCOSLOTS <#>
StringFormatter::send(stream,F("<# %d>"), MAX_LOCOS);
return;
default: //anything else will drop out to <X> default: //anything else will drop out to <X>
break; break;

View File

@ -40,14 +40,14 @@ void Hardware::setSignal(bool isMainTrack, bool high) {
} }
int Hardware::getCurrentMilliamps(bool isMainTrack) { int Hardware::getCurrentMilliamps(bool isMainTrack) {
int pin = isMainTrack ? MAIN_SENSE_PIN : PROG_SENSE_PIN; byte pin = isMainTrack ? MAIN_SENSE_PIN : PROG_SENSE_PIN;
float factor = isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR; float factor = isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR;
// IMPORTANT: This function can be called in Interrupt() time within the 56uS timer // IMPORTANT: This function can be called in Interrupt() time within the 56uS timer
// The default analogRead takes ~100uS which is catastrphic // The default analogRead takes ~100uS which is catastrphic
// so analogReadFast is used here. (-2uS) // so analogReadFast is used here. (-2uS)
int rawCurrent = analogReadFast(pin); int rawCurrent = analogReadFast(pin);
return (int)(rawCurrent * factor); return (int)(rawCurrent * factor);
} }