Revision 1:d1764facee30, committed 2010-12-04
- Comitter:
- AndyHope
- Date:
- Sat Dec 04 22:47:38 2010 +0000
- Parent:
- 0:e526ff8f7602
- Commit message:
- new revision for version control
Changed in this revision
diff -r e526ff8f7602 -r d1764facee30 FATFileSystem.lib
--- a/FATFileSystem.lib Fri Nov 26 18:43:44 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_unsupported/code/fatfilesystem/
\ No newline at end of file
diff -r e526ff8f7602 -r d1764facee30 Infrared.cpp
--- a/Infrared.cpp Fri Nov 26 18:43:44 2010 +0000
+++ b/Infrared.cpp Sat Dec 04 22:47:38 2010 +0000
@@ -2,6 +2,8 @@
#include "Infrared.h"
#include "SDFileSystem.h"
+ Serial pc(USBTX, USBRX); // tx, rx
+
Infrared::Infrared(PinName pin) : irLed(pin) { // _pin(pin) means pass pin to the DigitalOut constructor
irLed = 0; // default the output to 0
}
@@ -14,7 +16,7 @@
repeat = phead/(cycleOn+cycleOff);
- repeat *= 0.78; // correction for overhead of loops
+ repeat *= 0.55; // correction for overhead of loops
/* uses the length of the header pulse over the length of the on/off
modulation to give an integer representation of the number of cycles */
@@ -50,8 +52,8 @@
/* uses the length of the header pulse over the length of the on/off
modulation to give an integer representation of the number of cycles */
- repeat1 *= 0.78; // correction for overhead of loops
- repeat0 *= 0.78; // correction for overhead of loops
+ repeat1 *= 0.55; // correction for overhead of loops
+ repeat0 *= 0.55; // correction for overhead of loops
for(char i = 0; i < dataBits; i++)
{
@@ -104,8 +106,8 @@
repeat1 = pone/(cycleOn+cycleOff);
repeat0 = pzero/(cycleOn+cycleOff);
- repeat1 *= 0.78; // correction for overhead of loops
- repeat0 *= 0.78; // correction for overhead of loops
+ repeat1 *= 0.55; // correction for overhead of loops
+ repeat0 *= 0.55; // correction for overhead of loops
/* uses the length of the header pulse over the length of the on/off
modulation to give an integer representation of the number of cycles */
@@ -160,7 +162,7 @@
/* uses the length of the header pulse over the length of the on/off
modulation to give an integer representation of the number of cycles */
- repeat *= 0.78; // correction factor for loop overheads
+ repeat *= 0.55; // correction factor for loop overheads
for(int k = 0; k < repeat; k++)
{
@@ -192,7 +194,7 @@
pulse(ptrail);
- wait(gap);
+ wait(gap1);
return;
}//sendCodeDVR
@@ -207,13 +209,13 @@
strobeSpace();
pulse(ptrail);
- wait(gap);
+ wait(gap1);
header();
strobeSpace();
pulse(ptrail);
- wait(gap);
+ wait(gap1);
return;
}//sendCodeGETV
@@ -222,34 +224,40 @@
{
invertCode(inversionMask, command);
-
+
+ gap1 = constLength(code);
+ gap2 = constLength(invCode);
+
+ pc.printf("gap1: %f, gap2: %f\n", gap1, gap2);
+
data = code;
strobeSpace();
pulse(ptrail);
- wait(gap);
+
+ wait(gap1);
data = invCode;
strobeSpace();
pulse(ptrail);
- wait(gap);
+ wait(gap2);
data = code;
strobeSpace();
pulse(ptrail);
- wait(gap);
+ wait(gap1);
data = invCode;
strobeSpace();
pulse(ptrail);
- wait(gap);
+ wait(gap2);
return;
}//sendCodeSharpTV
@@ -272,12 +280,7 @@
stoggle /= 1000000;
ptrail /= 1000000;
plead /= 1000000;
- gap /= 1000000;
-
- /*cycleOn = 100/dutycycle;
- irPeriod = 1/frequency;
- cycleOn = irPeriod/cycleOn;
- cycleOff = cycleOn;*/
+ gap1 /= 1000000;
cycleOn = dutycycle/100; // dutycycle is read in as a percentage value from 0 to 100
cycleOff = 1-cycleOn;
@@ -319,3 +322,35 @@
return;
}// invertCode
+
+double Infrared::constLength(int sent)
+{
+ int mask;
+ double gap = 0;
+
+ for(char i = 0; i < dataBits; i++)
+ {
+ mask = 0x01<<i;
+
+ if(sent & mask)
+ {
+ gap += pone;
+ gap += sone;
+ }// if
+
+ else
+ {
+ gap += pzero;
+ gap += szero;
+ }// else
+ }// for
+
+ if(ptrail){
+ gap += ptrail;}
+
+ pc.printf("\ngap: %f\n", gap);
+
+ return(gap);
+
+}// constLength
+
diff -r e526ff8f7602 -r d1764facee30 Infrared.h
--- a/Infrared.h Fri Nov 26 18:43:44 2010 +0000
+++ b/Infrared.h Sat Dec 04 22:47:38 2010 +0000
@@ -15,7 +15,7 @@
// Timing
double phead, shead, pone, sone; // values are time in us
double pzero, szero, ptoggle, stoggle, frequency;
- double ptrail, plead, foot, gap;
+ double ptrail, plead, foot, gap1, gap2;
double irPeriod, cycleOn, cycleOff;
// data
@@ -43,6 +43,7 @@
void convertTiming();
void maskBit(void);
void invertCode(int mask, int invertData);
+ double constLength(int sent);
private:
DigitalOut irLed;
diff -r e526ff8f7602 -r d1764facee30 SDFileSystem.lib
--- a/SDFileSystem.lib Fri Nov 26 18:43:44 2010 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/simon/code/SDFileSystem/#b1ddfc9a9b25