khikago
5
void SerialOpen(String Message)
{
int firstComma = Message.indexOf(',');
String sPort = Message.substring(0, firstComma);
String sBaud;
int nBaud;
if (sPort != "1" && sPort != "2")
{
Serial.print("Invalid Serial Command");
}
else
{
Message.remove(0, firstComma + 1);
sBaud = Message;
nBaud = sBaud.toInt();
sPort == "1" ? Serial1.begin(nBaud) : Serial2.begin(nBaud);
sPort == "1" ? Serial.println("sPort = 1, sBaud = " + sBaud) : Serial.println("sPort = 2, sBaud = " + sBaud);
}
}
void SerialClose(String Message)
{
int firstComma = Message.indexOf(',');
String sPort = Message.substring(0, firstComma);
String sBaud;
int nBaud;
if (sPort != "1" && sPort != "2")
{
Serial.print("Invalid Serial Command");
}
else
{
sPort == "1" ? Serial1.end() : Serial2.end();
sPort == "1" ? Serial.println("sPort = 1 closed") : Serial.println("sPort = 2 closed");
}
}
void FlashingFunction(bool LED_Flash1, bool LED_Flash2, bool LED_Flash3)
{
unsigned long currentMillis = millis();
for (int i = 1 ; i <= 3 ; i++)
{
if (currentMillis - previousMillis >= interval)
{
// save the last time you blinked the LED
previousMillis = currentMillis;
if (LED_Flash1 == true)
{
ledState1 == LOW ? ledState1 = HIGH : ledState1 = LOW;
digitalWrite(LED_1, ledState1);
}
if (LED_Flash2 == true)
{
ledState2 == LOW ? ledState2 = HIGH : ledState2 = LOW;
digitalWrite(LED_2, ledState2);
}
if (LED_Flash3 == true)
{
ledState3 == LOW ? ledState3 = HIGH : ledState3 = LOW;
digitalWrite(LED_3, ledState3);
}
}
}
}
void Test(String s_test)
{
Serial1.print(s_test);
}