⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cam.c

📁 用AVR单片机来控制数字摄像头
💻 C
字号:
/*
 * ----------------------------------------------------------------------------
 * CAM 
 *
 * By I馻ki Navarro Oiza
 * April 2004
 * ----------------------------------------------------------------------------
 */
 
#include "cam.h"
#include "delay.h"
#include "usart.h"
#include "servo.h"

void camports_init(void){
  DDRY = 0x00;
  DDRD = (DDRD & 0xE3);
}

void photo(void){
 	for(int y = 0; y<352; y++){
	  while(isVSYNup);
	  while(isVSYNdown);
	  for(int r = 0;r<244;r++){
	    while(isHREFdown);
		for(int h = 0;h<y;h++){
			  while(isPCLKup);
	    	  while(isPCLKdown);
	    }
		usart_putc(PINY);
		while(isHREFup);
	  }
	}
}

void panoramic(void){
    for(int x = -950; x<=950; x++){
	  set_servo_pos(-x);
	  Delay_1ms(30);		
	  while(isVSYNup);
	  while(isVSYNdown);
	  for(int r = 0;r<244;r++){
	    while(isHREFdown);
		for(int h = 0;h<176;h++){  // I take the center column
			  while(isPCLKup);
	    	  while(isPCLKdown);
	    }
		usart_putc(PINY);
		while(isHREFup);
	  }
	}
}

int getcenter(char *row){
    int maxvalue = 0;
	int maxpos = 0;
	int previous = 0;
	int center = -1;

	char *p;
    p = row;
	
	while(isVSYNup);
	while(isVSYNdown);
	for(int r = 0;r<20;r++){   // I wait for row 20
	while(isHREFup);
	while(isHREFdown);
	}
	while(isHREFup){
	  while(isPCLKdown);
	  *p = PINY;
	  p++;
	  while(isPCLKup);
	  while(isPCLKdown);
	  while(isPCLKup);
	  while(isPCLKdown);
	  while(isPCLKup);
	  while(isPCLKdown);
	  while(isPCLKup);
	}
			
	p = row;
	for(int i = 1;i<=88;i++){
	  if(*p >= 225){
	    previous++;
		if (previous>=maxvalue){
		  maxvalue = previous;
		  maxpos=i;
		}
	  } else previous = 0;
	  p++;
	}
	if(maxvalue>1) center = (int) maxpos - (maxvalue/2);
	return center;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -