HOme Sheriff And Lamp
Dependencies: CameraC328 HCSR04 SDFileSystem WIZnetInterface mbed
Fork of HoSAL by
Diff: main.cpp
- Revision:
- 3:8c4e0e7c8cea
- Parent:
- 2:3c7526a1893a
- Child:
- 4:ca368c50f8c9
--- a/main.cpp Tue Aug 11 16:30:37 2015 +0000 +++ b/main.cpp Tue Aug 11 17:35:33 2015 +0000 @@ -1,24 +1,33 @@ #include "mbed.h" -#include "hcsr04.h" -#include "rev_Hcsr04.h" #define DEBUG_TYPE 1 #define P_ uart.printf #include "rev_config.h" +#include "rev_Camera.h" +//#include "rev_httpFile.h" +#include "rev_Hcsr04.h" -#define CHECK_DISTANCE 1000 -#if 0 -int sum_dist[3] = {0,}; //ryuhs74@20150712 - -int avg_dist = 0; //ryuhs74@20150712 - -int index_dist = 0; //ryuhs74@20150712 - -#endif +#define MAC "\x00\x08\xDC\x11\x34\x78" +#define IP "192.168.5.5" +#define MASK "255.255.255.0" +#define GATEWAY "192.168.5.1" + +#define HTTPD_SERVER_PORT 80 Serial uart(USBTX, USBRX); // tx, rx +#if defined(USE_CAMERA) +//CameraC328 cam(PA_14, PA_13, CameraC328::Baud14400); +CameraC328 *g_pCam; +#endif // defined(USE_CAMERA) + +#if defined(USE_MEASURE_DISTANCE) //HCSR04 sensor(D12, D11); HCSR04 *g_pHcrs; +#define CHECK_DISTANCE 50 +#endif // defined(USE_MEASURE_DISTANCE) DigitalOut led1(LED1); //server listning status DigitalOut led2(LED2); //socket connecting status @@ -35,16 +44,32 @@ ////////////////////////////////////////////////////////////////////////// int main() { + Timer tm1; + ledTick.attach(&ledTickfunc,0.5); uart.baud(115200); - DM_fLN("init"); - + + DM_fLN("INIT DEVICE"); +#if defined(USE_CAMERA) + DM_fLN("Init camera C328"); + g_pCam = new CameraC328(PA_14, PA_13, CameraC328::Baud14400); + revSync(g_pCam); + tm1.reset(); + tm1.start(); + //revJpeg_snapshot(g_pCam, "/sd/file05.jpg", CameraC328::JpegResolution640x480); + tm1.stop(); + DM_fLN("time of capture: %d", tm1.read_ms()); +#endif // defined(USE_CAMERA) +#if defined(USE_MEASURE_DISTANCE) g_pHcrs = new HCSR04(D12, D11); +#endif // defined(USE_MEASURE_DISTANCE) + + DM_fLN("start main loop"); while(1) { +#if defined(USE_MEASURE_DISTANCE) get_distance(g_pHcrs); +#endif // defined(USE_MEASURE_DISTANCE) wait_ms(1000); } } - -