/**
  * @brief  Animation demo
  * @param  None
  * @retval None
  */
void Animation_demo (void)
{
  uint32_t exit = 0;
  uint32_t entry = 1;
  uint32_t initialState = 0;

  Animation_SetHint();

  /* Infinite loop */
  while (exit == 0)
  {
    if(entry == 1)  /* Entry */
    {
      entry = 0;

      BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
      BSP_LCD_SetTextColor(LCD_COLOR_BLUE);

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

    }  /* of if(entry == 1) */


    /* Read initial state of button User */
    initialState = BSP_PB_GetState(BUTTON_USER);

    /* 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);

    /* update the scene */
    anime_draw_scene(anime_lcd_frame_buffer);

    /* Re check button state */
    if(BSP_PB_GetState(BUTTON_USER) != initialState)
    {
      exit = 1;
    }

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

}
示例#2
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 */
}