unified the code to use the Time and TimeAlarm libraries. This simplifies the code greatly and should improve the accuracy.

This commit is contained in:
foley@ru.is
2014-01-15 02:33:44 +00:00
parent 75bd4dcb42
commit ffc3610c00
7 changed files with 403 additions and 281 deletions

View File

@@ -10,31 +10,28 @@ const String SVN_ID="$Id$";
* Streaming http://arduiniana.org/libraries/streaming/
* Time http://www.pjrc.com/teensy/td_libs_Time.html
* TimeAlarms http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
*
* Useful information at http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
* More codes at http://www.lirc.org/
* This uses remote Sony RMT-B122P
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*
*
*/
#include <IRremote.h>
#include <Streaming.h>
#include <Time.h>
#include <TimeAlarms.h>
// IR LED pin 3 should be longer
// IR LED pin 3 should be the longer leg
int pinGND=4; // Shorter leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int secs;
int heartbeat_state=0;
String INST_NAME="Trajectories";
String ARTIST="Sigurdur Gudjonsson (video) & Anna Thorvaldsdottir (sound)";
String YEAR="2014";
//int videotime = 14*60+44; // set here your DVD title playtime in seconds
int videotime = 5*60; // set here your DVD title playtime in sec
// Fill this information in so that it will be easy to identify later
String INST_NAME="<TITLE>";
String ARTIST="<ARTIST>";
String YEAR="<YEAR>";
int videotime = 1*60+1; // set here your DVD title playtime in seconds
int choptime = 3; // how much to chop at the end if the videos are
// not exactly the same length
int playtime = videotime - choptime;
@@ -42,10 +39,10 @@ int resetdelay = 3; // seconds from reset to playing from beginning
IRsend irsend;
int alarm_bell = false;
int heartbeat_state=0;
void showtime(int secs) {
Serial << "sec:" << secs << " / mm:ss " << secs/60 << ":" << secs % 60 << endl;
}
void showtime(int secs) { Serial << "sec:" << secs << " / mm:ss " << secs/60 << ":" << secs % 60 << endl; }
void trigger_sync() { alarm_bell = true; }
void setup() {
pinMode(pinGND,OUTPUT);
@@ -59,14 +56,10 @@ void setup() {
Serial << SVN_URL << endl << SVN_ID << endl;
Serial << "Playtime: " << playtime << endl;
sync();
showtime(playtime);
Alarm.timerRepeat(playtime, trigger_sync);
}
void trigger_sync() {
alarm_bell = true;
}
/********************************************************************/
void loop() {
if (alarm_bell == true) {
@@ -92,8 +85,8 @@ void sync() {
Serial << "Sync" << endl;
//send_pause();
//waitsec(resetdelay);
send_previous();
showtime(playtime);
}
/**************************************************************/
@@ -130,6 +123,6 @@ void send_pause() {
/********************************************************************/
void send_previous() {
// First comes the pre-data bits, then the command code
Serial.println(" previous");
Serial << " previous" << endl;
irsend.sendSony(0xEAB47,20);
}

View File

@@ -1,13 +1,17 @@
/* DVD IR Synchronizer for Philips DVP3142/12
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
*
const String DESCRIPTION="IR Synchronizer for Philips DVP3142/12";
const String AUTHOR="Joe Foley <foley@ru.is>";
const String SVN_REVISION="$Rev$";
const String SVN_URL="$URL$";
const String SVN_ID="$Id$";
/* Code written by Joe Foley <foley@ru.is> on 2013-09-08
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
* Instructions http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
* Streaming http://arduiniana.org/libraries/streaming/
* Time http://www.pjrc.com/teensy/td_libs_Time.html
* TimeAlarms http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
*
* IR Remote codes from IRrecvDemo
* Instructions http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
*
* Details on the Philips RC6 coding
* http://www.pcbheaven.com/userpages/The_Philips_RC6_Protocol/
@@ -16,47 +20,74 @@
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
#include <Streaming.h>
#include <Time.h>
#include <TimeAlarms.h>
// IR LED pin 3 should be the longer leg
int pinGND=4; // Shorter leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int heartbeat=0;
int secs;
int playtime=1*60+1; // Play time in seconds, you usually leave off a second or two
// Fill this information in so that it will be easy to identify later
String INST_NAME="<TITLE>";
String ARTIST="<ARTIST>";
String YEAR="<YEAR>";
int videotime = 1*60+1; // set here your DVD title playtime in seconds
int choptime = 3; // how much to chop at the end if the videos are
// not exactly the same length
int playtime = videotime - choptime;
int resetdelay = 3; // seconds from reset to playing from beginning
IRsend irsend;
int alarm_bell = false;
int heartbeat_state=0;
void showtime(int secs) { Serial << "sec:" << secs << " / mm:ss " << secs/60 << ":" << secs % 60 << endl;}
void trigger_sync() { alarm_bell = true; }
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
setTime(23,15,16,1,14,14); // set time to 23:15:16 Jan 14 2014
Serial.println("Panasonic DVD DVP-3142/12 Synchronizer $Rev$");
Serial.println("For \"$INSTALLATION NAME$\" by $ARTIST$ ($YEAR$)");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
Serial << DESCRIPTION << " " << SVN_REVISION << endl;
Serial << "Code by " << AUTHOR << endl;
Serial << "For \""<< INST_NAME << "\" by "<< ARTIST <<"(" << YEAR << ")" << endl;
Serial << SVN_URL << endl << SVN_ID << endl;
Serial << "Playtime: " << playtime << endl;
sync();
showtime(playtime);
secs=playtime;
Alarm.timerRepeat(playtime, trigger_sync);
send_play();
}
/********************************************************************/
void loop() {
Serial.println("Sync");
if (alarm_bell == true) {
sync();
alarm_bell = false;
}
heartbeat();
}
void heartbeat() {
if (heartbeat_state == 1) {
digitalWrite(pinLED, HIGH);
heartbeat_state = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat_state = 1;
}
Alarm.delay(1000);
}
void sync() {
Serial << "Sync" << endl;
//send_pause();
//waitsec(2);
//waitsec(resetdelay);
// The three players don't always see the "previous command" so we send it multiple times
send_previous();
@@ -66,58 +97,34 @@ void loop() {
// Don't send play because previous automatically starts it
// If we hit play it will merely pause it.
//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 ");
Serial.print(t/60);
Serial.print(":");
Serial.print(t % 60);
Serial.println("");
if (heartbeat == 1) {
digitalWrite(pinLED, HIGH);
heartbeat = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat = 1;
}
delay(1000);
}
}
/**************************************************************/
void waitsec(int sec) {
Serial.print("Wait ");
Serial.print(sec);
Serial.println(" seconds");
delay(sec*1000);
}
/**************************************************************/
void waitsec(int sec) {
Serial << "Wait " << sec << " seconds" << endl;
Alarm.delay(sec*1000);
}
/********************************************************************/
void send_stop() {
// First comes the pre-data bits, then the command code
Serial.println(" stop");
Serial << " stop" << endl;
irsend.sendRC6(0x10431,20);
}
/********************************************************************/
void send_play() {
// First comes the pre-data bits, then the command code
Serial.println(" play");
Serial << " play" << endl;
irsend.sendRC6(0x1042C,20);
}
/********************************************************************/
void send_pause() {
// First comes the pre-data bits, then the command code
Serial << " step/pause" << endl;
Serial.println(" pause");
irsend.sendRC6(0x1042C,20);
}

View File

@@ -1,60 +1,97 @@
/* DVD IR Synchronizer for Philips DVP3142/12
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
*
const String DESCRIPTION="IR Synchronizer for Scott DVX605 HD(Rev2)";
const String AUTHOR="Joe Foley <foley@ru.is>";
const String SVN_REVISION="$Rev$";
const String SVN_URL="$URL$";
const String SVN_ID="$Id$";
/* Code written by Joe Foley <foley@ru.is> on 2013-09-08
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
* Streaming http://arduiniana.org/libraries/streaming/
* Time http://www.pjrc.com/teensy/td_libs_Time.html
* TimeAlarms http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
*
* Instructions http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
*
* IR Remote codes from IRrecvDemo
* Details on the Philips RC6 coding
* http://www.pcbheaven.com/userpages/The_Philips_RC6_Protocol/
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
#include <Streaming.h>
#include <Time.h>
#include <TimeAlarms.h>
// IR LED pin 3 should be the longer leg
int pinGND=4; // Shorter leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int heartbeat=0;
int secs;
int playtime= 1*60+1; // Play time in seconds, you usually leave off a second or two
// Fill this information in so that it will be easy to identify later
String INST_NAME="<TITLE>";
String ARTIST="<ARTIST>";
String YEAR="<YEAR>";
int videotime = 1*60+1; // set here your DVD title playtime in seconds
int choptime = 3; // how much to chop at the end if the videos are
// not exactly the same length
int playtime = videotime - choptime;
int resetdelay = 3; // seconds from reset to playing from beginning
IRsend irsend;
int alarm_bell = false;
int heartbeat_state=0;
void showtime(int secs) {
Serial << "sec:" << secs << " / mm:ss " << secs/60 << ":" << secs % 60 << endl;
}
void trigger_sync() { alarm_bell = true; }
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
setTime(23,15,16,1,14,14); // set time to 23:15:16 Jan 14 2014
Serial.println("Scott DVX605 HD(Rev2) Synchronizer $Rev$");
Serial.println("For \"$INSTALLATION NAME$\" by $ARTIST$ ($YEAR$)");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
secs=playtime;
Serial << DESCRIPTION << " " << SVN_REVISION << endl;
Serial << "Code by " << AUTHOR << endl;
Serial << "For \""<< INST_NAME << "\" by "<< ARTIST <<"(" << YEAR << ")" << endl;
Serial << SVN_URL << endl << SVN_ID << endl;
Serial << "Playtime: " << playtime << endl;
sync();
showtime(playtime);
Alarm.timerRepeat(playtime, trigger_sync);
send_play();
}
/********************************************************************/
void loop() {
Serial.println("Sync");
//send_pause();
//waitsec(2);
if (alarm_bell == true) {
sync();
alarm_bell = false;
}
heartbeat();
}
void heartbeat() {
if (heartbeat_state == 1) {
digitalWrite(pinLED, HIGH);
heartbeat_state = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat_state = 1;
}
Alarm.delay(1000);
}
void sync() {
Serial << "Sync" << endl;
//send_pause();
//waitsec(resetdelay);
// The three players don't always see the "previous command" so we send it multiple times
send_previous();
send_previous();
send_previous();
@@ -62,40 +99,15 @@ void loop() {
// Don't send play because previous automatically starts it
// If we hit play it will merely pause it.
//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 ");
Serial.print(t/60);
Serial.print(":");
Serial.print(t % 60);
Serial.println("");
if (heartbeat == 1) {
digitalWrite(pinLED, HIGH);
heartbeat = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat = 1;
}
delay(1000);
}
}
/**************************************************************/
void waitsec(int sec) {
Serial.print("Wait ");
Serial.print(sec);
Serial.println(" seconds");
delay(sec*1000);
}
/**************************************************************/
void waitsec(int sec) {
Serial << "Wait " << sec << " seconds" << endl;
Alarm.delay(sec*1000);
}
/********************************************************************/
void send_stop() {

View File

@@ -1,102 +1,111 @@
/* DVD IR Synchronizer for Toshiba SD1091EKE
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
const String DESCRIPTION="IR Synchronizer for Philips Toshiba SD1091EKE";
const String AUTHOR="Joe Foley <foley@ru.is>";
const String SVN_REVISION="$Rev$";
const String SVN_URL="$URL$";
const String SVN_ID="$Id$";
/* Code written by Joe Foley <foley@ru.is> on 2013-09-08
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
* Streaming http://arduiniana.org/libraries/streaming/
* Time http://www.pjrc.com/teensy/td_libs_Time.html
* TimeAlarms http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
*
* More codes at http://www.lirc.org/
* The compatible remote is SE-R0301
* We use the codes for the SE-R0031
* http://lirc.sourceforge.net/remotes/toshiba/SE-R0031
* Note that this has some similar codes
* Instructions http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
*
* Details on the Philips RC6 coding
* http://www.pcbheaven.com/userpages/The_Philips_RC6_Protocol/
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*
*
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
#include <Streaming.h>
#include <Time.h>
#include <TimeAlarms.h>
// IR LED pin 3 should be the longer leg
int pinGND=4; // Shorter leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int secs;
int heartbeat=0;
int playtime= 1*60+1; // set here your DVD title playtime in sec leave a little extra
// Fill this information in so that it will be easy to identify later
String INST_NAME="<TITLE>";
String ARTIST="<ARTIST>";
String YEAR="<YEAR>";
int videotime = 1*60+1; // set here your DVD title playtime in seconds
int choptime = 3; // how much to chop at the end if the videos are
// not exactly the same length
int playtime = videotime - choptime;
int resetdelay = 3; // seconds from reset to playing from beginning
IRsend irsend;
int alarm_bell = false;
int heartbeat_state=0;
void showtime(int secs) { Serial << "sec:" << secs << " / mm:ss " << secs/60 << ":" << secs % 60 << endl; }
void trigger_sync() { alarm_bell = true; }
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
setTime(23,15,16,1,14,14); // set time to 23:15:16 Jan 14 2014
Serial << DESCRIPTION << " " << SVN_REVISION << endl;
Serial << "Code by " << AUTHOR << endl;
Serial << "For \""<< INST_NAME << "\" by "<< ARTIST <<"(" << YEAR << ")" << endl;
Serial << SVN_URL << endl << SVN_ID << endl;
Serial << "Playtime: " << playtime << endl;
sync();
showtime(playtime);
Serial.println("Toshiba DVD SD1091EKE Synchronizer $Rev$");
Serial.println("For \"$INSTALLATION NAME$\" by $ARTIST$ ($YEAR$)");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
secs=playtime;
Alarm.timerRepeat(playtime, trigger_sync);
send_play();
}
/********************************************************************/
void loop() {
Serial.println("Sync");
// The DVD player starts playing automatically, so we should pause it
send_pause();
waitsec(2);
if (alarm_bell == true) {
sync();
alarm_bell = false;
}
heartbeat();
}
send_previous();
// on this model, previous immediately starts playing
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 ");
Serial.print(t/60);
Serial.print(":");
Serial.print(t % 60);
Serial.println("");
if (heartbeat == 1) {
void heartbeat() {
if (heartbeat_state == 1) {
digitalWrite(pinLED, HIGH);
heartbeat = 0;
heartbeat_state = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat = 1;
heartbeat_state = 1;
}
delay(1000);
Alarm.delay(1000);
}
void sync() {
Serial << "Sync" << endl;
//send_pause();
//waitsec(resetdelay);
// The three players don't always see the "previous command" so we send it multiple times
send_previous();
send_previous();
send_previous();
//waitsec(2);
// Don't send play because previous automatically starts it
// If we hit play it will merely pause it.
//send_play();
}
/**************************************************************/
void waitsec(int sec) {
Serial.print("Wait ");
Serial.print(sec);
Serial.println(" seconds");
delay(sec*1000);
}
/**************************************************************/
void waitsec(int sec) {
Serial << "Wait " << sec << " seconds" << endl;
Alarm.delay(sec*1000);
}
/********************************************************************/
// NEC data format: first comes the pre-data bits, then the command code

View File

@@ -1,89 +1,99 @@
/* DVD IR Synchronizer for Toshiba SD590EKE
* Code written by Joe Foley <foley@ru.is>
* on 2013-09-08
const String DESCRIPTION="IR Synchronizer for Philips DVP3142/12";
const String AUTHOR="Joe Foley <foley@ru.is>";
const String SVN_REVISION="$Rev$";
const String SVN_URL="$URL$";
const String SVN_ID="$Id$";
/* Code written by Joe Foley <foley@ru.is> on 2013-09-08
*
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
* Streaming http://arduiniana.org/libraries/streaming/
* Time http://www.pjrc.com/teensy/td_libs_Time.html
* TimeAlarms http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
*
* IR Remote codes from SE-R0313
* http://lirc.sourceforge.net/remotes/toshiba/SE-R0313
* Instructions http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
*
* Details on the Philips RC6 coding
* http://www.pcbheaven.com/userpages/The_Philips_RC6_Protocol/
*
* The IRremote library uses Pin 3 for the Anode (longer pin)
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
*/
#include <IRremote.h>
int pinGND=4; // Longer leg on the IR LED
#include <Streaming.h>
#include <Time.h>
#include <TimeAlarms.h>
// IR LED pin 3 should be the longer leg
int pinGND=4; // Shorter leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int heartbeat=0;
int secs;
int playtime= 1*60+1; // set here your DVD title playtime in sec leave a little extra
// Fill this information in so that it will be easy to identify later
String INST_NAME="<TITLE>";
String ARTIST="<ARTIST>";
String YEAR="<YEAR>";
int videotime = 1*60+1; // set here your DVD title playtime in seconds
int choptime = 3; // how much to chop at the end if the videos are
// not exactly the same length
int playtime = videotime - choptime;
int resetdelay = 2; // seconds from reset to playing from beginning
IRsend irsend;
int alarm_bell = false;
int heartbeat_state=0;
void showtime(int secs) { Serial << "sec:" << secs << " / mm:ss " << secs/60 << ":" << secs % 60 << endl; }
void trigger_sync() { alarm_bell = true; }
void setup() {
pinMode(pinGND,OUTPUT);
pinMode(pinLED,OUTPUT);
Serial.begin(115200);
setTime(23,15,16,1,14,14); // set time to 23:15:16 Jan 14 2014
Serial.println("Toshiba DVD SD590EKE Synchronizer $Rev$");
Serial.println("For \"$INSTALLATION NAME$\" by $ARTIST$ ($YEAR$)");
Serial.println("Code by Joe Foley <foley@ru.is>");
Serial.println("$URL$");
Serial.println("$Id$");
Serial.print("Playtime: ");
secs=playtime;
Serial.print("sec:");
Serial.print(secs);
Serial.print(" / mm:ss ");
Serial.print(secs/60);
Serial.print(":");
Serial.print(secs % 60);
Serial.println("");
// The DVD player starts playing automatically, so maybe we should pause it
//send_pause();
//waitsec(2);
secs=playtime;
Serial << DESCRIPTION << " " << SVN_REVISION << endl;
Serial << "Code by " << AUTHOR << endl;
Serial << "For \""<< INST_NAME << "\" by "<< ARTIST <<"(" << YEAR << ")" << endl;
Serial << SVN_URL << endl << SVN_ID << endl;
Serial << "Playtime: " << playtime << endl;
sync();
showtime(playtime);
Alarm.timerRepeat(playtime, trigger_sync);
send_play();
}
/********************************************************************/
void loop() {
Serial.println("Sync");
send_pause();
waitsec(2);
send_previous();
//waitsec(2);
if (alarm_bell == true) {
sync();
alarm_bell = false;
}
heartbeat();
}
//send_play(); // this should not be necessary, but just in case
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 ");
Serial.print(t/60);
Serial.print(":");
Serial.print(t % 60);
Serial.println("");
if (heartbeat == 1) {
void heartbeat() {
if (heartbeat_state == 1) {
digitalWrite(pinLED, HIGH);
heartbeat = 0;
heartbeat_state = 0;
}
else {
digitalWrite(pinLED, LOW);
heartbeat = 1;
heartbeat_state = 1;
}
delay(1000);
Alarm.delay(1000);
}
void sync() {
Serial << "Sync" << endl;
send_pause();
waitsec(resetdelay);
send_previous();
//waitsec(2);
// Don't send play because previous automatically starts it
// If we hit play it will merely pause it.
//send_play();
}
/**************************************************************/

View File

@@ -8,6 +8,8 @@ const String SVN_ID="$Id$";
* Requires libraries:
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
* Streaming http://arduiniana.org/libraries/streaming/
* Time http://www.pjrc.com/teensy/td_libs_Time.html
* TimeAlarms http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
* More codes at http://www.lirc.org/
* This uses remote Sony RMT-B122P
*
@@ -21,7 +23,8 @@ const String SVN_ID="$Id$";
#include <Streaming.h>
#include <Time.h>
#include <TimeAlarms.h>
int pinGND=4; // Longer leg on the IR LED
// IR LED pin 3 should be longer
int pinGND=4; // Shorter leg on the IR LED
int pinLED=13; // The heartbeat LED on the board
int secs;
@@ -30,15 +33,17 @@ int heartbeat_state=0;
String INST_NAME="Trajectories";
String ARTIST="Sigurdur Gudjonsson (video) & Anna Thorvaldsdottir (sound)";
String YEAR="2014";
int videotime = 14*60+44; // set here your DVD title playtime in sec
//int videotime = 14*60+44; // set here your DVD title playtime in seconds
int videotime = 5*60; // set here your DVD title playtime in sec
int choptime = 3; // how much to chop at the end if the videos are
// not exactly the same length
int playtime = videotime - choptime;
int resetdelay = 3; // seconds from reset to playing from beginning
IRsend irsend;
int alarm_bell = false;
void showtime() {
void showtime(int secs) {
Serial << "sec:" << secs << " / mm:ss " << secs/60 << ":" << secs % 60 << endl;
}
@@ -53,14 +58,21 @@ void setup() {
Serial << "For \""<< INST_NAME << "\" by "<< ARTIST <<"(" << YEAR << ")" << endl;
Serial << SVN_URL << endl << SVN_ID << endl;
Serial << "Playtime: " << playtime << endl;
secs=playtime;
showtime();
sync();
showtime(playtime);
Alarm.timerRepeat(playtime, sync);
Alarm.timerRepeat(playtime, trigger_sync);
}
void trigger_sync() {
alarm_bell = true;
}
/********************************************************************/
void loop() {
if (alarm_bell == true) {
sync();
alarm_bell = false;
}
heartbeat();
}
@@ -78,19 +90,10 @@ void heartbeat() {
void sync() {
Serial << "Sync" << endl;
send_pause();
waitsec(resetdelay);
//send_pause();
//waitsec(resetdelay);
send_previous();
/* 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.
showtime();
}
*/
}
/**************************************************************/
@@ -104,14 +107,14 @@ void waitsec(int sec) {
// NEC data format: first comes the pre-data bits, then the command code
void send_stop() {
Serial << " stop" << endl;
irsend.sendNEC(0xA25D28D7,32);
irsend.sendSony(0x18B47,20);
}
/********************************************************************/
void send_play() {
// Note that play and pause are a toggle for the same command
Serial << " play" << endl;
irsend.sendNEC(0xA25DA857, 32);
irsend.sendSony(0x58B47,20);
}
@@ -121,12 +124,12 @@ void send_pause() {
// We use the "step" command which will always pause, no matter
// how many times we press it.
Serial << " step/pause" << endl;
irsend.sendNEC(0xA25D00FF,32);
irsend.sendSony(0x98B47,20);
}
/********************************************************************/
void send_previous() {
// First comes the pre-data bits, then the command code
Serial.println(" previous");
irsend.sendNEC(0xA25DC43B, 32);
irsend.sendSony(0xEAB47,20);
}

View File

@@ -0,0 +1,88 @@
/*
* IRremote: IRrecvDump - dump details of IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
* Small modifications by Joe Foley <foley@ru.is> for Reykjavik Art Museum Synchronizers
*/
#include <IRremote.h>
int IR_VCC_PIN = 12;
int IR_GND_PIN = 11;
int RECV_PIN = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
pinMode(IR_VCC_PIN, OUTPUT);
digitalWrite(IR_VCC_PIN, HIGH);
pinMode(IR_GND_PIN, OUTPUT);
digitalWrite(IR_GND_PIN, LOW);
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
// Dumps out the decode_results structure.
// Call this after IRrecv::decode()
// void * to work around compiler issue
//void dump(void *v) {
// decode_results *results = (decode_results *)v
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.print("Unknown encoding: ");
}
else if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
else if (results->decode_type == PANASONIC) {
Serial.print("Decoded PANASONIC - Address: ");
Serial.print(results->panasonicAddress,HEX);
Serial.print(" Value: ");
}
else if (results->decode_type == JVC) {
Serial.print("Decoded JVC: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
for (int i = 0; i < count; i++) {
if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" ");
}
Serial.println("");
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
dump(&results);
irrecv.resume(); // Receive the next value
}
}