Exemplo n.º 1
0
void ILI9341_Show()
{
	uint8_t tmpreg;
	tmpreg = L3GD20_GetDataStatus();
	/** 
  	* @brief Display String
  	* 		 
  	*/ 

	char str_convert_buffer[16];
	char str_output_buffer[32];

	LCD_DisplayStringLine(LCD_LINE_1, (uint8_t *)"WELCOME TO TKU");
    LCD_DisplayStringLine(LCD_LINE_2, (uint8_t *)"ASFL");

	strcpy(str_output_buffer, "X-AXIS:");
    sprintf(str_convert_buffer, "%d", tmpreg );
    strcat(str_output_buffer, str_convert_buffer); 
    LCD_ClearLine(LCD_LINE_6);
    LCD_DisplayStringLine(LCD_LINE_6, (uint8_t*)str_output_buffer); 

	strcpy(str_output_buffer, "Y-AXIS:");
    sprintf(str_convert_buffer, "%d", 10 );
    strcat(str_output_buffer, str_convert_buffer); 
    LCD_ClearLine(LCD_LINE_7);
    LCD_DisplayStringLine(LCD_LINE_7, (uint8_t*)str_output_buffer); 

   	strcpy(str_output_buffer, "Z-AXIS:");
    sprintf(str_convert_buffer, "%d", 10 );
    strcat(str_output_buffer, str_convert_buffer); 
    LCD_ClearLine(LCD_LINE_8);
    LCD_DisplayStringLine(LCD_LINE_8, (uint8_t*)str_output_buffer); 

}
Exemplo n.º 2
0
/**
* @brief  Display the application header (title) on the LCD screen 
* @param  Title :  pointer to the string to be displayed
* @retval None
*/
void LCD_LOG_SetHeader (uint8_t *Title)
{
  sFONT *cFont;

  uint32_t size = 0 , idx,cnt=LCD_PIXEL_WIDTH/cFont->Width+1; 
  uint8_t  *ptr = Title;
  uint8_t  tmp[80];
// #ifdef inch_4
//   uint8_t  tmp[66];
// #endif
// #ifdef inch_7
//   uint8_t  tmp[66];
// #endif	
	
  LCD_SetFont (&Font12x12);
  cFont = LCD_GetFont();
	cnt=LCD_PIXEL_WIDTH/cFont->Width+1;
  /* center the header */
  while (*ptr++) size ++ ;

  /* truncate extra text */
  if(size > cnt)
  {
     size = cnt;
  }
  
  for (idx = 0 ; idx <cnt ; idx ++)
  { 
    tmp[idx] = ' '; 
  }

  for (idx = 0 ; idx < size ; idx ++)
  { 
    tmp[idx + (cnt - size)/2] = Title[idx];
  }
  
  /* Clear the LCD */
  LCD_Clear(Black);
    
  /* Set the LCD Font */
 

  cFont = LCD_GetFont();  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
  LCD_SetBackColor(Blue);
  LCD_ClearLine(0);
  LCD_DisplayStringLine(cFont->Height, tmp);
  LCD_ClearLine(2 * cFont->Height);

  LCD_SetBackColor(Black);
  LCD_SetFont (&Font8x12);
}
Exemplo n.º 3
0
/*******************************************************************************
* Function Name  : RegulateMonth
* Description    : Regulates month.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
static void RegulateMonth(void)
{
  uint32_t tmpValue = 0;
  uint32_t MyKey = 0;

  /* Initialize tmpValue */
  tmpValue = date_s.month;

  /* Endless loop */
  while(1)
  {
    /* Check which key is pressed */
    MyKey = ReadKey();

    /* If "UP" pushbutton is pressed */
    if(MyKey == UP)
    {
      /* Increase the value of the digit */
      if(tmpValue == 12)
      {
        tmpValue = 0;
      }
      LCD_ClearLine(Line3);
      LCD_ClearLine(Line7);
      LCD_ClearLine(Line8);
      Date_Display(date_s.year, ++tmpValue, date_s.day);
    }
    /* If "DOWN" pushbutton is pressed */
    if(MyKey == DOWN)
    {
      /* Decrease the value of the digit */
      if(tmpValue == 1)
      {
        tmpValue = 13;
      }
      LCD_ClearLine(Line3);
      LCD_ClearLine(Line7);
      LCD_ClearLine(Line8);     
      /* Display new value */
      Date_Display(date_s.year, --tmpValue, date_s.day);
    }
    /* If "SEL" pushbutton is pressed */
    if(MyKey == SEL)
    {
      LCD_ClearLine(Line3);
      LCD_ClearLine(Line7);
      LCD_ClearLine(Line8);     
      /* Display new value */
      Date_Display(date_s.year, tmpValue, date_s.day);
      /* Return the digit value and exit */
      date_s.month = tmpValue;
      return;
    }
  }
}
Exemplo n.º 4
0
/**
  * @brief  This function handles External lines 15 to 10 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI15_10_IRQHandler(void)
{
  /* TimeStamp Event detected */
  if(EXTI_GetITStatus(TAMPER_BUTTON_EXTI_LINE) != RESET)
  {
    count++;
    
    /* Turn on LED2 and off LED1 */
    STM_EVAL_LEDOn(LED2);
    STM_EVAL_LEDOff(LED1);
    
    /* LCD display */
    LCD_ClearLine(LCD_LINE_2);
    LCD_DisplayStringLine(LCD_LINE_3,(uint8_t *) "TimeStamp Event Occurred      " );
    
    /* Display the TimeStamp */
    RTC_TimeStampShow();
    
    /* Display the date */
    RTC_DateShow();
    
    /* Display the Time */
    RTC_TimeShow();
    
    /* Clear the TAMPER Button EXTI line pending bit */
    EXTI_ClearITPendingBit(TAMPER_BUTTON_EXTI_LINE); 
  }
}
Exemplo n.º 5
0
/**
  * @brief  Displays the current date.
  * @param  None
  * @retval None
  */
void Date_Display(void)
{
  /* Clear Line16 */
  LCD_ClearLine(LCD_LINE_16);

  /* Display time separators "/" on Line14 */
  LCD_DisplayChar(LCD_LINE_16, 260, '/');
  LCD_DisplayChar(LCD_LINE_16, 212, '/');
  LCD_DisplayChar(LCD_LINE_16, 166, '/');

  /* Get the current Date */
  RTC_GetDate(RTC_Format_BIN, &RTC_DateStructure);

  /* Display Date WeekDay */
  LCD_DisplayChar(LCD_LINE_16, 276,((RTC_DateStructure.RTC_WeekDay) + 0x30));

  /* Display Date Day */
  LCD_DisplayChar(LCD_LINE_16, 244,((RTC_DateStructure.RTC_Date /10) + 0x30));
  LCD_DisplayChar(LCD_LINE_16, 228,((RTC_DateStructure.RTC_Date % 10) + 0x30));

  /* Display Date Month */
  LCD_DisplayChar(LCD_LINE_16, 196,((RTC_DateStructure.RTC_Month / 10) + 0x30));
  LCD_DisplayChar(LCD_LINE_16, 182,((RTC_DateStructure.RTC_Month % 10) + 0x30));

  /* Display Date Year */
  LCD_DisplayChar(LCD_LINE_16, 150, '2');
  LCD_DisplayChar(LCD_LINE_16, 134, '0');
  LCD_DisplayChar(LCD_LINE_16, 118,((RTC_DateStructure.RTC_Year / 10) + 0x30));
  LCD_DisplayChar(LCD_LINE_16, 102,((RTC_DateStructure.RTC_Year % 10) + 0x30));
}
Exemplo n.º 6
0
/**
  * @brief  Clear LCD screen.
  * @param  None
  * @retval None
  */
void Demo_LCD_Clear(void)
{
  uint32_t j;
  for( j= 5; j < 19; j++ )
  {
    LCD_ClearLine(LINE(j));
  }
}
/*******************************************************************************
* Function Name  : Mass_Storage_Start
* Description    : Starts the mass storage demo.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Mass_Storage_Start (void)
{
  /* Disble the JoyStick interrupts */
  IntExtOnOffConfig(DISABLE);

  /* Clear the LCD screen */
  LCD_Clear(White);

  LCD_SetDisplayWindow(160, 223, 128, 128);
 
  LCD_DrawBMP(0x00647C00);

  /* Disable LCD Window mode */
  LCD_WindowModeDisable();
  
  /* Set the Back Color */
  LCD_SetBackColor(Blue);
  /* Set the Text Color */
  LCD_SetTextColor(White); 

  if(MSD_Init() != 0x00)
  {
    LCD_DisplayStringLine(Line8, " No MSD Card Present");
    LCD_DisplayStringLine(Line9, "  To exit Press SEL ");

    /* Loop until SEL key pressed */
    while(ReadKey() != SEL)
    {
    }
  }
  else
  {
    Get_Medium_Characteristics();

    /* Display the "  Plug the USB   " message */
    LCD_DisplayStringLine(Line8, " Plug the USB Cable ");
    LCD_DisplayStringLine(Line9, "Exit:  Push JoyStick");
    
    /* Intialize the USB cell */
    USB_Init();
  
    LCD_ClearLine(Line9);
    /* Display the "To stop Press SEL" message */
    LCD_DisplayStringLine(Line8, "  To stop Press SEL ");

    /* Loop until SEL key pressed */
    while(ReadKey() != SEL)
    {
    }

    PowerOff();
  }
  LCD_Clear(White);
  DisplayMenu();
  IntExtOnOffConfig(ENABLE);
  /* Flush SPI1 Data Register */
  SPI_I2S_ReceiveData(SPI1);
}
Exemplo n.º 8
0
/**
* @brief  Display the application header (title) on the LCD screen 
* @param  Title :  pointer to the string to be displayed
* @retval None
*/
void LCD_LOG_SetHeader (uint8_t *Title)
{
  sFONT *cFont;
  uint32_t size = 0 , idx; 
  uint8_t  *ptr = Title;
  uint8_t  tmp[27];
  
  /* center the header */
  while (*ptr++) size ++ ;

  /* truncate extra text */
  if(size > 26)
  {
     size = 26;
  }
  
  for (idx = 0 ; idx < 27 ; idx ++)
  { 
    tmp[idx] = ' '; 
  }

  for (idx = 0 ; idx < size ; idx ++)
  { 
    tmp[idx + (27 - size)/2] = Title[idx];
  }
  
  /* Clear the LCD */
  LCD_Clear(Black);
    
  /* Set the LCD Font */
  LCD_SetFont (&Font12x12);

  cFont = LCD_GetFont();  
  /* Set the LCD Text Color */
  LCD_SetTextColor(White);
  LCD_SetBackColor(Blue);
  LCD_ClearLine(0);
  LCD_DisplayStringLine(cFont->Height, tmp);
  LCD_ClearLine(2 * cFont->Height);

  LCD_SetBackColor(Black);
  LCD_SetFont (&Font8x12);
}
Exemplo n.º 9
0
void printLCDMaintenanceMenu(){//done
	LCD_TurnOnDisplay();
	LCD_Goto(0,0);LCD_WriteString("1-Set doorcode");
	LCD_Goto(0,1);LCD_WriteString("2-Set admincode");
	LCD_Goto(0,2);LCD_WriteString("3-Set clock");
	LCD_Goto(0,3);LCD_WriteString("4-Set calendar");
	LCD_Goto(0,4);LCD_WriteString("5-View history");
	LCD_Goto(0,5);LCD_WriteString("A-Leave        ");
	LCD_ClearLine(7);
	LCD_BL_State(1);
}
Exemplo n.º 10
0
/**
* @brief  Clear the Text Zone 
* @param  None 
* @retval None
*/
void LCD_LOG_ClearTextZone(void)
{
  uint8_t i=0;
  sFONT *cFont = LCD_GetFont();
  
  for (i= 0 ; i < YWINDOW_SIZE; i++)
  {
    LCD_ClearLine((i + YWINDOW_MIN) * cFont->Height);
  }
  
  LCD_LOG_DeInit();
}
Exemplo n.º 11
0
/**
  * @brief  This function handles External line 0 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI0_IRQHandler(void)
{
  /* Clear the TimeStamp registers */
  if(EXTI_GetITStatus(WAKEUP_BUTTON_EXTI_LINE) != RESET)
  {
    /* Clear the Wakeup Button EXTI line pending bit */
    EXTI_ClearITPendingBit(WAKEUP_BUTTON_EXTI_LINE);
    
    /* 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_ClearLine(LCD_LINE_2);
    LCD_ClearLine(LCD_LINE_3);
    LCD_ClearLine(LCD_LINE_8);
    LCD_ClearLine(LCD_LINE_9);
    LCD_ClearLine(LCD_LINE_10);
    LCD_DisplayStringLine(LCD_LINE_3,(uint8_t *) "TimeStamp Event Cleared        " );
    
  }
}
Exemplo n.º 12
0
void timestuff(void)
{
	systick_count++;
	output.str(std::string());
	mytimerobject.setMin(systick_count/100/60);
	mytimerobject.setSec(systick_count/100);
	mytimerobject.setHun(systick_count/1);
	output << "Time " << mytimerobject.printtime();
	outputstring = "";
	outputstring = output.str();
	chararray = "";
	chararray = outputstring.c_str();
	LCD_DisplayStringLine(LCD_LINE_3,(uint8_t*) chararray);
	LCD_ClearLine(LCD_LINE_4);
}
Exemplo n.º 13
0
/*******************************************************************************
* Function Name  : Alarm_PreAdjust
* Description    : Configures an alarm event to occurs within the current day.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Alarm_PreAdjust(void)
{
  uint32_t tmp = 0;

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

  /* Set the LCD Text Color */
  LCD_SetTextColor(White);

  if(BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
  {
    LCD_DisplayStringLine(Line8, "Time not configured ");
    LCD_DisplayStringLine(Line9, "     Press SEL      ");
    while(ReadKey() == NOKEY)
    {
    }
    return;
  }
  /* Read the alarm value stored in the Backup register */
  tmp = BKP_ReadBackupRegister(BKP_DR6);
  tmp |= BKP_ReadBackupRegister(BKP_DR7) << 16;
  
  /* Clear Line8 */
  LCD_ClearLine(Line8);
    
  /* Display time separators ":" on Line4 */
  LCD_DisplayChar(Line8, 212, ':');
  LCD_DisplayChar(Line8, 166, ':');

  /* Display the alarm value */
  Alarm_Display(tmp);
  /* Store new alarm value */
  tmp = Alarm_Regulate();

  /* Wait until last write operation on RTC registers has finished */
  RTC_WaitForLastTask();
  /* Set RTC Alarm register with the new value */
  RTC_SetAlarm(tmp);
  /* Wait until last write operation on RTC registers has finished */
  RTC_WaitForLastTask();  

  /* Save the Alarm value in the Backup register */
  BKP_WriteBackupRegister(BKP_DR6, (tmp & 0x0000FFFF));
  BKP_WriteBackupRegister(BKP_DR7, (tmp >> 16));
}
Exemplo n.º 14
0
static void prvLCDTask( void *pvParameters )
{
unsigned char *pucMessage;
unsigned long ulLine = Line3;
const unsigned long ulLineHeight = 24;
static char cMsgBuf[ 30 ];
extern unsigned short usMaxJitter;

	( void ) pvParameters;

	/* The LCD gatekeeper task as described in the comments at the top of this
	file. */

	/* Initialise the LCD and display a startup message that includes the
	configured IP address. */
	STM3210D_LCD_Init();
	LCD_Clear(White);
	LCD_SetTextColor(Green);
	LCD_DisplayStringLine( Line0, ( unsigned char * ) "  www.FreeRTOS.org" );
    LCD_SetTextColor(Blue);
    sprintf( cMsgBuf, "  %d.%d.%d.%d", configIP_ADDR0, configIP_ADDR1, configIP_ADDR2, configIP_ADDR3 );
	LCD_DisplayStringLine( Line1, ( unsigned char * ) cMsgBuf );
	LCD_SetTextColor(Black);

	for( ;; )
	{
		/* Wait for a message to arrive to be displayed. */
		xQueueReceive( xLCDQueue, &pucMessage, portMAX_DELAY );

		/* Clear the current line of text. */
		LCD_ClearLine( ulLine );

		/* Move on to the next line. */
		ulLine += ulLineHeight;
		if( ulLine > Line9 )
		{
			ulLine = Line3;
		}

		/* Display the received text, and the max jitter value. */
		sprintf( cMsgBuf, "%s [%uns]", pucMessage, usMaxJitter * mainNS_PER_CLOCK );
		LCD_DisplayStringLine( ulLine, ( unsigned char * ) cMsgBuf );
	}
}
Exemplo n.º 15
0
/**
  * @brief  Returns the time entered by user, using menu navigation keys.
  * @param  None
  * @retval Current time RTC counter value
  */
void Time_Regulate(void)
{
  uint8_t Tmp_HH = 0, Tmp_MM = 0, Tmp_SS = 0;

  LCD_DisplayStringLine(LCD_LINE_12, "Set time: hh:mm:ss");

  /* Read time hours */
  Tmp_HH = ReadDigit(LCD_LINE_13, 244, (RTC_TimeStructure.RTC_Hours / 10), 0x2, 0x0);

  if(Tmp_HH == 2)
  {
    if((RTC_TimeStructure.RTC_Hours % 10) > 3)
    {
      RTC_TimeStructure.RTC_Hours = 0;
    }
    Tmp_HH = Tmp_HH * 10 + ReadDigit(LCD_LINE_13, 228, (RTC_TimeStructure.RTC_Hours % 10), 0x3, 0x0);
  }
  else
  {
    Tmp_HH = Tmp_HH * 10 + ReadDigit(LCD_LINE_13, 228, (RTC_TimeStructure.RTC_Hours % 10), 0x9, 0x0);
  }
  /* Read time  minutes */
  Tmp_MM = ReadDigit(LCD_LINE_13, 196, (RTC_TimeStructure.RTC_Minutes / 10), 5, 0x0);
  Tmp_MM = Tmp_MM * 10 + ReadDigit(LCD_LINE_13, 182, (RTC_TimeStructure.RTC_Minutes % 10), 0x9, 0x0);

  /* Read time seconds */
  Tmp_SS = ReadDigit(LCD_LINE_13, 150, (RTC_TimeStructure.RTC_Seconds / 10), 5, 0x0);
  Tmp_SS = Tmp_SS * 10 + ReadDigit(LCD_LINE_13, 134, (RTC_TimeStructure.RTC_Seconds % 10), 0x9, 0x0);

  RTC_TimeStructure.RTC_Hours = Tmp_HH;
  RTC_TimeStructure.RTC_Minutes = Tmp_MM;
  RTC_TimeStructure.RTC_Seconds = Tmp_SS;
  RTC_SetTime(RTC_Format_BIN, &RTC_TimeStructure);

  /* Set the Back Color */
  LCD_SetBackColor(LCD_COLOR_BLACK);

  /* Set the Text Color */
  LCD_SetTextColor(LCD_COLOR_WHITE);

  /* Clear Line12 */
  LCD_ClearLine(LCD_LINE_12);
}
Exemplo n.º 16
0
/**
  * @brief  This function handles External line 0 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI0_IRQHandler(void)
{
  if((EXTI_GetITStatus(WAKEUP_BUTTON_EXTI_LINE) != RESET) && (ubStartevent == 0))
  {
    /* Set the LCD Back Color */
    LCD_SetBackColor(White);

    /* Clear the LCD line 5 */
    LCD_ClearLine(Line5);
  
    /* Enable the RTC Clock */
    RCC_RTCCLKCmd(ENABLE);

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

    /* start count */
    ubStartevent = 1;
  }
  /* Clear the Wakeup EXTI pending bit */
  EXTI_ClearITPendingBit(WAKEUP_BUTTON_EXTI_LINE);  
}  
Exemplo n.º 17
0
/**
  * @brief  This function handles External line 0 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI0_IRQHandler(void)
{
  if((EXTI_GetITStatus(WAKEUP_BUTTON_EXTI_LINE) != RESET))
  {
    /* Set the LCD Back Color */
    LCD_SetBackColor(White);
    
    /* Clear the LCD line 2 */
    LCD_ClearLine(Line2);
   
    /* Disable the RTC Clock */
    RCC_RTCCLKCmd(DISABLE);
   
    /* Reset Counter*/
    uwRTCAlarmCount = 0;
    
    /* Disable the alarm */
    RTC_AlarmCmd(RTC_Alarm_A, DISABLE);
    
    /* Set the LCD Back Color */
    LCD_SetBackColor(White);
  
    /* Display a Full rectangle on the LCD */
    LCD_DrawFullRect(80, 290,240, 25 );
    
    /* Set LCD text color */
    LCD_SetTextColor(Red);

    /* Display rectangle on the LCD */
    LCD_DrawRect(80, 290, 25, 240 );
    
    /* Clear the WAKEUP EXTI  pending bit */
    EXTI_ClearITPendingBit(WAKEUP_BUTTON_EXTI_LINE);  
  }

}
Exemplo n.º 18
0
/**
  * @brief  Displays the current time.
  * @param  None
  * @retval None
  */
void Time_Display(void)
{
  /* Clear Line13 */
  LCD_ClearLine(LCD_LINE_13);

  /* Display time separators ":" on Line4 */
  LCD_DisplayChar(LCD_LINE_13, 212, ':');
  LCD_DisplayChar(LCD_LINE_13, 166, ':');

  /* Get the current Time */
  RTC_GetTime(RTC_Format_BIN, &RTC_TimeStructure);

  /* Display time hours */
  LCD_DisplayChar(LCD_LINE_13, 244,((RTC_TimeStructure.RTC_Hours / 10) + 0x30));
  LCD_DisplayChar(LCD_LINE_13, 228,((RTC_TimeStructure.RTC_Hours % 10) + 0x30));

  /* Display time minutes */
  LCD_DisplayChar(LCD_LINE_13, 196,((RTC_TimeStructure.RTC_Minutes /10) + 0x30));
  LCD_DisplayChar(LCD_LINE_13, 182,((RTC_TimeStructure.RTC_Minutes % 10) + 0x30));

  /* Display time seconds */
  LCD_DisplayChar(LCD_LINE_13, 150,((RTC_TimeStructure.RTC_Seconds / 10) + 0x30));
  LCD_DisplayChar(LCD_LINE_13, 134,((RTC_TimeStructure.RTC_Seconds % 10) + 0x30));
}
Exemplo n.º 19
0
/*******************************************************************************
* Function Name  : LCD_Update
* Description    : Controls the wave player application LCD display messages.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_Update(uint32_t Status)
{
  uint8_t tmp = 0;
  uint32_t counter = 0;

  /* Enable the FSMC that share a pin w/ I2C1 (LBAR) */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);

  switch (Status)
  {
   case PROGRESS:
         tmp = (uint8_t) ((uint32_t)((GetVar_AudioDataIndex()) * 100) / GetVar_AudioDataLength());
         if (tmp == 0)
         { 
           LCD_SetTextColor(Magenta);
           LCD_ClearLine(Line8);
           LCD_DrawRect(Line8, 310, 16, 300);
         }
         else
         {
           LCD_SetTextColor(Magenta);
           LCD_DrawLine(Line8, 310 - (tmp * 3), 16, Vertical);
         }         
         break;
   case FRWD:
         tmp = (uint8_t) ((uint32_t)((GetVar_AudioDataIndex()) * 100) / GetVar_AudioDataLength());

         LCD_SetTextColor(Magenta);
         LCD_ClearLine(Line8);
         LCD_DrawRect(Line8, 310, 16, 300);
         LCD_SetTextColor(Magenta);

         for (counter = 0; counter <= tmp; counter++)
         {
           LCD_DrawLine(Line8, 310 - (counter * 3), 16, Vertical);
         }          
         break;
   case STOP:
         /* Display the stopped status menu */ 
         LCD_SetTextColor(White); 
         LCD_DisplayStringLine(Line3, CmdTitle1Stopped);
         LCD_DisplayStringLine(Line4, CmdTitle2Stopped);
         LCD_SetTextColor(Red);
         LCD_DisplayStringLine(Line6, StatusTitleStopped);
         LCD_ClearLine(Line9);
         LCD_SetTextColor(Black);
         LCD_DisplayChar(Line9, 250, 'v'); 
         LCD_DisplayChar(Line9, 235, 'o'); 
         LCD_DisplayChar(Line9, 220, 'l'); 
         LCD_DisplayChar(Line9, 200, '-'); 
         LCD_DisplayChar(Line9, 85, '+'); 
         LCD_DrawRect(Line9 + 8, 185, 10, 100); 
         break; 
   case PAUSE: 
         /* Display the paused status menu */ 
         LCD_SetTextColor(White);
         LCD_DisplayStringLine(Line3, CmdTitle1Paused);
         LCD_DisplayStringLine(Line4, CmdTitle2Paused);
         LCD_SetTextColor(Red);
         LCD_DisplayStringLine(Line6, StatusTitlePaused);
         break;
   case PLAY:
         /* Display the Titles */   
         LCD_SetTextColor(Black);
         LCD_DisplayStringLine(Line0, DemoTitle);
         LCD_DisplayStringLine(Line2, CmdTitle0); 

         /* Display the Playing status menu */ 
         LCD_SetTextColor(White);
         LCD_DisplayStringLine(Line3, CmdTitle1Playing);
         LCD_DisplayStringLine(Line4, CmdTitle2Playing);
         LCD_SetTextColor(Red);
         LCD_DisplayStringLine(Line6, StatusTitlePlaying);
         LCD_ClearLine(Line9);
         LCD_SetTextColor(Black);
         LCD_DisplayChar(Line9, 250, 'v'); 
         LCD_DisplayChar(Line9, 235, 'o'); 
         LCD_DisplayChar(Line9, 220, 'l'); 
         LCD_DisplayChar(Line9, 200, '-'); 
         LCD_DisplayChar(Line9, 85, '+'); 
         LCD_DrawRect(Line9 + 8, 185, 10, 100); 
         break;
   case ALL: 
         I2S_CODEC_LCDConfig();
         /* Display the stopped status menu */ 
         LCD_SetTextColor(White); 
         LCD_DisplayStringLine(Line3, CmdTitle1Stopped);
         LCD_DisplayStringLine(Line4, CmdTitle2Stopped);
         LCD_SetTextColor(Red);
         LCD_DisplayStringLine(Line6, StatusTitleStopped);
         LCD_ClearLine(Line9);
         LCD_SetTextColor(Black);
         LCD_DisplayChar(Line9, 250, 'v'); 
         LCD_DisplayChar(Line9, 235, 'o'); 
         LCD_DisplayChar(Line9, 220, 'l'); 
         LCD_DisplayChar(Line9, 200, '-'); 
         LCD_DisplayChar(Line9, 85, '+'); 
         LCD_DrawRect(Line9 + 8, 185, 10, 100); 
         break;
  }
  /* Update the volume bar in all cases except when progress bar is to be apdated */
  if (Status != PROGRESS)
  {
    /* Compute the current volume percentage */
    tmp = (uint8_t) ((uint16_t)((0xFF - GetVar_CurrentVolume()) * 100) / 0xFF) ;
 
    /* Clear the previuos volume bar */
    LCD_SetTextColor(Blue);
    LCD_DrawLine(Line9 + 10, 185 - previoustmp , 8, Vertical);
    LCD_DrawLine(Line9 + 10, 185 - previoustmp + 1 , 8, Vertical);    
 
    /* Draw the new volume bar */
    LCD_SetTextColor(Red);
    LCD_DrawLine(Line9 + 10, 185 - tmp , 8, Vertical);
    LCD_DrawLine(Line9 + 10, 185 - tmp + 1 , 8, Vertical);
 
    /* save the current position */
    previoustmp = tmp;
  }
  /* Disable the FSMC that share a pin w/ I2C1 (LBAR) */
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, DISABLE);
}
Exemplo n.º 20
0
void WriteChar(register Console * C, char c)
{
    int loopx, loopy;

    if (c == '\f') {
	C->xpos = 0;
	C->ypos = 0;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	if (Visible == &Con[Current_VCminor])
#endif

	    LCD_Position(C->xpos, C->ypos);

	for (loopy = 0; loopy < HEIGHT; loopy++) {

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	    for (loopx = 0; loopx < WIDTH; loopx++)
		C->screen[loopy][loopx] = ' ';

	    if (Visible == &Con[Current_VCminor])
#endif

		LCD_ClearLine(loopy);
	}
	return;
    }

    switch (c) {

    case '\b':
	if (C->xpos > 0) {
	    C->xpos--;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	    if (Visible == &Con[Current_VCminor])
#endif

		LCD_Position(C->xpos, C->ypos);

	    /* clear the character */
	    WriteChar(C, ' ');

	    /* and move back again */
	    C->xpos--;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	    if (Visible == &Con[Current_VCminor])
#endif

		LCD_Position(C->xpos, C->ypos);
	}
	return;

    case '\r':

#ifdef CONFIG_SIBO_CONSOLE_ECHO

	send_byte('\n');

#endif

	C->xpos = 0;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	if (Visible == &Con[Current_VCminor])
#endif

	    LCD_Position(C->xpos, C->ypos);

	return;

    case '\n':

#ifdef CONFIG_SIBO_CONSOLE_ECHO

	send_byte('\n');

#endif

	C->ypos++;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	if (Visible == &Con[Current_VCminor])
#endif
	    LCD_Position(C->xpos, C->ypos);

	if (C->ypos == HEIGHT) {
	    C->ypos--;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	    for (loopy = 0; loopy < HEIGHT - 1; loopy++)
		for (loopx = 0; loopx < WIDTH; loopx++)
		    C->screen[loopy][loopx] = C->screen[loopy + 1][loopx];

	    for (loopx = 0; loopx < WIDTH; loopx++)
		C->screen[C->ypos][loopx] = ' ';

	    if (Visible == &Con[Current_VCminor])
#endif

	    {
		LCD_ScrollUp();
		LCD_ClearLine(C->ypos);
		LCD_Position(C->xpos, C->ypos);
	    }
	}
	return;
    }

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

    C->screen[C->ypos][C->xpos] = c;

    if (Visible == &Con[Current_VCminor])
#endif

	LCD_WriteChar(c);

#ifdef CONFIG_SIBO_CONSOLE_ECHO

    send_byte(c);

#endif

    C->xpos++;

    if (C->xpos == WIDTH) {
	WriteChar(C, '\r');
	WriteChar(C, '\n');
    }
}
Exemplo n.º 21
0
/**
* @brief  LwIP_DHCP_Process_Handle
* @param  None
* @retval None
*/
void LwIP_DHCP_Process_Handle()
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;
  uint8_t iptab[4] = {0};
  uint8_t iptxt[20];
  
  switch (DHCP_state)
  {
  case DHCP_START:
    {
      DHCP_state = DHCP_WAIT_ADDRESS;
      dhcp_start(&gnetif);
      /* IP address should be set to 0 
         every time we want to assign a new DHCP address */
      IPaddress = 0;
#ifdef USE_LCD
      LCD_DisplayStringLine(Line4, (uint8_t*)"     Looking for    ");
      LCD_DisplayStringLine(Line5, (uint8_t*)"     DHCP server    ");
      LCD_DisplayStringLine(Line6, (uint8_t*)"     please wait... ");
#endif
    }
    break;

  case DHCP_WAIT_ADDRESS:
    {
      /* Read the new IP address */
      IPaddress = gnetif.ip_addr.addr;
      
      if (IPaddress!=0) 
      {
        DHCP_state = DHCP_ADDRESS_ASSIGNED;	
        
        /* Stop DHCP */
        dhcp_stop(&gnetif);

#ifdef USE_LCD      
        iptab[0] = (uint8_t)(IPaddress >> 24);
        iptab[1] = (uint8_t)(IPaddress >> 16);
        iptab[2] = (uint8_t)(IPaddress >> 8);
        iptab[3] = (uint8_t)(IPaddress);

        sprintf((char*)iptxt, " %d.%d.%d.%d", iptab[3], iptab[2], iptab[1], iptab[0]);       

        LCD_ClearLine(Line4);
        LCD_ClearLine(Line5);
        LCD_ClearLine(Line6);

        /* Display the IP address */
        LCD_DisplayStringLine(Line7, (uint8_t*)"IP address assigned ");
        LCD_DisplayStringLine(Line8, (uint8_t*)"  by a DHCP server  ");
        LCD_DisplayStringLine(Line9, iptxt);
#endif
        STM_EVAL_LEDOn(LED1);
      }
      else
      {
        /* DHCP timeout */
        if (gnetif.dhcp->tries > MAX_DHCP_TRIES)
        {
          DHCP_state = DHCP_TIMEOUT;

          /* Stop DHCP */
          dhcp_stop(&gnetif);

          /* Static address used */
          IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
          IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
          IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
          netif_set_addr(&gnetif, &ipaddr , &netmask, &gw);

#ifdef USE_LCD   
          LCD_DisplayStringLine(Line7, (uint8_t*)"    DHCP timeout    ");

          iptab[0] = IP_ADDR3;
          iptab[1] = IP_ADDR2;
          iptab[2] = IP_ADDR1;
          iptab[3] = IP_ADDR0;

          sprintf((char*)iptxt, "  %d.%d.%d.%d", iptab[3], iptab[2], iptab[1], iptab[0]);

          LCD_ClearLine(Line4);
          LCD_ClearLine(Line5);
          LCD_ClearLine(Line6);

          LCD_DisplayStringLine(Line8, (uint8_t*)"  Static IP address   ");
          LCD_DisplayStringLine(Line9, iptxt);         
#endif
          STM_EVAL_LEDOn(LED1);
        }
      }
    }
Exemplo n.º 22
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);

  STM_EVAL_LEDOn(LED1);

 /* Initialize the LCD */
  LCD_Init();
  LCD_Clear(Black);
  LCD_SetTextColor(White);

  LCD_LOG_SetHeader((uint8_t*)"STM32 Camera Demo");
  LCD_LOG_SetFooter ((uint8_t*)"   Copyright (c) STMicroelectronics" );

  /* ADC configuration */
  ADC_Config();

  /* Initializes the DCMI interface (I2C and GPIO) used to configure the camera */
  OV2640_HW_Init();

  /* Read the OV9655/OV2640 Manufacturer identifier */
  OV9655_ReadID(&OV9655_Camera_ID);
  OV2640_ReadID(&OV2640_Camera_ID);

  if(OV9655_Camera_ID.PID  == 0x96)
  {
    Camera = OV9655_CAMERA;
    sprintf((char*)abuffer, "OV9655 Camera ID 0x%x", OV9655_Camera_ID.PID);
    ValueMax = 2;
  }
  else if(OV2640_Camera_ID.PIDH  == 0x26)
  {
    Camera = OV2640_CAMERA;
    sprintf((char*)abuffer, "OV2640 Camera ID 0x%x", OV2640_Camera_ID.PIDH);
    ValueMax = 2;
  }
  else
  {
    LCD_SetTextColor(LCD_COLOR_RED);
    LCD_DisplayStringLine(LINE(4), (uint8_t*)"Check the Camera HW and try again");
    while(1);
  }

  LCD_SetTextColor(LCD_COLOR_YELLOW);
  LCD_DisplayStringLine(LINE(4), (uint8_t*)abuffer);
  LCD_SetTextColor(LCD_COLOR_WHITE);
  Delay(200);

  /* Initialize demo */
  ImageFormat = (ImageFormat_TypeDef)Demo_Init();

  /* Configure the Camera module mounted on STM324xG-EVAL/STM324x7I-EVAL boards */
  Demo_LCD_Clear();
  LCD_DisplayStringLine(LINE(4), (uint8_t*)"Camera Init..               ");
  Camera_Config();

  sprintf((char*)abuffer, " Image selected: %s", ImageForematArray[ImageFormat]);
  LCD_DisplayStringLine(LINE(4),(uint8_t*)abuffer);

  /* Enable DMA2 stream 1 and DCMI interface then start image capture */
  DMA_Cmd(DMA2_Stream1, ENABLE);
  DCMI_Cmd(ENABLE);

  /* Insert 100ms delay: wait 100ms */
  Delay(200);

  DCMI_CaptureCmd(ENABLE);

  LCD_ClearLine(LINE(4));
  Demo_LCD_Clear();

  if(ImageFormat == BMP_QQVGA)
  {
    /* LCD Display window */
    LCD_SetDisplayWindow(179, 239, 120, 160);
    LCD_WriteReg(LCD_REG_3, 0x1038);
    LCD_WriteRAM_Prepare();
  }
  else if(ImageFormat == BMP_QVGA)
  {
    /* LCD Display window */
    LCD_SetDisplayWindow(239, 319, 240, 320);
    LCD_WriteReg(LCD_REG_3, 0x1038);
    LCD_WriteRAM_Prepare();
  }

  while(1)
  {
    /* Blink LD1, LED2 and LED4 */
    STM_EVAL_LEDToggle(LED1);
    STM_EVAL_LEDToggle(LED2);
    STM_EVAL_LEDToggle(LED3);
    STM_EVAL_LEDToggle(LED4);

    /* Insert 100ms delay */
    Delay(10);

    /* Get the last ADC3 conversion result data */
    uhADCVal = ADC_GetConversionValue(ADC3);

    /* Change the Brightness of camera using "Brightness Adjustment" register:
       For OV9655 camera Brightness can be positively (0x01 ~ 0x7F) and negatively (0x80 ~ 0xFF) adjusted
       For OV2640 camera Brightness can be positively (0x20 ~ 0x40) and negatively (0 ~ 0x20) adjusted */
    if(Camera == OV9655_CAMERA)
    {
      OV9655_BrightnessConfig(uhADCVal);
    }
    if(Camera == OV2640_CAMERA)
    {
      OV2640_BrightnessConfig(uhADCVal/2);
    }
  }
}
Exemplo n.º 23
0
/*******************************************************************************
* Function Name  : LCD_DisplayString
* Description    : Displays a maximum of 200 char on the LCD.
* Input          : - Line: the starting Line where to display the character shape.
*                    This parameter can be one of the following values:
*                       - Linex: where x can be 0..9
*                  - *ptr: pointer to string to display on LCD.
* Output         : None
* Return         : None
*******************************************************************************/
void LCD_DisplayString(u8 Line, u8 *ptr)
{
  u32 i = 0, column = 0, index = 0, spaceindex = 0;
  u16 refcolumn = 319;
  u32 length = 0;

  /* Get the string length */
  length = StrLength(ptr);
  if(length > 200)
  {
    /* Set the Cursor position */
    LCD_SetCursor(Line, 0x013F);
    /* Clear the Selected Line */
    LCD_ClearLine(Line);
    LCD_DisplayStringLine(Line, "   String too long  ");
  }
  else
  {
    /* Set the Cursor position */
    LCD_SetCursor(Line, 0x013F);
    /* Clear the Selected Line */
//    LCD_ClearLine(Line);

    while(length--)
    {
      if(index == 20)
      {
        if(*ptr == 0x20)
        {
          ptr++;
        }
        else
        {
          for(i = 0; i < spaceindex; i++)
          {
            LCD_DisplayChar(Line, column, ' ');
            column -= 16;
          }
          ptr -= (spaceindex - 1);
          length += (spaceindex - 1);
        }
        Line += 24;
        /* Clear the Selected Line */
//        LCD_ClearLine(Line);
        refcolumn = 319;
        index = 0;
      }
      /* Display one character on LCD */
      LCD_DisplayChar(Line, refcolumn, *ptr);

      /* Increment character number in one line */
      index++;

      /* Decrement the column position by 16 */
      refcolumn -= 16;
      /* Point on the next character */
      ptr++;
      /* Increment the number of character after the last space */
      spaceindex++;
      if(*ptr == 0x20)
      {
        spaceindex = 0;
        column = refcolumn - 16;
      }
    }
  }
}
Exemplo n.º 24
0
/**
  * @brief Validation firmware main entry point.
  * @par Parameters:
  * None
  * @retval 
  * None
  */
void main(void)
{
    int ButtonIndex =0;
    u8 i =0;
    u8 LedState =1;
    u8 pos =0;
    u8 s[16];

    /* Initialize I/Os in Output Mode for LEDs */
    GPIO_Init(LEDS_PORT, LED1_PIN | LED2_PIN | LED3_PIN | LED4_PIN,GPIO_MODE_OUT_PP_LOW_FAST);

    /* Initialization of I/O in Input Mode with Interrupt for Key button */
    GPIO_Init(BUTTON_PORT, BUTTON_PIN, GPIO_MODE_IN_FL_IT);

    /* Initialization of the Interrupt sensitivity */
    EXTI_SetExtIntSensitivity(EXTI_PORT_GPIOC, EXTI_SENSITIVITY_FALL_ONLY);

    /* Enable general interrupts for Key button reading */
    enableInterrupts();

    /* Initialize SPI */
    SPI_DeInit();
    SPI_Init(SPI_FIRSTBIT_MSB, SPI_BAUDRATEPRESCALER_128, SPI_MODE_MASTER,
             SPI_CLOCKPOLARITY_HIGH, SPI_CLOCKPHASE_2EDGE, SPI_DATADIRECTION_1LINE_TX,
             SPI_NSS_SOFT, 0x07);
    SPI_Cmd(ENABLE);

    /* Initialize LCD */
    LCD_Init();

    /* Clear LCD lines */
    LCD_Clear();

    /* Display "moving" ST logo on first line */
    for (pos = 0x80; pos < 0x88; pos++)
    {
        LCD_Clear();
        LCD_DisplayLogo(pos);
        Delay(20000);
    }

    /* Display "moving" ST logo on second line */
    for (pos = 0x90; pos < 0x98; pos++)
    {
        LCD_Clear();
        LCD_DisplayLogo(pos);
        Delay(20000);
    }

    LCD_Clear();

    /* More than 15 characters: the message is displayed on 2 lines */
    /* LCD_PrintMsg("STM8S - SPI/LCD example"); */

    /* Max 15 characters per line */
    LCD_PrintString(LCD_LINE1, ENABLE, DISABLE, " *** STM8S *** ");
    LCD_PrintString(LCD_LINE2, ENABLE, DISABLE, "SPI-LCD example");

    for (i = 0; i < 10; i++)
    {
        Delay(0xFFFF);
    }

    LCD_Clear();

    LCD_PrintString(LCD_LINE1, ENABLE, DISABLE, "Press KEY...");

    while (1)
    {
        /* Check button status */
        if (GetVar_ButtonPressed() == TRUE) /* Button is pressed */
        {
            ButtonPressed = FALSE;
            LCD_ClearLine(LCD_LINE2);
            LCD_PrintString(LCD_LINE2, DISABLE, DISABLE, "LED #");
						
           /*Use the  sprintf() and LCD_Print() function to print a digit on the LCD */
 					 if (LedState == 0)
            {
                sprintf(s,"%d ", ButtonIndex + 1);
                LCD_Print(s);
								LCD_SetCursorPos(LCD_LINE2, 4); /* 8th position */
                LCD_PrintChar('O');
                LCD_PrintChar('F');
                LCD_PrintChar('F');
            }
						/*Use the LCD_PrintDec1() function to print a digit on the LCD */
            else
            {
                LCD_PrintDec1((u8)(ButtonIndex + 1)); /* Display at current cursor position */
                LCD_SetCursorPos(LCD_LINE2, 4); /* 8th position */ 
								LCD_PrintChar('O');
                LCD_PrintChar('N');
                LCD_PrintChar(' ');
            }
             switch (ButtonIndex)
            {
            case 0:
                GPIO_WriteReverse(LEDS_PORT, LED1_PIN);
                ButtonIndex++;
                break;
            case 1:
                GPIO_WriteReverse(LEDS_PORT, LED2_PIN);
                ButtonIndex++;
                break;
            case 2:
                GPIO_WriteReverse(LEDS_PORT, LED3_PIN);
                ButtonIndex++;
                break;
            default:
            case 3:
                GPIO_WriteReverse(LEDS_PORT, LED4_PIN);
                ButtonIndex = 0;
                LedState ^= 0x01;
                break;
            }
        }
    }

}
Exemplo n.º 25
0
/**
  * @brief  This function handles External lines 15 to 10 interrupt request.
  * @param  None
  * @retval None
  */
void EXTI15_10_IRQHandler(void)
{
  if((EXTI_GetITStatus(TAMPER_BUTTON_EXTI_LINE) != RESET) && (ubStartevent !=0) && (uwBackupindex < 11))
  {
    uint16_t Colorx;
    uint8_t index = 0;
    
    if (uwBackupindex < 10)
    {
      /* Increment counter */
      ubRTCCount++;
      
      /* Set LCD background color*/
      if((uint8_t)(ubRTCCount % 2) != 0)
      { 
        LCD_SetBackColor(Blue2);
        Colorx = White;
      }
      else
      {
        LCD_SetBackColor(Cyan);
        Colorx = Black;
      }
      
      /* Get the Current sub seconds and time */
      ubSSecondfraction = 1000 - ((uint32_t)((uint32_t)RTC_GetSubSecond() * 1000) / (uint32_t)0x3FF);
      RTC_GetTime(RTC_Format_BCD, &RTC_StampTimeStruct);
      
      LCD_SetFont(&Font12x12);
      
      /* Display result on the LCD */
      RTC_Time_display(LINE(7 + uwBackupindex), Colorx, RTC_Get_Time(ubSSecondfraction , &RTC_StampTimeStruct)); 
      
      /* Save time register  to Backup register (the first 10 registers are reserved for time) */
      RTC_WriteBackupRegister(aBKPDataReg[uwBackupindex],(uint32_t)RTC->TR);
      
      /* Save sub second time stamp register (the latest 10 registers are reserved for sub second) */
      RTC_WriteBackupRegister(aBKPDataReg[uwBackupindex + 10], ubSSecondfraction);
    }
    else
    {      
      /* Set the LCD Background Color */
      LCD_SetBackColor(White);
      LCD_SetFont(&Font12x12);
      
      /* Clear all LCD lines from 7 to 19 */
      for (index = 0; index < 13; index++)
      {
        LCD_ClearLine(LINE(7 + index));
      }
      
      /* Reset Counters */
      ubRTCCount = 0;
      uwBackupindex = 0 ;
      
      /* Enter to idle */
      ubStartevent =0;
      
      /* Set the time to 00h 00mn 00s AM */
      RTC_TimeStructure.RTC_H12     = RTC_H12_AM;
      RTC_TimeStructure.RTC_Hours   = 0;
      RTC_TimeStructure.RTC_Minutes = 0;
      RTC_TimeStructure.RTC_Seconds = 0;  
      RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
      
      /* Disable the RTC Clock */
      RCC_RTCCLKCmd(DISABLE);
      LCD_SetFont(&Font16x24);
      
      /* Set the LCD Text Color */
      LCD_SetTextColor(Blue);
      
      /* Display message to the LCD */
      LCD_DisplayStringLine(LINE(5), (uint8_t *)MESSAGE1);
      
      /* Clear EXTI line 21 */
      EXTI_ClearITPendingBit(EXTI_Line21);
      
      /* Clear Tamper pin interrupt pending bit */
      RTC_ClearITPendingBit(RTC_IT_TAMP1);
    }  
    
    uwBackupindex++;
  }
  /* Clear the TAMPER EXTI pending bit */
  EXTI_ClearITPendingBit(TAMPER_BUTTON_EXTI_LINE);     
}
Exemplo n.º 26
0
/**
  * @brief  LwIP_DHCP_Process_Handle
  * @param  None
  * @retval None
  */
void LwIP_DHCP_task(void * pvParameters)
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;
  uint32_t IPaddress;
  uint8_t iptab[4];
  uint8_t iptxt[20];
  uint8_t DHCP_state;  
  DHCP_state = DHCP_START;

  for (;;)
  {
    switch (DHCP_state)
    {
      case DHCP_START:
      {
        dhcp_start(&xnetif);
        IPaddress = 0;
        DHCP_state = DHCP_WAIT_ADDRESS;
#ifdef USE_LCD
        LCD_DisplayStringLine(Line4, (uint8_t*)"     Looking for    ");
        LCD_DisplayStringLine(Line5, (uint8_t*)"     DHCP server    ");
        LCD_DisplayStringLine(Line6, (uint8_t*)"     please wait... ");
#endif
      }
      break;

      case DHCP_WAIT_ADDRESS:
      {
        /* Read the new IP address */
        IPaddress = xnetif.ip_addr.addr;

        if (IPaddress!=0) 
        {
          DHCP_state = DHCP_ADDRESS_ASSIGNED;	
          
          /* Stop DHCP */
          dhcp_stop(&xnetif);

#ifdef USE_LCD      
          iptab[0] = (uint8_t)(IPaddress >> 24);
          iptab[1] = (uint8_t)(IPaddress >> 16);
          iptab[2] = (uint8_t)(IPaddress >> 8);
          iptab[3] = (uint8_t)(IPaddress);

          sprintf((char*)iptxt, "  %d.%d.%d.%d", iptab[3], iptab[2], iptab[1], iptab[0]);  

          LCD_ClearLine(Line4);
          LCD_ClearLine(Line5);
          LCD_ClearLine(Line6);
          /* Display the IP address */
          LCD_DisplayStringLine(Line7, (uint8_t*)"IP address assigned ");
          LCD_DisplayStringLine(Line8, (uint8_t*)"  by a DHCP server  ");
          LCD_DisplayStringLine(Line9, iptxt);
#endif  
          /* end of DHCP process: LED1 stays ON*/
          STM_EVAL_LEDOn(LED1);
          vTaskDelete(NULL);
        }
        else
        {
          /* DHCP timeout */
          if (xnetif.dhcp->tries > MAX_DHCP_TRIES)
          {
            DHCP_state = DHCP_TIMEOUT;

            /* Stop DHCP */
            dhcp_stop(&xnetif);

            /* Static address used */
            IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
            IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
            IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
            netif_set_addr(&xnetif, &ipaddr , &netmask, &gw);

#ifdef USE_LCD   
            LCD_DisplayStringLine(Line7, (uint8_t*)"    DHCP timeout    ");

            iptab[0] = IP_ADDR3;
            iptab[1] = IP_ADDR2;
            iptab[2] = IP_ADDR1;
            iptab[3] = IP_ADDR0;

            sprintf((char*)iptxt, "  %d.%d.%d.%d", iptab[3], iptab[2], iptab[1], iptab[0]); 

            LCD_ClearLine(Line4);
            LCD_ClearLine(Line5);
            LCD_ClearLine(Line6);
            LCD_DisplayStringLine(Line8, (uint8_t*)"  Static IP address   ");
            LCD_DisplayStringLine(Line9, iptxt);
#endif
            /* end of DHCP process: LED1 stays ON*/
            STM_EVAL_LEDOn(LED1);
            vTaskDelete(NULL);
          }
        }
      }
      break;

      default: break;
    }
Exemplo n.º 27
0
void LCD_UpdateMessage ( const char string[] ) {
    LCD_ClearLine(1);
    LCD_PrintString(string);
}
Exemplo n.º 28
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
  */
  
  uint32_t index = 0;
  
  /* NVIC Configuration */
  NVIC_Config();
  
  /* Initialize the LCD */
  STM320518_LCD_Init();
  
  /* Initialize the Temperature Sensor */
  LM75_Init();
  
  if (LM75_GetStatus() == SUCCESS)
  {
    /* Clear the LCD */
    LCD_Clear(LCD_COLOR_WHITE);
    
    /* Set the Back Color */
    LCD_SetBackColor(LCD_COLOR_BLUE);
    /* Set the Text Color */
    LCD_SetTextColor(LCD_COLOR_GREEN);
    
    LCD_DisplayStringLine(LCD_LINE_0, "     Temperature    ");
    
    /* Configure the Temperature sensor device STLM75:
    - Thermostat mode Interrupt
    - Fault tolerance: 00
    */
    LM75_WriteConfReg(0x02);
    
    /* Configure the THYS and TOS in order to use the SMbus alert interrupt */
    LM75_WriteReg(LM75_REG_THYS, TEMPERATURE_THYS << 8);  /*31°C*/
    LM75_WriteReg(LM75_REG_TOS, TEMPERATURE_TOS << 8);   /*32°C*/
    
    /* Enables the I2C SMBus Alert feature */
    I2C_SMBusAlertCmd(LM75_I2C, ENABLE);    
    I2C_ClearFlag(LM75_I2C, I2C_FLAG_ALERT);
    
    SMbusAlertOccurred = 0;
    
    /* Enable SMBus Alert interrupt */
    I2C_ITConfig(LM75_I2C, I2C_IT_ERRI, ENABLE);
    
    /* Infinite Loop */
    while (1)
    {
      /* Get double of Temperature value */
      TempValue = LM75_ReadTemp();
      
      if (TempValue <= 256)
      {
        /* Positive temperature measured */
        TempCelsiusDisplay[7] = '+';        
        /* Initialize the temperature sensor value*/
        TempValueCelsius = TempValue;
      }
      else
      {
        /* Negative temperature measured */
        TempCelsiusDisplay[7] = '-';        
        /* Remove temperature value sign */
        TempValueCelsius = 0x200 - TempValue;
      }
      
      /* Calculate temperature digits in °C */
      if ((TempValueCelsius & 0x01) == 0x01)
      {
        TempCelsiusDisplay[12] = 0x05 + 0x30;
        TempFahrenheitDisplay[12] = 0x05 + 0x30;
      }
      else
      {
        TempCelsiusDisplay[12] = 0x00 + 0x30;
        TempFahrenheitDisplay[12] = 0x00 + 0x30;
      }
      
      TempValueCelsius >>= 1;
      
      TempCelsiusDisplay[8] = (TempValueCelsius / 100) + 0x30;
      TempCelsiusDisplay[9] = ((TempValueCelsius % 100) / 10) + 0x30;
      TempCelsiusDisplay[10] = ((TempValueCelsius % 100) % 10) + 0x30;
      
      if (TempValue > 256)
      {
        if (((9 * TempValueCelsius) / 5) <= 32)
        {
          /* Convert temperature °C to Fahrenheit */
          TempValueFahrenheit = abs (32 - ((9 * TempValueCelsius) / 5));          
          /* Calculate temperature digits in °F */
          TempFahrenheitDisplay[8] = (TempValueFahrenheit / 100) + 0x30;
          TempFahrenheitDisplay[9] = ((TempValueFahrenheit % 100) / 10) + 0x30;
          TempFahrenheitDisplay[10] = ((TempValueFahrenheit % 100) % 10) + 0x30;          
          /* Positive temperature measured */
          TempFahrenheitDisplay[7] = '+';
        }
        else
        {
          /* Convert temperature °C to Fahrenheit */
          TempValueFahrenheit = abs(((9 * TempValueCelsius) / 5) - 32);
          /* Calculate temperature digits in °F */
          TempFahrenheitDisplay[8] = (TempValueFahrenheit / 100) + 0x30;
          TempFahrenheitDisplay[9] = ((TempValueFahrenheit % 100) / 10) + 0x30;
          TempFahrenheitDisplay[10] = ((TempValueFahrenheit % 100) % 10) + 0x30;          
          /* Negative temperature measured */
          TempFahrenheitDisplay[7] = '-';
        }
      }
      else
      {
        /* Convert temperature °C to Fahrenheit */
        TempValueFahrenheit = ((9 * TempValueCelsius) / 5) + 32;
        
        /* Calculate temperature digits in °F */
        TempFahrenheitDisplay[8] = (TempValueFahrenheit / 100) + 0x30;
        TempFahrenheitDisplay[9] = ((TempValueFahrenheit % 100) / 10) + 0x30;
        TempFahrenheitDisplay[10] = ((TempValueFahrenheit % 100) % 10) + 0x30;
        
        /* Positive temperature measured */
        TempFahrenheitDisplay[7] = '+';
      }
      
      /* Display Fahrenheit value on LCD */
      for (index = 0; index < 20; index++)
      {
        LCD_DisplayChar(LCD_LINE_6, (319 - (16 * index)), TempCelsiusDisplay[index]);
        
        LCD_DisplayChar(LCD_LINE_7, (319 - (16 * index)), TempFahrenheitDisplay[index]);
      }
      
      if (SMbusAlertOccurred == 1)
      {
        /* Set the Back Color */
        LCD_SetBackColor(LCD_COLOR_BLUE);
        /* Set the Text Color */
        LCD_SetTextColor(LCD_COLOR_RED);
        LCD_DisplayStringLine(LCD_LINE_2, "Warning: Temp exceed");
        LCD_DisplayStringLine(LCD_LINE_3, "        32 C        ");
      }
      if (SMbusAlertOccurred == 2)
      {
        /* Set the Back Color */
        LCD_SetBackColor(LCD_COLOR_WHITE);
        /* Set the Text Color */
        LCD_SetTextColor(LCD_COLOR_WHITE);
        LCD_ClearLine(LCD_LINE_2);
        LCD_ClearLine(LCD_LINE_3);
        SMbusAlertOccurred = 0;
        /* Set the Back Color */
        LCD_SetBackColor(LCD_COLOR_BLUE);
        /* Set the Text Color */
        LCD_SetTextColor(LCD_COLOR_GREEN);
      }
    }
  }
Exemplo n.º 29
0
/**
  * @brief  Link callback function, this function is called on change of link status.
  * @param  The network interface
  * @retval None
  */
void ETH_link_callback(struct netif *netif)
{
  __IO uint32_t timeout = 0;
 uint32_t tmpreg;
 uint16_t RegValue;
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;
#ifndef USE_DHCP
  uint8_t iptab[4] = {0};
  uint8_t iptxt[20];
#endif /* USE_DHCP */

  /* Clear LCD */
//  LCD_ClearLine(Line4);
//  LCD_ClearLine(Line5);
//  LCD_ClearLine(Line6);
 // LCD_ClearLine(Line7);
//  LCD_ClearLine(Line8);
//  LCD_ClearLine(Line9);

  if(netif_is_link_up(netif))
  {
    /* Restart the auto-negotiation */
    if(ETH_InitStructure.ETH_AutoNegotiation != ETH_AutoNegotiation_Disable)
    {
      /* Reset Timeout counter */
      timeout = 0;

      /* Enable auto-negotiation */
      ETH_WritePHYRegister(DP83848_PHY_ADDRESS, PHY_BCR, PHY_AutoNegotiation);

      /* Wait until the auto-negotiation will be completed */
      do
      {
        timeout++;
      } while (!(ETH_ReadPHYRegister(DP83848_PHY_ADDRESS, PHY_BSR) & PHY_AutoNego_Complete) && (timeout < (uint32_t)PHY_READ_TO));  

      /* Reset Timeout counter */
      timeout = 0;

      /* Read the result of the auto-negotiation */
      RegValue = ETH_ReadPHYRegister(DP83848_PHY_ADDRESS, PHY_SR);

      /* Configure the MAC with the Duplex Mode fixed by the auto-negotiation process */
      if((RegValue & PHY_DUPLEX_STATUS) != (uint16_t)RESET)
      {
        /* Set Ethernet duplex mode to Full-duplex following the auto-negotiation */
        ETH_InitStructure.ETH_Mode = ETH_Mode_FullDuplex;  
      }
      else
      {
        /* Set Ethernet duplex mode to Half-duplex following the auto-negotiation */
        ETH_InitStructure.ETH_Mode = ETH_Mode_HalfDuplex;
      }
      /* Configure the MAC with the speed fixed by the auto-negotiation process */
      if(RegValue & PHY_SPEED_STATUS)
      {
        /* Set Ethernet speed to 10M following the auto-negotiation */
        ETH_InitStructure.ETH_Speed = ETH_Speed_10M; 
      }
      else
      {
        /* Set Ethernet speed to 100M following the auto-negotiation */
        ETH_InitStructure.ETH_Speed = ETH_Speed_100M;
      }

      /*------------------------ ETHERNET MACCR Re-Configuration --------------------*/
      /* Get the ETHERNET MACCR value */  
      tmpreg = ETH->MACCR;

      /* Set the FES bit according to ETH_Speed value */ 
      /* Set the DM bit according to ETH_Mode value */ 
      tmpreg |= (uint32_t)(ETH_InitStructure.ETH_Speed | ETH_InitStructure.ETH_Mode);

      /* Write to ETHERNET MACCR */
      ETH->MACCR = (uint32_t)tmpreg;

      _eth_delay_(ETH_REG_WRITE_DELAY);
      tmpreg = ETH->MACCR;
      ETH->MACCR = tmpreg;
    }

    /* Restart MAC interface */
    ETH_Start();

#ifdef USE_DHCP
    ipaddr.addr = 0;
    netmask.addr = 0;
    gw.addr = 0;
    DHCP_state = DHCP_START;
#else
    IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
    IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
    IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
#endif /* USE_DHCP */

    netif_set_addr(&gnetif, &ipaddr , &netmask, &gw);
    
    /* When the netif is fully configured this function must be called.*/
    netif_set_up(&gnetif);    

#ifdef USE_LCD
    /* Set the LCD Text Color */
    LCD_SetTextColor(Green);

    /* Display message on the LCD */
    LCD_DisplayStringLine(Line5, (uint8_t*)"  Network Cable is  ");
    LCD_DisplayStringLine(Line6, (uint8_t*)"    now connected   ");

    /* Set the LCD Text Color */
    LCD_SetTextColor(White);

  #ifndef USE_DHCP
    /* Display static IP address */
    iptab[0] = IP_ADDR3;
    iptab[1] = IP_ADDR2;
    iptab[2] = IP_ADDR1;
    iptab[3] = IP_ADDR0;
    sprintf((char*)iptxt, "  %d.%d.%d.%d", iptab[3], iptab[2], iptab[1], iptab[0]); 
    LCD_DisplayStringLine(Line8, (uint8_t*)"  Static IP address   ");
    LCD_DisplayStringLine(Line9, iptxt);

    /* Clear LCD */
    LCD_ClearLine(Line5);
    LCD_ClearLine(Line6);
  #endif /* USE_DHCP */
#endif /* USE_LCD */
    EthLinkStatus = 0;
  }
  else
  {
    ETH_Stop();
#ifdef USE_DHCP
    DHCP_state = DHCP_LINK_DOWN;
    dhcp_stop(netif);
#endif /* USE_DHCP */

    /*  When the netif link is down this function must be called.*/
    netif_set_down(&gnetif);
#ifdef USE_LCD
    /* Set the LCD Text Color */
    LCD_SetTextColor(Red);

    /* Display message on the LCD */
    LCD_DisplayStringLine(Line5, (uint8_t*)"  Network Cable is  ");
    LCD_DisplayStringLine(Line6, (uint8_t*)"     unplugged   ");

    /* Set the LCD Text Color */
    LCD_SetTextColor(White);
#endif /* USE_LCD */
  }
}
Exemplo n.º 30
0
/**
  * @brief  Returns the time entered by user, using menu navigation keys.
  * @param  None
  * @retval Current date value
  */
void Date_Regulate(void)
{
  uint8_t weekday = 0, date = 0, month = 0, year = 0;

  LCD_DisplayStringLine(LCD_LINE_15, "Set date: Weekday / Date / Month / Year");

  /* Read Date Weekday */
  weekday = ReadDigit(LCD_LINE_16, 276, (RTC_DateStructure.RTC_WeekDay / 10), 0x7, 0x1);

  /* Read Date Day */
  date = ReadDigit(LCD_LINE_16, 244, (RTC_DateStructure.RTC_Date / 10), 3, 0x0);

  if(date == 3)
  {
    if((RTC_DateStructure.RTC_Date % 10) > 1)
    {
      RTC_DateStructure.RTC_Date = 0;
    }
    date = date * 10 + ReadDigit(LCD_LINE_16, 228, (RTC_DateStructure.RTC_Date % 10), 0x1, 0x0);
  }
  else
  {
    date = date * 10 + ReadDigit(LCD_LINE_16, 228, (RTC_DateStructure.RTC_Date % 10), 0x9, 0x0);
  }

  /* Read Date Month */
  month = ReadDigit(LCD_LINE_16, 196, (RTC_DateStructure.RTC_Month / 10), 1, 0x0);

  if(month == 1)
  {
    if((RTC_DateStructure.RTC_Month % 10) > 2)
    {
      RTC_DateStructure.RTC_Month = 0;
    }
    month = month * 10 + ReadDigit(LCD_LINE_16, 182, (RTC_DateStructure.RTC_Month % 10), 0x2, 0x0);
  }
  else
  {
    month = month * 10 + ReadDigit(LCD_LINE_16, 182, (RTC_DateStructure.RTC_Month % 10), 0x9, 0x0);
  }

  /* Read Date Year */
  LCD_DisplayChar(LCD_LINE_16, 150, '2');
  LCD_DisplayChar(LCD_LINE_16, 134, '0');
  year = ReadDigit(LCD_LINE_16, 118, (RTC_DateStructure.RTC_Year / 10), 0x9, 0x0);
  year = year * 10 + ReadDigit(LCD_LINE_16, 102, (RTC_DateStructure.RTC_Year % 10), 0x9, 0x0);

  RTC_DateStructure.RTC_WeekDay = weekday;
  RTC_DateStructure.RTC_Date = date;
  RTC_DateStructure.RTC_Month = month;
  RTC_DateStructure.RTC_Year = year;
  RTC_SetDate(RTC_Format_BIN, &RTC_DateStructure);

  /* Set the Back Color */
  LCD_SetBackColor(LCD_COLOR_BLACK);

  /* Set the Text Color */
  LCD_SetTextColor(LCD_COLOR_WHITE);

  /* Clear Line15 */
  LCD_ClearLine(LCD_LINE_15);
}