test

Dependencies:   CameraC1098 FatFileSystem HeptaGPS SDHC_Lib mbed

Fork of CameraC1098_picture by Tadao Iida

Files at this revision

API Documentation at this revision

Comitter:
sunifu
Date:
Fri Jul 27 13:59:35 2012 +0000
Child:
1:06966e960702
Commit message:
??????? Web? ???????????????<15> ???????(C1098)?????????????????????????????http://www.eleki-jack.com/arm/2012/07/15.html

Changed in this revision

CameraC1098.lib Show annotated file Show diff for this revision Revisions of this file
FatFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
SDHC_Lib.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CameraC1098.lib	Fri Jul 27 13:59:35 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/sunifu/code/CameraC1098/#5a6468b4164d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FatFileSystem.lib	Fri Jul 27 13:59:35 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/SomeRandomBloke/code/FatFileSystem/#5baba5d5b728
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDHC_Lib.lib	Fri Jul 27 13:59:35 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/atommota/code/SDHC_Lib/#5e21e22ef223
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Fri Jul 27 13:59:35 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jul 27 13:59:35 2012 +0000
@@ -0,0 +1,122 @@
+#include "mbed.h"
+#include "CameraC1098.h"
+#include "SDHCFileSystem.h"
+#include "TextLCD.h"
+
+/*
+ * Definitions.
+ */
+#define USE_SD_CARD 1
+
+/*
+ * Variables.
+ */
+static const int CAPTURE_FRAMES = 1;
+static char buf[256+1];
+static FILE *fp_jpeg;
+
+/*
+ * Modules.
+ */
+#if USE_SD_CARD
+SDFileSystem sd(p5, p6, p7, p8, "fs");
+#else
+LocalFileSystem fs("fs");
+#endif
+
+TextLCD lcd(p24, p26, p27, p28, p29, p30);
+CameraC1098 camera(p9, p10);
+ 
+
+/**
+ * A callback function for jpeg images.
+ * You can block this function until saving the image datas.
+ *
+ * @param buf A pointer to the image buffer.
+ * @param siz A size of the image buffer.
+ */
+void jpeg_callback(char *buf, size_t siz) {
+    for (int i = 0; i < (int)siz; i++) {
+        fprintf(fp_jpeg, "%c", buf[i]);
+    }
+}
+
+/**
+ * Synchronizing.
+ */
+void sync(void) {
+    CameraC1098::ErrorNumber err = CameraC1098::NoError;
+
+    err = camera.sync();
+    lcd.locate(0,0);
+    if (CameraC1098::NoError == err) {
+        printf("[ OK ] : CameraC1098::sync\r\n");
+        lcd.printf("C1098:Sync [OK] ");
+        
+    } else {
+        printf("[FAIL] : CameraC1098::sync (Error=%02X)\r\n", (int)err);
+        lcd.printf("C1098:Sync[FAIL]");
+    }
+}
+
+
+/**
+ * A test function for jpeg snapshot picture.
+ */
+void test_jpeg_snapshot_picture(int j) {
+    CameraC1098::ErrorNumber err = CameraC1098::NoError; 
+    for (int i = 0; i < CAPTURE_FRAMES; i++) {
+        char fname[64];
+        snprintf(fname, sizeof(fname), "/fs/jpss%02d-%02d.jpg",i, j);
+        fp_jpeg = fopen(fname, "w");
+        if ( fp_jpeg == NULL ){
+            lcd.locate(0,1);
+            lcd.printf("File Open Fail ");
+            exit(1);
+        }
+
+        err = camera.getJpegSnapshotPicture(jpeg_callback);
+        lcd.locate(0,1);
+        if (CameraC1098::NoError == err) {
+            printf("[ OK ] : CameraC1098::getJpegSnapshotPicture\r\n");
+            lcd.printf("getJpgPict [OK] ");
+        } else {
+            printf("[FAIL] : CameraC1098::getJpegSnapshotPicture (Error=%02X)\r\n", (int)err);
+            lcd.printf("getJpgPict[FAIL]");
+        }
+        fclose(fp_jpeg);
+    }
+}
+
+/**
+ * A entry point.
+ */
+int main() {
+    printf("\r\n");
+    printf("==========\r\n"); 
+    printf("CameraC1098\r\n");
+    printf("==========\r\n");
+    CameraC1098::ErrorNumber err = CameraC1098::NoError;
+    err = camera.init(CameraC1098::Baud460800, CameraC1098::JpegResolution80x64);    
+     
+    lcd.cls();
+    lcd.locate(0,0);
+    if (CameraC1098::NoError == err) {
+        printf("[ OK ] : CameraC1098::init\r\n");
+        lcd.printf("C1098:init [OK] ");
+    } else {
+        printf("[FAIL] : CameraC1098::init (Error=%02X)\r\n", (int)err);
+        lcd.printf("C1098:init[FAIL]");
+    }
+    sync();
+    
+    test_jpeg_snapshot_picture(1); 
+    err = camera.init(CameraC1098::Baud460800, CameraC1098::JpegResolution160x128);   
+    test_jpeg_snapshot_picture(2);        
+    err = camera.init(CameraC1098::Baud460800, CameraC1098::JpegResolution320x240);   
+    test_jpeg_snapshot_picture(3);    
+    err = camera.init(CameraC1098::Baud460800, CameraC1098::JpegResolution640x480);   
+    test_jpeg_snapshot_picture(4);         
+    
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jul 27 13:59:35 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/737756e0b479
\ No newline at end of file