mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-07-28 09:53:45 +02:00
Virtual LCD phase 1
This commit is contained in:
@@ -105,6 +105,7 @@ void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream
|
||||
void CommandDistributor::forget(byte clientId) {
|
||||
if (clients[clientId]==WITHROTTLE_TYPE) WiThrottle::forget(clientId);
|
||||
clients[clientId]=NONE_TYPE;
|
||||
if (virtualLCDClient==clientId) virtualLCDClient=RingStream::NO_CLIENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -280,3 +281,51 @@ void CommandDistributor::broadcastRouteState(uint16_t routeId, byte state ) {
|
||||
void CommandDistributor::broadcastRouteCaption(uint16_t routeId, const FSH* caption ) {
|
||||
broadcastReply(COMMAND_TYPE, F("<jB %d \"%S\">\n"),routeId,caption);
|
||||
}
|
||||
|
||||
Print * CommandDistributor::getVirtualLCDSerial(byte screen, byte row) {
|
||||
Print * stream=virtualLCDSerial;
|
||||
#ifdef CD_HANDLE_RING
|
||||
rememberVLCDClient=RingStream::NO_CLIENT;
|
||||
if (!stream && virtualLCDClient!=RingStream::NO_CLIENT) {
|
||||
// If we are broadcasting from a wifi/eth process we need to complete its output
|
||||
// before merging broadcasts in the ring, then reinstate it in case
|
||||
// the process continues to output to its client.
|
||||
if ((rememberVLCDClient = ring->peekTargetMark()) != RingStream::NO_CLIENT) {
|
||||
ring->commit();
|
||||
}
|
||||
ring->mark(virtualLCDClient);
|
||||
stream=ring;
|
||||
}
|
||||
#endif
|
||||
if (stream) StringFormatter::send(stream,F("<@ %d %d \""), screen,row);
|
||||
return stream;
|
||||
}
|
||||
|
||||
void CommandDistributor::commitVirtualLCDSerial() {
|
||||
#ifdef CD_HANDLE_RING
|
||||
if (virtualLCDClient!=RingStream::NO_CLIENT) {
|
||||
StringFormatter::send(ring,F("\">\n"));
|
||||
ring->commit();
|
||||
if (rememberVLCDClient!=RingStream::NO_CLIENT) ring->mark(rememberVLCDClient);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
StringFormatter::send(virtualLCDSerial,F("\">\n"));
|
||||
}
|
||||
|
||||
void CommandDistributor::setVirtualLCDSerial(Print * stream) {
|
||||
#ifdef CD_HANDLE_RING
|
||||
virtualLCDClient=RingStream::NO_CLIENT;
|
||||
if (stream && stream->availableForWrite()==RingStream::THIS_IS_A_RINGSTREAM) {
|
||||
virtualLCDClient=((RingStream *) stream)->peekTargetMark();
|
||||
virtualLCDSerial=nullptr;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
virtualLCDSerial=stream;
|
||||
}
|
||||
|
||||
Print* CommandDistributor::virtualLCDSerial=nullptr;
|
||||
byte CommandDistributor::virtualLCDClient=0xFF;
|
||||
byte CommandDistributor::rememberVLCDClient=0;
|
||||
|
||||
|
Reference in New Issue
Block a user