Communication on both Serial 0/1
This commit is contained in:
parent
a82e886101
commit
ef04fadbae
|
@ -101,18 +101,35 @@ union ReceivedCommand_t {
|
|||
#define C_PIN 72
|
||||
#define D_PIN 71
|
||||
|
||||
#define LR_PIN 9
|
||||
#define MUTE_PIN 8
|
||||
#define LR_PIN 10
|
||||
#define MUTE_PIN 9
|
||||
#define BRIGHT_PIN 8
|
||||
|
||||
// "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
|
||||
|
||||
boolean dataAvailable(char &digit) {
|
||||
if (Serial1.available())
|
||||
{
|
||||
digit = Serial1.read(); // Read serial buffer
|
||||
return 1;
|
||||
}
|
||||
else if (Serial.available())
|
||||
{
|
||||
digit = Serial.read(); // Read serial buffer
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
pinMode(LR_PIN, INPUT_PULLUP);
|
||||
pinMode(MUTE_PIN, INPUT_PULLUP);
|
||||
pinMode(BRIGHT_PIN, INPUT_PULLUP);
|
||||
|
||||
CATDDR(ABCD_PORT) = 0xFF;
|
||||
CATDDR(LEFTDIGIT_PORT) = 0xFF;
|
||||
|
@ -127,7 +144,7 @@ void setup()
|
|||
|
||||
// Load system configuration
|
||||
cfg.BuzzerStatus = digitalRead(MUTE_PIN) ? BUZZER_ON : BUZZER_OFF;
|
||||
cfg.PanelSide = digitalRead(LR_PIN) ? LEFT : RIGHT;
|
||||
cfg.PanelSide = digitalRead(LR_PIN) ? LEFT : RIGHT;
|
||||
|
||||
// Communication w/PC for debug or other puroposes
|
||||
Serial.begin(9600);
|
||||
|
@ -141,14 +158,14 @@ void setup()
|
|||
void loop()
|
||||
{
|
||||
// A command is received
|
||||
if (Serial1.available())
|
||||
char digit;
|
||||
if (dataAvailable(digit))
|
||||
{
|
||||
/* ** Buffer to store received char **
|
||||
* Data is an integer string terminated with newline '\n'
|
||||
* */
|
||||
static String inputString = "";
|
||||
|
||||
char digit = Serial1.read(); // Read serial buffer
|
||||
// Check if string terminator
|
||||
if (digit == '\n')
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue