Traffic light

This commit is contained in:
giuliof 2019-04-25 16:16:49 +02:00
parent 0c1b2d4058
commit 8dff933150
1 changed files with 16 additions and 4 deletions

View File

@ -299,9 +299,15 @@ void loop()
digitalWrite(ORANGEP_PIN, ReceivedCommand.t.TrafficLightRight & _BV(1)); // orange right side
digitalWrite(REDP_PIN, ReceivedCommand.t.TrafficLightRight & _BV(2)); // red right side
#ifndef GOLEM_PANEL
CATPORT(TRAFLIGHT_PORT) = (ReceivedCommand.t.TrafficLightRight & _BV(0) ? 0b1001 << 2 : 0) |
(ReceivedCommand.t.TrafficLightRight & _BV(1) ? 0b1001 << 1 : 0) |
(ReceivedCommand.t.TrafficLightRight & _BV(2) ? 0b1001 << 0 : 0);
#else
CATPORT(TRAFLIGHT_PORT) = (ReceivedCommand.t.TrafficLightRight & _BV(0) ? 0b11 << 6 : 0) |
(ReceivedCommand.t.TrafficLightRight & _BV(1) ? 0b1001 << 2 : 0) |
(ReceivedCommand.t.TrafficLightRight & _BV(2) ? 0b11 << 3 : 0);
(ReceivedCommand.t.TrafficLightRight & _BV(1) ? 0b1001 << 2 : 0) |
(ReceivedCommand.t.TrafficLightRight & _BV(2) ? 0b11 << 3 : 0);
#endif
}
else
{
@ -309,9 +315,15 @@ void loop()
digitalWrite(ORANGEP_PIN, ReceivedCommand.t.TrafficLightLeft & _BV(1)); // orange left side
digitalWrite(REDP_PIN, ReceivedCommand.t.TrafficLightLeft & _BV(2)); // red left side
#ifndef GOLEM_PANEL
CATPORT(TRAFLIGHT_PORT) = (ReceivedCommand.t.TrafficLightLeft & _BV(0) ? 0b1001 << 2 : 0) |
(ReceivedCommand.t.TrafficLightLeft & _BV(1) ? 0b1001 << 1 : 0) |
(ReceivedCommand.t.TrafficLightLeft & _BV(2) ? 0b1001 << 0 : 0);
#else
CATPORT(TRAFLIGHT_PORT) = (ReceivedCommand.t.TrafficLightLeft & _BV(0) ? 0b11 << 6 : 0) |
(ReceivedCommand.t.TrafficLightLeft & _BV(1) ? 0b1001 << 2 : 0) |
(ReceivedCommand.t.TrafficLightLeft & _BV(2) ? 0b11 << 3 : 0);
(ReceivedCommand.t.TrafficLightLeft & _BV(1) ? 0b1001 << 2 : 0) |
(ReceivedCommand.t.TrafficLightLeft & _BV(2) ? 0b11 << 3 : 0);
#endif
}
// Set ABCD(EF)