Version 3: Trying to interleave capture and read
Dependencies: ov7670_lib Project_test
Diff: main.cpp
- Revision:
- 8:36adb37e976d
- Parent:
- 7:9e4e66a8554e
- Child:
- 9:bfd025b059ab
--- a/main.cpp Mon Apr 06 11:23:49 2020 +0000 +++ b/main.cpp Sat Jun 20 11:07:07 2020 +0000 @@ -5,40 +5,57 @@ */ #include "main.h" - +#include "EthernetInterface.h" #define VGA 307200 //640*480 #define QVGA 76800 //320*240 #define QQVGA 19200 //160*120 -//FileSystem local("local"); +#define lines 120 +#define columns 160 static char format = ' '; static int resolution = 0; +EthernetInterface net; +UDPSocket sock; - +void ether(){ + //net.connect(); + const char *ip = net.get_ip_address(); + pc.printf("IP address is: %s\n", ip ? ip : "No IP"); + sock.open(&net); +} + int main() -{ -//FILE *wrt=fopen("/local/out.txt","w"); - int pixel[QVGA]; - int pixel2[QVGA]; - camera.Init('y', QVGA); - pc.printf("\r\nCamera initiated"); - camera.CaptureNext(); - while(camera.CaptureDone() == false); - camera.ReadStart(); - t1 = t.read_ms(); +{ char fin[]="Finished"; + int pixel[160]; + int pix[160]; + //uint_8 p[160]; + ether(); + camera.Init('y', QQVGA); + pc.printf("\r\nCamera initiated\r\n"); + //Start capturing images in black and white + t.reset(); + while(1){ + t.reset(); t.start(); - for(int x = 0; x<QVGA; x++) - { - pixel[x]=camera.ReadOnebyte(); - //fprintf(fp,"%i", pixel[x]); - //pixel2[x]=camera.ReadOnebyte(); - //fprintf(fp,"%i/n", pixel2[x]); - pc.printf("%d ", camera.ReadOnebyte()); + camera.CaptureNext(); + pc.printf("\r\nDone in %f\r\n",t.read()); + while(camera.CaptureDone() == false); + camera.ReadStart(); + led1=0; + //wait(1); + for(int x = 0; x<lines; x++){ + for(int j=0; j<columns; j++){ + camera.ReadOnebyte(); + pixel[j]=camera.ReadOnebyte(); + //pc.printf("%d", pixel[j]); + } + //sock.sendto("192.168.1.4", 1001, pixel, sizeof(pixel)); + //pc.printf("%d", a); } - + //sock.sendto("192.168.1.4", 1001, fin, sizeof(fin)); + led1=1; camera.ReadStop(); - pc.printf("done in %f\r\n",t.read()); - //fclose(fp); - + wait(1); + } } \ No newline at end of file