Exemplo n.º 1
0
int main()
{
    setup();
    unsigned long previous_time = 0;
    static int k = 0;
    uint8_t temp;
    struct timeval tv;
    struct timezone tz;
    write_reg(ARDUCHIP_MODE, 0x01);		 	//Switch to CAM

    while(1)
    {
        temp = read_reg(ARDUCHIP_TRIG);

        if(!(temp & VSYNC_MASK))				//New Frame is coming
        {
            write_reg(ARDUCHIP_MODE, 0x00);    	//Switch to MCU
            resetXY();
            write_reg(ARDUCHIP_MODE, 0x01);    	//Switch to CAM
            while(!(read_reg(ARDUCHIP_TRIG)&0x01)); 	//Wait for VSYNC is gone
        }
        else if(temp & SHUTTER_MASK)
        {
            gettimeofday (&tv , &tz);
            previous_time = tv.tv_sec;
            //printf("previous_time is %d.\n",previous_time);
            while(read_reg(ARDUCHIP_TRIG) & SHUTTER_MASK)
            {
                gettimeofday (&tv , &tz);
                //printf("put time is %d.\n",tv.tv_sec);
                if((tv.tv_sec - previous_time) >= 2)
                {
                    Playback();
                    delayms(1000);
                }
            }

            gettimeofday (&tv , &tz);
            if((tv.tv_sec - previous_time) < 2)
            {
                //printf(" get time is %d.\n",tv.tv_sec);
                memset(filePath,0,28);
                strcat(filePath,"/home/pi/");
                getnowtime();
                strcat(filePath,nowtime);
                strcat(filePath,".bmp");
                //Open the new file
                fp = fopen(filePath,"w+");
                if (fp == NULL)
                {
                    printf("open file failed\n");
                    return 0;
                }				//Generate file name
                write_reg(ARDUCHIP_MODE, 0x00);    	//Switch to MCU, freeze the screen
                GrabImage(filePath);
            }
        }
    }
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
void main(void)
{
  Init_Sys();                               // Initialize system

  while (1)                                 // Repeat forever
  {
    // wait for key-press event, hold CPU in low-power mode
    P1IFG = 0;                              // Clear all P1.x interrupt flags
    P1IE |= 0xc0;                           // Enable int for buttons
    _BIS_SR(LPM3_bits + GIE);               // Enter LPM3 w/ interrupts
    _DINT();                                // Disable interrupts
    P1IE &= ~0xc0;                          // Disable interrupts for buttons

    // process key-press event
    if (!(P1IN & 0x40))                     // Record button pressed?
      Record();                             
    else                                    // No, -> must be playback button
      Playback();                           
  }
}
Exemplo n.º 3
0
void PlayMove(int iirec)
{
  Playback(rgirecMin[iirec], rgirecMax[iirec]);
}