part 4
void power_OFF()
{
digitalWrite(ledPin,HIGH); // turns on LED
lcd_clear();
lcd_goto(0);
delay(10);
Serial.println("Power OFF ");
lcd_puts("Sending PWR OFF");
lcd_goto(40);
delay(10);
lcd_puts("..PLEASE WAIT.. ");
delay(1000);
proj_send(proj_powerOFF);
char feedback = mySerial.read();
Serial.println(feedback);
checkPower();
checkInput();
power_STATUS = 0;
timeoutReset();
digitalWrite(ledPin,LOW);
}
void input_PC()
{
digitalWrite(ledPin,HIGH); // turns on LED
lcd_clear();
lcd_goto(0);
delay(10);
lcd_puts("INPUT = PC ");
Serial.println("INPUT = PC");
proj_send(proj_inputPC);
char feedback = mySerial.read();
Serial.println(feedback);
inputPCReset = 0;
input_STATUS = 0;
timeoutReset();
digitalWrite(ledPin, LOW); // turns off LED
}
void input_DVD()
{
digitalWrite(ledPin,HIGH); // turns on LED
lcd_clear();
lcd_goto(0);
delay(10);
lcd_puts("Input DVD ");
Serial.println("INPUT DVD");
proj_send(proj_inputDVD);
char feedback = mySerial.read();
Serial.println(feedback);
inputDVDReset = 0;
input_STATUS = 1;
timeoutReset();
digitalWrite(ledPin, LOW); // turns off LED
}
void proj_send(char command[])
{
mySerial.print(command);
mySerial.print(execute);
}
void timeoutReset()
{
lastActivity = millis();
timeoutScreen = 1;
}
void setup()
{
lcd_init();
Serial.begin(9600);
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
mySerial.begin(9600);
// mySerial.print(clearBuffer);
}
void loop()
{
if (startup == 1)
{
menu_show(0);
delay(5000);
lastActivity = millis();
startup = 0;
}
if (millis() - lastActivity > timeout) // if current millis (milliseconds since boot) minus lastActivity is greater than timeout
{
if (timeoutScreen == 0)
{
//menu_show(1); // go to status screen
checkPower();
checkInput();
lastActivity = millis();
timeoutScreen = 1;
}
else
{
menu_show(0); // go to welcome screen
lastActivity = millis();
timeoutScreen = 0;
}
menu_current = menu_last;
}
statusUp = analogRead(menuUp); // reads the input of menuUp
statusDn = analogRead(menuDn); // reads the input of menuDn
statusSel = analogRead(menuSel); // reads the input of menuSel
statusPw = analogRead(powerSel); // reads the input of powerSel
statusPC = digitalRead(inputPC); // reads the input of inputPC
statusDVD = digitalRead(inputDVD); // reads the input of inputDVD
if (statusUp < hiReset)
menuUpReset = 1;
if (statusDn < hiReset)
menuDnReset = 1;
if (statusSel < hiReset)
menuSelReset = 1;
if (statusPC == 1)
inputPCReset = 1;
if (statusDVD == 1)
inputDVDReset = 1;
if (statusUp >= hiThreshold && menuUpReset == 1)
menu_prev();
if (statusDn >= hiThreshold && menuDnReset == 1)
menu_next();
if (statusSel >= hiThreshold && menuSelReset == 1)
menu_select(menu_option);
if (statusPw >= hiThreshold && power_STATUS != 1)
power_ON();
if (statusPw < lowThreshold && power_STATUS != 0)
power_OFF();
if (statusPC == 0 && input_STATUS != 0)
input_PC();
if (statusDVD == 0 && input_STATUS != 1)
input_DVD();
}
I know it's long... gives full user feedback via 16x2 lcd. Pictures tomorrow (hopefully)