TSL1401 is the line sensor camera.This library is used to read the raw data.

Files at this revision

API Documentation at this revision

Comitter:
ht
Date:
Sun Oct 05 04:12:56 2014 +0000
Commit message:
This library operates the camera using TSL1401.

Changed in this revision

TSL1401.cpp Show annotated file Show diff for this revision Revisions of this file
TSL1401.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSL1401.cpp	Sun Oct 05 04:12:56 2014 +0000
@@ -0,0 +1,59 @@
+#include "TSL1401.h"
+
+/* Macro */
+#define TAOS_SI_HIGH    TAOS_SI = 1
+#define TAOS_SI_LOW     TAOS_SI = 0
+#define TAOS_CLK_HIGH   TAOS_CLK = 1
+#define TAOS_CLK_LOW    TAOS_CLK = 0
+
+/* Constructor */
+TSL1401::TSL1401(PinName s, PinName c, PinName a )
+{
+
+    SI = s;
+    CLK = c;
+    A0 = new AnalogIn( a );
+}
+/* Destructor */
+TSL1401::~TSL1401()
+{
+    if( A0 != NULL)
+    {
+        delete  A0;
+    }
+}
+/* Image Caputure */
+int *TSL1401::Capture( int LineStart, int LineStop)
+{
+    int i;
+    DigitalOut TAOS_SI(SI);
+    DigitalOut TAOS_CLK(CLK);
+    
+    Max = 0,Min = 70000;
+    TAOS_SI_HIGH;
+    TAOS_CLK_HIGH;
+    TAOS_SI_LOW;
+    ImageData[0] = 0;
+    TAOS_CLK_LOW;
+    for(i = 1; i < LineStart; i++) {        
+        TAOS_CLK_HIGH;      
+        TAOS_CLK_LOW;
+    }
+    for(i = LineStart; i < LineStop; i++) {                  
+        TAOS_CLK_HIGH;
+        ImageData[i] = A0->read_u16();  // inputs data from camera (one pixel each time through loop) 
+        TAOS_CLK_LOW;
+            
+        if(Max < ImageData[i]){
+            Max = ImageData[i];
+        }           
+        if(Min > ImageData[i]){
+            Min = ImageData[i];
+        }
+            
+    }
+    return ImageData;
+}
+
+
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TSL1401.h	Sun Oct 05 04:12:56 2014 +0000
@@ -0,0 +1,22 @@
+#ifndef TSL1401_H
+#define TSL1401_H
+
+#include "mbed.h"
+#include "USBSerial.h"
+extern USBSerial serial;
+class   TSL1401
+{
+    public:
+        TSL1401(PinName s, PinName c, PinName a );
+        ~TSL1401();
+        int *Capture( int LineStart, int LineStop);     /*caputure image */
+
+    
+        int   ImageData[128];    /* カメラの値 */
+        int   Max,Min;           /*カメラ読み取り最大値、最小値 */
+    private:
+        PinName SI;
+        PinName CLK;
+        AnalogIn *A0;
+ };
+#endif
\ No newline at end of file