mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-02-17 06:29:15 +01:00
smaller code
This commit is contained in:
parent
8a17965cd2
commit
43538d3b32
@ -958,18 +958,20 @@ void DCCEXParser::callback_R(int16_t result)
|
|||||||
commitAsyncReplyStream();
|
commitAsyncReplyStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCCEXParser::callback_Rloco(int16_t result)
|
void DCCEXParser::callback_Rloco(int16_t result) {
|
||||||
{
|
const FSH * detail;
|
||||||
if (result <= 0)
|
if (result<=0) {
|
||||||
StringFormatter::send(getAsyncReplyStream(), F("<r ERROR>\n"));
|
detail=F("<r ERROR %d>\n");
|
||||||
else if (result & LONG_ADDR_MARKER ) { //long addr
|
} else {
|
||||||
result = result & ~LONG_ADDR_MARKER;
|
bool longAddr=result & LONG_ADDR_MARKER; //long addr
|
||||||
if (result > HIGHEST_SHORT_ADDR) //real long
|
if (longAddr)
|
||||||
StringFormatter::send(getAsyncReplyStream(), F("<r %d>\n"), result);
|
result = result^LONG_ADDR_MARKER;
|
||||||
|
if (longAddr && result <= HIGHEST_SHORT_ADDR)
|
||||||
|
detail=F("<r LONG %d UNSUPPORTED>\n");
|
||||||
else
|
else
|
||||||
StringFormatter::send(getAsyncReplyStream(), F("<r LONG %d UNSUPPORTED>\n"), result);
|
detail=F("<r %d>\n");
|
||||||
} else // short addr
|
}
|
||||||
StringFormatter::send(getAsyncReplyStream(), F("<r %d>\n"), result);
|
StringFormatter::send(getAsyncReplyStream(), detail, result);
|
||||||
commitAsyncReplyStream();
|
commitAsyncReplyStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "RMFT2.h"
|
#include "RMFT2.h"
|
||||||
|
|
||||||
|
#define STR_HELPER(x) #x
|
||||||
|
#define STR(x) STR_HELPER(x)
|
||||||
|
|
||||||
#define LOOPLOCOS(THROTTLECHAR, CAB) for (int loco=0;loco<MAX_MY_LOCO;loco++) \
|
#define LOOPLOCOS(THROTTLECHAR, CAB) for (int loco=0;loco<MAX_MY_LOCO;loco++) \
|
||||||
if ((myLocos[loco].throttle==THROTTLECHAR || '*'==THROTTLECHAR) && (CAB<0 || myLocos[loco].cab==CAB))
|
if ((myLocos[loco].throttle==THROTTLECHAR || '*'==THROTTLECHAR) && (CAB<0 || myLocos[loco].cab==CAB))
|
||||||
@ -422,23 +424,25 @@ char WiThrottle::stashThrottleChar;
|
|||||||
void WiThrottle::getLocoCallback(int16_t locoid) {
|
void WiThrottle::getLocoCallback(int16_t locoid) {
|
||||||
stashStream->mark(stashClient);
|
stashStream->mark(stashClient);
|
||||||
|
|
||||||
char addrchar;
|
|
||||||
if (locoid & LONG_ADDR_MARKER) { // long addr
|
|
||||||
locoid = locoid & ~LONG_ADDR_MARKER;
|
|
||||||
addrchar = 'L';
|
|
||||||
} else
|
|
||||||
addrchar = 'S';
|
|
||||||
|
|
||||||
if (locoid<=0)
|
if (locoid<=0)
|
||||||
StringFormatter::send(stashStream,F("HMNo loco found on prog track\n"));
|
StringFormatter::send(stashStream,F("HMNo loco found on prog track\n"));
|
||||||
else if (addrchar == 'L' && locoid <= HIGHEST_SHORT_ADDR )
|
|
||||||
StringFormatter::send(stashStream,F("HMLong addr <= 127 not supported\n"));
|
|
||||||
else {
|
else {
|
||||||
char addcmd[20]={'M',stashThrottleChar,'+', addrchar};
|
// short or long
|
||||||
itoa(locoid,addcmd+4,10);
|
char addrchar;
|
||||||
stashInstance->multithrottle(stashStream, (byte *)addcmd);
|
if (locoid & LONG_ADDR_MARKER) { // long addr
|
||||||
DCCWaveform::progTrack.setPowerMode(POWERMODE::ON);
|
locoid = locoid ^ LONG_ADDR_MARKER;
|
||||||
DCC::setProgTrackSyncMain(true); // <1 JOIN> so we can drive loco away
|
addrchar = 'L';
|
||||||
|
} else
|
||||||
|
addrchar = 'S';
|
||||||
|
if (addrchar == 'L' && locoid <= HIGHEST_SHORT_ADDR )
|
||||||
|
StringFormatter::send(stashStream,F("HMLong addr <= " STR(HIGHEST_SHORT_ADDR) " not supported\n"));
|
||||||
|
else {
|
||||||
|
char addcmd[20]={'M',stashThrottleChar,'+', addrchar};
|
||||||
|
itoa(locoid,addcmd+4,10);
|
||||||
|
stashInstance->multithrottle(stashStream, (byte *)addcmd);
|
||||||
|
DCCWaveform::progTrack.setPowerMode(POWERMODE::ON);
|
||||||
|
DCC::setProgTrackSyncMain(true); // <1 JOIN> so we can drive loco away
|
||||||
|
}
|
||||||
}
|
}
|
||||||
stashStream->commit();
|
stashStream->commit();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user