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
* 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);
}
/**************************************************************/
@@ -123,13 +116,13 @@ 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;
Serial << " step/pause" << endl;
irsend.sendSony(0x98B47,20);
}
/********************************************************************/
void send_previous() {
// First comes the pre-data bits, then the command code
Serial.println(" previous");
Serial << " previous" << endl;
irsend.sendSony(0xEAB47,20);
}