Example #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);

}
Example #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);
}
/*
 *	Main function: initializes all system values and components, then starts
 *	operation of the two threads.
 *
 *	@author HP Truong, Jacob Barnett
 *
 *	@param void
 *	@return void
 */
int main (void) {
	CC2500_LowLevel_Init();
	CC2500_Reset();

	osKernelInitialize ();                    // initialize CMSIS-RTOS
	
	// initialize peripherals here
	/* LCD initiatization */
	LCD_Init();
  
	/* LCD Layer initiatization */
	LCD_LayerInit();

	/* Enable the LTDC controler */
	LTDC_Cmd(ENABLE);

	/* Set LCD foreground layer as the current layer */
	LCD_SetLayer(LCD_FOREGROUND_LAYER);

	LCD_SetFont(&Font16x24);
	LCD_Clear(LCD_COLOR_WHITE);

	receive_and_plot_thread = osThreadCreate(osThread(receive_and_plot), NULL);
	print_lcd_debug_thread = osThreadCreate(osThread(print_lcd_debug), NULL);

	osKernelStart ();                         // start thread execution 
}
int main(void)
{
	LCD_Init();
	LCD_LayerInit();

	/* LTDC reload configuration */
	LTDC_ReloadConfig(LTDC_IMReload);

	/* Enable the LTDC */
	LTDC_Cmd(ENABLE);

	/* Set LCD foreground layer */
	LCD_SetLayer(LCD_FOREGROUND_LAYER);
	LCD_SetTransparency(0);

	/* Set LCD background layer */
	LCD_SetLayer(LCD_BACKGROUND_LAYER);

	/* LCD display message */
	LCD_Clear(LCD_COLOR_RED);
	LCD_SetTextColor(LCD_COLOR_BLACK);
	LCD_DisplayStringLine(LCD_LINE_2,(uint8_t*)"     YOU'LL    ");
	LCD_DisplayStringLine(LCD_LINE_4,(uint8_t*)"     NEVER     ");
	LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)"      TAKE     ");
	LCD_DisplayStringLine(LCD_LINE_8,(uint8_t*)"       ME      ");
	LCD_DisplayStringLine(LCD_LINE_10,(uint8_t*)"     ALIVE     ");


	while(1)
	{

	}
}
Example #5
0
/**
  * @brief LCD configuration.
  * @note  This function Configure tha LTDC peripheral :
  *        1) Configure the Pixel Clock for the LCD
  *        2) Configure the LTDC Timing and Polarity
  *        3) Configure the LTDC Layer 1 :
  *           - ARGB4444 as pixel format  
  *           - The frame buffer is located at internal RAM : The output of DMA2D transfer
  *           - The Layer size configuration : 150x150  
  * @retval
  *  None
  */
static void LCD_Config(void)
{
  /* Initialize the LCD */
  LCD_Init();
  
  /* Initialize the LCD Layers */
  LCD_LayerInit();
  
  /* Set the Foreground as active Layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

  LCD_SetTransparency(0);
  
  /* Set the Background as active Layer */
  LCD_SetLayer(LCD_BACKGROUND_LAYER); 
  
  /* Configure the window size and position */
  LCD_SetDisplayWindow(165, 61, 150, 150);

  /* Configure the LCD Pixel Format */
  LCD_SetPixelFormat(LTDC_Pixelformat_ARGB4444);
  
  /* Configure the LCD frame Buffer Address */
  LCD_SetAddress((uint32_t)&aBufferResult);  
}  
static void LCD_Config(void)
{
  /* Initialise the LCD */
  LCD_Init();
  
  /* Initialise the LCD Layers */
  LCD_LayerInit();
  
  /* Set the Foreground as active Layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

  /* Configure the window size and position */
  LCD_SetDisplayWindow(90, 137, 120, 300);
  
  /* Configure the LCD frame Buffer Address */
  LCD_SetAddress((uint32_t)&aBufferResult);

  /* Configure the LCD Pixel Format */
  LCD_SetPixelFormat(LTDC_Pixelformat_ARGB4444);  
  
  /* Set the Background as active Layer */
  LCD_SetLayer(LCD_BACKGROUND_LAYER); 
  
  /* Configure the window size and position */
  LCD_SetDisplayWindow(90, 15, 120, 300);
  
  /* Configure the LCD frame Buffer Address */
  LCD_SetAddress((uint32_t)&ARGB8888_300x120); 
  
  /* Configure the LCD Pixel Format */
  LCD_SetPixelFormat(LTDC_Pixelformat_ARGB8888);
}    
Example #7
0
void ui_init()
{
    LCD_Init();

    LCD_LayerInit();

    LTDC_Cmd(ENABLE);

    LCD_DisplayOn();
}
Example #8
0
void LCDinit(){
	LCD_Init();
	LCD_LayerInit();
	LCD_SetLayer(LCD_BACKGROUND_LAYER);
	LCD_SetTransparency(0);
	LCD_SetLayer(LCD_FOREGROUND_LAYER);
	LTDC_ReloadConfig(LTDC_IMReload);
	LTDC_Cmd(ENABLE);
	LCD_Clear(LCD_COLOR_BLACK);
}
/*===========================================================================*/
static inline void init_board(GDisplay *g) {
	g->board = 0;

	/* Init LCD and LTCD. Enable layer1 only. */
	LCD_Init();
	LCD_LayerInit();
	LTDC_LayerCmd(LTDC_Layer1, ENABLE);
	LTDC_LayerCmd(LTDC_Layer2, DISABLE);
	LTDC_ReloadConfig(LTDC_IMReload);
	LTDC_Cmd(ENABLE);
	LCD_SetLayer(LCD_BACKGROUND_LAYER);
}
Example #10
0
/**
  * @brief  Display Init (LCD)
  * @param  None
  * @retval None
  */
static void Display_Init(void)
{
  /* Initialize the LCD */
  LCD_Init();
  LCD_LayerInit();
  /* Enable the LTDC */
  LTDC_Cmd(ENABLE);
  
  /* Set LCD Background Layer  */
  LCD_SetLayer(LCD_BACKGROUND_LAYER);
  
  /* Clear the Background Layer */ 
  LCD_Clear(LCD_COLOR_WHITE);
  
  /* Configure the transparency for background */
  LCD_SetTransparency(0);
  
  /* Set LCD Foreground Layer  */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

  /* Configure the transparency for foreground */
  LCD_SetTransparency(200);
  
  /* Clear the Foreground Layer */ 
  LCD_Clear(LCD_COLOR_WHITE);
  
  /* Set the LCD Back Color and Text Color*/
  LCD_SetBackColor(LCD_COLOR_BLUE);
  LCD_SetTextColor(LCD_COLOR_WHITE);
  
    /* Set the LCD Text size */
  LCD_SetFont(&FONTSIZE);
  
  /* Set the LCD Back Color and Text Color*/
  LCD_SetBackColor(LCD_COLOR_BLUE);
  LCD_SetTextColor(LCD_COLOR_WHITE);
  
  LCD_DisplayStringLine(LINE(LINENUM), (uint8_t*)MESSAGE1);
  LCD_DisplayStringLine(LINE(LINENUM + 1), (uint8_t*)MESSAGE1_1);
  LCD_DisplayStringLine(LINE(0x17), (uint8_t*)"                               ");
  
  /* Set the LCD Text size */
  LCD_SetFont(&Font16x24);
  
  LCD_DisplayStringLine(LCD_LINE_0, (uint8_t*)MESSAGE2);
  LCD_DisplayStringLine(LCD_LINE_1, (uint8_t*)MESSAGE2_1);
  
  /* Set the LCD Back Color and Text Color*/
  LCD_SetBackColor(LCD_COLOR_WHITE);
  LCD_SetTextColor(LCD_COLOR_BLUE); 
}
Example #11
0
/**
* @brief  Main Function
* @param  
* @retval int 0
*/
int main (void) {

  osKernelInitialize ();                    // initialize CMSIS-RTOS
  wireless_init();  //Initialize wireless
  LCD_Init();  //Initialize LCD
  LCD_LayerInit(); //Initialize Layer  
  /* Enable the LTDC controler */
  LTDC_Cmd(ENABLE);
  /* Set LCD foreground layer as the current layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
	DisplayLCD_thread = osThreadCreate(osThread(DisplayLCD), NULL);
  Rx_thread = osThreadCreate(osThread(RxPacket), NULL);
	osKernelStart();
}
Example #12
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);
}
Example #13
0
void ILI9341_Configuration()
{
	/** 
  	* @brief ILI9341 Configuration
  	* 		 Do not change the following except you had known all 
  	*	 	 configurations.
  	*/ 
	LCD_Init();
	LTDC_Cmd( ENABLE );
	LCD_LayerInit();
	LCD_SetLayer(LCD_FOREGROUND_LAYER );
	LCD_Clear(LCD_COLOR_BLACK );
	LCD_SetTextColor(LCD_COLOR_BLACK );

}
Example #14
0
/**
  * @brief  Initializes the hardware
  * @param  None
  * @retval None
  */
static void prvHardwareInit()
{
  GPIO_InitTypeDef GPIO_InitStructure;
  /* BL ADJ */
  __GPIOA_CLK_ENABLE();
  GPIO_InitStructure.Pin    = BACKLIGHT_ADJ_PIN;
  GPIO_InitStructure.Mode   = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStructure.Pull   = GPIO_NOPULL;
  GPIO_InitStructure.Speed  = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
  HAL_GPIO_WritePin(GPIOA, BACKLIGHT_ADJ_PIN, GPIO_PIN_SET);

  /* LCD-DISP-ENABLE */
  __GPIOC_CLK_ENABLE();
  GPIO_InitStructure.Pin    = DISPLAY_ENABLE_PIN;
  GPIO_InitStructure.Mode   = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStructure.Pull   = GPIO_NOPULL;
  GPIO_InitStructure.Speed  = GPIO_SPEED_LOW;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStructure);
  HAL_GPIO_WritePin(GPIOC, DISPLAY_ENABLE_PIN, GPIO_PIN_SET);

  /* LCD */
  LCD_Init();
  LCD_LayerInit();

//  LCD_DrawAntiAliasedLineOnLayer(0xFFFFFFFF, 200, 200, 100, 100, LCD_LAYER_1);
//  LCD_ClearScreenBuffer(0x0000);
//  LCD_DrawLayerToBuffer(GUILayer_1);
//  LCD_RefreshActiveDisplay();
//
//
//  while (1);

  /* Capacitive Touch */
  FT5206_Init();

//  FT5206_TestMode();
//  GPIO_InitTypeDef GPIO_InitStructure;
//  GPIO_InitStructure.Pin    = GPIO_PIN_7;
//  GPIO_InitStructure.Mode   = GPIO_MODE_OUTPUT_PP;
//  GPIO_InitStructure.Pull   = GPIO_NOPULL;
//  GPIO_InitStructure.Speed  = GPIO_SPEED_LOW;
//  HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
//  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_7, GPIO_PIN_SET);
}
Example #15
0
/**
* @brief  USBH_USR_Init 
*         Displays the message on LCD for host lib initialization
* @param  None
* @retval None
*/
void USBH_USR_Init(void)
{
  static uint8_t startup = 0;  
  
  if(startup == 0 )
  {
    startup = 1;
    /* Configure the LEDs */
    STM_EVAL_LEDInit(LED3); 
    STM_EVAL_LEDInit(LED4); 
    
    STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
       
    /* Initialize the LCD */
    LCD_Init();
    LCD_LayerInit();
    
    /* Set LCD background layer */
    LCD_SetLayer(LCD_BACKGROUND_LAYER);
    
    /* Set LCD transparency */
    LCD_SetTransparency(0);
    
    /* Set LCD foreground layer */
    LCD_SetLayer(LCD_FOREGROUND_LAYER);
    
    /* LTDC reload configuration */  
    LTDC_ReloadConfig(LTDC_IMReload);
    
    /* Enable the LTDC */
    LTDC_Cmd(ENABLE);
    
    /* LCD Log initialization */
    LCD_LOG_Init(); 
    
    
#ifdef USE_USB_OTG_HS 
    LCD_LOG_SetHeader("PDF Create");
#else
    LCD_LOG_SetHeader(" USB OTG FS MSC Host");
#endif
    LCD_UsrLog("> USB Host library started.\n"); 
    LCD_LOG_SetFooter ("     USB Host Library v2.1.0" );
  }
}
Example #16
0
void
prvInit()
{
	//LCD init
	LCD_Init();
	IOE_Config();
	LTDC_Cmd( ENABLE );

	LCD_LayerInit();
	LCD_SetLayer( LCD_FOREGROUND_LAYER );
	LCD_Clear( LCD_COLOR_BLACK );
	LCD_SetTextColor( LCD_COLOR_WHITE );

	//Button
	STM_EVAL_PBInit( BUTTON_USER, BUTTON_MODE_GPIO );

	//LED
	STM_EVAL_LEDInit( LED3 );
}
Example #17
0
static void LCD_Config(void)
{
  /* Initialise the LCD */
  LCD_Init();
  
  /* Initialise the LCD Layers */
  LCD_LayerInit();
  
  /* Set the Foreground as active Layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

  LCD_SetTransparency(0);
  
  /* Set the Background as active Layer */
  LCD_SetLayer(LCD_BACKGROUND_LAYER); 
  
  /* Configure the window size and position */
  LCD_SetDisplayWindow(120, 70, 130, 240);
  
  /* Configure the LCD frame Buffer Address */
  LCD_SetAddress((uint32_t)&aBlendedImage);  
}
Example #18
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. 
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32f4xx.c file
  */  
  /* SysTick end of count event each 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
  
  /* Initialize the LCD */
  LCD_Init();
  /* Initialize the LCD Layers*/
  LCD_LayerInit();
  
  /* Enable the LTDC */
  LTDC_Cmd(ENABLE);
  
  /* Set LCD Background Layer  */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  
  /* Clear the Background Layer */ 
  LCD_Clear(LCD_COLOR_WHITE);

  /* Gyroscope configuration */
  Demo_GyroConfig();

  /* Gyroscope calibration */
  Gyro_SimpleCalibration(Gyro);
  
  /* Infinite loop */
  while (1)
  {
    Demo_MEMS();
  }
}
Example #19
0
void lcd_init(void)
{
	LCD_Init();
	LCD_LayerInit();

	SysTick_init ();

	pushbutton_init();

	/* Enable the LTDC */
	LTDC_Cmd(ENABLE);

	/* Set LCD foreground layer */
	LCD_SetLayer(LCD_FOREGROUND_LAYER);
	LCD_SetTransparency(0);

	/* Set LCD background layer */
	LCD_SetLayer(LCD_BACKGROUND_LAYER);

	/* LCD display message */
	LCD_Clear(LCD_COLOR_BLACK);
	LCD_SetBackColor(LCD_COLOR_BLACK);
	LCD_SetTextColor(LCD_COLOR_WHITE);
}
Example #20
0
static void LCD_Config(void)
{
  
  /* Initialise the LCD */
  LCD_Init();
  
  /* Initialise the LCD Layers */
  LCD_LayerInit();
  
  /* Clear the Hole LCD */
  LCD_Clear(LCD_COLOR_WHITE);   
  
  /* Set the Foreground as active Layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  
  /* Configure the window size and position */
  LCD_SetDisplayWindow(0, 0, 100, 100);
  
  /* Configure the LCD frame Buffer Address */
  LCD_SetAddress((uint32_t)&aBufferResult);

  /* Configure the LCD Pixel Format */
  LCD_SetPixelFormat(LTDC_Pixelformat_ARGB4444);   
}
LCDTFTConf::LCDTFTConf()
{
	CurrentFrameBuffer = LCD_FRAME_BUFFER;
	CurrentLayer = LCD_BACKGROUND_LAYER;

	LTDC_InitTypeDef       LTDC_InitStruct;

	/* Configure the LCD Control pins ------------------------------------------*/
	LCD_CtrlLinesConfig();
	LCD_ChipSelect(DISABLE);
	LCD_ChipSelect(ENABLE);

	/* Configure the LCD_SPI interface -----------------------------------------*/
	LCD_SPIConfig();

	/* Power on the LCD --------------------------------------------------------*/
	LCD_PowerOn();

	/* Enable the LTDC Clock */
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);

	/* Enable the DMA2D Clock */
	RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE);

	/* Configure the LCD Control pins */
	LCD_AF_GPIOConfig();

	/* Configure the FMC Parallel interface : SDRAM is used as Frame Buffer for LCD */
	SDRAM_Init();

	/* LTDC Configuration *********************************************************/
	/* Polarity configuration */
	/* Initialize the horizontal synchronization polarity as active low */
	LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL;
	/* Initialize the vertical synchronization polarity as active low */
	LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL;
	/* Initialize the data enable polarity as active low */
	LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL;
	/* Initialize the pixel clock polarity as input pixel clock */
	LTDC_InitStruct.LTDC_PCPolarity = LTDC_PCPolarity_IPC;

	/* Configure R,G,B component values for LCD background color */
	LTDC_InitStruct.LTDC_BackgroundRedValue = 0;
	LTDC_InitStruct.LTDC_BackgroundGreenValue = 0;
	LTDC_InitStruct.LTDC_BackgroundBlueValue = 0;

	/* Configure PLLSAI prescalers for LCD */
	/* Enable Pixel Clock */
	/* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */
	/* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAI_N = 192 Mhz */
	/* PLLLCDCLK = PLLSAI_VCO Output/PLLSAI_R = 192/4 = 48 Mhz */
	/* LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 48/8 = 6 Mhz */
	RCC_PLLSAIConfig(192, 7, 4);
	RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div8);

	/* Enable PLLSAI Clock */
	RCC_PLLSAICmd(ENABLE);
	/* Wait for PLLSAI activation */
	while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET);

	/* Timing configuration */
	/* Configure horizontal synchronization width */
	LTDC_InitStruct.LTDC_HorizontalSync = 9;
	/* Configure vertical synchronization height */
	LTDC_InitStruct.LTDC_VerticalSync = 1;
	/* Configure accumulated horizontal back porch */
	LTDC_InitStruct.LTDC_AccumulatedHBP = 29;
	/* Configure accumulated vertical back porch */
	LTDC_InitStruct.LTDC_AccumulatedVBP = 3;
	/* Configure accumulated active width */
	LTDC_InitStruct.LTDC_AccumulatedActiveW = 269;
	/* Configure accumulated active height */
	LTDC_InitStruct.LTDC_AccumulatedActiveH = 323;
	/* Configure total width */
	LTDC_InitStruct.LTDC_TotalWidth = 279;
	/* Configure total height */
	LTDC_InitStruct.LTDC_TotalHeigh = 327;

	LTDC_Init(&LTDC_InitStruct);



	LCD_LayerInit();

	/* LTDC reload configuration */
	LTDC_ReloadConfig(LTDC_IMReload);

	/* Enable the LTDC */
	LTDC_Cmd(ENABLE);
}
Example #22
0
int main(void){
	
	//configure push-button interrupts
	PB_Config();
	
	 /* LCD initiatization */
  LCD_Init();
  
  /* LCD Layer initiatization */
  LCD_LayerInit();
    
  /* Enable the LTDC */
  LTDC_Cmd(ENABLE);
  
  /* Set LCD foreground layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);

	
	
	//======You need to develop the following functions======
	//Note: these are just placeholders; function definitions are at bottom of this file
	//configure real-time clock
	RTC_Config();
	
	//configure external push-buttons and interrupts
	ExtPB_Config();
	ExtPBNum2();
	
	
	//main program
	
	LCD_Clear(LCD_COLOR_WHITE);
		
	//line=0;
	//Display a string in one line, on the first line (line=0)
	//LCD_DisplayStringLine(LINE(line),  (uint8_t *) "Init EEPROM...");
	//line++;
	
	//i2c_init(); //initialize the i2c chip
	sEE_Init();  

	
	//LCD_DisplayStringLine(LINE(line),  (uint8_t *) "done..."); 
	//line++;
	
	//LCD_DisplayStringLine(LINE(line),  (uint8_t *) "Writing...");
	//line++;
	
	
	/* First write in the memory followed by a read of the written data --------*/
  /* Write on I2C EEPROM from memLocation */
  //sEE_WriteBuffer(&Tx1_Buffer, memLocation,1); 

  /* Wait for EEPROM standby state */
  //sEE_WaitEepromStandbyState();  
 
  
	//LCD_DisplayStringLine(LINE(line),  (uint8_t *) "Reading...");
  /* Read from I2C EEPROM from memLocation */
  //sEE_ReadBuffer(&Rx1_Buffer, memLocation, (uint16_t *)(&NumDataRead)); 
	//line++;
	
	//LCD_DisplayStringLine(LINE(line),  (uint8_t *) "Comparing...");  
	//line++;
	
	
	//if(Tx1_Buffer== Rx1_Buffer){
		//LCD_DisplayStringLine(LINE(line),  (uint8_t *) "Success!");  
	//}else{
		//LCD_DisplayStringLine(LINE(line),  (uint8_t *) "Mismatch!"); 
	//}
	
	//main loop
	while(1){
		RTC_GetTime(RTC_Format_BIN,&RTC_TimeStructure);
		hours = RTC_TimeStructure.RTC_Hours;
		minutes = RTC_TimeStructure.RTC_Minutes;
		seconds = RTC_TimeStructure.RTC_Seconds;

		sprintf(time,"%0.2d:%0.2d:%0.2d",hours,minutes,seconds);
		LCD_DisplayStringLine(LINE(6),  (uint8_t *) time); 
		
		if(UBPressed == 1){
			
			toBeSaved = time[7];
			sEE_WriteBuffer(&toBeSaved, memLocation+1,1); 
			sEE_WaitEepromStandbyState();  
			
			sEE_ReadBuffer(&Rx1_Buffer, memLocation+1, (uint16_t *)(&NumDataRead)); 
			saved[0] = Rx1_Buffer;

			
			
			LCD_DisplayStringLine(LINE(7),  (uint8_t *) saved);
			
			UBPressed = 0;
			PB_Config();
			
		}
		if(EB1Pressed == 1 && state == 0){
			state = 1;
			EB1Pressed = 0;
			ExtPB_Config();
		}
		if(EB1Pressed == 1 && state == 1){
			state = 2;
			EB1Pressed = 0;
			ExtPB_Config();
			
		}
		if(EB1Pressed == 1 && state == 2){
			state = 3;
			EB1Pressed = 0;
			ExtPB_Config();
			
		}
		if(EB1Pressed == 1 && state == 3){
			state = 0;
			EB1Pressed = 0;
			ExtPB_Config();
			
		}
		if(EB2Pressed == 1 && state == 1){
			
			RTC_TimeStructure.RTC_Hours = hours + 1;
			RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
			EB2Pressed = 0;
			ExtPBNum2();
		}
		if(EB2Pressed == 1 && state == 2){
			
			RTC_TimeStructure.RTC_Minutes = minutes + 1;
			RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
			EB2Pressed = 0;
			ExtPBNum2();
		}
		if(EB2Pressed == 1 && state == 3){
			
			RTC_TimeStructure.RTC_Seconds = seconds + 1;
			RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
			EB2Pressed = 0;
			ExtPBNum2();
		}
		
	}
}
Example #23
0
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
     */
	
//initiate user button
  PB_Config();

	//initiate LEDs and turn them on
  LED_Config();	
	
 

  /* -----------------------------------------------------------------------
    TIM3 Configuration: Output Compare Timing Mode:
    
    In this example TIM3 input clock (TIM3CLK) is set to 2 * APB1 clock (PCLK1), 
    since APB1 prescaler is different from 1.   
      TIM3CLK = 2 * PCLK1  
      PCLK1 = HCLK / 4 
      => TIM3CLK = HCLK / 2 = SystemCoreClock /2
          
    To get TIM3 counter clock at 50 MHz, the prescaler is computed as follows:
       Prescaler = (TIM3CLK / TIM3 counter clock) - 1
       Prescaler = ((SystemCoreClock /2) /0.5 MHz) - 1
                                              
    CC1 update rate = TIM3 counter clock / CCR1_Val = 10.0 Hz
    ==> Toggling frequency = 5 Hz

    Note: 
     SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file.
     Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate()
     function to update SystemCoreClock variable value. Otherwise, any configuration
     based on this variable will be incorrect.    
		 ----------------------------------------------------------------------- */ 	
	
	//=======================Configure and init Timer======================
  /* Compute the prescaler value */
  PrescalerValue = (uint16_t) ((SystemCoreClock / 2) / 500000) - 1;

 /* TIM Configuration */
  TIM3_Config();

	// configure the output compare
	TIM3_OCConfig();

  /* TIM Interrupts enable */
  TIM_ITConfig(TIM3, TIM_IT_CC1, ENABLE);

  /* TIM3 enable counter */
  TIM_Cmd(TIM3, ENABLE);
	
//======================================configure and init LCD  ======================	
	 /* LCD initiatization */
  LCD_Init();
  
  /* LCD Layer initiatization */
  LCD_LayerInit();
    
  /* Enable the LTDC */
  LTDC_Cmd(ENABLE);
  
  /* Set LCD foreground layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
	
//================EEPROM init====================================

/* Unlock the Flash Program Erase controller */
		FLASH_Unlock();
		/* EEPROM Init */
		EE_Init();
		

//============ Set up for random number generation==============
	RNG_Config();


	//with the default font, LCD can display  12 lines of chars, they are LINE(0), LINE(1)...LINE(11) 
	//with the default font, LCD can display  15 columns, they are COLUMN(0)....COLUMN(14)


		LCD_Clear(LCD_COLOR_WHITE);
			
	

		
		LCD_DisplayStringLine(LINE(0),  (uint8_t *) "Attempt");
		LCD_DisplayStringLine(LINE(2),  (uint8_t *) "Record");
		
		EE_WriteVariable(VirtAddVarTab[0],VarValue);
		EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);
		sprintf(str, "%d", VarDataTab[0]);
		//LCD_DisplayStringLine(LINE(3),  (uint8_t *) str);
		//randomNumber = RNG_GetRandomNumber()/100000;

		//sprintf(str, "%d", randomNumber());
		//LCD_DisplayStringLine(LINE(5),  (uint8_t *) str);
		
		resetTimer();
		
		/*the following while loop is where the main part of the code is
		* it currently uses the userbutton on board since Mario forgot to bring along his
		* jumper cables to test out the push button part
		*/
		
		//if toggle = 0 lights are  blinking
		//if toggle = 1 2 second wait
		//if toggle = 2 LED toggle off, the lights stay on
		
		//@TODO add external push button to code
		externalButton();
  while (1){ 
			int num = TIM_GetCounter(TIM3);
		//This is for the start of the procedure 
		if(toggle==0){
			if(num == 3000){
					STM_EVAL_LEDOn(LED3);
				  STM_EVAL_LEDOn(LED4);
			}
			else if(num == 6000){
					STM_EVAL_LEDOff(LED3);
					STM_EVAL_LEDOff(LED4);
					resetTimer();
			}
		}
			//if the user button has been pressed and the lights are blinking
			if (UBPressed==1 && toggle==0) {
				STM_EVAL_LEDOff(LED3);
				STM_EVAL_LEDOff(LED4);
				UBPressed=0;
				PB_Config();
				resetTimerLong();
				toggle = 1;
				rand = randomNumber();//generate a random number 
			}

			//this is the to get the wait time for the reaction test.
			if(toggle==1){
					if(num == rand){ //if num is equal to the ramdom gened number turn on the LEDs and reset the timer
							STM_EVAL_LEDOn(LED3);
							STM_EVAL_LEDOn(LED4);
							resetTimerLong();
					}
			}
			//this is the code for when the reaction timer has gone off
			if (UBPressed==1 && toggle==1) {
				 
				//this if statement is to prevent cheating
				//if the number = 0 it means that the user cheated as someone should not be able to get 0
				if(num == 0){
					ExtButtonPressed=0;
					PB_Config();
					externalButton();
					resetTimer();
					toggle = 0;
				}else{
				sprintf(str, "%d", num);
				//this block of code writes to the LCD the lastest user reaction time.
				LCD_DisplayStringLine(LINE(1),  (uint8_t *) "          ");
				LCD_DisplayStringLine(LINE(1),  (uint8_t *) str);
				EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);
				//this if statement determines wheter the user has beat their best reaction time
				if(num < VarDataTab[0]){
						VarValue = num;
						EE_WriteVariable(VirtAddVarTab[0],VarValue);
				}
				/*the following block of code writes to the LCD the record reaction time*/
				EE_ReadVariable(VirtAddVarTab[0], &VarDataTab[0]);
				sprintf(str, "%d", VarDataTab[0]);
				LCD_DisplayStringLine(LINE(3),  (uint8_t *) "          ");
				LCD_DisplayStringLine(LINE(3),  (uint8_t *) str);
				UBPressed=0;
				PB_Config();
				resetTimerLong();
				toggle = 2; 
			}
			}
			//the user needs to press the button to get the reaction time game going again. 
			//to reset the reaction timer
			if (ExtButtonPressed==1) {
				ExtButtonPressed=0;
				PB_Config();
				externalButton();
				resetTimer();
				toggle = 0;
			}
			
	}
	
}
Example #24
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_stm32f429_439xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32f4xx.c file
  */     
  
  /* LCD initiatization */
  LCD_Init();
  LCD_LayerInit();
  
  /* LTDC reload configuration */  
  LTDC_ReloadConfig(LTDC_IMReload);
  
  /* Enable the LTDC */
  LTDC_Cmd(ENABLE);
  
  /* Set LCD foreground layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  
  /* Initialize LEDs mounted on STM32F429I-DISCO */
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  
  /* Initialize User Button mounted on STM32F429I-DISCO */
  STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
  
  /* Display tset name on LCD */
  LCD_Clear(LCD_COLOR_WHITE);
  LCD_SetBackColor(LCD_COLOR_BLUE);
  LCD_SetTextColor(LCD_COLOR_WHITE);
  LCD_DisplayStringLine(LCD_LINE_4,(uint8_t*)" Flash Write   ");
  LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)"protection test");
  LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" Press User    ");
  LCD_DisplayStringLine(LCD_LINE_8,(uint8_t*)" push-button   ");
  
  while (1)
  {
    /* Wait for User push-button is pressed */
    while (STM_EVAL_PBGetState(BUTTON_USER) != Bit_RESET)
    {
    }
    
    /* Wait for User push-button is released */
    while (STM_EVAL_PBGetState(BUTTON_USER) != Bit_SET)
    {
    }
    
    /* Get FLASH_WRP_SECTORS write protection status */
    SectorsWRPStatus = FLASH_OB_GetWRP() & FLASH_WRP_SECTORS;
    
    if (SectorsWRPStatus == 0x00)
    {
      /* If FLASH_WRP_SECTORS are write protected, disable the write protection */
      
      /* Enable the Flash option control register access */
      FLASH_OB_Unlock();
      
      /* Disable FLASH_WRP_SECTORS write protection */
      FLASH_OB_WRPConfig(FLASH_WRP_SECTORS, DISABLE); 
      
      /* Start the Option Bytes programming process */  
      if (FLASH_OB_Launch() != FLASH_COMPLETE)
      {
        /* User can add here some code to deal with this error */
        while (1)
        {
        }
      }
      /* Disable the Flash option control register access (recommended to protect 
      the option Bytes against possible unwanted operations) */
      FLASH_OB_Lock();
      
      /* Get FLASH_WRP_SECTORS write protection status */
      SectorsWRPStatus = FLASH_OB_GetWRP() & FLASH_WRP_SECTORS;
      
      /* Check if FLASH_WRP_SECTORS write protection is disabled */
      if (SectorsWRPStatus == FLASH_WRP_SECTORS)
      {
        LCD_Clear(LCD_COLOR_GREEN);
        LCD_SetTextColor(LCD_COLOR_BLACK);
        LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)"     Write      ");
        LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" protection is  ");
        LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" disabled       ");
      }
      else
      {
        LCD_Clear(LCD_COLOR_RED);
        LCD_SetTextColor(LCD_COLOR_BLACK);
        LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)"     Write      ");
        LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" protection is  ");
        LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" not disabled   ");
      }
    }
    else
    { /* If FLASH_WRP_SECTORS are not write protected, enable the write protection */
      
      /* Enable the Flash option control register access */
      FLASH_OB_Unlock();
      
      /* Enable FLASH_WRP_SECTORS write protection */
      FLASH_OB_WRPConfig(FLASH_WRP_SECTORS, ENABLE); 
      
      /* Start the Option Bytes programming process */  
      if (FLASH_OB_Launch() != FLASH_COMPLETE)
      {
        /* User can add here some code to deal with this error */
        while (1)
        {
        }
      }
      
      /* Disable the Flash option control register access (recommended to protect 
      the option Bytes against possible unwanted operations) */
      FLASH_OB_Lock();
      
      /* Get FLASH_WRP_SECTORS write protection status */
      SectorsWRPStatus = FLASH_OB_GetWRP() & FLASH_WRP_SECTORS;
      
      /* Check if FLASH_WRP_SECTORS are write protected */
      if (SectorsWRPStatus == 0x00)
      {
        LCD_Clear(LCD_COLOR_GREEN);
        LCD_SetTextColor(LCD_COLOR_BLACK);
        LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)"     Write      ");
        LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" protection is  ");
        LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" enabled        ");
      }
      else
      {
        LCD_Clear(LCD_COLOR_RED);
        LCD_SetTextColor(LCD_COLOR_BLACK);
        LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*)"     Write      ");
        LCD_DisplayStringLine(LCD_LINE_6,(uint8_t*)" protection is  ");
        LCD_DisplayStringLine(LCD_LINE_7,(uint8_t*)" not enabled    ");
      }
    }
  }
}
Example #25
0
int main(void)
{
	LCD_Init();
	LCD_LayerInit();

	SysTick_init ();

	pushbutton_init();

	/* Enable the LTDC */
	LTDC_Cmd(ENABLE);

	/* Set LCD foreground layer */
	LCD_SetLayer(LCD_FOREGROUND_LAYER);
	LCD_SetTransparency(0);

	/* Set LCD background layer */
	LCD_SetLayer(LCD_BACKGROUND_LAYER);

	/* LCD display message */
	LCD_Clear(LCD_COLOR_BLUE);
	LCD_SetBackColor(LCD_COLOR_BLUE);
	LCD_SetTextColor(LCD_COLOR_WHITE);

	std::stringstream output;
	std::string outputstring;
	const char * chararray;

	Timer mytimerobject(12,34,56);

	LCD_DisplayStringLine(LCD_LINE_0,(uint8_t*)"h_da    ");
	LCD_DisplayStringLine(LCD_LINE_1,(uint8_t*)"RZS     ");
	LCD_DisplayStringLine(LCD_LINE_2,(uint8_t*)"WS 15/16     ");

	STM_EVAL_LEDInit(LED3);
	STM_EVAL_LEDInit(LED4);

	// Super loop
	while(1)
	{
		switch(get_event()){

		case TICK:
			if(mystate==RUNNING)
				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);
			break;

		case START_STOP:
			LCD_DisplayStringLine(LCD_LINE_4,(uint8_t*) "START_STOP");

			if(mystate == RUNNING)
			{
				mystate = HALTED;
				LCD_ClearLine(LCD_LINE_5);
				LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*) "HALTED");
			}
			else if(mystate == HALTED)
			{
				mystate = RUNNING;
				LCD_DisplayStringLine(LCD_LINE_5,(uint8_t*) "RUNNING");
			}
			break;

		default:
			break;
		}
	}
}
Example #26
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
}
Example #27
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
  }
}
Example #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_stm32f4xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */
	
//initiate user button
  //PB_Config();
	STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);

	//initiate LEDs and turn them on
  LED_Config();	
	
 

  /* -----------------------------------------------------------------------
    TIM3 Configuration: Output Compare Timing Mode:
    
    In this example TIM3 input clock (TIM3CLK) is set to 2 * APB1 clock (PCLK1), 
    since APB1 prescaler is different from 1.   
      TIM3CLK = 2 * PCLK1  
      PCLK1 = HCLK / 4 
      => TIM3CLK = HCLK / 2 = SystemCoreClock /2
          
    To get TIM3 counter clock at 50 MHz, the prescaler is computed as follows:
       Prescaler = (TIM3CLK / TIM3 counter clock) - 1
       Prescaler = ((SystemCoreClock /2) /0.5 MHz) - 1
                                              
    CC1 update rate = TIM3 counter clock / CCR1_Val = 10.0 Hz
    ==> Toggling frequency = 5 Hz

    Note: 
     SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file.
     Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate()
     function to update SystemCoreClock variable value. Otherwise, any configuration
     based on this variable will be incorrect.    
		 ----------------------------------------------------------------------- */ 	
	
	//=======================Configure and init Timer======================
  /* Compute the prescaler value */
  PrescalerValue = (uint16_t) ((SystemCoreClock / 2) / 500000) - 1; //configures clock speed at 500 KHz. Both Tim2 and Tim3 use the same prescsaler and therefore run at the same speed.

 /* TIM Configuration */
  TIM3_Config();
	TIM2_Config();

	// configure the output compare
	TIM3_OCConfig();
	TIM2_OCConfig();

  /* TIM Interrupts enable */
  TIM_ITConfig(TIM3, TIM_IT_CC1, ENABLE);
	TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
	
  /* TIM3 enable counter */
  TIM_Cmd(TIM3, ENABLE);
	TIM_Cmd(TIM2, ENABLE); 
	
//======================================configure and init LCD  ======================	
	 /* LCD initiatization */
  LCD_Init();
  
  /* LCD Layer initiatization */
  LCD_LayerInit();
    
  /* Enable the LTDC */
  LTDC_Cmd(ENABLE);
  
  /* Set LCD foreground layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
	
//================EEPROM init====================================

/* Unlock the Flash Program Erase controller */
		FLASH_Unlock();
		/* EEPROM Init */
		EE_Init();

//============ Set up for random number generation==============
	RNG_Config();
	Ext_PushButton_Interrupt(); //configures external push button

	//with the default font, LCD can display  12 lines of chars, they are LINE(0), LINE(1)...LINE(11) 
	//with the default font, LCD can display  15 columns, they are COLUMN(0)....COLUMN(14)


		LCD_Clear(LCD_COLOR_WHITE); //change the background colour of LCD 
			
		//Display a string in one line, on the first line (line=0)
		LCD_DisplayString(0, 2, (uint8_t *) "Best: ");  //the line will not wrap
		
  while (1){ 
		
			if (UBPressed==1) { //press user button
					if (pause==1){	//pause mode
						randnum = ((RNG_GetRandomNumber()%2000)+1000); //generates a random number between 1000 and 3000
						Pause_Random(randnum); //see below function to see how the pause is implemented
					}
					else { //measure time mode
						TIM_ITConfig(TIM2, TIM_IT_CC1, DISABLE); //turns off timer 2
						TIM_Cmd(TIM2, DISABLE);
						time = timer; //gets user's time
						if (initial == 1) { //sets initial best_time to first time 
						best_time = time; 
						initial = 0;
						LCD_DisplayInt((uint16_t) 0, (uint16_t) 7, best_time);
						} 
						LCD_DisplayString(2, 1, (uint8_t *) "Time: "); //print time
						LCD_DisplayString(2, 7, (uint8_t *) "                 "); //clears line
						LCD_DisplayInt((uint16_t) 2, (uint16_t) 7, time); //displays user's time
						LCD_DisplayString(2, 11, (uint8_t *) "ms"); //print ms
						if (time > 10 && time < best_time) { //set new best time
							best_time = time;
							LCD_DisplayString(0, 7, (uint8_t *) "          "); //clears line
							LCD_DisplayInt((uint16_t) 0, (uint16_t) 7, best_time);
						}
						TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE); //turns on timer 2
						TIM_Cmd(TIM2, ENABLE);
						pause = 1; //this makes it so that you can use the user button to repeat the cycle in case you don't have an external push button
					}
				UBPressed=0;				
			}

	}
}
Example #29
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  uint16_t linenum = 0;
  static TP_STATE* TP_State; 
    
  /*!< At this stage the microcontroller clock setting is already configured, 
  this is done through SystemInit() function which is called from startup
  file (startup_stm32f429_439xx.s) before to branch to application main.
  To reconfigure the default setting of SystemInit() function, refer to
  system_stm32f4xx.c file
  */      

  /* LCD initialization */
  LCD_Init();
  
  /* LCD Layer initialization */
  LCD_LayerInit();
    
  /* Enable the LTDC */
  LTDC_Cmd(ENABLE);
  
  /* Set LCD foreground layer */
  LCD_SetLayer(LCD_FOREGROUND_LAYER);
  
  /* Touch Panel configuration */
  TP_Config();
    
  while (1)
  {
 
    TP_State = IOE_TP_GetState();
    
    if((TP_State->TouchDetected) && ((TP_State->Y < 245) && (TP_State->Y >= 3)))
    {
      if((TP_State->X >= 237) || (TP_State->X < 3))
      {}     
      else
      {
        LCD_DrawFullCircle(TP_State->X, TP_State->Y, 3);
      }
    }
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && (TP_State->Y >= 250) && (TP_State->X >= 5) && (TP_State->X <= 35))
    {
      LCD_SetTextColor(LCD_COLOR_BLUE2);
    }
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && (TP_State->Y >= 250) && (TP_State->X >= 40) && (TP_State->X <= 70))
    {
      LCD_SetTextColor(LCD_COLOR_CYAN); 
    }
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 280) && (TP_State->Y >= 250) && (TP_State->X >= 75) && (TP_State->X <= 105))
    {
      LCD_SetTextColor(LCD_COLOR_YELLOW); 
    }      
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 5) && (TP_State->X <= 35))
    {
      LCD_SetTextColor(LCD_COLOR_RED);
    }
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 40) && (TP_State->X <= 70))
    {
      LCD_SetTextColor(LCD_COLOR_BLUE); 
    }
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 75) && (TP_State->X <= 105))
    {
      LCD_SetTextColor(LCD_COLOR_GREEN); 
    }
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 110) && (TP_State->X <= 140))
    {
      LCD_SetTextColor(LCD_COLOR_BLACK); 
    }
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 288) && (TP_State->X >= 145) && (TP_State->X <= 175))
    {
      LCD_SetTextColor(LCD_COLOR_MAGENTA); 
    }
    else if ((TP_State->TouchDetected) && (TP_State->Y <= 318) && (TP_State->Y >= 270) && (TP_State->X >= 180) && (TP_State->X <= 230))
    {
      LCD_SetFont(&Font8x8);
      for(linenum = 0; linenum < 31; linenum++)
      {
        LCD_ClearLine(LINE(linenum));
      }
    }
    else
    {
    }
  }
}