1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-07-28 18:03:45 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Harald Barth
4790339a76 only update if changed 2021-11-15 18:09:34 +01:00
Harald Barth
f7861e5103 show current from main on LDC every 2 sec 2021-11-14 20:37:24 +01:00
3 changed files with 22 additions and 9 deletions

View File

@@ -34,6 +34,9 @@ int DCCWaveform::progTripValue=0;
volatile uint8_t DCCWaveform::numAckGaps=0;
volatile uint8_t DCCWaveform::numAckSamples=0;
uint8_t DCCWaveform::trailingEdgeCounter=0;
static unsigned long lastLCDCurrentDisplay=0;
#define LCD_SAMPLE_PERIOD 2000 // milliseconds
static uint16_t lastLCDCurrent=0xFFFF;
void DCCWaveform::begin(MotorDriver * mainDriver, MotorDriver * progDriver) {
mainTrack.motorDriver=mainDriver;
@@ -119,8 +122,9 @@ void DCCWaveform::setPowerMode(POWERMODE mode) {
void DCCWaveform::checkPowerOverload(bool ackManagerActive) {
if (millis() - lastSampleTaken < sampleDelay) return;
lastSampleTaken = millis();
unsigned long now = millis();
if (now - lastSampleTaken < sampleDelay) return;
lastSampleTaken = now;
int tripValue= motorDriver->getRawCurrentTripValue();
if (!isMainTrack && !ackManagerActive && !progTrackSyncMain && !progTrackBoosted)
tripValue=progTripValue;
@@ -181,6 +185,14 @@ void DCCWaveform::checkPowerOverload(bool ackManagerActive) {
default:
sampleDelay = 999; // cant get here..meaningless statement to avoid compiler warning.
}
if (isMainTrack && now - lastLCDCurrentDisplay > LCD_SAMPLE_PERIOD) {
lastLCDCurrentDisplay=now;
uint16_t c=mainTrack.getCurrentmA();
if (c != lastLCDCurrent) {
lastLCDCurrent=c;
LCD(2,F("I=%dmA"), c);
}
}
}
// For each state of the wave nextState=stateTransform[currentState]
const WAVE_STATE DCCWaveform::stateTransform[]={

View File

@@ -1 +1 @@
#define GITHUB_SHA "ee5db61"
#define GITHUB_SHA "LDC-show-current 2021114-20:14"

View File

@@ -50,12 +50,13 @@ void StringFormatter::lcd(byte row, const FSH* input...) {
va_list args;
// Issue the LCD as a diag first
send(diagSerial,F("<* LCD%d:"),row);
va_start(args, input);
send2(diagSerial,input,args);
send(diagSerial,F(" *>\n"));
if (!LCDDisplay::lcdDisplay) return;
if (!LCDDisplay::lcdDisplay) {
send(diagSerial,F("<* LCD%d:"),row);
va_start(args, input);
send2(diagSerial,input,args);
send(diagSerial,F(" *>\n"));
return;
}
LCDDisplay::lcdDisplay->setRow(row);
va_start(args, input);
send2(LCDDisplay::lcdDisplay,input,args);