Пример #1
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();

  /* Configure the system clock to 168 MHz */
  SystemClock_Config();

  /*##-1- Initialize the SRAM ################################################*/
  BSP_SRAM_Init();

  /*##-2- Initialize the LCD #################################################*/
  BSP_LCD_Init();

  /*##-3- Camera Initialization and start capture ############################*/
  /* Initialize the Camera */
  BSP_CAMERA_Init(CAMERA_R320x240);

  /* Start the Camera Capture */
  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);

  /* Infinite loop */
  while (1)
  {
  }
}
Пример #2
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint32_t  i;
  uint32_t  *ptrLcd;

  /* Enable the CPU Cache */
  CPU_CACHE_Enable();
  
  /* STM32F7xx HAL library initialization:
       - Configure the Flash ART accelerator on ITCM interface
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();

  /* Configure the system clock to 200 MHz */
  SystemClock_Config();
  
  /*##-1- Initialise the LCD #################################################*/
  BSP_LCD_Init();

  /* Init LCD screen buffer */
  ptrLcd = (uint32_t*)(LCD_FRAME_BUFFER);
  for (i=0; i<(BSP_LCD_GetXSize()*BSP_LCD_GetYSize()); i++)
  {
    ptrLcd[i]=0;
  }
  
  BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER);

  /* Enable the LCD */
  BSP_LCD_DisplayOn();

  /* Select the LCD Foreground layer */
  BSP_LCD_SelectLayer(1);

  /* Set active window */
  BSP_LCD_SetLayerWindow(1, xoffset, yoffset, xsize, ysize);
    
  /*##-2- Camera Initialisation and start capture ############################*/
  /* Initialize the Camera */
  BSP_CAMERA_Init(resolution);


  /* Start the Camera Capture */
  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);  

  while (1)
  {
  }
}
Пример #3
0
/**
  * @brief  Initialize the camera module.
  * @param  None
  * @retval None
  */
void CAMERA_Init(void)
{  
  /* Initialize the Camera */
  CameraError = BSP_CAMERA_Init(RESOLUTION_R160x120);
  if( CameraError != CAMERA_ERROR)
  {
    
    GUI_Delay(100);
    /* Start the capture */
    BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);
    
    CAMERA_Set_ContrastBrightness(CameraSettings.b.contrast, CameraSettings.b.brightness);
  }
}
Пример #4
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
void DCMI_CaptureMode_example(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock */
  SystemClock_Config();

  /*##-1- Disable SAI1_SDA signal ############################################*/  
  /* Note: In STM324X9I-EVAL RevB, PE6 pin is shared between data_7 of camera 
           and SAI1_SDA of codec WM8994, after power on, SAI1_SDA pin of codec WM8994 
           is in output state, thus preventing MCU from Receiving correct signal 
           from camera, so we need to configure SAI1_SDA pin of codec WM8994 
           in tri-state 
  */
  /* Initialize the Control interface of the Audio Codec */
  BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_SPEAKER, 0, 0);
  /* ADCDAT1 is tri-stated */
  AUDIO_IO_Write(AUDIO_I2C_ADDRESS, 0x200, 0);
  AUDIO_IO_Write(AUDIO_I2C_ADDRESS, 0x300, 0x6010);
  
  /*##-2- Initialise the LCD #################################################*/
  BSP_LCD_Init();
  
  /*##-3- Initialise the LCD Layer ###########################################*/
  BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER);
  
  /* Enable the LCD */
  BSP_LCD_DisplayOn();

  /* Select the LCD Foreground layer */
  BSP_LCD_SelectLayer(1);

  /*##-4- Camera Initialisation and start capture ############################*/
  /* Initialize the Camera */
  BSP_CAMERA_Init(RESOLUTION_R480x272);

  /* Start the Camera Capture */
  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);
  
  while (1)
  {
  }
}
/**
  * @brief  Initialize the camera module.
  * @param  None
  * @retval None
  */
void CAMERA_Init(void)
{
  /* Initialize the Camera */
  CameraError = BSP_CAMERA_Init(RESOLUTION_R160x120);

  if( CameraError != CAMERA_ERROR)
  {
    CAMERA_Configured = 1;
    GUI_Delay(100);
    /* Start the capture */
    BSP_CAMERA_ContinuousStart((uint8_t *)&buffer_camera);

    CameraSettings.b.contrast = 3;
    CameraSettings.b.brightness = 3;

    CAMERA_Set_ContrastBrightness(CameraSettings.b.contrast, CameraSettings.b.brightness);
  }
}
Пример #6
0
/**
  * @brief  Initialize the camera module.
  * @param  None
  * @retval None
  */
void CAMERA_Init(void)
{
  /* Disable AUDIO Clock, because of shared pins */
  BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_SPEAKER, 0, 0); 
  AUDIO_IO_Write(AUDIO_I2C_ADDRESS, 0x200, 0x0);
  AUDIO_IO_Write(AUDIO_I2C_ADDRESS, 0x300, 0x6010);
  
  /* Initialize the Camera */
  CameraError = BSP_CAMERA_Init(RESOLUTION_R320x240);
  if( CameraError != CAMERA_ERROR)
  {
    GUI_Delay(100);
    /* Start the capture */
    BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);
    
    CAMERA_Set_ContrastBrightness(CameraSettings.b.contrast, CameraSettings.b.brightness);
  }
}
Пример #7
0
/**
  * @brief  Camera demo
  * @param  None
  * @retval None
  */
void Camera_demo (void)
{
  uint8_t  status = 0;
  uint32_t exit = 0;
  uint32_t camera_status = CAMERA_OK;
  uint32_t argb8888_Value = 0x00FF00FF; /* = 0xF81F in RGB565 format */
  TS_StateTypeDef  TS_State;
  uint32_t TS_command = TS_RESOLUTION;

  Camera_SetHint();

  status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());

  if (status != TS_OK)
  {
    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
    BSP_LCD_SetTextColor(LCD_COLOR_RED);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 95, (uint8_t *)"ERROR", CENTER_MODE);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - 80, (uint8_t *)"Touchscreen cannot be initialized", CENTER_MODE);
  }

  /*## Camera Initialization and start capture ############################*/

  CameraResIndex = CAMERA_R160x120;     /* Set QQVGA default resolution */
  CameraResX = CAMERA_QQVGA_RES_X;
  CameraResY = CAMERA_QQVGA_RES_Y;

  /* Infinite loop */
  while (exit == 0)
  {
    if (TS_command == TS_RESOLUTION)  /* A camera change resolution has been asked */
    {
      TS_command = TS_NO_COMMAND;

      BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
      BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
      BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"Wait for camera initialization...", CENTER_MODE);

      BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
      BSP_LCD_SetTextColor(LCD_COLOR_BLUE);

      switch (CameraResIndex)
      {
        case CAMERA_R160x120:
          CameraResX = CAMERA_QQVGA_RES_X;
          CameraResY = CAMERA_QQVGA_RES_Y;
          /* Initialize the Camera */
          camera_status = BSP_CAMERA_Init(RESOLUTION_R160x120);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"       QQVGA camera stream       ", CENTER_MODE);
          break;

        case CAMERA_R320x240:
          CameraResX = CAMERA_QVGA_RES_X;
          CameraResY = CAMERA_QVGA_RES_Y;
          /* Initialize the Camera */
          camera_status = BSP_CAMERA_Init(RESOLUTION_R320x240);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"       QVGA camera stream        ", CENTER_MODE);
          break;

        case CAMERA_R480x272:
          CameraResX = CAMERA_480x272_RES_X;
          CameraResY = CAMERA_480x272_RES_Y;
          /* Initialize the Camera */
          camera_status = BSP_CAMERA_Init(RESOLUTION_R480x272);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"      480x272 camera stream      ", CENTER_MODE);
          break;

        case CAMERA_R640x480:
          CameraResX = CAMERA_VGA_RES_X;
          CameraResY = CAMERA_VGA_RES_Y;
          /* Initialize the Camera */
          camera_status = BSP_CAMERA_Init(RESOLUTION_R640x480);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"        VGA camera stream        ", CENTER_MODE);
          break;

        default :
          break;
      }

      if (camera_status != CAMERA_OK)
      {
        BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS - 15, (uint8_t *)"        CAMERA INIT ERROR        ", CENTER_MODE);
      }
      else
      {
        offset_cam = 0;
        offset_lcd = 0;
        display_line_counter = 0;

        special_effect = CAMERA_BLACK_WHITE;      /* No special effect applied */
        color_effect = CAMERA_BLACK_WHITE_NORMAL;
        contrast = CAMERA_CONTRAST_LEVEL2;        /* Mid-level brightness */
        brightness = CAMERA_BRIGHTNESS_LEVEL2;    /* Mid-level contrast */

        CameraFrameBufferInitComplete = 0;
        CameraFrameBufferInitError    = 0;

        /* Init or Re-Init Camera frame buffer by using DMA2D engine in mode Register to Memory */
        camera_status = CameraFrameBufferRgb565_Init(CAMERA_VGA_RES_X,
                                                     CAMERA_VGA_RES_Y,
                                                     argb8888_Value);
        ASSERT(camera_status != CAMERA_OK);

        /* Wait end of DMA2D operation of error : via IT callback update */
        while((CameraFrameBufferInitComplete == 0) && (CameraFrameBufferInitError == 0)) {;}

        /* Assert if error : no transfer complete */
        ASSERT(CameraFrameBufferInitComplete != 1);

        /* Start / Restart camera stream */
        BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);

        /* Allow DMA2D copy from Camera frame buffer to LCD Frame buffer location */
        Camera_AllowDma2dCopyCamFrmBuffToLcdFrmBuff = 1;
      }
    }  /* (CameraResIndex != CameraCurrentResIndex) */

    if (camera_status == CAMERA_OK)
    {
      /* Check in polling mode in touch screen the touch status and coordinates */
      /* if touch occurred                                                      */
      BSP_TS_GetState(&TS_State);
      if(TS_State.touchDetected >= 1)
      {
        /* Check touch position to apply brightness or contrast change */
        if (TS_State.touchDetected == 1)
        {
          if ((TS_State.touchY[0] < 30) && (brightness < CAMERA_BRIGHTNESS_MAX))
          {
            TS_command = TS_BRIGHTNESS_INC;
            brightness++;
          }
          else if ((TS_State.touchY[0] > (BSP_LCD_GetYSize() - 30)) && (brightness > CAMERA_BRIGHTNESS_MIN) )
          {
            TS_command = TS_BRIGHTNESS_DEC;
            brightness--;
          }
          else if ((TS_State.touchX[0] < 30) && (contrast > CAMERA_CONTRAST_MIN))
          {
            TS_command = TS_CONTRAST_DEC;
            contrast--;
          }
          else if ((TS_State.touchX[0] > (BSP_LCD_GetXSize() - 30)) && (contrast < CAMERA_CONTRAST_MAX))
          {
            TS_command = TS_CONTRAST_INC;
            contrast++;
          }
          else
          {
            TS_command = TS_NO_COMMAND;
          }
        }

        /* Special effect change */
        if (TS_State.touchDetected == 2)
        {
          TS_command = TS_EFFECT;
          switch (special_effect)
          {
            case CAMERA_BLACK_WHITE :
              if (color_effect < CAMERA_BLACK_WHITE_NORMAL)
              {
                /* From BW effect to another BW effect */
                color_effect++;
              }
              else
              {
                /* From BW or none effect to color effect */
                special_effect = CAMERA_COLOR_EFFECT;
                color_effect = CAMERA_COLOR_EFFECT_BLUE;
              }
              break;

            case CAMERA_COLOR_EFFECT :
              if (color_effect < CAMERA_COLOR_EFFECT_ANTIQUE)
              {
                /* From color effect to another color effect */
                color_effect++;
              }
              else
              {
                /* From color effect to BW effect */
                special_effect = CAMERA_BLACK_WHITE;
                color_effect = CAMERA_BLACK_WHITE_BW;
              }
              break;

            default :
              /* None effect */
              special_effect = CAMERA_BLACK_WHITE;
              color_effect = CAMERA_BLACK_WHITE_NORMAL;
              break;
          }
        }

        if (TS_command == TS_NO_COMMAND)
        {
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"                                 ", CENTER_MODE);
        }

        if ((TS_command == TS_BRIGHTNESS_INC) || (TS_command == TS_BRIGHTNESS_DEC) || (TS_command == TS_CONTRAST_INC) || (TS_command == TS_CONTRAST_DEC))
        {
          /* A brightness change has been asked */
          BSP_CAMERA_ContrastBrightnessConfig(contrast, brightness);
          if ((TS_command == TS_BRIGHTNESS_INC) || (TS_command == TS_BRIGHTNESS_DEC))
          {
            BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"        Brightness change        ", CENTER_MODE);
          }
          else
          {
            BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"         Contrast change         ", CENTER_MODE);
          }
        }

        if (TS_command == TS_EFFECT)
        {
          /* A color effect change has been asked */
          switch (special_effect)
          {
            case CAMERA_BLACK_WHITE :
              BSP_CAMERA_BlackWhiteConfig(color_effect);
              switch (color_effect)
              {
                case CAMERA_BLACK_WHITE_NORMAL :
                  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"        No effect applied        ", CENTER_MODE);
                  break;
                case CAMERA_BLACK_WHITE_BW :
                  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)" Black and white effect applied  ", CENTER_MODE);
                  break;
                case CAMERA_BLACK_WHITE_NEGATIVE :
                  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"     Negative effect applied     ", CENTER_MODE);
                  break;
                case CAMERA_BLACK_WHITE_BW_NEGATIVE :
                  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"   BW negative effect applied    ", CENTER_MODE);
                  break;
              }
              break;

            case CAMERA_COLOR_EFFECT :
              BSP_CAMERA_ColorEffectConfig(color_effect);
              switch (color_effect)
              {
                case CAMERA_COLOR_EFFECT_ANTIQUE :
                  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"   Sepia color effect applied    ", CENTER_MODE);
                  break;
                case CAMERA_COLOR_EFFECT_BLUE :
                  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"    Blue color effect applied    ", CENTER_MODE);
                  break;
                case CAMERA_COLOR_EFFECT_GREEN :
                  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"   Green color effect applied    ", CENTER_MODE);
                  break;
                case CAMERA_COLOR_EFFECT_RED :
                  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"     Red color effect applied    ", CENTER_MODE);
                  break;
              }
              break;
          }
        }

        if (TS_State.touchDetected >= 3)  /* 3 or more fingers touch to change resolution */
        {
          TS_command = TS_RESOLUTION;
          if (CameraResIndex < CAMERA_RES_INDEX_MAX)
          {
            CameraResIndex++;     /* Switch to higher resolution */
          }
          else
          {
            CameraResIndex = CAMERA_RES_INDEX_MIN;
          }

          /* Disallow DMA2D copy from Camera frame buffer to LCD Frame buffer location */
          Camera_AllowDma2dCopyCamFrmBuffToLcdFrmBuff = 0;

          /* Insert 10 ms delay */
          HAL_Delay(10);

          /* Stop camera stream */
          camera_status = BSP_CAMERA_Stop();
          ASSERT(camera_status != CAMERA_OK);

          /* Clear screen */
          Camera_SetHint();
        }

        /* Wait for touch screen no touch detected */
        do
        {
          BSP_TS_GetState(&TS_State);
        }while(TS_State.touchDetected > 0);
      }
    }

    if (CheckForUserInput() > 0)
    {
      exit = 1;
    }
  }

  if (camera_status == CAMERA_OK)
  {
    /* Stop camera stream */
    camera_status = BSP_CAMERA_Stop();
    ASSERT(camera_status != CAMERA_OK);
  }
  /* End of camera demo */
}
Пример #8
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 168 MHz */
  SystemClock_Config();
  
  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);
  
  /*##-1- Init Host Library ##################################################*/
  USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSB_Host);
  
  /*##-2- Disable SAI1_SDA signal ############################################*/  
  /* Note: In STM324x9I-EVAL RevB, PE6 pin is shared between data_7 of camera 
           and SAI1_SDA of codec WM8994, after power on, SAI1_SDA pin of codec WM8994 
           is in output state, thus preventing MCU from receiving correct signal 
           from camera, so we need to configure SAI1_SDA pin of codec WM8994 
           in tri-state */
  
  /* Initialize the Control interface of the Audio Codec */
  BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_SPEAKER, 70, AUDIO_FREQUENCY_48K); 
  /* ADCDAT1 is tri-stated */
  AUDIO_IO_Write(AUDIO_I2C_ADDRESS, 0x200, 0);
  AUDIO_IO_Write(AUDIO_I2C_ADDRESS, 0x300, 0x6010);  

  /*##-3- Configure TAMPER Button ############################################*/
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);
  
  /*##-4- Link the USB Host disk I/O driver ##################################*/
  FATFS_LinkDriver(&USBH_Driver, MSC_Path);
  
  /*##-5- Initialize the LCD #################################################*/
  BSP_LCD_Init();
  
  /* Foreground Layer Initialization */
  BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER_LAYER1);
  /* Set Foreground Layer */
  BSP_LCD_SelectLayer(1);
  /* Clear the LCD Foreground layer */
  BSP_LCD_Clear(LCD_COLOR_WHITE);
  BSP_LCD_SetLayerVisible(1, DISABLE);
  
  /* Background Layer Initialization */
  BSP_LCD_LayerDefaultInit(0, LCD_FRAME_BUFFER);
  
  /* Enable the LCD */
  BSP_LCD_DisplayOn();   
  
  /* Select the LCD Foreground layer */
  BSP_LCD_SelectLayer(0);
  BSP_LCD_Clear(LCD_COLOR_WHITE);
  
  /*##-6- Camera Initialization and start capture ############################*/
  /* Initialize the Camera */
  BSP_CAMERA_Init(RESOLUTION_R480x272);
  
  /* Start the Camera Capture */
  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);
  
  /*##-7- Run Application ####################################################*/
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSB_Host);
    
    switch(Appli_state)
    {
    case STORAGE_READY:
      CAMERA_Capture();
      break;
      
    case STORAGE_IDLE:
      break;      
    } 
  }
}
Пример #9
0
/**
  * @brief  Camera demo
  * @param  None
  * @retval None
  */
void Camera_demo (void)
{ 
  uint8_t status = 0;
  uint16_t  *ptrCamera;
  uint32_t  i;
  uint32_t  exit = 0;

  Camera_SetHint();

  status = BSP_JOY_Init(JOY_MODE_GPIO);

  /* Initialize the SDRAM for CAMERA_FRAME_BUFFER */
  BSP_SDRAM_Init();

  if (status != IO_OK)
  {
    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
    BSP_LCD_SetTextColor(LCD_COLOR_RED);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- CAMERA_STATUS_TEXT_POS, (uint8_t *)"ERROR", CENTER_MODE);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- CAMERA_STATUS_TEXT_POS - 15, (uint8_t *)"Joystick cannot be initialized", CENTER_MODE);
    status = 0;
  }

  /*## Camera Initialization and start capture ############################*/

  BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
  BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- CAMERA_STATUS_TEXT_POS, (uint8_t *)"Wait for camera initialization...", CENTER_MODE);

  /* Init Camera buffer */
  ptrCamera = (uint16_t*)(CAMERA_FRAME_BUFFER);
  CameraResIndex = CAMERA_R160x120;     /* Set QQVGA default resolution */
  CameraChangeResolutionAsked = 1;
  for (i=0; i<(CAMERA_QVGA_RES_X * CAMERA_QVGA_RES_Y); i++)   /* Camera buffer initialization */
  {
    ptrCamera[i]=0xFFFF;
  }

  /* Initialize IO */
  BSP_IO_Init();

  /* Infinite loop */
  while(exit == 0)
  {
    if (CameraChangeResolutionAsked)  /* A camera change resolution has been asked */
    {
      CameraChangeResolutionAsked = 0;
      if (CameraResIndex > CAMERA_R160x120)
      { /* If camera stream already started, it has to be stopped before reconfiguration */
        /* Stop camera stream */
        status = BSP_CAMERA_Stop();
        ASSERT(status != CAMERA_OK);

        /* Clear screen */
        Camera_SetHint();

        BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
        BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- CAMERA_STATUS_TEXT_POS, (uint8_t *)"Wait for camera initialization...", CENTER_MODE);
      }
 
      BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
      BSP_LCD_SetTextColor(LCD_COLOR_BLUE);

      status = 0;

      switch (CameraResIndex)
      {
        case CAMERA_R160x120:
          /* Initialize the Camera */
          status = BSP_CAMERA_Init(RESOLUTION_R160x120);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- CAMERA_STATUS_TEXT_POS, (uint8_t *)"       QQVGA camera stream       ", CENTER_MODE);
          break;

        case CAMERA_R320x240:
          /* Initialize the Camera */
          status = BSP_CAMERA_Init(RESOLUTION_R320x240);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- CAMERA_STATUS_TEXT_POS, (uint8_t *)"       QVGA camera stream        ", CENTER_MODE);
          break;
      }

      if (status != CAMERA_OK)
      {
        BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- CAMERA_STATUS_TEXT_POS - 15, (uint8_t *)"        CAMERA INIT ERROR        ", CENTER_MODE);
      }


      /* Start / Restart camera stream */
      BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);
    }  /* (CameraResIndex != CameraCurrentResIndex) */


    /* Toggle LED4 */
    BSP_LED_Toggle(LED3);

    /* Insert 100 ms delay */
    HAL_Delay(100);

    /* Toggle LED2 */
    BSP_LED_Toggle(LED2);

    /* Insert 100 ms delay */
    HAL_Delay(100);
    if(CheckForUserInput() > 0)
    {
      if (CameraResIndex < CAMERA_RES_INDEX_MAX)
      {
        CameraResIndex++;     /* Switch to higher resolution */
        CameraChangeResolutionAsked = 1;
      }
      else
      {
        BSP_CAMERA_DeInit();
        exit = 1;
      }
    }
  }

  /* Stop camera stream */
  status = BSP_CAMERA_Stop();
  ASSERT(status != CAMERA_OK);

  /* End of camera demo */
}
Пример #10
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
	uint8_t lcd_status = LCD_OK;
        
  p_bmp_converted_pixel_data    = (uint8_t *)CONVERTED_FRAME_BUFFER;

  offset_address_area_cam_in_lcd_buffer = ((((LcdResY - CameraResY) / 2) * LcdResX)
                                          +   ((LcdResX - CameraResX) / 2))
                                          * ARGB8888_BYTE_PER_PIXEL;

  /* For the first Camera line event callback : set the offset to display camera image in the center */
  /* of LCD frame buffer background */
  lcd_datapointer = offset_address_area_cam_in_lcd_buffer;

	/* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();

  /* Configure the system clock to 180 MHz */
  SystemClock_Config();

  BSP_IO_Init();

  /* Reset and power down camera to be sure camera is Off prior start testing BSP */
  BSP_CAMERA_HwReset();
  BSP_CAMERA_PwrDown();

  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);

  /*##-1- LCD DSI initialization in mode Video Burst  with two LTDC layers of size 800x480 */
  lcd_status = BSP_LCD_Init();
  if(lcd_status != LCD_OK)
  {
	  Error_Handler();
  }
  
  BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER_BACKGROUND, LCD_BG_LAYER_ADDRESS);
  BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER_FOREGROUND, LCD_FB_START_ADDRESS);

  /* Select Foreground Layer */
  BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_FOREGROUND);

  /* Clear the LCD Foreground layer */
  BSP_LCD_Clear(LCD_COLOR_WHITE);

  /* Disable the LTDC Foreground layer */
  BSP_LCD_SetLayerVisible(LTDC_ACTIVE_LAYER_FOREGROUND, DISABLE);

  /* Select the LCD Background layer */
  BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER_BACKGROUND);
  BSP_LCD_Clear(LCD_COLOR_WHITE);

  /*##-2- Init Host Library ##################################################*/

  /* Display USB initialization message */
  BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
  BSP_LCD_SetFont(&Font24);
  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 24), (uint8_t *)"USB init ..", RIGHT_MODE);

  USBH_Init(&hUSB_Host, USBH_UserProcess, 0);

  /* Add Supported Class */
  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);

  /* Start Host Process */
  USBH_Start(&hUSB_Host);

  /*##-3- Configure TAMPER Button ############################################*/
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);

  /*##-4- Link the USB Host disk I/O driver ##################################*/
  FATFS_LinkDriver(&USBH_Driver, MSC_Path);

  /*##-5- Camera Initialization and start capture ############################*/

  /* Display camera initialization message */
  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 24), (uint8_t *)"Camera init ..", RIGHT_MODE);

  /* Initialize the Camera */
  BSP_CAMERA_Init(RESOLUTION_R480x272);

  /* Start the Camera Capture */
  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);

  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 48), (uint8_t *)"Press TAMPER button to take snapshot", RIGHT_MODE);
  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 24), (uint8_t *)"Camera Play ..", RIGHT_MODE);

  /*##-6- Run Application ####################################################*/
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSB_Host);

    switch(Appli_state)
    {
    case STORAGE_READY:
      CAMERA_Capture();
      break;

    case STORAGE_IDLE:
      break;
    }
  }
}
Пример #11
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 168 MHz */
  SystemClock_Config();
  
  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);
  
  /*##-1- Init Host Library ##################################################*/
  USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);
  
  /* Start Host Process */
  USBH_Start(&hUSB_Host);
  
  /*##-2- Configure Tamper button ############################################*/
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);
  
  /*##-3- Link the USB Host disk I/O driver ##################################*/
  FATFS_LinkDriver(&USBH_Driver, MSC_Path);

  /*##-4- Initialize the SRAM and LCD ########################################*/ 
  BSP_LCD_Init(); 
  BSP_SRAM_Init();
  
  /*##-5- Camera Initialization and start capture ############################*/
  /* Initialize the Camera */
  BSP_CAMERA_Init(RESOLUTION_R320x240);
  
  /* Start the Camera Capture */
  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);
   
  /*##-6- Run Application ####################################################*/
  while (1)
  { 
    /* USB Host Background task */
    USBH_Process(&hUSB_Host);

    switch(Appli_state)
    {
    case STORAGE_READY:
      CAMERA_Capture();
      break;
        
    case STORAGE_IDLE:
    default:
      break;      
    } 
  }
}
Пример #12
0
/**
  * @brief  Animation demo
  * @param  None
  * @retval None
  */
void Animation_demo (void)
{
  uint32_t exit = 0;
  uint32_t CameraChangeResolutionAsked = 1;
#ifdef USE_CAMERA_IN_ANIMATION
  uint32_t camera_status = CAMERA_OK;
  uint32_t argb8888_Value = 0x00556677;
  uint32_t CameraResX = CAMERA_VGA_RES_X;
  uint32_t CameraResY = CAMERA_VGA_RES_Y;
#endif /* USE_CAMERA_IN_ANIMATION */

  Animation_SetHint();

  /*## Camera Initialization and start capture ############################*/

  BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
  BSP_LCD_SetTextColor(LCD_COLOR_WHITE);

#ifdef USE_CAMERA_IN_ANIMATION
  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - ANIMATION_STATUS_TEXT_POS, (uint8_t *)"Wait for camera initialization...", CENTER_MODE);
#endif /* USE_CAMERA_IN_ANIMATION */

  /* Infinite loop */
  while (exit == 0)
  {
    if(CameraChangeResolutionAsked)  /* A camera change resolution has been asked */
    {
      CameraChangeResolutionAsked = 0;

      BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
      BSP_LCD_SetTextColor(LCD_COLOR_BLUE);

#ifdef USE_CAMERA_IN_ANIMATION
      /* Initialize the Camera */
      camera_status = BSP_CAMERA_Init(RESOLUTION_R640x480);
      BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - ANIMATION_STATUS_TEXT_POS, (uint8_t *)"        VGA camera stream        ", CENTER_MODE);
      if (camera_status != CAMERA_OK)
      {
        BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - ANIMATION_STATUS_TEXT_POS - 15, (uint8_t *)"        CAMERA INIT ERROR        ", CENTER_MODE);
      }
#endif /* USE_CAMERA_IN_ANIMATION */

      /* Clear first the LCD */
      BSP_LCD_Clear(LCD_COLOR_WHITE);

#ifdef USE_CAMERA_IN_ANIMATION
      /* Init or Re-Init Camera frame buffer by using DMA2D engine in mode Register to Memory */
      camera_status = AnimationCameraFrameBufferRgb565_Init(CameraResX,
                                                            CameraResY,
                                                            argb8888_Value);
      BSP_TEST_APPLI_ASSERT(camera_status != CAMERA_OK);

      /* Start / Restart camera stream */
      BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FB_START_ADDR);
#endif /* USE_CAMERA_IN_ANIMATION */

      /* Forbid in that case the DMA2D copy from Camera frame buffer to LCD Frame buffer location by BSP_CAMERA_LineEventCallback() */
      Camera_AllowDma2dCopyCamFrmBuffToLcdFrmBuff = 0;

    }  /* of if (CameraChangeResolutionAsked) */

    /* Toggle LED4 */
    BSP_LED_Toggle(LED4);

    /* Insert 100 ms delay */
    HAL_Delay(100);

    /* Toggle LED2 */
    BSP_LED_Toggle(LED2);

    /* Insert 400 ms delay */
    HAL_Delay(400);
    if(CheckForUserInput() > 0)
    {
      exit = 1;
    }

    anime_draw_scene(anime_lcd_frame_buffer);

  } /* of while (exit == 0) */

#ifdef USE_CAMERA_IN_ANIMATION
  /* Stop camera stream */
  camera_status = BSP_CAMERA_Stop();
  BSP_TEST_APPLI_ASSERT(camera_status != CAMERA_OK);
#endif /* USE_CAMERA_IN_ANIMATION */
}
Пример #13
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Enable the CPU Cache */
  CPU_CACHE_Enable();

  /* STM32F7xx HAL library initialization:
       - Configure the Flash ART accelerator on ITCM interface
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 200 MHz */
  SystemClock_Config(); 
  
  /* Configure LED1 and LED3 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED3);
  
  /*##-1- Initialize the LCD #################################################*/
  /* Two layers are used in this application simultaneously 
     so "LCD_MIN_PCLK" is recommended to programme the PCLK at 20 MHz */   
  BSP_LCD_InitEx(LCD_MIN_PCLK);
  
  /* Foreground Layer Initialization */
  BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER_LAYER1);
  /* Set Foreground Layer */
  BSP_LCD_SelectLayer(1);
  /* Clear the LCD Foreground layer */
  BSP_LCD_Clear(LCD_COLOR_WHITE);
  BSP_LCD_SetLayerVisible(1, DISABLE);

  /* Background Layer Initialization */
  BSP_LCD_LayerDefaultInit(0, LCD_FRAME_BUFFER);
  
  /* Enable the LCD */
  BSP_LCD_DisplayOn();   
  
  /* Select the LCD Foreground layer */
  BSP_LCD_SelectLayer(0);
  BSP_LCD_Clear(LCD_COLOR_WHITE);
  
  BSP_LCD_SetLayerWindow(0, 0, 0, 480, 272);
  /*##-2- Init Host Library ##################################################*/

  /* Display USB initialization message */
  BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE);
  BSP_LCD_SetFont(&Font24);
  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 24), (uint8_t *)"USB init ..", RIGHT_MODE);

  USBH_Init(&hUSB_Host, USBH_UserProcess, 0);
  
  /* Add Supported Class */
  USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);

  /* Start Host Process */
  USBH_Start(&hUSB_Host);

  /*##-3- Configure TAMPER Button ############################################*/
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);

  /*##-4- Link the USB Host disk I/O driver ##################################*/
  FATFS_LinkDriver(&USBH_Driver, MSC_Path);

  /*##-5- Camera Initialization and start capture ############################*/

  /* Display camera initialization message */
  BSP_LCD_DisplayStringAt(20, (BSP_LCD_GetYSize() - 24), (uint8_t *)"Camera init ..", RIGHT_MODE);

  /* Initialize the Camera */
  BSP_CAMERA_Init(RESOLUTION_R480x272);
  
  /* Start the Camera Capture */
  BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FRAME_BUFFER);
  
  /*##-6- Run Application ####################################################*/
  while (1)
  {
    /* USB Host Background task */
    USBH_Process(&hUSB_Host);
    
    switch(Appli_state)
    {
    case STORAGE_READY:
      CAMERA_Capture();
      break;
      
    case STORAGE_IDLE:
      break;      
    } 
  }
}
Пример #14
0
/**
  * @brief  Camera demo
  * @param  None
  * @retval None
  */
void Camera_demo (void)
{
  uint8_t  status = 0;
  uint32_t exit = 0;
  uint32_t camera_status = CAMERA_OK;
  uint32_t argb8888_Value = 0x00556677;

  Camera_SetHint();

  /* Activate joystick as used for contrast, brightness and visual effect settings */
  /* on image from camera sensor                                                   */
  status = BSP_JOY_Init(JOY_MODE_GPIO);
  if (status != IO_OK)
  {
    BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
    BSP_LCD_SetTextColor(LCD_COLOR_RED);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"ERROR", CENTER_MODE);
    BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS - 15, (uint8_t *)"Joystick cannot be initialized", CENTER_MODE);
  }

  /*## Camera Initialization and start capture ############################*/

  BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
  BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
  BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"Wait for camera initialization...", CENTER_MODE);

  CameraResIndex = CAMERA_R160x120;     /* Set QQVGA default resolution */
  CameraChangeResolutionAsked = 1;
  CameraResX = CAMERA_QQVGA_RES_X;
  CameraResY = CAMERA_QQVGA_RES_Y;

  /* Infinite loop */
  while (exit == 0)
  {
    if (CameraChangeResolutionAsked)  /* A camera change resolution has been asked */
    {
      CameraChangeResolutionAsked = 0;

      if (CameraResIndex > CAMERA_R160x120)
      { /* If camera stream already started, it has to be stopped before reconfiguration */
        /* Stop camera stream */
        refresh_authorized = 0;
        camera_status = BSP_CAMERA_Stop();
        BSP_TEST_APPLI_ASSERT(camera_status != CAMERA_OK);

        /* Clear screen */
        Camera_SetHint();

        BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
        BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"Wait for camera initialization...", CENTER_MODE);
      }

      BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
      BSP_LCD_SetTextColor(LCD_COLOR_BLUE);

      switch (CameraResIndex)
      {
        case CAMERA_R160x120:
          CameraResX = CAMERA_QQVGA_RES_X;
          CameraResY = CAMERA_QQVGA_RES_Y;
          /* Initialize the Camera */
          camera_status = BSP_CAMERA_Init(RESOLUTION_R160x120);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"       QQVGA camera stream       ", CENTER_MODE);
          break;

        case CAMERA_R320x240:
          CameraResX = CAMERA_QVGA_RES_X;
          CameraResY = CAMERA_QVGA_RES_Y;
          /* Initialize the Camera */
          camera_status = BSP_CAMERA_Init(RESOLUTION_R320x240);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"       QVGA camera stream        ", CENTER_MODE);
          break;

        case CAMERA_R480x272:
          CameraResX = CAMERA_480x272_RES_X;
          CameraResY = CAMERA_480x272_RES_Y;
          /* Initialize the Camera */
          camera_status = BSP_CAMERA_Init(RESOLUTION_R480x272);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"      480x272 camera stream      ", CENTER_MODE);
          break;

        case CAMERA_R640x480:
          CameraResX = CAMERA_VGA_RES_X;
          CameraResY = CAMERA_VGA_RES_Y;
          /* Initialize the Camera */
          camera_status = BSP_CAMERA_Init(RESOLUTION_R640x480);
          BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"        VGA camera stream        ", CENTER_MODE);
          break;

        default :
          break;
      }

      if (camera_status != CAMERA_OK)
      {
        BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS - 15, (uint8_t *)"        CAMERA INIT ERROR        ", CENTER_MODE);
      }

      offset_cam = 0;
      offset_lcd = 0;
      display_line_counter = 0;
      display_rotated_line_counter = 0;

      special_effect = CAMERA_BLACK_WHITE;      /* No special effect applied */
      color_effect = CAMERA_BLACK_WHITE_NORMAL;
      contrast = CAMERA_CONTRAST_LEVEL2;        /* Mid-level brightness */
      brightness = CAMERA_BRIGHTNESS_LEVEL2;    /* Mid-level contrast */

      refresh_authorized = 1;

      CameraFrameBufferInitComplete = 0;
      CameraFrameBufferInitError    = 0;

      if(CameraResIndex == CAMERA_R640x480)
      {
        /* Clear first the LCD */
        BSP_LCD_Clear(LCD_COLOR_WHITE);
      }

      /* Init or Re-Init Camera frame buffer by using DMA2D engine in mode Register to Memory */
      camera_status = CameraFrameBufferRgb565_Init(CAMERA_VGA_RES_X,
                                                   CAMERA_VGA_RES_Y,
                                                   argb8888_Value);
      BSP_TEST_APPLI_ASSERT(camera_status != CAMERA_OK);

      /* Wait end of DMA2D operation of error : via IT callback update */
      while((CameraFrameBufferInitComplete == 0) && (CameraFrameBufferInitError == 0)) {;}

      /* Assert if error : no transfer complete */
      BSP_TEST_APPLI_ASSERT(CameraFrameBufferInitComplete != 1);

      /* Start / Restart camera stream */
      BSP_CAMERA_ContinuousStart((uint8_t *)CAMERA_FB_START_ADDR);

      /* Allow DMA2D copy from Camera frame buffer to LCD Frame buffer location */
      Camera_AllowDma2dCopyCamFrmBuffToLcdFrmBuff = 1;

    }  /* (CameraResIndex != CameraCurrentResIndex) */

    /* Get the Joystick State */
    JoyState = BSP_JOY_GetState();

    switch (JoyState)
    {
      case JOY_UP:
        if (brightness < CAMERA_BRIGHTNESS_MAX)
        {
          brightness++;
        }
        else
        {
          JoyState = JOY_NONE;  /* Cancel brightness change */
        }
        break;

      case JOY_DOWN:
        if (brightness > CAMERA_BRIGHTNESS_MIN)
        {
          brightness--;
        }
        else
        {
          JoyState = JOY_NONE;  /* Cancel brightness change */
        }
        break;

      case JOY_LEFT:
        if (contrast > CAMERA_CONTRAST_MIN)
        {
          contrast--;
        }
        else
        {
          JoyState = JOY_NONE;  /* Cancel contrast change */
        }
        break;

      case JOY_RIGHT:
        if (contrast < CAMERA_CONTRAST_MAX)
        {
          contrast++;
        }
        else
        {
          JoyState = JOY_NONE;  /* Cancel contrast change */
        }
        break;

      case JOY_SEL:
        switch (special_effect)
        {
          case CAMERA_BLACK_WHITE :
            if (color_effect < CAMERA_BLACK_WHITE_NORMAL)
            {
              /* From BW effect to another BW effect */
              color_effect++;
            }
            else
            {
              /* From BW or none effect to color effect */
              special_effect = CAMERA_COLOR_EFFECT;
              color_effect = CAMERA_COLOR_EFFECT_ANTIQUE;
            }
            break;

          case CAMERA_COLOR_EFFECT :
            if (color_effect < CAMERA_COLOR_EFFECT_RED)
            {
              /* From color effect to another color effect */
              color_effect++;
            }
            else
            {
              /* From color effect to BW effect */
              special_effect = CAMERA_BLACK_WHITE;
              color_effect = CAMERA_BLACK_WHITE_BW;
            }
            break;

          default :
            /* None effect */
            special_effect = CAMERA_BLACK_WHITE;
            color_effect = CAMERA_BLACK_WHITE_NORMAL;
            break;
        }
        break;

      default:
        break;
    }

    if ((JoyState == JOY_UP) || (JoyState == JOY_DOWN) || (JoyState == JOY_LEFT) || (JoyState == JOY_RIGHT))
    {
      /* A brightness change has been asked */
      BSP_CAMERA_ContrastBrightnessConfig(contrast, brightness);
      if ((JoyState == JOY_UP) || (JoyState == JOY_DOWN))
      {
        BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"        Brightness change        ", CENTER_MODE);
      }
      else
      {
        BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"         Contrast change         ", CENTER_MODE);
      }
    }

    if (JoyState == JOY_SEL)
    {
      /* A color effect change has been asked */
      switch (special_effect)
      {
        case CAMERA_BLACK_WHITE :
          BSP_CAMERA_BlackWhiteConfig(color_effect);
          switch (color_effect)
          {
            case CAMERA_BLACK_WHITE_NORMAL :
              BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"        No effect applied        ", CENTER_MODE);
              break;
            case CAMERA_BLACK_WHITE_BW :
              BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)" Black and white effect applied  ", CENTER_MODE);
              break;
            case CAMERA_BLACK_WHITE_NEGATIVE :
              BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"     Negative effect applied     ", CENTER_MODE);
              break;
            case CAMERA_BLACK_WHITE_BW_NEGATIVE :
              BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"   BW negative effect applied    ", CENTER_MODE);
              break;
          }
          break;

        case CAMERA_COLOR_EFFECT :
          BSP_CAMERA_ColorEffectConfig(color_effect);
          switch (color_effect)
          {
            case CAMERA_COLOR_EFFECT_ANTIQUE :
              BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"   Sepia color effect applied    ", CENTER_MODE);
              break;
            case CAMERA_COLOR_EFFECT_BLUE :
              BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"    Blue color effect applied    ", CENTER_MODE);
              break;
            case CAMERA_COLOR_EFFECT_GREEN :
              BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"   Green color effect applied    ", CENTER_MODE);
              break;
            case CAMERA_COLOR_EFFECT_RED :
              BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - CAMERA_STATUS_TEXT_POS, (uint8_t *)"     Red color effect applied    ", CENTER_MODE);
              break;
          }
          break;
      }
    }

    /* Toggle LED4 */
    BSP_LED_Toggle(LED3);

    /* Insert 100 ms delay */
    HAL_Delay(100);

    /* Toggle LED2 */
    BSP_LED_Toggle(LED2);

    /* Insert 100 ms delay */
    HAL_Delay(100);
    if (CheckForUserInput() > 0)
    {
      if (CameraResIndex < CAMERA_RES_INDEX_MAX)
      {
        CameraResIndex++;     /* Switch to higher resolution */
        CameraChangeResolutionAsked = 1;

        /* Disallow DMA2D copy from Camera frame buffer to LCD Frame buffer location */
        Camera_AllowDma2dCopyCamFrmBuffToLcdFrmBuff = 0;

        /* Insert 10 ms delay */
        HAL_Delay(10);
      }
      else
      {
        BSP_CAMERA_DeInit();
        exit = 1;
      }
    }
  }

  /* Stop camera stream */
  camera_status = BSP_CAMERA_Stop();
  BSP_TEST_APPLI_ASSERT(camera_status != CAMERA_OK);

  /* End of camera demo */
}