mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-01-11 21:31:02 +01:00
Merge branch 'tinker2-uno' into mergefix
Conflicts: Config.h DCCWaveform.h Hardware.cpp
This commit is contained in:
commit
e0dbe06939
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);
|
||||
opcode=0; // tell parser to ignore this command
|
||||
break;
|
||||
case '#': // Diagnose parser <#....>
|
||||
DIAG(F("# paramCount=%d\n"),paramCount);
|
||||
case '$': // Diagnose parser <$....>
|
||||
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]);
|
||||
opcode=0; // Normal parser wont understand #,
|
||||
opcode=0; // Normal parser wont understand $,
|
||||
break;
|
||||
default: // drop through and parser will use the command unaltered.
|
||||
break;
|
||||
@ -50,7 +50,8 @@ DCCEXParser serialParser;
|
||||
|
||||
// Try monitoring the memory
|
||||
#include "freeMemory.h"
|
||||
int minMemory=32767;
|
||||
//int minMemory=32767;
|
||||
int minMemory=2048;
|
||||
|
||||
void setup() {
|
||||
|
||||
@ -68,8 +69,10 @@ void setup() {
|
||||
// and a 9600 baud rate.
|
||||
// setup(serial, F(router name), F(password) , port)
|
||||
//
|
||||
#ifdef WIFI
|
||||
Serial1.begin(115200);
|
||||
WifiInterface::setup(Serial1, F("BTHub5-M6PT"), F("49de8d4862"),3532); // (3532 is 0xDCC decimal... )
|
||||
#endif
|
||||
|
||||
// This is just for demonstration purposes
|
||||
DIAG(F("\n===== CVReader demonstrating DCC::getLocoId() call ==========\n"));
|
||||
@ -95,7 +98,9 @@ void loop() {
|
||||
serialParser.loop(Serial);
|
||||
|
||||
// Responsibility 3: Optionally handle any incoming WiFi traffic
|
||||
#ifdef WIFI
|
||||
WifiInterface::loop(Serial1);
|
||||
#endif
|
||||
|
||||
// Your additional code e.g. Report any decrease in memory
|
||||
int freeNow=freeMemory();
|
||||
|
3
Config.h
3
Config.h
@ -8,6 +8,7 @@ const byte MAIN_SIGNAL_PIN = 12;
|
||||
const byte MAIN_SIGNAL_PIN_ALT = 0; // for hardware that flipflops signal pins
|
||||
const byte MAIN_SENSE_PIN = A0;
|
||||
const byte MAIN_BRAKE_PIN = 9;
|
||||
const float MAIN_SENSE_FACTOR=1.717; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps
|
||||
|
||||
const int MAIN_MAX_MILLIAMPS=2000;
|
||||
const float MAIN_SENSE_FACTOR=2.99; // analgRead(MAIN_SENSE_PIN) * MAIN_SENSE_FACTOR = milliamps
|
||||
@ -19,7 +20,7 @@ const byte PROG_SENSE_PIN = A1;
|
||||
const byte PROG_BRAKE_PIN = 8;
|
||||
|
||||
const int PROG_MAX_MILLIAMPS=250;
|
||||
const float PROG_SENSE_FACTOR=2.99; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps
|
||||
const float PROG_SENSE_FACTOR=1.717; // analgRead(PROG_SENSE_PIN) * PROG_SENSE_FACTOR = milliamps
|
||||
|
||||
// Allocations with memory implications..!
|
||||
// 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);
|
||||
return;
|
||||
|
||||
case '#': // NUMBER OF LOCOSLOTS <#>
|
||||
StringFormatter::send(stream,F("<# %d>"), MAX_LOCOS);
|
||||
return;
|
||||
|
||||
default: //anything else will drop out to <X>
|
||||
break;
|
||||
|
||||
|
@ -140,8 +140,9 @@ bool DCCWaveform::interrupt1() {
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
// ACK check is prog track only
|
||||
if (ackPending) checkAck();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -190,11 +191,6 @@ void DCCWaveform::interrupt2() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ACK check is prog track only and will only be checked if bits_sent=4 ...
|
||||
// This means only once per 9-bit-byte AND never at the same cycle as the
|
||||
// relatively expensive packet change code just above.
|
||||
if (ackPending && bits_sent==4) checkAck();
|
||||
}
|
||||
|
||||
|
||||
@ -272,7 +268,7 @@ void DCCWaveform::checkAck() {
|
||||
// detected trailing edge of pulse
|
||||
ackPulseDuration=micros()-ackPulseStart;
|
||||
|
||||
if (ackPulseDuration>1000 && ackPulseDuration<9000) {
|
||||
if (ackPulseDuration>3000 && ackPulseDuration<8500) {
|
||||
ackCheckDuration=millis()-ackCheckStart;
|
||||
ackDetected=true;
|
||||
ackPending=false;
|
||||
|
@ -47,10 +47,6 @@ int Hardware::getCurrentRaw(bool isMainTrack) {
|
||||
|
||||
}
|
||||
|
||||
unsigned int Hardware::getCurrentMilliamps(bool isMainTrack, int raw) {
|
||||
return (int)(raw * (isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR));
|
||||
}
|
||||
|
||||
void Hardware::setCallback(int duration, void (*isr)()) {
|
||||
Timer1.initialize(duration);
|
||||
// We don't want the timer to set pins because these often clash with motor shields etc.
|
||||
|
Loading…
Reference in New Issue
Block a user