Move the second waiting and print into waitsec() function. Changed code to start by pausing the DVD twice with a short pause. Moved the play function to the beginning of the loop. Moved all the print operations into the functions that send the IR commands.
This commit is contained in:
@@ -47,35 +47,25 @@ void setup() {
|
||||
Serial.print(secs % 60);
|
||||
Serial.println("");
|
||||
|
||||
Serial.println("play");
|
||||
send_play();
|
||||
Serial.println("wait 7 seconds");
|
||||
delay(7000);
|
||||
|
||||
// The DVD player starts playing automatically, so we should pause it
|
||||
send_pause();
|
||||
waitsec(1);
|
||||
send_pause();
|
||||
waitsec(2);
|
||||
secs=playtime;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
void loop() {
|
||||
Serial.println("Sync");
|
||||
|
||||
Serial.println(" pause");
|
||||
send_pause();
|
||||
delay(2000);
|
||||
|
||||
Serial.println(" skip");
|
||||
send_previous();
|
||||
delay(2000);
|
||||
|
||||
Serial.println(" play");
|
||||
send_play();
|
||||
|
||||
|
||||
Serial.println("Sync");
|
||||
send_play();
|
||||
|
||||
for(int t = 0; t < playtime; t++) {
|
||||
// This will not give us perfect 1 second timing
|
||||
// but it is good enough for most video applications
|
||||
// The most critical is having everything start at the
|
||||
// same time.
|
||||
Serial.print("sec:");
|
||||
Serial.print(playtime);
|
||||
Serial.print(" / mm:ss ");
|
||||
@@ -86,29 +76,49 @@ void loop() {
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
send_pause();
|
||||
waitsec(1);
|
||||
|
||||
send_pause();
|
||||
waitsec(2);
|
||||
|
||||
send_previous();
|
||||
waitsec(5);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
void waitsec(int sec) {
|
||||
Serial.print("wait");
|
||||
Serial.print(sec);
|
||||
Serial.println("seconds");
|
||||
delay(sec*1000);
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************/
|
||||
void send_stop() {
|
||||
// First comes the pre-data bits, then the command code
|
||||
Serial.println(" stop");
|
||||
irsend.sendNEC(0xA25D28D7,32);
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
void send_play() {
|
||||
// First comes the pre-data bits, then the command code
|
||||
Serial.println(" play");
|
||||
irsend.sendNEC(0xA25DA857,32);
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
void send_pause() {
|
||||
// First comes the pre-data bits, then the command code
|
||||
Serial.println(" pause");
|
||||
irsend.sendNEC(0xA25D00FF, 32);
|
||||
}
|
||||
|
||||
/********************************************************************/
|
||||
void send_previous() {
|
||||
// First comes the pre-data bits, then the command code
|
||||
Serial.println(" previous");
|
||||
irsend.sendNEC(0xA25DC43B, 32);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user