Fixed pins and other stuff
This commit is contained in:
parent
dcd995f351
commit
171da65486
|
@ -43,7 +43,7 @@ struct cfg_t
|
|||
|
||||
struct trafficvalue_t
|
||||
{
|
||||
uint8_t cmd : 3;
|
||||
uint8_t cmd : 3; // < 0b111
|
||||
BuzzerStatus_t buzzer : 1;
|
||||
uint8_t TrafficLightLeft : 3;
|
||||
uint8_t TrafficLightRight : 3;
|
||||
|
@ -53,7 +53,7 @@ struct trafficvalue_t
|
|||
|
||||
struct statevalue_t
|
||||
{
|
||||
uint8_t cmd : 4;
|
||||
uint8_t cmd : 4; // = 0b1111
|
||||
uint8_t abcd : 3; // unclear meaning
|
||||
uint8_t competition : 3; // unclear meaning
|
||||
uint8_t : 3;
|
||||
|
@ -80,6 +80,7 @@ union ReceivedCommand_t {
|
|||
} ReceivedCommand;
|
||||
|
||||
#define DOTS_bm _BV(7)
|
||||
#define DOTS_PIN 23
|
||||
|
||||
#define ABCD_PORT A
|
||||
#define LEFTDIGIT_PORT K
|
||||
|
@ -92,14 +93,16 @@ union ReceivedCommand_t {
|
|||
#define ORANGEP_PIN 5
|
||||
#define GREENP_PIN 4
|
||||
|
||||
#define notA_PIN 78
|
||||
#define notB_PIN 77
|
||||
#define notC_PIN 76
|
||||
#define notD_PIN 75
|
||||
#define A_PIN 74
|
||||
#define B_PIN 73
|
||||
#define C_PIN 72
|
||||
#define D_PIN 71
|
||||
//#define notA_PIN 78
|
||||
//#define notB_PIN 77
|
||||
//#define notC_PIN 76
|
||||
//#define notD_PIN 75
|
||||
#define A_PIN 22
|
||||
#define B_PIN 24
|
||||
#define C_PIN 26
|
||||
#define D_PIN 27
|
||||
#define AC_PIN 25
|
||||
#define BD_PIN 28
|
||||
|
||||
#define LR_PIN 10
|
||||
#define MUTE_PIN 9
|
||||
|
@ -108,7 +111,8 @@ union ReceivedCommand_t {
|
|||
// "translation" for seven segment
|
||||
#define CHAR_P 15
|
||||
#define CHAR_DASH 10
|
||||
const uint8_t segment[16] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x40, 0x00, 0x3f, 0x00, 0x00, 0x73}; //0,1,2,3,4,5,6,7,8,9,-, , , , ,P
|
||||
//const uint8_t segment[16] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, 0x40, 0x00, 0x3f, 0x00, 0x00, 0x73}; //0,1,2,3,4,5,6,7,8,9,-, , , , ,P
|
||||
const uint8_t segment[16] = {0xbe, 0x82, 0x6e, 0xea, 0xd2, 0xf8, 0xfc, 0x8a, 0xfe, 0xfa, 0x40, 0x0, 0xbe, 0x0, 0x0, 0x5e}; //0,1,2,3,4,5,6,7,8,9,-, , , , ,P
|
||||
|
||||
boolean dataAvailable(char &digit) {
|
||||
if (Serial1.available())
|
||||
|
@ -185,16 +189,16 @@ void loop()
|
|||
CATPORT(MIDDIGIT_PORT) = segment[ReceivedCommand.d.mDigit];
|
||||
CATPORT(RIGHTDIGIT_PORT) = segment[ReceivedCommand.d.rDigit];
|
||||
// Turn on dot between minutes and seconds only if count is in minutes and its digit is a representable value (not dash)
|
||||
CATPORT(LEFTDIGIT_PORT) = segment[ReceivedCommand.d.lDigit];
|
||||
|
||||
if (ReceivedCommand.d.lDigit != CHAR_DASH && ReceivedCommand.d.minutes)
|
||||
{
|
||||
CATPORT(LEFTDIGIT_PORT) = segment[ReceivedCommand.d.lDigit] | DOTS_bm;
|
||||
}
|
||||
digitalWrite(DOTS_PIN, HIGH);
|
||||
else
|
||||
CATPORT(LEFTDIGIT_PORT) = segment[ReceivedCommand.d.lDigit];
|
||||
digitalWrite(DOTS_PIN, LOW);
|
||||
}
|
||||
}
|
||||
// Parsing of TRAFFIC command
|
||||
else if (ReceivedCommand.t.cmd < 0b111)
|
||||
else if (ReceivedCommand.t.cmd == 0b111)
|
||||
{
|
||||
// Set buzzer depending on mute switch
|
||||
if (cfg.BuzzerStatus == BUZZER_ON)
|
||||
|
@ -205,22 +209,32 @@ void loop()
|
|||
// Set Traffic lights depending on side switch
|
||||
if (cfg.PanelSide == RIGHT)
|
||||
{
|
||||
digitalWrite(GREENP_PIN, ReceivedCommand.t.TrafficLightRight | _BV(0)); // green right side
|
||||
digitalWrite(ORANGEP_PIN, ReceivedCommand.t.TrafficLightRight | _BV(1)); // orange right side
|
||||
digitalWrite(REDP_PIN, ReceivedCommand.t.TrafficLightRight | _BV(2)); // red right side
|
||||
digitalWrite(GREENP_PIN, ReceivedCommand.t.TrafficLightRight & _BV(0)); // green right side
|
||||
digitalWrite(ORANGEP_PIN, ReceivedCommand.t.TrafficLightRight & _BV(1)); // orange right side
|
||||
digitalWrite(REDP_PIN, ReceivedCommand.t.TrafficLightRight & _BV(2)); // red right side
|
||||
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(GREENP_PIN, ReceivedCommand.t.TrafficLightLeft | _BV(0)); // green left side
|
||||
digitalWrite(ORANGEP_PIN, ReceivedCommand.t.TrafficLightLeft | _BV(1)); // orange left side
|
||||
digitalWrite(REDP_PIN, ReceivedCommand.t.TrafficLightLeft | _BV(2)); // red left side
|
||||
digitalWrite(GREENP_PIN, ReceivedCommand.t.TrafficLightLeft & _BV(0)); // green left side
|
||||
digitalWrite(ORANGEP_PIN, ReceivedCommand.t.TrafficLightLeft & _BV(1)); // orange left side
|
||||
digitalWrite(REDP_PIN, ReceivedCommand.t.TrafficLightLeft & _BV(2)); // red left side
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Set ABCD(EF)
|
||||
digitalWrite(A_PIN, ReceivedCommand.t.ArcherGroups | _BV(0)); //A
|
||||
digitalWrite(B_PIN, ReceivedCommand.t.ArcherGroups | _BV(1)); //B
|
||||
digitalWrite(C_PIN, ReceivedCommand.t.ArcherGroups | _BV(2)); //C
|
||||
digitalWrite(D_PIN, ReceivedCommand.t.ArcherGroups | _BV(3)); //D
|
||||
digitalWrite(A_PIN, ReceivedCommand.t.ArcherGroups & _BV(0) ); //A
|
||||
digitalWrite(B_PIN, ReceivedCommand.t.ArcherGroups & _BV(1) ); //B
|
||||
digitalWrite(C_PIN, ReceivedCommand.t.ArcherGroups & _BV(2) ); //C
|
||||
digitalWrite(D_PIN, ReceivedCommand.t.ArcherGroups & _BV(3) ); //D
|
||||
digitalWrite(AC_PIN, ReceivedCommand.t.ArcherGroups & (_BV(0) | _BV(2))); //AC
|
||||
digitalWrite(BD_PIN, ReceivedCommand.t.ArcherGroups & (_BV(1) | _BV(3))); //BD
|
||||
// EF not implemented in this hardware
|
||||
/*
|
||||
digitalWrite(6, (((statevalue >> 7) & B00000111) != 2) and (trafficvalue & 0x4000)); //E
|
||||
|
@ -230,7 +244,7 @@ void loop()
|
|||
*/
|
||||
|
||||
// Set not{A,B,C,D,(E,F)}
|
||||
if (cfg.abcd != 6)
|
||||
/*if (cfg.abcd != 6)
|
||||
{
|
||||
uint8_t notABCD_on = 0;
|
||||
// not A is on if archer group A is not selected
|
||||
|
@ -249,12 +263,6 @@ void loop()
|
|||
digitalWrite(notC_PIN, LOW);
|
||||
digitalWrite(notD_PIN, LOW);
|
||||
}
|
||||
|
||||
// EF not implemented in this hardware
|
||||
/*
|
||||
digitalWrite(8, (((((statevalue >> 13) & B00000111) < 4) ? LOW : HIGH) and ((((statevalue >> 7) & B00000111) == 2) ? LOW : HIGH) and ((((statevalue >> 7) & B00000111) == 4) ? LOW : HIGH) and (not(trafficvalue & 0x4000) ? HIGH : LOW))); //notE. Is on if Archer E exist but it is not his/her turn to shoot
|
||||
digitalWrite(9, (((((statevalue >> 13) & B00000111) < 5) ? LOW : HIGH) and ((((statevalue >> 7) & B00000111) == 2) ? LOW : HIGH) and ((((statevalue >> 7) & B00000111) == 4) ? LOW : HIGH) and (not(trafficvalue & 0x8000) ? HIGH : LOW))); //notF. Is on if Archer F exist but it is not his/her turn to shoot
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -262,13 +270,7 @@ void loop()
|
|||
digitalWrite(notB_PIN, HIGH);
|
||||
digitalWrite(notC_PIN, HIGH);
|
||||
digitalWrite(notD_PIN, HIGH);
|
||||
|
||||
// EF not implemented in this hardware
|
||||
/*
|
||||
digitalWrite(8, (blinkl));
|
||||
digitalWrite(9, (blinkl));
|
||||
*/
|
||||
}
|
||||
}*/
|
||||
}
|
||||
// Parsing of STATE command
|
||||
else if (ReceivedCommand.s.cmd == 0b1111)
|
||||
|
|
Loading…
Reference in New Issue