Esempio n. 1
0
static void LCD_Config(void)
{
  /* LCD Initialization */
  LCD_Init();

  /* LCD Layers Initialization */
  LCD_LayerInit();

  /* Enable the LCD */
  LCD_DisplayOn();

  /* Set LCD Background Layer  */
  LCD_SetLayer(LCD_BACKGROUND_LAYER);
  /* Clear the Background Layer */
  LCD_Clear(LCD_COLOR_WHITE);

  /* Set LCD Foreground Layer  */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  /* Clear the Foreground Layer */
  LCD_Clear(LCD_COLOR_WHITE);

  /* Configure and enable the Color Keying feature */
  LCD_SetColorKeying(0);

  /* Configure the transparency for foreground : Increase the transprency */
  LCD_SetTransparency(100);

}
Esempio n. 2
0
static void LCD_Config(void)
{
  /* LCD Initialization */ 
  LCD_Init();

  /* LCD Initialization */ 
  LCD_LayerInit();

  /* Enable the LCD */ 
  LCD_DisplayOn(); 
  
  /* Connect the Output Buffer to LCD Background Layer  */
  LCD_SetLayer(LCD_BACKGROUND_LAYER);
  /* Clear the Background Layer */ 
  LCD_Clear(LCD_COLOR_BLACK);
  
  /* Configure the transparency for background : Increase the transparency */
  LCD_SetTransparency(0);
   
  /* Connect the Output Buffer to LCD Foreground Layer  */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  /* Clear the Background Layer */ 
  LCD_Clear(LCD_COLOR_BLACK);
  
  /* Configure the transparency for foreground : Increase the transparency */
  LCD_SetTransparency(100);
}
Esempio n. 3
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
     */      
    
  /* Configure DMA2D : Configure foreground and background */
  DMA2D_Config();
  
  /* Start Transfer */ 
  DMA2D_StartTransfer();
  
  /* Wait for TC Flag activation */
  while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET)
  {
  } 

  /* Configure LCD */
  LCD_Config(); 
  
  /* LCD Display */
  LCD_DisplayOn();  

  while (1)
  {
  }
}
Esempio n. 4
0
/**
 * @brief  Switches the backlight either ON or OFF
 * @param  state. This parameter can be one of the following values:
 *     @arg   GL_ON
 *     @arg   GL_OFF
 * @retval None
 */
void GL_BackLightSwitch(uint8_t u8_State)
{
	if (u8_State == GL_OFF) {
		LCD_DisplayOff();
	}
	else if (u8_State == GL_ON) {
		LCD_DisplayOn();
	}
}
Esempio n. 5
0
void ui_init()
{
    LCD_Init();

    LCD_LayerInit();

    LTDC_Cmd(ENABLE);

    LCD_DisplayOn();
}
Esempio n. 6
0
void LCD_Init( uint8_t numLines, uint8_t numCols )
{
    OSRAMInit( false );

    gNumLines = numLines;
    gNumCols  = numCols;

    LCD_Clear();
    LCD_DisplayOn();

} // LCD_Init
Esempio n. 7
0
void init()
{
    // LCD Init
    LCD_Start();
    LCD_DisplayOn();
    //LCD_PrintNumber(1);
    
    
    ADC_Start();
    

}
Esempio n. 8
0
/**
  * @brief  Display Init (LCD)
  * @param  None
  * @retval None
  */
void Display_Init(void)
{

  /* Initialize the LCD */
  LCD_Init();

  /* Display message on LCD ***************************************************/
#if defined (USE_STM324x9I_EVAL) 
  /* Initialize the LCD Layers */
  LCD_LayerInit();
  
  /* Enable The Display */
  LCD_DisplayOn(); 
  /* Set LCD Background Layer  */
  LCD_SetLayer(LCD_BACKGROUND_LAYER);
  /* Clear the Background Layer */ 
  LCD_Clear(LCD_COLOR_WHITE);
  
  /* Set LCD Foreground Layer  */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

  /* Configure the transparency for foreground */
  LCD_SetTransparency(100);
#endif /* USE_STM324x9I_EVAL */
  
  /* Clear the LCD */
  LCD_Clear(White);

  /* Set the LCD Text size */
  LCD_SetFont(&FONTSIZE);

  /* Set the LCD Back Color and Text Color*/
  LCD_SetBackColor(Blue);
  LCD_SetTextColor(White);

  LCD_DisplayStringLine(LINE(LINENUM), (uint8_t*)MESSAGE1);
  LCD_DisplayStringLine(LINE(0x16), (uint8_t*)"                                        ");
  
  /* Set the LCD Text size */
  LCD_SetFont(&Font16x24);

  LCD_DisplayStringLine(LCD_LINE_0, (uint8_t*)MESSAGE2);

  /* Set the LCD Back Color and Text Color*/
  LCD_SetBackColor(White);
  LCD_SetTextColor(Blue);

  LCD_DisplayStringLine(LCD_LINE_2, (uint8_t*)MESSAGE3);
  LCD_DisplayStringLine(LCD_LINE_4, (uint8_t*)MESSAGE4);
}
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f429_439xx.s) before to branch to application main.
     */     
       
  /* Example description.
     ------------------------------------------
  This example provides a description of how to configure DMA2D periph in 
  Memory_to_Memory with pixel format conversion transfer mode and display the 
  result on LCD.
  In this case two images will be displayed on the LCD, original image before 
  the pixel format conversion and the transferred data after pixel format conversion
  In this example the pixel format conversion is done from ARGB8888 to ARGB4444 
  and you can see on LCD the difference between the two images
   */  
  
  /* DMA2D configuration */
  DMA2D_Config();
  
  /* Start Transfer */
  DMA2D_StartTransfer(); 
  
  /* Wait for CTC Flag activation */
  while(DMA2D_GetFlagStatus(DMA2D_FLAG_TC) == RESET)
  {
  }  

  /* Configure LCD */
  LCD_Config();
  
  /* LCD Display */
  LCD_DisplayOn();

  while (1)
  {
  }
}
Esempio n. 10
0
File: LCD.c Progetto: TheCbac/OV5620
/*******************************************************************************
* Function Name: LCD_Enable
********************************************************************************
*
* Summary:
*  Turns on the display.
*
* Parameters:
*  None.
*
* Return:
*  None.
*
* Reentrant:
*  No.
*
* Theory:
*  This finction has no effect when it called first time as
*  LCD_Init() turns on the LCD.
*
*******************************************************************************/
void LCD_Enable(void) 
{
    LCD_DisplayOn();
    LCD_enableState = 1u;
}
/**
  * @brief  Enables the display.
  * @param  None
  * @retval None
  */
void BSP_LCD_DisplayOn(void)
{
  LCD_DisplayOn();
}
Esempio n. 12
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f0xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f0xx.c file
     */  
  
  /* Initialize the LCD */
#ifdef USE_STM320518_EVAL
    STM320518_LCD_Init();
#else
    STM32072B_LCD_Init();
#endif /* USE_STM320518_EVAL */
         
  /* Enable The Display */
  LCD_DisplayOn(); 

  /* Clear the Background Layer */ 
  LCD_Clear(LCD_COLOR_WHITE);
  
  /* Clear the LCD */ 
  LCD_Clear(White);

  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
   
  /* Displays MESSAGE1 on line 0 */
  LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1);

  /* RTC configuration */
  RTC_Config();
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Red);
  
  /* Displays a rectangle on the LCD */
  LCD_DrawRect(80, 280, 25, 240 );
  
  /* Configure the external interrupt "WAKEUP" and "TAMPER" buttons */
  STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_EXTI);  
     
  /* Configure RTC AlarmA register to generate 8 interrupts per 1 Second */
  RTC_AlarmConfig();
  
  /* set LCD Font */
  LCD_SetFont(&Font12x12);

  /* Set the LCD Back Color */
  LCD_SetBackColor(White); 

  /* Set the LCD Text Color */
  LCD_SetTextColor(Black);
  
  /* Set the Back Color */
  LCD_SetBackColor(LCD_COLOR_CYAN);
  /* Displays MESSAGE2 and MESSAGE3 on the LCD */
  LCD_DisplayStringLine(LINE(18), (uint8_t *)MESSAGE2);  
  LCD_DisplayStringLine(LINE(19), (uint8_t *)MESSAGE3);  

  /* Infinite loop */
  while (1)
  {
    uint32_t tmp =0;
    /* ALARM Interrupt */
    if (ALARM_Occured)
    {
      if(RTCAlarmCount != 480)
      {
        /* Increament the counter of Alarma interrupts */
        RTCAlarmCount++;
        
        /* Set the LCD Back Color */
        LCD_SetTextColor(Green);
        
        /* Draw rectangle on the LCD */
        LCD_DrawFullRect(81, 359, 80+ (((RTCAlarmCount)-1)/2) , 24);
        
        /* Set the LCD text color */
        LCD_SetTextColor(Red);
        
        /* Display rectangle on the LCD */
        LCD_DrawRect(80, 280, 25, 240 );
        
        /* Define the rate of Progress bar */
        tmp = (RTCAlarmCount * 100)/ 480; 
        
        /* Set the LCD Font */
        LCD_SetFont(&Font16x24);
        
        /* Display Char on the LCD : XXX% */
        LCD_DisplayChar(LINE(2),200, (tmp / 100) +0x30);
        LCD_DisplayChar(LINE(2),180, ((tmp  % 100 ) / 10) +0x30);
        LCD_DisplayChar(LINE(2),160, (tmp % 10) +0x30);
        LCD_DisplayChar(LINE(2),140, 0x25);
      }
      else
      {
        /* Disable the RTC Clock */
        RCC_RTCCLKCmd(DISABLE);
        
      }
      /* Reinitialize the ALARM variable */
      ALARM_Occured = 0;
    }
  }
}
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */     
#if defined (RTC_CLOCK_SOURCE_LSI) 
  /* Enable the LSI OSC */ 
  RCC_LSICmd(ENABLE);
#endif /* RTC_CLOCK_SOURCE_LSI */
  
  /* Configure the external interrupt "WAKEUP" and "TAMPER" buttons */ 
  STM_EVAL_PBInit(BUTTON_TAMPER , BUTTON_MODE_EXTI);
  STM_EVAL_PBInit(BUTTON_SEL , BUTTON_MODE_EXTI);

  /* Configure LEDs */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDOn(LED1);
  
  /* Initialize the LCD */
#ifdef USE_STM320518_EVAL
    STM320518_LCD_Init();
#else
    STM32072B_LCD_Init();
#endif /* USE_STM320518_EVAL */

  /* Clear the LCD */ 
  LCD_Clear(White);
  
  /* Enable The Display */
  LCD_DisplayOn(); 
  
  /* Set the LCD Back Color and Text Color*/
  LCD_SetBackColor(Blue);
  LCD_SetTextColor(White);

 
  LCD_DisplayStringLine(LCD_LINE_0,(uint8_t *) "  TimeStamp Example " );
  
  /* Set the LCD Text size */
  LCD_SetFont(&Font16x24);
  
  if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2)
  {
    /* RTC configuration  */
    RTC_Config();

    /* Configure the time&date register */
    RTC_TimeRegulate(); 
    
    /* Display the Date */
    RTC_DateShow();
    
    /* Display the Time */
    RTC_TimeShow();
    
  }
  else
  {
    /* Check if the Power On Reset flag is set */
    if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
    {
      /* Set the Back Color */
      LCD_SetBackColor(LCD_COLOR_CYAN);
      
      /* Set the Text Color */
      LCD_SetTextColor(LCD_COLOR_BLACK);
      LCD_SetFont(&Font12x12);
      LCD_DisplayStringLine(LCD_LINE_2,(uint8_t *) "  Power On Reset occurred        " );
    }
    /* Check if the Pin Reset flag is set */
    else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
    {
      /* Set the Back Color */
      LCD_SetBackColor(LCD_COLOR_CYAN);
      
      /* Set the Text Color */
      LCD_SetTextColor(LCD_COLOR_BLACK);
      LCD_SetFont(&Font12x12);
      LCD_DisplayStringLine(LCD_LINE_2,(uint8_t *) "  External Reset occurred       " );
    }

    /* Set the Back Color */
    LCD_SetBackColor(LCD_COLOR_CYAN);
    
    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_BLACK);
    LCD_SetFont(&Font12x12);
    LCD_DisplayStringLine(LCD_LINE_3,(uint8_t *) " No need to configure RTC     " );
    
    /* Enable the PWR clock */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);

    /* Allow access to RTC */
    PWR_BackupAccessCmd(ENABLE);

    /* Wait for RTC APB registers synchronisation */
    RTC_WaitForSynchro();

    /* Clear the RTC Alarm Flag */
    RTC_ClearFlag(RTC_FLAG_ALRAF);

    /* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */
    EXTI_ClearITPendingBit(EXTI_Line17);

    /* Display the RTC Time/Date and TimeStamp Time/Date */ 
    RTC_DateShow();
    RTC_TimeShow();

  }
   
  while (1)
  {
    if (Button_State == TAMPER_ON)
    {
      /* Turn LED4 ON */
      STM_EVAL_LEDOn(LED2);
      LCD_SetFont(&Font12x12);
      LCD_DisplayStringLine(LCD_LINE_5,(uint8_t *) " TimeStamp Event Occurred      " );
      LCD_SetFont(&Font16x24);
      LCD_ClearLine(LCD_LINE_4);
      LCD_ClearLine(LCD_LINE_5);
      LCD_ClearLine(LCD_LINE_6);
      LCD_ClearLine(LCD_LINE_7);
      LCD_ClearLine(LCD_LINE_8);
      /* Display the TimeStamp */
      RTC_TimeStampShow();
      Button_State = 0;
    }
    else if (Button_State == SEL_ON)
    {
      /* Turn LED1 ON and LED2 OFF */
      STM_EVAL_LEDOn(LED1);
      STM_EVAL_LEDOff(LED2);
      
      /* Clear The TSF Flag (Clear TimeStamp Registers) */
      RTC_ClearFlag(RTC_FLAG_TSF);
      LCD_SetFont(&Font12x12);
      LCD_ClearLine(LCD_LINE_5);
      LCD_SetFont(&Font12x12);
      LCD_DisplayStringLine(LCD_LINE_5,(uint8_t *) " TimeStamp Event Cleared        " );
      Button_State = 0;
    }
  }
}
Esempio n. 14
0
/*
 ******************************************************************************
 *函数:void LCD_GPIOInit(void)
 *输入:void
 *输出:void
 *描述:LCD初始化
 ******************************************************************************
 */
void LCD_Init(void)
{
  LTDC_InitTypeDef       LTDC_InitStruct;
  LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct;
  LTDC_Layer_TypeDef     LTDC_Layerx;
  
	
  /* IO口初始化 */
  LCD_GPIOInit();
	
  LCD_DisplayOff();
  /* 使能LCD时钟 */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
  /* 使能DMA失踪*/
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);
	
  /* 水平同步信号---低电平有效 */
  LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL;     
  /* 垂直同步信号---低电平有效 */  
  LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL;     
  /* 数据使能信号---低电平有效 */
  LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL;     
  /* 像素时钟配置--- */ 
  LTDC_InitStruct.LTDC_PCPolarity = LTDC_DEPolarity_AL;
	/* LCD背光设置 */
  LTDC_InitStruct.LTDC_BackgroundRedValue = 0;            
  LTDC_InitStruct.LTDC_BackgroundGreenValue = 0;          
  LTDC_InitStruct.LTDC_BackgroundBlueValue = 0;  	
  /*
   ****************************************************************************
   *PLLSAI_VCO = HSE*PLLSAI_N / PLL_M = 8 * 192 / 8 = 192MHz
   *PLLLCDCLK = PLLSAI_VCO / PLLSAI_R = 192 / 3 = 64 Mhz
   *LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 64 / 8 = 8 Mhz
   ****************************************************************************
   */
  RCC_PLLSAIConfig(192, 7, 3);
  RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);	
  /* 使能PLLSAI时钟 */
  RCC_PLLSAICmd(ENABLE);
  /* 等待PLLSAI时钟 */
  while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET){}
  /*  */
  LTDC_InitStruct.LTDC_HorizontalSync = 40;
  /*  */
  LTDC_InitStruct.LTDC_VerticalSync = 9;
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedHBP = 42; 
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedVBP = 11;  
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedActiveW = 522;
  /*  */
  LTDC_InitStruct.LTDC_AccumulatedActiveH = 283;
  /*  */
  LTDC_InitStruct.LTDC_TotalWidth = 524; 
  /*  */
  LTDC_InitStruct.LTDC_TotalHeigh = 285;
            
  LTDC_Init(&LTDC_InitStruct);
		
  LTDC_Layer_InitStruct.LTDC_HorizontalStart = 43;
  LTDC_Layer_InitStruct.LTDC_HorizontalStop = (480 + 43 - 1); 
  LTDC_Layer_InitStruct.LTDC_VarticalStart = 12;
  LTDC_Layer_InitStruct.LTDC_VerticalStop = (272 + 12 - 1);	

  /* Pixel Format configuration*/            
  LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
  /* Alpha constant (255 totally opaque) */
  LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; 
  /* Default Color configuration (configure A,R,G,B component values) */          
  LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0;        
  LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0;       
  LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0;         
  LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0;
  /* Configure blending factors */       
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA;    
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;
  /* the length of one line of pixels in bytes + 3 then :
     Line Lenth = Active high width x number of bytes per pixel + 3 
     Active high width         = LCD_PIXEL_WIDTH 
     number of bytes per pixel = 2    (pixel_format : RGB565) 
  */
  LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((480 * 2) + 3);
  /*  the pitch is the increment from the start of one line of pixels to the 
      start of the next line in bytes, then :
      Pitch = Active high width x number of bytes per pixel     
  */ 
  LTDC_Layer_InitStruct.LTDC_CFBPitch = (480 * 2);
  /* configure the number of lines */  
  LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 272;

  /* Input Address configuration */    
  LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER;
   
  LTDC_LayerInit(LTDC_Layer1, &LTDC_Layer_InitStruct);

  /* Configure Layer2 */
  LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET;
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;    
  LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
  LTDC_LayerInit(LTDC_Layer2, &LTDC_Layer_InitStruct);
	
  LTDC_ReloadConfig(LTDC_IMReload);
  
  /* Enable foreground & background Layers */
  LTDC_LayerCmd(LTDC_Layer1, ENABLE);
//  LTDC_LayerCmd(LTDC_Layer2, ENABLE);
  LTDC_ReloadConfig(LTDC_IMReload);
	
  LCD_DisplayOn();
}
Esempio n. 15
0
/**
 * @brief	Initializes the LCD
 * @param	None
 * @retval	None
 */
void LCD_Init()
{
	xLCDSemaphore = xSemaphoreCreateMutex();

	/* Try to take the semaphore - should not be a problem here */
	xSemaphoreTake(xLCDSemaphore, portMAX_DELAY);

	LCD.LCD_REG = (uint16_t*) 0x60080000;
	LCD.LCD_RAM = (uint16_t*) 0x60000000;

	/*
	 * Create the binary semaphores:
	 * The semaphore is created in the 'empty' state, meaning
	 * the semaphore must first be given before it can be taken (obtained)
	 * using the xSemaphoreTake() function.
	 */
	LCD.xWaitSemaphore = xSemaphoreCreateBinary();
	/* Give the semaphore because the LCD should be when we start */
	xSemaphoreGive(LCD.xWaitSemaphore);

	prvLCD_GPIOConfig();
	prvLCD_FSMCConfig();
//	prvLCD_InterruptConfig();

	/* Software reset the LCD */
	prvLCD_WriteCommandWithData(LCD_PWRR, 0x01);
	vTaskDelay(10 / portTICK_PERIOD_MS);
	prvLCD_WriteCommandWithData(LCD_PWRR, 0x00);

	prvLCD_PLLInit();

	/* 16 bit, 65k */
	prvLCD_WriteCommandWithData(LCD_SYSR, 0x0F);

	/* PDAT is fetched at PCLK falling edge, PCLK period = 2 times of System Clock period */
	prvLCD_WriteCommandWithData(LCD_PCSR, 0x81);

	vTaskDelay(1 / portTICK_PERIOD_MS);

	/* Horizontal set */
	/* Horizontal display width(pixels) = (HDWR + 1)*8 */
	prvLCD_WriteCommandWithData(LCD_HDWR, 0x63);
	/* Horizontal Non-Display Period Fine Tuning(HNDFT) [3:0] */
	prvLCD_WriteCommandWithData(LCD_HNDFTR, 0x00);
	/* Horizontal Non-Display Period (pixels) = (HNDR + 1)*8 */
	prvLCD_WriteCommandWithData(LCD_HNDR, 0x03);
	/* HSYNC Start Position(PCLK) = (HSTR + 1)*8 */
	prvLCD_WriteCommandWithData(LCD_HSTR, 0x03);
	/* HSYNC Width [4:0]   HSYNC Pulse width(PCLK) = (HPWR + 1)*8 */
	prvLCD_WriteCommandWithData(LCD_HPWR, 0x0B);

	/* Vertical set */
	/* Vertical pixels = VDHR + 1 */
	prvLCD_WriteCommandWithData(LCD_VDHR0, 0xDF);
	prvLCD_WriteCommandWithData(LCD_VDHR1, 0x01);
	/* Vertical Non-Display area = (VNDR + 1) */
	prvLCD_WriteCommandWithData(LCD_VNDR0, 0x20);
	prvLCD_WriteCommandWithData(LCD_VNDR1, 0x00);
	/* VSYNC Start Position(PCLK) = (VSTR + 1) */
	prvLCD_WriteCommandWithData(LCD_VSTR0, 0x16);
	prvLCD_WriteCommandWithData(LCD_VSTR1, 0x00);
	/* VSYNC Pulse Width(PCLK) = (VPWR + 1) */
	prvLCD_WriteCommandWithData(LCD_VPWR, 0x01);

	/* Give back the semaphore */
	xSemaphoreGive(xLCDSemaphore);

	/* Clear the whole screen and set it as active window */
	LCD_ClearActiveWindow(0, 799, 0, 479);

	/* Full Brightness */
	LCD_SetBrightness(0xFF);

	/* Display on */
	LCD_DisplayOn();
}
Esempio n. 16
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
       before to branch to application main.
     */     

  /* SysTick end of count event each 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
         
  /* Initialize LEDs mounted on EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);

  /* Select the Button test mode (polling or interrupt) BUTTON_MODE in main.h */
  STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE);
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE);

  /* Initialize the LCD */
  LCD_Init();

  /* Initialize the LCD Layers */
  LCD_LayerInit();  
  
  /* Enable LCD display */
  LCD_DisplayOn();
  
  /* Set foreground layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  
  /* Clear the LCD */ 
  LCD_Clear(White);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(White);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Blue);    
 
  LCD_DisplayStringLine(LCD_LINE_0, (uint8_t *)"        STM324x9I-EVAL       ");
  LCD_DisplayStringLine(LCD_LINE_1, (uint8_t *)"      Example on how to      ");
  LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *)"     use the IO Expander     ");
  
  /* Configure the IO Expander */
  if (IOE_Config() == IOE_OK && IOE16_Config() == IOE16_OK)
  {
    LCD_DisplayStringLine(LCD_LINE_3, (uint8_t *)"      IO Expander OK       ");
  }
  else
  {
    LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"IO Expander FAILED    ");
    LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)" Please Reset the     ");
    LCD_DisplayStringLine(LCD_LINE_6, (uint8_t *)"   board and start    ");
    LCD_DisplayStringLine(LCD_LINE_7, (uint8_t *)"    again             ");
    while(1);
  }

  /* LEDs Control blocks */
  LCD_SetTextColor(Blue);
  LCD_DrawRect(310, 180,  40, 60);
  LCD_SetTextColor(Red);
  LCD_DrawRect(230, 180, 40, 60);
  LCD_SetTextColor(Yellow);
  LCD_DrawRect(150, 180, 40, 60);
  LCD_SetTextColor(Green);
  LCD_DrawRect(70, 180, 40, 60);

#ifdef IOE_INTERRUPT_MODE
  /* Configure motherboard interrupt source IO_EXP4 */ 
  IOE16_IOPinConfig(IOE16_TS_IT,Direction_IN);
  IOE16_ITConfig(IOE16_TS_IT);
  
  /* Enable joystick interrupt */
  IOE16_ITConfig(JOY_IO16_PINS);
  
  /* Enable the Touch Screen interrupt */
  IOE_TSITConfig(); 
  
  /* Read IOs state to let IO interrupt occur */
  IOE16_I2C_ReadDeviceRegister(IOE16_REG_GPMR_LSB);
  IOE16_I2C_ReadDeviceRegister(IOE16_REG_GPMR_MSB);
#endif /* IOE_INTERRUPT_MODE */
  
  
  while(1)
  {
#ifdef IOE_POLLING_MODE
    static JOY_State_TypeDef JoyState = JOY_NONE;
    static TS_STATE* TS_State;
    
    /* Get the Joystick State */
    JoyState = IOE16_JoyStickGetState();
    
    /* Set the LCD Text Color */
    LCD_SetTextColor(Blue); 
   
    switch (JoyState)
    {
      case JOY_NONE:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:     ----        ");
        break;
      case JOY_UP:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:     UP         ");
        break;     
      case JOY_DOWN:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:    DOWN        ");
        break;          
      case JOY_LEFT:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:    LEFT        ");
        break;         
      case JOY_RIGHT:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:    RIGHT        ");
        break;                 
      case JOY_CENTER:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:   CENTER       ");
        break; 
      default:
        LCD_DisplayStringLine(LCD_LINE_5, (uint8_t *)"JOY:   ERROR      ");
        break;         
    }

    /* Update the structure with the current position */
    TS_State = IOE_TS_GetState();  
    
    if ((TS_State->TouchDetected) && (TS_State->Y < 92) && (TS_State->Y > 52))
    {
      if ((TS_State->X > 60) && (TS_State->X < 120))
      {
        LCD_SetTextColor(LCD_COLOR_GREEN);   
        LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *)"     LD1                ");
        STM_EVAL_LEDOn(LED1);
      }
      else if ((TS_State->X > 140) && (TS_State->X < 200))
      {
        LCD_SetTextColor(LCD_COLOR_YELLOW); 
        LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *)"          LD2           ");
        STM_EVAL_LEDOn(LED2);
      }
      else if ((TS_State->X > 220) && (TS_State->X < 280))
      {
        LCD_SetTextColor(LCD_COLOR_RED); 
        LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *)"               LD3      ");
        STM_EVAL_LEDOn(LED3);
      }     
      else if ((TS_State->X > 300) && (TS_State->X < 360))
      {
        LCD_SetTextColor(LCD_COLOR_BLUE); 
        LCD_DisplayStringLine(LCD_LINE_10, (uint8_t *)"                    LD4 ");
        STM_EVAL_LEDOn(LED4);
      }
    }
    else
    {
      STM_EVAL_LEDOff(LED1);
      STM_EVAL_LEDOff(LED2);
      STM_EVAL_LEDOff(LED3);
      STM_EVAL_LEDOff(LED4);
    }
#endif /* IOE_POLLING_MODE */  
    
#ifdef BUTTON_POLLING_MODE
    /* Insert 10 ms delay */
    Delay(1);
    
    /* Set the LCD Text Color */
    LCD_SetTextColor(Blue); 

    if (STM_EVAL_PBGetState(BUTTON_TAMPER) == 0)
    {
      /* Toggle LD2 */
      STM_EVAL_LEDToggle(LED2);

      LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"Pol: TAMPER/KEY Pressed  ");
    }

    if (STM_EVAL_PBGetState(BUTTON_WAKEUP) != 0)
    {
      /* Toggle LD3 */
      STM_EVAL_LEDToggle(LED3);
      LCD_DisplayStringLine(LCD_LINE_4, (uint8_t *)"Pol: WAKEUP Pressed      ");
    }
#endif
  }
}
Esempio n. 17
0
/**
 * @brief	Main program
 * @param	None
 * @retval	None: no exit point
 */
int main(void)
{
	uint16_t u16Menu = 0;
	uint16_t uVal;

	NVIC_Relocate();

	/* Initialize SysTick - 1msec resolution */
	SysTick_Config(SystemCoreClock / 1000);

	/* Initialize main board peripherals */
	MBD_Init();
	printf("miniSTM32 mainboard initialized.\n");

	/* Initialize LCD support */
	LCD_Init();
	LCD_DisplayOn();
	printf("LCD initialized.\n");
	LCD_BacklightOn();
	printf("\n\nPress the button to start demo.\n\n");

	while (1) 
	{
		/* main menu controlled by pushbutton interrupt */
		if( uIRQFlag == MAIN_BTN_EXTI_LINE ) {

			/* clear button interrupt flag */
			uIRQFlag = 0;

			/* droid family fonts */

			if( u16Menu == MENU_FONT_TEST1 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&DroidSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans Bold 18 pt");

				uVal += DroidSans_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif 18 point");

				uVal += DroidSerif_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Bold 18 pt");

				uVal += DroidSerif_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Italic 18");

			#else

				LCD_SetFont(&DroidSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans Bold 18 point");

				uVal += DroidSans_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif 18 point");

				uVal += DroidSerif_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Bold 18 point");

				uVal += DroidSerif_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Italic 18 point");

			#endif
			}

			/* liberation family fonts, federant font */

			else if( u16Menu == MENU_FONT_TEST2 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&LiberationSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Liberation Sans 18 point");

				uVal += LiberationSans_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif 18 point");

				uVal += LiberationSerif_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif Italic 18");

				uVal += LiberationSerif_Italic_18.Height + LINE_SEP;
				LCD_SetFont(&Federant_18); 
				LCD_DisplayStringLine(START_X, uVal, "Federant 18 point");

			#else

				LCD_SetFont(&LiberationSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Liberation Sans 18 point");

				uVal += LiberationSans_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif 18 point");

				uVal += LiberationSerif_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif Italic 18 point");

				uVal += LiberationSerif_Italic_18.Height + LINE_SEP;
				LCD_SetFont(&Federant_18); 
				LCD_DisplayStringLine(START_X, uVal, "Federant 18 point");

			#endif
			}

			/* Ubuntu family fonts */

			else if( u16Menu == MENU_FONT_TEST3 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));
			
			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&Ubuntu_18);
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu 18 point");

				uVal += Ubuntu_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Bold 18 point");

				uVal += Ubuntu_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Italic 18");

			#else

				LCD_SetFont(&Ubuntu_18);
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu 18 point");

				uVal += Ubuntu_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Bold 18 point");

				uVal += Ubuntu_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Italic 18 point");

			#endif
			}

			/* various size of droid sans */

			else if( u16Menu == MENU_FONT_TEST4 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

				LCD_SetFont(&DroidSans_10);
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 10 point");

				uVal += DroidSans_10.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_12); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 12 point");

				uVal += DroidSans_12.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_14); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 14 point");

				uVal += DroidSans_14.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_16); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 16 point");

				uVal += DroidSans_16.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_18); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_20); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 20 point");

			}

			/* at the end of menu, restart all over */
			if( ++u16Menu == MENU_END )
			{
				printf("\n\nEnd of Demo: Press the button to restart... \n\n\n");
				u16Menu = 0;
			}

		}

		/* usual household routine goes here */
		{
		}
	}
}
Esempio n. 18
0
/**
  * @brief  Display Init (LCD or/and USART)
  * @param  None
  * @retval None
  */
static void Display_Init(void)
{
#ifdef PRINT_ON_USART 

 USART_InitTypeDef USART_InitStructure;
  /* USARTx configured as follows:
        - BaudRate = 115200 baud  
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Hardware flow control disabled (RTS and CTS signals)
        - Receive and transmit enabled
  */
  USART_InitStructure.USART_BaudRate = 115200;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

  STM_EVAL_COMInit(COM1, &USART_InitStructure);

  printf("\n\r ========================================\n");
  printf("\n\r ==== Multiple RNG Generator Example ====\n");
  printf("\n\r ======================================== \n\n\r");
  printf("\n\r  Press key button to generate 8 x 32bit random number\n");
#endif

#ifdef PRINT_ON_LCD  
/* Initialize the LCD */
  LCD_Init();

/* Display message on LCD ***************************************************/
#if defined (USE_STM324x9I_EVAL) 
  /* Initialize the LCD Layers */
  LCD_LayerInit();
  /* Enable The Display */
  LCD_DisplayOn(); 
  /* Set LCD Background Layer  */
  LCD_SetLayer(LCD_BACKGROUND_LAYER);
  /* Clear the Background Layer */ 
  LCD_Clear(LCD_COLOR_WHITE);
  
  /* Set LCD Foreground Layer  */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

  /* Configure the transparency for foreground */
  LCD_SetTransparency(100);
#endif /* USE_STM324x9I_EVAL */  
  
  /* Clear the LCD */ 
  LCD_Clear(White);

  /* Set the LCD Text size */
  LCD_SetFont(&FONTSIZE);

  /* Set the LCD Back Color and Text Color*/
  LCD_SetBackColor(Blue);
  LCD_SetTextColor(White);
  
  LCD_DisplayStringLine(LINE(LINENUM), (uint8_t*)MESSAGE1);
  LCD_DisplayStringLine(LINE(0x16), (uint8_t*)"                                         ");
  
  /* Set the LCD Text size */
  LCD_SetFont(&Font16x24);

  LCD_DisplayStringLine(LINE(0), (uint8_t*)MESSAGE2);

  /* Set the LCD Back Color and Text Color*/
  LCD_SetBackColor(White);
  LCD_SetTextColor(Blue); 

  LCD_DisplayStringLine(LINE(3), (uint8_t*)MESSAGE3);
  LCD_DisplayStringLine(LINE(5), (uint8_t*)MESSAGE4);
#endif
}