mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-24 21:21:24 +01:00
Make last current available from API
Required for JMRI interface.
This commit is contained in:
parent
23f15131a8
commit
3a8c83afa6
@ -73,7 +73,6 @@ void DCCWaveform::setPowerMode(POWERMODE mode) {
|
|||||||
|
|
||||||
void DCCWaveform::checkPowerOverload() {
|
void DCCWaveform::checkPowerOverload() {
|
||||||
if (millis() < nextSampleDue) return;
|
if (millis() < nextSampleDue) return;
|
||||||
int current;
|
|
||||||
int delay;
|
int delay;
|
||||||
|
|
||||||
switch (powerMode) {
|
switch (powerMode) {
|
||||||
@ -82,11 +81,11 @@ void DCCWaveform::checkPowerOverload() {
|
|||||||
break;
|
break;
|
||||||
case POWERMODE::ON:
|
case POWERMODE::ON:
|
||||||
// Check current
|
// Check current
|
||||||
current = Hardware::getCurrentMilliamps(isMainTrack);
|
lastCurrent = Hardware::getCurrentMilliamps(isMainTrack);
|
||||||
if (current < POWER_SAMPLE_MAX) delay = POWER_SAMPLE_ON_WAIT;
|
if (lastCurrent < POWER_SAMPLE_MAX) delay = POWER_SAMPLE_ON_WAIT;
|
||||||
else {
|
else {
|
||||||
setPowerMode(POWERMODE::OVERLOAD);
|
setPowerMode(POWERMODE::OVERLOAD);
|
||||||
DIAG(F("\n*** %s TRACK POWER OVERLOAD current=%d max=%d ***\n"), isMainTrack ? "MAIN" : "PROG", current, POWER_SAMPLE_MAX);
|
DIAG(F("\n*** %s TRACK POWER OVERLOAD current=%d max=%d ***\n"), isMainTrack ? "MAIN" : "PROG", lastCurrent, POWER_SAMPLE_MAX);
|
||||||
delay = POWER_SAMPLE_OVERLOAD_WAIT;
|
delay = POWER_SAMPLE_OVERLOAD_WAIT;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -245,3 +244,7 @@ bool DCCWaveform::schedulePacketWithAck(const byte buffer[], byte byteCount, byt
|
|||||||
DIAG(F("ack=%d max=%d, up=%d"), result, maxCurrent, upsamples);
|
DIAG(F("ack=%d max=%d, up=%d"), result, maxCurrent, upsamples);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DCCWaveform::getLastCurrent() {
|
||||||
|
return lastCurrent;
|
||||||
|
}
|
||||||
|
@ -44,6 +44,7 @@ class DCCWaveform {
|
|||||||
void setPowerMode(POWERMODE);
|
void setPowerMode(POWERMODE);
|
||||||
POWERMODE getPowerMode();
|
POWERMODE getPowerMode();
|
||||||
void checkPowerOverload();
|
void checkPowerOverload();
|
||||||
|
int getLastCurrent();
|
||||||
void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
|
void schedulePacket(const byte buffer[], byte byteCount, byte repeats);
|
||||||
bool schedulePacketWithAck(const byte buffer[], byte byteCount, byte repeats);
|
bool schedulePacketWithAck(const byte buffer[], byte byteCount, byte repeats);
|
||||||
volatile bool packetPending;
|
volatile bool packetPending;
|
||||||
@ -72,6 +73,7 @@ class DCCWaveform {
|
|||||||
byte pendingPacket[MAX_PACKET_SIZE];
|
byte pendingPacket[MAX_PACKET_SIZE];
|
||||||
byte pendingLength;
|
byte pendingLength;
|
||||||
byte pendingRepeats;
|
byte pendingRepeats;
|
||||||
|
int lastCurrent;
|
||||||
|
|
||||||
|
|
||||||
// current sampling
|
// current sampling
|
||||||
|
Loading…
Reference in New Issue
Block a user