Web Camera for mbed-os. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE
Dependencies: HttpServer_snapshot_mbed-os LWIPBP3595Interface_STA_for_mbed-os RomRamBlockDevice mbed-rpc
Fork of GR-Boards_WebCamera by
このサンプルは 「GR-LYCHEE」ではじめる電子工作 で紹介しています。
出版時と内容が異ならないよう、各ライブラリはアップデートせずに使用してください。
このサンプルの最新バージョンは下記から入手できます。最新バージョンは本の内容と一部処理が異なります。
https://github.com/d-kato/GR-Boards_WebCamera
Diff: main.cpp
- Revision:
- 11:ad8ff26679bb
- Parent:
- 10:3a176dc33f74
- Child:
- 12:6c002b871c4d
--- a/main.cpp Wed Jan 27 09:05:19 2016 +0000 +++ b/main.cpp Thu Mar 03 10:13:39 2016 +0000 @@ -9,9 +9,6 @@ #include "file_table.h" //Binary data of web pages #include "i2c_setting.h" -RomRamFileSystem romramfs("romram"); -EthernetInterface eth; - #define VIDEO_CVBS (0) /* Analog Video Signal */ #define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */ #define VIDEO_YCBCR422 (0) @@ -19,6 +16,14 @@ #define VIDEO_RGB565 (2) /**** User Selection *********/ +/** Network setting **/ +#define USE_DHCP (1) /* Select 0(static configuration) or 1(use DHCP) */ +#if (USE_DHCP == 0) + #define IP_ADDRESS ("192.168.0.2") /* IP address */ + #define SUBNET_MASK ("255.255.255.0") /* Subnet mask */ + #define DEFAULT_GATEWAY ("192.168.0.3") /* Default gateway */ +#endif +/** Camera setting **/ #define VIDEO_INPUT_METHOD (VIDEO_CMOS_CAMERA) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */ #define VIDEO_INPUT_FORMAT (VIDEO_YCBCR422) /* Select VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565 */ #define USE_VIDEO_CH (0) /* Select 0 or 1 If selecting VIDEO_CMOS_CAMERA, should be 0.) */ @@ -47,7 +52,8 @@ #define VIDEO_BUFFER_STRIDE (((PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u) #define VIDEO_BUFFER_HEIGHT (PIXEL_VW) -DigitalIn button(USER_BUTTON0); +EthernetInterface network; +RomRamFileSystem romramfs("romram"); static uint8_t FrameBuffer_Video[VIDEO_BUFFER_STRIDE * VIDEO_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(16))); //16 bytes aligned!; static volatile int32_t vsync_count = 0; @@ -353,20 +359,24 @@ RPCFunction rpcFunc(TerminalWrite, "TerminalWrite"); RPCFunction rpcSetI2C(SetI2CfromWeb, "SetI2CfromWeb"); - printf("EthernetInterface Setting up...\r\n"); - if (eth.init() != 0) { //for DHCP Server -// if (eth.init("192.168.0.2","255.255.255.0","192.168.0.3") != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway) - printf("EthernetInterface Initialize Error \r\n"); + printf("Network Setting up...\r\n"); +#if (USE_DHCP == 1) + if (network.init() != 0) { //for DHCP Server +#else + if (network.init(IP_ADDRESS, SUBNET_MASK, DEFAULT_GATEWAY) != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway) +#endif + printf("Network Initialize Error \r\n"); return -1; } - if (eth.connect() != 0) { - printf("EthernetInterface Connect Error \r\n"); + if (network.connect() != 0) { + printf("Network Connect Error \r\n"); return -1; } - printf("IP Address is %s\r\n", eth.getIPAddress()); - printf("NetMask is %s\r\n", eth.getNetworkMask()); - printf("Gateway Address is %s\r\n", eth.getGateway()); - printf("Ethernet Setup OK\r\n"); + printf("MAC Address is %s\r\n", network.getMACAddress()); + printf("IP Address is %s\r\n", network.getIPAddress()); + printf("NetMask is %s\r\n", network.getNetworkMask()); + printf("Gateway Address is %s\r\n", network.getGateway()); + printf("Network Setup OK\r\n"); SnapshotHandler::attach_req(&snapshot_req); HTTPServerAddHandler<SnapshotHandler>("/camera"); //Camera