Ejemplo n.º 1
0
void handleAWB()
{
	static uint32_t timer;
	static uint8_t state = 0;
	uint8_t awbp=0;

	if (state==2)
		return;

	prm_get("Auto White Balance on power-up", &awbp, END);
	if (!awbp)
		return; // exit if auto white balance on power-up is disabled

	else if (state==0)
	{
		setTimer(&timer);
		cam_setAWB(1);
		state = 1;
	}
	else if (state==1)
	{
		if (getTimer(timer)>AWB_TIMEOUT)
		{
			cam_setAWB(0);
		 	state = 2; // end state machine (only run once)
		}
	}
}
Ejemplo n.º 2
0
void handleAWB()
{
	static uint32_t timer;
	static uint8_t state = 0;
	
	if (state==2)
		return;
	else if (state==0)
	{
		setTimer(&timer);
		state = 1;
	}
	else if (state==1)
	{
		if (getTimer(timer)>AWB_TIMEOUT)
		{
			cam_setAWB(0);
		 	state = 2;
		}
	}
}
Ejemplo n.º 3
0
bool ButtonMachine::handleSignature()
{
	uint32_t bt;

	bt = button();

   	if (m_ledPipe) // if ledpipe, grab frame, but don't flush 
	{
		cam_getFrameChirpFlags(CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT, g_chirpUsb, 0);
		ledPipe();
	}
	else if (m_goto!=0) // else grab frame and flush
		cam_getFrameChirpFlags(CAM_GRAB_M1R2, 0, 0, CAM_RES2_WIDTH, CAM_RES2_HEIGHT, g_chirpUsb);

	switch(m_goto)
	{
	case 0:  // wait for button press
		if (bt)
		{
			setTimer(&m_timer);
			led_setMaxCurrent(g_ledBrightness); // restore default brightness
			m_goto = 1;
			led_set(0);
		}
		break;

	case 1: // wait for button timeout
		if (!bt)
			m_goto = 0;
		else if (getTimer(m_timer)>BT_INITIAL_BUTTON_TIMEOUT)
		{
			if (cam_getAWB())
				m_index = 1;
			else
				m_index = 0;
			setTimer(&m_timer);
			setLED();
			m_goto = 2;
		}
		break;

	case 2: // wait and increment index 
		if (!bt)
		{
			flashLED(3);
			setTimer(&m_timer);
			if (m_index==0)
				cam_setAWB(1);
			else
				m_ledPipe = true;
			m_goto = 3;
		}
		else if (getTimer(m_timer)>BT_INDEX_CYCLE_TIMEOUT)
		{
			setTimer(&m_timer);
			m_index++;
			if (m_index==CL_NUM_SIGNATURES+1)
				m_index = 0;

			setLED();
		}							   
		break;

	case 3: // wait for button down
		if (bt)
		{
			setTimer(&m_timer);
			m_goto = 4;
		}
		else if (getTimer(m_timer)>BT_LIGHTPIPE_TIMEOUT) // abort
			reset();
		break;

	case 4: // wait for button up
		if (!bt)
		{
			if (m_index==0)
			{
				cam_setAWB(0);
				flashLED(4); 
			}
			else
				setSignature();
			reset(); // done	
		}
		else if (getTimer(m_timer)>BT_INITIAL_BUTTON_TIMEOUT)
		{
 			if (m_index==0)
				cam_setAWB(0);

			reset();
			m_goto = 5;
		}
	 	break;

	case 5: // wait for button up only
		if (!bt)
			reset();
		break;

	default:
		reset();
	}	

	return m_goto!=0;
}