mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 13:41:23 +01:00
First test on Uno
This commit is contained in:
parent
b0debd1fab
commit
3d7a9500cf
13
CVReader.ino
13
CVReader.ino
@ -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();
|
||||||
|
5
Config.h
5
Config.h
@ -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
|
||||||
|
@ -233,6 +233,10 @@ void DCCEXParser::parse(Print & stream, const byte *com, bool banAsync) {
|
|||||||
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;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ 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
|
||||||
|
Loading…
Reference in New Issue
Block a user