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.print(secs % 60);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
|
||||||
Serial.println("play");
|
// The DVD player starts playing automatically, so we should pause it
|
||||||
send_play();
|
send_pause();
|
||||||
Serial.println("wait 7 seconds");
|
waitsec(1);
|
||||||
delay(7000);
|
send_pause();
|
||||||
|
waitsec(2);
|
||||||
secs=playtime;
|
secs=playtime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
void loop() {
|
void loop() {
|
||||||
Serial.println("Sync");
|
Serial.println("Sync");
|
||||||
|
send_play();
|
||||||
Serial.println(" pause");
|
|
||||||
send_pause();
|
|
||||||
delay(2000);
|
|
||||||
|
|
||||||
Serial.println(" skip");
|
|
||||||
send_previous();
|
|
||||||
delay(2000);
|
|
||||||
|
|
||||||
Serial.println(" play");
|
|
||||||
send_play();
|
|
||||||
|
|
||||||
|
|
||||||
for(int t = 0; t < playtime; t++) {
|
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("sec:");
|
||||||
Serial.print(playtime);
|
Serial.print(playtime);
|
||||||
Serial.print(" / mm:ss ");
|
Serial.print(" / mm:ss ");
|
||||||
@@ -86,29 +76,49 @@ void loop() {
|
|||||||
delay(1000);
|
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() {
|
void send_stop() {
|
||||||
// First comes the pre-data bits, then the command code
|
// First comes the pre-data bits, then the command code
|
||||||
|
Serial.println(" stop");
|
||||||
irsend.sendNEC(0xA25D28D7,32);
|
irsend.sendNEC(0xA25D28D7,32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
void send_play() {
|
void send_play() {
|
||||||
// First comes the pre-data bits, then the command code
|
// First comes the pre-data bits, then the command code
|
||||||
|
Serial.println(" play");
|
||||||
irsend.sendNEC(0xA25DA857,32);
|
irsend.sendNEC(0xA25DA857,32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
void send_pause() {
|
void send_pause() {
|
||||||
// First comes the pre-data bits, then the command code
|
// First comes the pre-data bits, then the command code
|
||||||
|
Serial.println(" pause");
|
||||||
irsend.sendNEC(0xA25D00FF, 32);
|
irsend.sendNEC(0xA25D00FF, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
void send_previous() {
|
void send_previous() {
|
||||||
// First comes the pre-data bits, then the command code
|
// First comes the pre-data bits, then the command code
|
||||||
|
Serial.println(" previous");
|
||||||
irsend.sendNEC(0xA25DC43B, 32);
|
irsend.sendNEC(0xA25DC43B, 32);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user