Changed sending command to send the command 5 time with 10ms spacing, now much more robust. Playtime now adds in the "delay" from resetting. Some weirdness with EOL, setting to CRLF for now.
This commit is contained in:
@@ -1,134 +1,138 @@
|
|||||||
const String DESCRIPTION="IR Synchronizer for Sony Blu-ray player BDP-S790";
|
const String DESCRIPTION="IR Synchronizer for Sony Blu-ray player BDP-S790";
|
||||||
const String AUTHOR="Joe Foley <foley@ru.is>";
|
const String AUTHOR="Joe Foley <foley@ru.is>";
|
||||||
const String SVN_REVISION="$Rev$";
|
const String SVN_REVISION="$Rev$";
|
||||||
const String SVN_URL="$URL$";
|
const String SVN_URL="$URL$";
|
||||||
const String SVN_ID="$Id$";
|
const String SVN_ID="$Id$";
|
||||||
/* Code written by Joe Foley <foley@ru.is> on 2014-01-14
|
/* Code written by Joe Foley <foley@ru.is> on 2014-01-14
|
||||||
*
|
*
|
||||||
* Requires libraries:
|
* Requires libraries:
|
||||||
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
|
* Arduino-IRremote https://github.com/shirriff/Arduino-IRremote
|
||||||
* Streaming http://arduiniana.org/libraries/streaming/
|
* Streaming http://arduiniana.org/libraries/streaming/
|
||||||
* Time http://www.pjrc.com/teensy/td_libs_Time.html
|
* Time http://www.pjrc.com/teensy/td_libs_Time.html
|
||||||
* TimeAlarms http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
|
* TimeAlarms http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
|
||||||
* More codes at http://www.lirc.org/
|
* More codes at http://www.lirc.org/
|
||||||
* This uses remote Sony RMT-B122P
|
* This uses remote Sony RMT-B122P
|
||||||
*
|
*
|
||||||
* The IRremote library uses Pin 3 for the Anode (longer pin)
|
* 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)
|
* We have made a ground pin on Pin 4 for the Cathode (shorter pin)
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <IRremote.h>
|
#include <IRremote.h>
|
||||||
#include <Streaming.h>
|
#include <Streaming.h>
|
||||||
#include <Time.h>
|
#include <Time.h>
|
||||||
#include <TimeAlarms.h>
|
#include <TimeAlarms.h>
|
||||||
// IR LED pin 3 should be longer
|
// IR LED pin 3 should be longer
|
||||||
int pinGND=4; // Shorter leg on the IR LED
|
int pinGND=4; // Shorter leg on the IR LED
|
||||||
int pinLED=13; // The heartbeat LED on the board
|
int pinLED=13; // The heartbeat LED on the board
|
||||||
|
|
||||||
int secs;
|
int secs;
|
||||||
int heartbeat_state=0;
|
int heartbeat_state=0;
|
||||||
|
|
||||||
String INST_NAME="Trajectories";
|
String INST_NAME="Trajectories";
|
||||||
String ARTIST="Sigurdur Gudjonsson (video) & Anna Thorvaldsdottir (sound)";
|
String ARTIST="Sigurdur Gudjonsson (video) & Anna Thorvaldsdottir (sound)";
|
||||||
String YEAR="2014";
|
String YEAR="2014";
|
||||||
int videotime = 14*60+44; // set here your DVD title playtime in seconds
|
int videotime = 10; // set here your DVD title playtime in seconds
|
||||||
int choptime = 3; // how much to chop at the end if the videos are
|
int choptime = 2; // how much to chop at the end if the videos are
|
||||||
// not exactly the same length
|
// not exactly the same length
|
||||||
int playtime = videotime - choptime;
|
int resetdelay = 1; // seconds from reset to playing from beginning
|
||||||
int resetdelay = 3; // seconds from reset to playing from beginning
|
int playtime = videotime - choptime + resetdelay;
|
||||||
|
|
||||||
IRsend irsend;
|
|
||||||
int alarm_bell = false;
|
IRsend irsend;
|
||||||
|
int alarm_bell = false;
|
||||||
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 setup() {
|
|
||||||
pinMode(pinGND,OUTPUT);
|
void setup() {
|
||||||
pinMode(pinLED,OUTPUT);
|
pinMode(pinGND,OUTPUT);
|
||||||
Serial.begin(115200);
|
pinMode(pinLED,OUTPUT);
|
||||||
setTime(23,15,16,1,14,14); // set time to 23:15:16 Jan 14 2014
|
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 << DESCRIPTION << " " << SVN_REVISION << endl;
|
||||||
Serial << "For \""<< INST_NAME << "\" by "<< ARTIST <<"(" << YEAR << ")" << endl;
|
Serial << "Code by " << AUTHOR << endl;
|
||||||
Serial << SVN_URL << endl << SVN_ID << endl;
|
Serial << "For \""<< INST_NAME << "\" by "<< ARTIST <<"(" << YEAR << ")" << endl;
|
||||||
Serial << "Playtime: " << playtime << endl;
|
Serial << SVN_URL << endl << SVN_ID << endl;
|
||||||
sync();
|
Serial << "Playtime: " << playtime << endl;
|
||||||
showtime(playtime);
|
sync();
|
||||||
|
showtime(playtime);
|
||||||
Alarm.timerRepeat(playtime, trigger_sync);
|
|
||||||
}
|
Alarm.timerRepeat(playtime, trigger_sync);
|
||||||
|
}
|
||||||
void trigger_sync() {
|
|
||||||
alarm_bell = true;
|
void trigger_sync() {
|
||||||
}
|
alarm_bell = true;
|
||||||
/********************************************************************/
|
}
|
||||||
void loop() {
|
/********************************************************************/
|
||||||
if (alarm_bell == true) {
|
void loop() {
|
||||||
sync();
|
if (alarm_bell == true) {
|
||||||
alarm_bell = false;
|
sync();
|
||||||
}
|
alarm_bell = false;
|
||||||
heartbeat();
|
}
|
||||||
}
|
heartbeat();
|
||||||
|
}
|
||||||
void heartbeat() {
|
|
||||||
if (heartbeat_state == 1) {
|
void heartbeat() {
|
||||||
digitalWrite(pinLED, HIGH);
|
if (heartbeat_state == 1) {
|
||||||
heartbeat_state = 0;
|
digitalWrite(pinLED, HIGH);
|
||||||
}
|
heartbeat_state = 0;
|
||||||
else {
|
}
|
||||||
digitalWrite(pinLED, LOW);
|
else {
|
||||||
heartbeat_state = 1;
|
digitalWrite(pinLED, LOW);
|
||||||
}
|
heartbeat_state = 1;
|
||||||
Alarm.delay(1000);
|
}
|
||||||
}
|
Alarm.delay(1000);
|
||||||
|
}
|
||||||
void sync() {
|
|
||||||
Serial << "Sync" << endl;
|
void sync() {
|
||||||
//send_pause();
|
Serial << "Sync" << endl;
|
||||||
//waitsec(resetdelay);
|
//send_pause();
|
||||||
|
//waitsec(resetdelay);
|
||||||
send_previous();
|
|
||||||
}
|
for (int i=0; i<5; i++) {
|
||||||
|
send_previous();
|
||||||
/**************************************************************/
|
delay(10); // need short pause between commands, 10ms is good
|
||||||
void waitsec(int sec) {
|
}
|
||||||
Serial << "Wait " << sec << " seconds" << endl;
|
}
|
||||||
Alarm.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
|
}
|
||||||
void send_stop() {
|
|
||||||
Serial << " stop" << endl;
|
|
||||||
irsend.sendSony(0x18B47,20);
|
/********************************************************************/
|
||||||
}
|
// NEC data format: first comes the pre-data bits, then the command code
|
||||||
|
void send_stop() {
|
||||||
/********************************************************************/
|
Serial << " stop" << endl;
|
||||||
void send_play() {
|
irsend.sendSony(0x18B47,20);
|
||||||
// Note that play and pause are a toggle for the same command
|
}
|
||||||
Serial << " play" << endl;
|
|
||||||
irsend.sendSony(0x58B47,20);
|
/********************************************************************/
|
||||||
|
void send_play() {
|
||||||
}
|
// Note that play and pause are a toggle for the same command
|
||||||
|
Serial << " play" << endl;
|
||||||
/********************************************************************/
|
irsend.sendSony(0x58B47,20);
|
||||||
void send_pause() {
|
|
||||||
// On this model, pause and play are the same button so it toggles
|
}
|
||||||
// We use the "step" command which will always pause, no matter
|
|
||||||
// how many times we press it.
|
/********************************************************************/
|
||||||
Serial << " step/pause" << endl;
|
void send_pause() {
|
||||||
irsend.sendSony(0x98B47,20);
|
// On this model, pause and play are the same button so it toggles
|
||||||
}
|
// We use the "step" command which will always pause, no matter
|
||||||
|
// how many times we press it.
|
||||||
/********************************************************************/
|
Serial << " step/pause" << endl;
|
||||||
void send_previous() {
|
irsend.sendSony(0x98B47,20);
|
||||||
// First comes the pre-data bits, then the command code
|
}
|
||||||
Serial.println(" previous");
|
|
||||||
irsend.sendSony(0xEAB47,20);
|
/********************************************************************/
|
||||||
}
|
void send_previous() {
|
||||||
|
// First comes the pre-data bits, then the command code
|
||||||
|
Serial.println(" previous");
|
||||||
|
irsend.sendSony(0xEAB47,20);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user