Commit 416cc09e authored by Chris Young's avatar Chris Young

Update to version 1.5

Version 1.5 features include: New bit-bang output for PWM frequency no
longer requires hardware timers. New IRfrequency class for detecting
received frequency. Updated documentation. Other changes.
parent e076400e
Change Log for IRLib – an Arduino library for infrared encoding and decoding
Copyright 2013-2014 by Chris Young http://tech.cyborg5.com/irlib/
Version 1.5 June 2014
New bit-bang option for PWM output frequency setting. Now can use any output pin with no hardware timers. Note:bit-bang output not as accurate as timer-based frequency selection.
Major rewrite of IRLibTimer.h to facilitate bit-bang. Separated hardware timer selection and specification into sending and receiving sections in order to implement bit-bang.
New IRfrequency class for detecting input frequencies. Previously was a stand-alone special sketch but now is a class including a DumpResults method.
New IRfreq and IRrecvDumpFreq illustrate simultaneous detection of frequency and pattern with both an IR learner and IR receiver is connected.
New #define USE_IRRECV define can be commented out to completely remove the interrupt driven IRrecv receiver class from the library. This resolves ISR conflicts with other libraries such as Tone() when not using IRrecv class.
New #define USE_DUMP define can be commented out to disable DumpResults methods. Saves code space when these methods are not needed.
Revised user manuals to document new features and correct previous documentation problems.
Version 1.42 May 2014
Added support ATmega256RFR2 based Pinoccio Scout platform with examples
Version 1.41 April 2014
......
This diff is collapsed.
/* IRLib.h from IRLib an Arduino library for infrared encoding and decoding
* Version 1.4 March 2014
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://cyborg5.com
*
* This library is a major rewrite of IRemote by Ken Shirriff which was covered by
......@@ -36,9 +36,19 @@
// If IRLIB_TRACE is defined, some debugging information about the decode will be printed
// IRLIB_TEST must be defined for the IRtest unittests to work. It will make some
// methods virtual, which will be slightly slower, which is why it is optional.
// #define IRLIB_TRACE
//#define IRLIB_TRACE
// #define IRLIB_TEST
/* If not using the IRrecv class but only using IRrecvPCI or IRrecvLoop you can eliminate
* some conflicts with the duplicate definition of ISR by turning this feature off.
* Comment out the following define to eliminate the conflicts.
*/
#define USE_IRRECV
/* If not using either DumpResults methods of IRdecode nor IRfrequency you can
* comment out the following define to eliminate considerable program space.
*/
#define USE_DUMP
// Only used for testing; can remove virtual for shorter code
#ifdef IRLIB_TEST
#define VIRTUAL virtual
......@@ -73,6 +83,7 @@ public:
unsigned char bits; // Number of bits in decoded value
volatile unsigned int *rawbuf; // Raw intervals in microseconds
unsigned char rawlen; // Number of records in rawbuf.
bool IgnoreHeader; // Relaxed header detection allows AGC to settle
virtual void Reset(void); // Initializes the decoder
virtual bool decode(void); // This base routine always returns false override with your routine
bool decodeGeneric(unsigned char Raw_Count, unsigned int Head_Mark, unsigned int Head_Space,
......@@ -176,6 +187,7 @@ protected:
VIRTUAL void mark(unsigned int usec);
VIRTUAL void space(unsigned int usec);
unsigned long Extent;
unsigned char OnTime,OffTime,iLength;//used by bit-bang output.
};
class IRsendNEC: public virtual IRsendBase
......@@ -264,6 +276,7 @@ protected:
* when trying to analyze unknown protocols, the 50s granularity may not be sufficient.
* In that case use either the IRrecvLoop or the IRrecvPCI class.
*/
#ifdef USE_IRRECV
class IRrecv: public IRrecvBase
{
public:
......@@ -272,6 +285,7 @@ public:
void enableIRIn(void);
void resume(void);
};
#endif
/* This receiver uses no interrupts or timers. Other interrupt driven receivers
* allow you to do other things and call GetResults at your leisure to see if perhaps
* a sequence has been received. Typically you would put GetResults in your loop
......@@ -309,12 +323,46 @@ private:
unsigned char intrnum;
};
/* This class facilitates detection of frequency of an IR signal. Requires a TSMP58000
* or equivalent device connected to the hardware interrupt pin.
* Create an instance of the object passing the interrupt number.
*/
//Un-comment only one of the following three lines depending on available RAM
//#define FREQUENCY_BUFFER_TYPE unsigned char
#define FREQUENCY_BUFFER_TYPE int
//#define FREQUENCY_BUFFER_TYPE long
class IRfrequency
{
public:
//Note this is interrupt number, not pin number
IRfrequency(unsigned char inum);
void enableFreqDetect(void);
bool HaveData(void); //detective data received
void disableFreqDetect(void);
void ComputeFreq(void); //computes but does not print results
void DumpResults(bool Detail); //computes and prints result
unsigned char getPinNum(void);//get value computed from interrupt number
double Results; //results in kHz
unsigned char Samples; //number of samples used in computation
private:
volatile unsigned FREQUENCY_BUFFER_TYPE Time_Stamp[256];
unsigned char intrnum, pin;
unsigned int i;
unsigned long Sum;
};
//Do the actual blinking off and on
//This is not part of IRrecvBase because it may need to be inside an ISR
//and we cannot pass parameters to them.
void do_Blink(void);
/* This routine maps interrupt numbers used by attachInterrupt() into pin numbers.
* NOTE: these interrupt numbers which are passed to attachInterrupt() are not
* necessarily identical to the interrupt numbers in the datasheet of the processor
* chip you are using. These interrupt numbers are a system unique to the
* attachInterrupt() Arduino function. It is used by both IRrecvPCI and IRfrequency.
*/
unsigned char Pin_from_Intr(unsigned char inum);
// Some useful constants
// Decoded value for NEC when a repeat code is received
#define REPEAT 0xffffffff
......
/* IRLibMatch.h from IRLib an Arduino library for infrared encoding and decoding
* Version 1.4 March 2014
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://cyborg5.com
*
* This library is a major rewrite of IRemote by Ken Shirriff which was covered by
......@@ -51,8 +51,8 @@
#define DEFAULT_ABS_TOLERANCE 75 //absolute tolerance in microseconds
/*
* These revised MATCH routines allow you to use either percentage were absolute tolerances.
* Use ABS_MATCH for absolute and PERC_MATCH percentages. The original MATCH macro
* These revised MATCH routines allow you to use either percentage or absolute tolerances.
* Use ABS_MATCH for absolute and PERC_MATCH for percentages. The original MATCH macro
* is controlled by the IRLIB_USE_PERCENT definition a few lines above.
*/
......
/* IRLibRData.h from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.4 March 2014
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://cyborg5.com
*
* This library is a major rewrite of IRemote by Ken Shirriff which was covered by
......
This diff is collapsed.
IRLib – an Arduino library for infrared encoding and decoding
Version 1.42 May 2014
Version 1.5 June 2014
Copyright 2013, 2014 by Chris Young http://cyborg5.com
This library is a major rewrite of IRemote by Ken Shirriff which was covered
......@@ -84,4 +83,4 @@ The library handles the following protocols:
NEC, Sony, RC5, RC6, Raw all of which were supported in the KS version.
Additionally added Panasonic_Old, JVC, NECx.
Also added KS hash code routines which he released separately.
Example code included but not in the library: Samsung36, DirecTV, GIcable.
Example code included but not in the library: Samsung36, DirecTV, GIcable. rcmm (U-Verse)
/* IRfreq: estimate modulation frequency of IR transmitter
* Version 1.3 January 2014
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://tech.cyborg5.com
* Based on Arduino firmware for use with AnalysIR IR signal analysis
* software for Windows PCs. Many thanks to the people
* at http://analysir.com for their assistance In developing this program.
*/
#define INTERRUPT_USED 1 // Value can be 0-5 depending on board.
// You should attach your TSMP5800 or equivalent
// receiver to appropriate pin as defined below.
/*
* IRLib: IRfreq - dump details of IR codes with IRrecvPCI and
* measures frequency using IRfrequency. You must connect an IR learner
* such as TSMP58000 to a hardware interrupt pin.
*/
#include <IRLib.h>
// Do not modified this section
#if defined(__AVR_ATmega32U4__) //Assume Arduino Leonardo
#if(INTERRUPT_USED==0)
#define PIN_USED 3
#elif (INTERRUPT_USED==1)
#define PIN_USED 2
#elif (INTERRUPT_USED==2)
#define PIN_USED 0
#elif (INTERRUPT_USED==3)
#define PIN_USED 1
#elif (INTERRUPT_USED==4)
#define PIN_USED 7
#else
#error "Invalid value for INTERRUPT_USED on Leonardo"
#endif
#elif (INTERRUPT_USED==0) //Uno or Mega
#define PIN_USED 2
#elif (INTERRUPT_USED==1) //Uno or Mega
#define PIN_USED 3
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
#if (INTERRUPT_USED==2) //Mega only
#define PIN_USED 21
#elif (INTERRUPT_USED==3) //Mega only
#define PIN_USED 20
#elif (INTERRUPT_USED==4) //Mega only
#define PIN_USED 19
#elif (INTERRUPT_USED==5) //Mega only
#define PIN_USED 18
#else
#error "invalid value for INTERRUPT_USED on Arduino press delete this Michael down five mega"
#endif
#else
#error "Invalid value for INTERRUPT_USED on non-Leonardo non-Mega board"
#endif
#define FREQUENCY_INTERRUPT 0
#define BUF_SIZE 200
// These are "volatile" because they are modified inside the interrupt handler
volatile byte Time_Stamp[BUF_SIZE]; //Punch the time clock using "micros()" each time a pulse causes interrupt
volatile byte Count; //Index into Time_Stamp
IRfrequency My_Freq(FREQUENCY_INTERRUPT);
void setup() {
void setup()
{
Serial.begin(9600);
while(!Serial);//for Leonardo
pinMode(PIN_USED, INPUT);
Serial.print(F("Using interrupt="));Serial.println(INTERRUPT_USED,DEC);
Serial.println(F("You should have Vishay TSMP58000 or equivalent"));
Serial.print(F("connected to pin=")); Serial.println(PIN_USED,DEC);
delay(2000);while(!Serial);//delay for Leonardo
Serial.print(F("Interrupt="));Serial.print(FREQUENCY_INTERRUPT,DEC);
Serial.print(F(" Pin=")); Serial.println(My_Freq.getPinNum(),DEC);
if(My_Freq.getPinNum()==255)
Serial.println(F("Invalid interrupt number."));
My_Freq.enableFreqDetect();//starts interrupt routine to compute frequency
}
void loop() {
attachInterrupt(INTERRUPT_USED, My_Interrupt_Handler, FALLING);
while(Count < (BUF_SIZE-10)); //do nothing but process interrupts until buffer almost fills
//We took that extra 10 off just in case interrupt came too fast for us to turn them off
detachInterrupt (INTERRUPT_USED);
Report_Freq();//reports modulation frequency to host over serial
}
void Report_Freq(){
byte Count_Usable=0; //Counts the number of usable valid intervals
unsigned long Sum=0; //Accumulate total of usable intervals
byte I;
byte Interval;//Interval between timestamps
Count--;//last one doesn't count
for (I=1;I<Count;I++){
Interval=(Time_Stamp[I]-Time_Stamp[I-1]);
if (Interval>50 || Interval<10) continue;//this is the period range length exclude extraneous ones
Sum +=Interval; // Accumulate usable intervals
Count_Usable++; // Count usable intervals
Time_Stamp[I-1]=0;//finished with it so clear for next time
if (My_Freq.HaveData()) {
delay(500); //it couldn't hurt to collect a little more just in case
My_Freq.disableFreqDetect();
My_Freq.DumpResults(false);//Change to "true" for more detail
My_Freq.enableFreqDetect();//Zero out previous results and restart YSR
}
Time_Stamp[I-1]=0;//now clear last one, which was missed in loop
Serial.print(F("Based on ")); Serial.print(Count_Usable,DEC);
Serial.print(F(" intervals totaling ")); Serial.print(Sum,DEC);
double Frequency=(double)Count_Usable/(double)Sum*1000;
Serial.print(F(" microseconds, the frequency is approx. =")); Serial.print(Frequency);
Serial.println(F("kHz"));
delay(1000);
Count=0; //reset value for next time
}
void My_Interrupt_Handler(){
Time_Stamp[Count++]=micros();
}
/* IRpattern: Send a test pattern of data for various protocols
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://tech.cyborg5.com
*/
#include <IRLib.h>
IRsend My_Sender;
void setup() {
Serial.begin(9600);
Serial.println(F("Type the protocol number:1-7"));
}
void loop() {
if (Serial.available ()>0) {
int i = Serial.parseInt();
int bits;
switch (i) {
case 2: bits= 20; break;
case 4: bits = 13; break;
default: bits = 0;
};
Serial.print(F("Sending:"));
Serial.println(Pnames(i));
My_Sender.send(IRTYPES(i),0x12345678,bits);
}
}
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.3 January 2014
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://cyborg5.com
* Based on original example sketch for IRremote library
* Version 0.11 September, 2009
......@@ -17,7 +17,7 @@
* the library routines.
* The logic is:
* If an IR code is received, record it.
* If g serial character is received, send the IR code.
* If a serial character is received, send the IR code.
*/
#include <IRLib.h>
......
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.3 January 2014
* Copyright 2014 by Chris Young http://cyborg5.com
* Based on original example sketch for IRremote library
* Based on original example sketch for IRremuote library
* Version 0.11 September, 2009
* Copyright 2009 Ken Shirriff
* http://www.righto.com/
......
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://tech.cyborg5.com
* Based on Arduino firmware for use with AnalysIR IR signal analysis
* software for Windows PCs. Many thanks to the people
* at http://analysir.com for their assistance In developing this program.
*/
/*
* IRLib: IRrecvDumpFreq - dump details of IR codes with IRrecvPCI and
* measures frequency using IRfrequency. You must connect an IR receiver
* such as TSOP58338 or equivalent to a hardware interrupt pin and connect
* an IR learner such as TSMP58000 to an additional hardware interrupt pin.
*/
#include <IRLib.h>
#define RECEIVER_INTERRUPT 1
#define FREQUENCY_INTERRUPT 0
//Using IRrecvPCI or IRrecvLoop for basic decoding when measuring frequency
// simultaneously. It produces more accurate results because they do not interfere
// with frequency interrupt as much as IRrecv which samples every 50 microseconds.
IRrecvPCI My_Receiver(RECEIVER_INTERRUPT);
//IRrecvLoop My_Receiver(3); //comment out previous line and un-comment this for loop version
IRfrequency My_Freq(FREQUENCY_INTERRUPT);
IRdecode My_Decoder;
void setup()
{
Serial.begin(9600);
delay(2000);while(!Serial);//delay for Leonardo
Serial.print(F("Receiver interrupt ="));Serial.print(RECEIVER_INTERRUPT,DEC);
Serial.print(F(" receiver pin =")); Serial.println(My_Receiver.getPinNum(),DEC);
Serial.print(F("Frequency interrupt="));Serial.print(FREQUENCY_INTERRUPT,DEC);
Serial.print(F(" frequency pin=")); Serial.println(My_Freq.getPinNum(),DEC);
if(My_Receiver.getPinNum()==255 || My_Freq.getPinNum()==255)
Serial.println(F("Invalid interrupt number."));
My_Receiver.enableIRIn(); // Start the receiver
My_Freq.enableFreqDetect();//starts interrupt routine to compute frequency
}
void loop() {
if (My_Receiver.GetResults(&My_Decoder)) {
My_Freq.disableFreqDetect();//Stop interrupt as soon as possible
My_Decoder.decode();
My_Freq.DumpResults(false);//Change to "true" for more detail
My_Decoder.DumpResults();
delay(500);
My_Receiver.resume();
My_Freq.enableFreqDetect();//Zero out previous results and restart YSR
}
}
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://tech.cyborg5.com
* Based on Arduino firmware for use with AnalysIR IR signal analysis
* software for Windows PCs. Many thanks to the people
* at http://analysir.com for their assistance In developing this program.
*/
/*
* IRLib: IRFreqScout - measures frequency using IRfrequency. You must
* connect an IR learner such as TSMP58000 to a hardware interrupt pin.
*/
/*
* This is a version of IRfreq modified for use with Pinoccio Scout
* Based upon "Bootstrap.ino" by the Pinoccio team
* https://pinocc.io/
*/
#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
#include "version.h"
#include <IRLib.h>
#define FREQUENCY_INTERRUPT 6
IRfrequency My_Freq(FREQUENCY_INTERRUPT);
void setup()
{
Scout.setup(SKETCH_NAME, SKETCH_REVISION, SKETCH_BUILD);
Serial.print(F("\nInterrupt="));Serial.print(FREQUENCY_INTERRUPT,DEC);
Serial.print(F(" Pin=")); Serial.println(My_Freq.getPinNum(),DEC);
if(My_Freq.getPinNum()==255)
Serial.println(F("Invalid interrupt number."));
My_Freq.enableFreqDetect();//starts interrupt routine to compute frequency
}
void loop() {
Scout.loop();
if (My_Freq.HaveData()) {
delay(500); //It couldn't hurt to collect a little bit more just in case
My_Freq.disableFreqDetect();
My_Freq.DumpResults(false);//Change to "true" for more detail
My_Freq.enableFreqDetect();//Zero out previous results and restart ISR
}
}
#define SKETCH_NAME "IRfreqScout"
#define SKETCH_BUILD 1.5
#define SKETCH_REVISION "1.5"
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://tech.cyborg5.com
* Based on Arduino firmware for use with AnalysIR IR signal analysis
* software for Windows PCs. Many thanks to the people
* at http://analysir.com for their assistance In developing this program.
*/
/*
* IRLib: IRrecvDumpFreqScout - dump details of IR codes with IRrecvPCI and
* measures frequency using IRfrequency. You must connect an IR receiver
* such as TSOP58338 or equivalent to a hardware interrupt pin and connect
* an IR learner such as TSMP58000 to an additional hardware interrupt pin.
*/
/*
* This is a version of IRrecvFreqDump modified for use with Pinoccio Scout
* Based upon "Bootstrap.ino" by the Pinoccio team
* https://pinocc.io/
*/
#include <SPI.h>
#include <Wire.h>
#include <Scout.h>
#include <GS.h>
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
#include "version.h"
#include <IRLib.h>
#define RECEIVER_INTERRUPT 0
#define FREQUENCY_INTERRUPT 6
//Using IRrecvPCI or IRrecvLoop for basic decoding when measuring frequency
// simultaneously. It produces more accurate results because they do not interfere
// with frequency interrupt as much as IRrecv which samples every 50 microseconds.
IRrecvPCI My_Receiver(RECEIVER_INTERRUPT);
//IRrecvLoop My_Receiver(4); //comment out previous line and un-comment this for loop version
IRfrequency My_Freq(FREQUENCY_INTERRUPT);
IRdecode My_Decoder;
void setup()
{
Scout.setup(SKETCH_NAME, SKETCH_REVISION, SKETCH_BUILD);
Serial.print(F("Receiver interrupt ="));Serial.print(RECEIVER_INTERRUPT,DEC);
Serial.print(F(" receiver pin =")); Serial.println(My_Receiver.getPinNum(),DEC);
Serial.print(F("Frequency interrupt="));Serial.print(FREQUENCY_INTERRUPT,DEC);
Serial.print(F(" frequency pin=")); Serial.println(My_Freq.getPinNum(),DEC);
if(My_Receiver.getPinNum()==255 || My_Freq.getPinNum()==255)
Serial.println(F("Invalid interrupt number."));
My_Receiver.enableIRIn(); // Start the receiver
My_Freq.enableFreqDetect();//starts interrupt routine to compute frequency
}
void loop() {
Scout.loop();
if (My_Receiver.GetResults(&My_Decoder)) {
My_Freq.disableFreqDetect();//Stop interrupt as soon as possible
My_Decoder.decode();
My_Freq.DumpResults(false);//Change to "true" for more detail
My_Decoder.DumpResults();
delay(500);
My_Receiver.resume();
My_Freq.enableFreqDetect();//Zero out previous results and restart ISR
}
}
#define SKETCH_NAME "IRrecvDumpFreqScout"
#define SKETCH_BUILD 1.5
#define SKETCH_REVISION "1.5"
/* Example program for from IRLib – an Arduino library for infrared encoding and decoding
* Version 1.42 May 2014
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://cyborg5.com
* Based on original example sketch for IRremote library
* Version 0.11 September, 2009
......@@ -22,7 +22,8 @@
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
#include <Arduino.h>
#include "version.h"
#include <IRLib.h> //Include the library
int RECV_PIN = 4; //Any digital I/O pin would work. We recommend 4
......@@ -32,7 +33,7 @@ unsigned int Buffer[RAWBUF];
void setup()
{
Scout.setup();
Scout.setup(SKETCH_NAME, SKETCH_REVISION, SKETCH_BUILD);
My_Receiver.enableIRIn(); // Start the receiver
My_Decoder.UseExtnBuf(Buffer);
}
......
#define SKETCH_NAME "IRrecvDumpScout"
#define SKETCH_BUILD 1.5
#define SKETCH_REVISION "1.5"
/* IRsendScout: adds "ir.send(p,c,b)" scout script command
* Version 1.42 May 2014
* Version 1.5 June 2014
* Copyright 2014 by Chris Young http://tech.cyborg5.com
* Based upon "Bootstrap.ino" by the Pinoccio team
* https://pinocc.io/
......@@ -15,6 +15,9 @@
#include <bitlash.h>
#include <lwm.h>
#include <js0n.h>
#include "version.h"
#include <IRLib.h> //Add IRLib library
IRsend My_Sender; //Create a sending object
......@@ -23,18 +26,16 @@ numvar irSend (void) {
unsigned char protocol = getarg(1);
unsigned long code = getarg(2);
unsigned char bits = getarg(3);
RgbLed.setColor(255,0,0); //just to confirm it works, turn on red LED
Led.setColor(255,0,0); //just to confirm it works, turn on red LED
My_Sender.send((IRTYPES)protocol,code,bits); //Send it
RgbLed.turnOff(); //turn it off
Led.turnOff(); //turn it off
}
void setup() {
addBitlashFunction("ir.send", (bitlash_function)irSend);
Scout.setup();
// Add custom setup code here
Scout.setup(SKETCH_NAME, SKETCH_REVISION, SKETCH_BUILD);
}
void loop() {
Scout.loop();
// Add custom loop code here
}
#define SKETCH_NAME "IRsendScout"
#define SKETCH_BUILD 1.5
#define SKETCH_REVISION "1.5"
IRLib – an Arduino library for infrared encoding and decoding
Version 1.42 May 2014
Version 1.5 June 2014
Copyright 2013, 2014 by Chris Young http://cyborg5.com
This library is covered by the GNU LESSER GENERAL PUBLIC LICENSE.
......@@ -12,13 +12,14 @@ based on the Atmel ATmega256RFR2 8-bit processor with 256K flash memory, 30 2K S
an available Wi-Fi backpack. Is billed as "A Complete Ecosystem for Building the Internet of Things".
(By the way Pinoccio is not a typo. They really do spell it without the "h")
It is currently only available to the original backers but will be available shortly as a public beta test.
It was initially only available to the original backers but is now available as a public beta test.
For more information on the platform see https://pinocc.io/
This IRLib package automatically detects the ATmega256RFR2 processor in IRLibTimer.h. We have included
a Pinoccio Scout specific version of the IRrecvDump sample sketch for receiving IR signals. There is also
sketch that adds an "ir.send(p,c,b)" command to the Scout Script language used by the system.
You can use the hq.pinocc.io portal on a Google Chrome browser to send IR codes using this command.
a Pinoccio Scout specific version of the IRrecvDump sample sketch for receiving IR signals and various
other sample sketches. There is also sketch that adds an "ir.send(p,c,b)" command to the Scout Script
language used by the system. You can use the hq.pinocc.io portal on a Google Chrome browser to send IR
codes using this command.
You should be able to adapt any other sample sketches or IRLib code of your own into the Pinoccio
infrastructure files by looking at those examples we provide.
......@@ -37,6 +38,9 @@ digital pin D3. Any input pin can be used for receiving but we recommend D4.
****************************************************
The folder contains:
IRrecvDumpScout Pinoccio Scout version of IRrecvDump sample sketch decoding codes.
IRfreqScout Frequency detection sketch ported to Pinoccio
IRrecvDumpFreqScout Detect frequency and pattern simultaneously.
IRsendScout Sketch adds "ir.send(p,c,b)" command to Scout Script
html Folder contains a simple web application in HTML and JavaScript for a
TV and cable box remote control use with IRsend Scout.
README.txt This file.
......@@ -21,6 +21,7 @@ Note that you do not need the receiver portion for this page to work.<br>
</td></tr></table>
<table id="RemoteTable">
</table>
<div id="CommandQueue"></div>
<script>myInitialize(); </script>
</body>
</html>
var api=pinoccioAPI();
//Enter your token here. Also troop ID and scout ID
//Enter your token here. Also troop ID and scout ID
api.token="enter your token here";
var troopid= 1;//replace this "1" with your troop ID
var scoutid=1;//replace this "1" with your scout ID
//handles to various parts of the screen. Initialized in myInitialize()
var LoginResults, RemoteErr, RemoteTable, KeyMessage;
var SendingFlag, DisplaySymbols;
var DisplaySymbols;
var myAccount= {};
var HotKeys= [];
// The codes below are for a Samsung TV and a Cisco/SA Bright House cable box
// You can edit it for any codes you want. Also any number of rows and columns.
// Each entry is protocol number, code, number of bits, label, keycode
var Button= [//object containing all buttons
[//object containing row 0
[7,0xe0e0e01f,0, "V+",187],//Object containing button 1
......@@ -113,13 +110,13 @@ function myInitialize() {
RemoteErr=document.getElementById ("RemoteErr");
RemoteTable=document.getElementById("RemoteTable");
KeyMessage=document.getElementById("KeyMessage");
CommandQueue=document.getElementById("CommandQueue");
document.onkeydown= function(e){KeyHandler(e);};
SendingFlag=0;
myGetAccountInfo(true,
function(err) {
if(err) {
RemoteErr.innerHTML="Error with Token ='"+api.token+"' troop ID: "+troopid+
" scout ID: "+ scoutid;
RemoteErr.innerHTML="Error with Token ='"+api.token+"' troop ID: "+troopid+
"scout ID: "+ scoutid;
} else {
LoginResults.innerHTML=
"Welcome "+myAccount.firstname+" "+myAccount.lastname+
......@@ -143,30 +140,9 @@ var x,r,c,s;
SendButton(t+" which corresponds to",HotKeys[x][0],HotKeys[x][1]);
else
KeyMessage.innerHTML=t;
RemoteErr.innerHTML= "";
//RemoteErr.innerHTML= "";
}
function IRsend(protocol, code, bits) {
if(protocol==0) return;
if(SendingFlag) {RemoteErr.innerText= "Ignoring Command while waiting on return."; return;}
SendingFlag=1;
RemoteErr.innerText= "Attempting sending...";
api.rest (
{url:"/v1/"+troopid+"/"+scoutid+"/command",
data:{command:"ir.send("+protocol+","+code+","+bits+")"}
},
function (err,data) {
var txt= "";
if(err) {
txt =err.code+ " message: "+err.message;
} else {
txt = "Sent:"+ protocol+ ", 0x"+code.toString(16)+ ", "+ bits;
}
RemoteErr.innerText=txt;
SendingFlag=0;
}
)
}
function TranslateSpecial(x) {
switch(x) {
case 187:s="+"; break; case 189:s="-"; break;
......@@ -178,8 +154,7 @@ function TranslateSpecial(x) {
case 219:s="["; break; case 221:s="]"; break;
case 188:s=","; break; case 190:s="."; break;
case 191:s="/"; break; case 120:s="|"; break;
case 20:s="ESC"; break;case 220:s="\\"; break;
case 0:s="-na-"; break;
case 20:s="ESC"; break;
default:s= String.fromCharCode(x);
}
return s;
......@@ -206,10 +181,38 @@ function ShowRemote () {
function DoButton (r,c) {
SendButton("You clicked",r,c);
}
var myQ= [];
function SendButton (t,r,c) {
var B= Button[r][c];
KeyMessage.innerHTML=t+" button("+r+","+c+")='"+B[3]+
"' Protocol:"+ B[0]+" Code:0x"+B[1].toString(16)+
" Bits:"+B[2];
IRsend(B[0],B[1],B[2]);
myQ.unshift(B)
IRsend();
}
function IRsend() {
var t="";
for(var i=0;i<myQ.length;i++) {