Version 3: Trying to interleave capture and read

Dependencies:   ov7670_lib Project_test

Committer:
sebbarpar
Date:
Mon Jun 22 11:07:45 2020 +0000
Revision:
9:bfd025b059ab
Parent:
8:36adb37e976d
Coomit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edodm85 0:19429e334b75 1 /*
edodm85 0:19429e334b75 2 * Author: Edoardo De Marchi
edodm85 3:b4e0cefc37f6 3 * Date: 07/04/13
edodm85 0:19429e334b75 4 * Notes: OV7670 + FIFO AL422B camera test
edodm85 0:19429e334b75 5 */
edodm85 0:19429e334b75 6
edodm85 0:19429e334b75 7 #include "main.h"
sebbarpar 8:36adb37e976d 8 #include "EthernetInterface.h"
edodm85 2:bbd557817319 9 #define VGA 307200 //640*480
edodm85 2:bbd557817319 10 #define QVGA 76800 //320*240
edodm85 2:bbd557817319 11 #define QQVGA 19200 //160*120
sebbarpar 8:36adb37e976d 12 #define lines 120
sebbarpar 8:36adb37e976d 13 #define columns 160
edodm85 2:bbd557817319 14 static char format = ' ';
edodm85 2:bbd557817319 15 static int resolution = 0;
sebbarpar 9:bfd025b059ab 16 int capturing=0;
sebbarpar 8:36adb37e976d 17 EthernetInterface net;
sebbarpar 8:36adb37e976d 18 UDPSocket sock;
sebbarpar 9:bfd025b059ab 19 EventFlags signals;
sebbarpar 9:bfd025b059ab 20 Thread h;
sebbarpar 9:bfd025b059ab 21 int capt=0;
sebbarpar 9:bfd025b059ab 22
sebbarpar 9:bfd025b059ab 23 #define href_en 0x01
edodm85 0:19429e334b75 24
sebbarpar 8:36adb37e976d 25 void ether(){
sebbarpar 8:36adb37e976d 26 //net.connect();
sebbarpar 8:36adb37e976d 27 const char *ip = net.get_ip_address();
sebbarpar 8:36adb37e976d 28 pc.printf("IP address is: %s\n", ip ? ip : "No IP");
sebbarpar 8:36adb37e976d 29 sock.open(&net);
sebbarpar 8:36adb37e976d 30 }
sebbarpar 8:36adb37e976d 31
sebbarpar 9:bfd025b059ab 32 void hrefen(){
sebbarpar 9:bfd025b059ab 33 short int pixel[160];
sebbarpar 9:bfd025b059ab 34 while(1){
sebbarpar 9:bfd025b059ab 35 if(capturing){
sebbarpar 9:bfd025b059ab 36 for(int j=0; j<columns; j++){
sebbarpar 9:bfd025b059ab 37 camera.ReadOnebyte();
sebbarpar 9:bfd025b059ab 38 pixel[j]=camera.ReadOnebyte();
sebbarpar 9:bfd025b059ab 39 pc.printf("%d ", pixel[j]);
sebbarpar 9:bfd025b059ab 40 }
sebbarpar 9:bfd025b059ab 41 //sock.sendto("192.168.1.4", 1001, pixel, sizeof(pixel));
sebbarpar 9:bfd025b059ab 42 capturing=0;
sebbarpar 9:bfd025b059ab 43 }
sebbarpar 9:bfd025b059ab 44 }
sebbarpar 9:bfd025b059ab 45
sebbarpar 9:bfd025b059ab 46 }
sebbarpar 5:4135ec0f88e6 47
sebbarpar 9:bfd025b059ab 48 void OV7670::HrefHandler(void)
sebbarpar 9:bfd025b059ab 49 {
sebbarpar 9:bfd025b059ab 50 if(capt){capturing=1;}
sebbarpar 9:bfd025b059ab 51 }
edodm85 0:19429e334b75 52
edodm85 0:19429e334b75 53 int main()
sebbarpar 8:36adb37e976d 54 { char fin[]="Finished";
sebbarpar 9:bfd025b059ab 55 h.start(hrefen);
sebbarpar 8:36adb37e976d 56 ether();
sebbarpar 8:36adb37e976d 57 camera.Init('y', QQVGA);
sebbarpar 8:36adb37e976d 58 pc.printf("\r\nCamera initiated\r\n");
sebbarpar 8:36adb37e976d 59 //Start capturing images in black and white
sebbarpar 8:36adb37e976d 60 t.reset();
sebbarpar 8:36adb37e976d 61 while(1){
sebbarpar 8:36adb37e976d 62 t.reset();
sebbarpar 5:4135ec0f88e6 63 t.start();
sebbarpar 9:bfd025b059ab 64 camera.ReadStart();
sebbarpar 8:36adb37e976d 65 camera.CaptureNext();
sebbarpar 9:bfd025b059ab 66 while(camera.CaptureDone() == false){capt=1;};
sebbarpar 9:bfd025b059ab 67 capt=0;
sebbarpar 8:36adb37e976d 68 led1=0;
sebbarpar 9:bfd025b059ab 69 camera.ReadStop();
sebbarpar 8:36adb37e976d 70 //wait(1);
sebbarpar 9:bfd025b059ab 71 /*for(int x = 0; x<lines; x++){
sebbarpar 8:36adb37e976d 72 for(int j=0; j<columns; j++){
sebbarpar 8:36adb37e976d 73 camera.ReadOnebyte();
sebbarpar 8:36adb37e976d 74 pixel[j]=camera.ReadOnebyte();
sebbarpar 8:36adb37e976d 75 //pc.printf("%d", pixel[j]);
sebbarpar 8:36adb37e976d 76 }
sebbarpar 8:36adb37e976d 77 //sock.sendto("192.168.1.4", 1001, pixel, sizeof(pixel));
sebbarpar 9:bfd025b059ab 78 }*/
sebbarpar 8:36adb37e976d 79 //sock.sendto("192.168.1.4", 1001, fin, sizeof(fin));
sebbarpar 8:36adb37e976d 80 led1=1;
sebbarpar 9:bfd025b059ab 81 pc.printf("\r\nDone in %f\r\n",t.read());
sebbarpar 8:36adb37e976d 82 wait(1);
sebbarpar 8:36adb37e976d 83 }
edodm85 2:bbd557817319 84 }