this camera C328 http sdcard file server example is for academy
Dependencies: CameraC328 SDFileSystem WIZnetInterface mbed
Insert below jpg file in your SDcard to take a picture in Web Server /media/uploads/IOP/take_a_picture.zip
Revision 1:a878f7545221, committed 2015-07-28
- Comitter:
- IOP
- Date:
- Tue Jul 28 07:53:41 2015 +0000
- Parent:
- 0:0a851a60b7a6
- Child:
- 2:4dfa60f33178
- Commit message:
- edited commit
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jul 28 07:27:08 2015 +0000
+++ b/main.cpp Tue Jul 28 07:53:41 2015 +0000
@@ -6,6 +6,9 @@
#define EnDebugMSG false //true-> print debug message to PC USB terminal, false->not print
#include "filelib.h"
+/*
+ * Set IP
+ */
#define IP "192.168.240.100"
#define MASK "255.255.255.0"
#define GATEWAY "192.168.240.1"
@@ -13,22 +16,21 @@
Serial pc (USBTX,USBRX); // tx, rx
SDFileSystem sd(PB_3, PB_2, PB_1, PB_0, "wfs"); // the pinout on the mbed
+CameraC328 camera(PA_13, PA_14, CameraC328::Baud115200); // camera pin set
char sMethod[7];
char sURL[250];
char sProtocol[8];
-
-/* --------------------------------camera interface -----------------------------------------------*/
-
+/*
+ * Camera C328 define
+ */
#define USE_JPEG_HIGH_RESOLUTION 1
-CameraC328 camera(PA_13, PA_14, CameraC328::Baud115200);
-
int take_picture = 0;
/*
- * Variables.
+ * Camera C328 Variables.
*/
static const int CAPTURE_FRAMES = 2;
static FILE *fp_jpeg;
@@ -47,21 +49,21 @@
}
/**
- * Synchronizing.
+ * Camera C328 Synchronizing.
*/
void sync(void) {
CameraC328::ErrorNumber err = CameraC328::NoError;
err = camera.sync();
if (CameraC328::NoError == err) {
- printf("[ OK ] : CameraC328::sync\n");
+ printf("[ OK ] : CameraC328::sync\r\n");
} else {
- printf("[FAIL] : CameraC328::sync (Error=%02X)\n", (int)err);
+ printf("[FAIL] : CameraC328::sync (Error=%02X)\r\n", (int)err);
}
}
/**
- * A test function for jpeg snapshot picture.
+ * Camera C328 function for jpeg snapshot picture.
*/
void test_jpeg_snapshot_picture(void) {
CameraC328::ErrorNumber err = CameraC328::NoError;
@@ -72,9 +74,9 @@
err = camera.init(CameraC328::Jpeg, CameraC328::RawResolution80x60, CameraC328::JpegResolution320x240);
#endif
if (CameraC328::NoError == err) {
- printf("[ OK ] : CameraC328::init\n");
+ printf("[ OK ] : CameraC328::init\r\n");
} else {
- printf("[FAIL] : CameraC328::init (Error=%02X)\n", (int)err);
+ printf("[FAIL] : CameraC328::init (Error=%02X)\r\n", (int)err);
}
for (int i = 0; i < CAPTURE_FRAMES; i++) {
@@ -84,15 +86,15 @@
err = camera.getJpegSnapshotPicture(jpeg_callback);
if (CameraC328::NoError == err) {
- printf("[ OK ] : CameraC328::getJpegSnapshotPicture\n");
+ printf("[ OK ] : CameraC328::getJpegSnapshotPicture\r\n");
} else {
- printf("[FAIL] : CameraC328::getJpegSnapshotPicture (Error=%02X)\n", (int)err);
+ printf("[FAIL] : CameraC328::getJpegSnapshotPicture (Error=%02X)\r\n", (int)err);
}
fclose(fp_jpeg);
}
}
-/* ------------------------------------------------------------------------------------ */
+
EthernetInterface eth;
@@ -178,7 +180,7 @@
unsigned int bytes_for_send=0;
long long filesize, all_send_bytes = 0;
- if (strcmp(file_path,"/wfs//take_a_picture.jpg") == 0)
+ if (strcmp(file_path,"/wfs//take_a_picture.jpg") == 0)
take_picture = 1;
else take_picture = 0;
@@ -380,11 +382,6 @@
int main()
{
- printf("CameraC328\n");
-
- sync();
- test_jpeg_snapshot_picture();
-
uint8_t MAC_Addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02};
ledTick.attach(&ledTickfunc,0.5);
//ledTick.detach();
@@ -416,11 +413,12 @@
if(svr.accept(client)<0) {
printf("failed to accept connection.\n\r");
}
- else if (take_picture) {
+ else if (take_picture) { // take a picture function
printf("start taking a picture\r\n");
+
sync();
- test_jpeg_snapshot_picture();
-
+ test_jpeg_snapshot_picture();
+
take_picture = 0;
}else {
//client.set_blocking(false,5000); //5000=5sec
IOP