From 099521a1606e285799c407049dcc6d2041e31029 Mon Sep 17 00:00:00 2001 From: "foley@ru.is" Date: Tue, 10 Sep 2013 15:20:36 +0000 Subject: [PATCH] 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. --- .../Synchronizer_Toshiba_SD590EKE.pde | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/dawn/Synchronizer_Toshiba_SD590EKE/Synchronizer_Toshiba_SD590EKE.pde b/dawn/Synchronizer_Toshiba_SD590EKE/Synchronizer_Toshiba_SD590EKE.pde index 1351ea8..f110c0b 100644 --- a/dawn/Synchronizer_Toshiba_SD590EKE/Synchronizer_Toshiba_SD590EKE.pde +++ b/dawn/Synchronizer_Toshiba_SD590EKE/Synchronizer_Toshiba_SD590EKE.pde @@ -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); }