138 lines
4.1 KiB
Plaintext
Executable File
138 lines
4.1 KiB
Plaintext
Executable File
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
|
|
*
|
|
* 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>
|
|
#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
|
|
|
|
// 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);
|
|
|
|
Alarm.timerRepeat(playtime, trigger_sync);
|
|
send_play();
|
|
}
|
|
|
|
/********************************************************************/
|
|
void loop() {
|
|
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();
|
|
//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 << "Wait " << sec << " seconds" << endl;
|
|
Alarm.delay(sec*1000);
|
|
}
|
|
|
|
/********************************************************************/
|
|
void send_stop() {
|
|
// First comes the pre-data bits, then the command code
|
|
Serial << " stop" << endl;
|
|
irsend.sendRC6(0x10431,20);
|
|
}
|
|
|
|
/********************************************************************/
|
|
void send_play() {
|
|
// First comes the pre-data bits, then the command code
|
|
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);
|
|
}
|
|
|
|
/********************************************************************/
|
|
void send_previous() {
|
|
// First comes the pre-data bits, then the command code
|
|
Serial.println(" previous");
|
|
irsend.sendRC6(0x10421, 20);
|
|
}
|