HOme Sheriff And Lamp

Dependencies:   CameraC328 HCSR04 SDFileSystem WIZnetInterface mbed

Fork of HoSAL by pi bae

Committer:
uasonice
Date:
Tue Aug 11 17:35:33 2015 +0000
Revision:
3:8c4e0e7c8cea
Parent:
2:3c7526a1893a
Child:
4:ca368c50f8c9
add library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uasonice 0:35211a622a44 1 #include "mbed.h"
uasonice 0:35211a622a44 2
uasonice 0:35211a622a44 3 #define DEBUG_TYPE 1
uasonice 0:35211a622a44 4 #define P_ uart.printf
uasonice 0:35211a622a44 5 #include "rev_config.h"
uasonice 0:35211a622a44 6
uasonice 3:8c4e0e7c8cea 7 #include "rev_Camera.h"
uasonice 3:8c4e0e7c8cea 8 //#include "rev_httpFile.h"
uasonice 3:8c4e0e7c8cea 9 #include "rev_Hcsr04.h"
uasonice 0:35211a622a44 10
uasonice 0:35211a622a44 11
uasonice 3:8c4e0e7c8cea 12 #define MAC "\x00\x08\xDC\x11\x34\x78"
uasonice 3:8c4e0e7c8cea 13 #define IP "192.168.5.5"
uasonice 3:8c4e0e7c8cea 14 #define MASK "255.255.255.0"
uasonice 3:8c4e0e7c8cea 15 #define GATEWAY "192.168.5.1"
uasonice 3:8c4e0e7c8cea 16
uasonice 3:8c4e0e7c8cea 17 #define HTTPD_SERVER_PORT 80
uasonice 0:35211a622a44 18
uasonice 0:35211a622a44 19 Serial uart(USBTX, USBRX); // tx, rx
uasonice 0:35211a622a44 20
uasonice 3:8c4e0e7c8cea 21 #if defined(USE_CAMERA)
uasonice 3:8c4e0e7c8cea 22 //CameraC328 cam(PA_14, PA_13, CameraC328::Baud14400);
uasonice 3:8c4e0e7c8cea 23 CameraC328 *g_pCam;
uasonice 3:8c4e0e7c8cea 24 #endif // defined(USE_CAMERA)
uasonice 3:8c4e0e7c8cea 25
uasonice 3:8c4e0e7c8cea 26 #if defined(USE_MEASURE_DISTANCE)
uasonice 2:3c7526a1893a 27 //HCSR04 sensor(D12, D11);
uasonice 2:3c7526a1893a 28 HCSR04 *g_pHcrs;
uasonice 3:8c4e0e7c8cea 29 #define CHECK_DISTANCE 50
uasonice 3:8c4e0e7c8cea 30 #endif // defined(USE_MEASURE_DISTANCE)
uasonice 0:35211a622a44 31
uasonice 0:35211a622a44 32 DigitalOut led1(LED1); //server listning status
uasonice 0:35211a622a44 33 DigitalOut led2(LED2); //socket connecting status
uasonice 0:35211a622a44 34
uasonice 0:35211a622a44 35 //////////////////////////////////////////////////////////////////////////
uasonice 0:35211a622a44 36 Ticker ledTick;
uasonice 0:35211a622a44 37
uasonice 0:35211a622a44 38 //////////////////////////////////////////////////////////////////////////
uasonice 0:35211a622a44 39 void ledTickfunc()
uasonice 0:35211a622a44 40 {
uasonice 0:35211a622a44 41 led1 = !led1;
uasonice 0:35211a622a44 42 }
uasonice 0:35211a622a44 43
uasonice 0:35211a622a44 44 //////////////////////////////////////////////////////////////////////////
uasonice 0:35211a622a44 45 int main()
uasonice 0:35211a622a44 46 {
uasonice 3:8c4e0e7c8cea 47 Timer tm1;
uasonice 3:8c4e0e7c8cea 48
uasonice 0:35211a622a44 49 ledTick.attach(&ledTickfunc,0.5);
uasonice 0:35211a622a44 50
uasonice 0:35211a622a44 51 uart.baud(115200);
uasonice 3:8c4e0e7c8cea 52
uasonice 3:8c4e0e7c8cea 53 DM_fLN("INIT DEVICE");
uasonice 3:8c4e0e7c8cea 54 #if defined(USE_CAMERA)
uasonice 3:8c4e0e7c8cea 55 DM_fLN("Init camera C328");
uasonice 3:8c4e0e7c8cea 56 g_pCam = new CameraC328(PA_14, PA_13, CameraC328::Baud14400);
uasonice 3:8c4e0e7c8cea 57 revSync(g_pCam);
uasonice 3:8c4e0e7c8cea 58 tm1.reset();
uasonice 3:8c4e0e7c8cea 59 tm1.start();
uasonice 3:8c4e0e7c8cea 60 //revJpeg_snapshot(g_pCam, "/sd/file05.jpg", CameraC328::JpegResolution640x480);
uasonice 3:8c4e0e7c8cea 61 tm1.stop();
uasonice 3:8c4e0e7c8cea 62 DM_fLN("time of capture: %d", tm1.read_ms());
uasonice 3:8c4e0e7c8cea 63 #endif // defined(USE_CAMERA)
uasonice 3:8c4e0e7c8cea 64 #if defined(USE_MEASURE_DISTANCE)
uasonice 2:3c7526a1893a 65 g_pHcrs = new HCSR04(D12, D11);
uasonice 3:8c4e0e7c8cea 66 #endif // defined(USE_MEASURE_DISTANCE)
uasonice 3:8c4e0e7c8cea 67
uasonice 3:8c4e0e7c8cea 68 DM_fLN("start main loop");
uasonice 0:35211a622a44 69 while(1) {
uasonice 3:8c4e0e7c8cea 70 #if defined(USE_MEASURE_DISTANCE)
uasonice 2:3c7526a1893a 71 get_distance(g_pHcrs);
uasonice 3:8c4e0e7c8cea 72 #endif // defined(USE_MEASURE_DISTANCE)
uasonice 0:35211a622a44 73 wait_ms(1000);
uasonice 0:35211a622a44 74 }
uasonice 0:35211a622a44 75 }