Exemplo n.º 1
0
/*
 * Set transparency of layer
 *
 * @param[in]	layer			layer to change
 * @param[in]	transparency	0x00 is transparent, 0xFF is opaque
 */
void lcd_set_transparency (lcd_layers_t layer, uint8_t transparency)
{
	switch (layer)
	{
		case LCD_BACKGROUND:
			LTDC_LayerAlpha (LTDC_Layer1, transparency);
			break;

		case LCD_FOREGROUND:
			LTDC_LayerAlpha (LTDC_Layer2, transparency);
			break;

		default:
			break;
	}

	if (lcd_vsync)
	{
		lcd_refreshed = false;

		LTDC_ITConfig (LTDC_IT_RR, ENABLE);

		/* reload shadow register on next vertical blank */
		LTDC_ReloadConfig (LTDC_VBReload);

		/* wait for registers to be reloaded */
		while (!lcd_refreshed);
	}
	else
	{
		/* immediately reload shadow registers */
		LTDC_ReloadConfig (LTDC_IMReload);
	}
}
void LCDTFTConf::LCD_SetTransparency(uint8_t transparency)
{
  if (CurrentLayer == LCD_BACKGROUND_LAYER)
  {
    LTDC_LayerAlpha(LTDC_Layer1, transparency);
  }
  else
  {
    LTDC_LayerAlpha(LTDC_Layer2, transparency);
  }
  LTDC_ReloadConfig(LTDC_IMReload);
}
Exemplo n.º 3
0
void ui_swap_layer()
{
    LTDC_LayerAlpha(layer_buffers[hidden_layer].LTDC_Layer, 0xff);
    LTDC_LayerAlpha(layer_buffers[show_layer].LTDC_Layer, 0x00);
    LCD_SetLayer(layer_buffers[show_layer].LCD_Layer);
    LTDC_ReloadConfig(LTDC_IMReload);
    LCD_Clear(LCD_COLOR_WHITE);

    show_layer = !show_layer;
    hidden_layer = !hidden_layer;

}
Exemplo n.º 4
0
void TM_ILI9341_UpdateLayerOpacity(void) {
	LTDC_LayerAlpha(LTDC_Layer1, ILI9341_Opts.Layer1Opacity);
	LTDC_LayerAlpha(LTDC_Layer2, ILI9341_Opts.Layer2Opacity);

	LTDC_ReloadConfig(LTDC_IMReload);
}
Exemplo n.º 5
0
void TM_ILI9341_InitLayers(void) {
	LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct;

	/* 	Windowing configuration */
	/* 	Horizontal start = horizontal synchronization + Horizontal back porch = 43 
		Vertical start   = vertical synchronization + vertical back porch     = 12
		Horizontal stop = Horizontal start + LCD_PIXEL_WIDTH - 1 
		Vertical stop   = Vertical start + LCD_PIXEL_HEIGHT - 1        
	*/      
	LTDC_Layer_InitStruct.LTDC_HorizontalStart = 30;
	LTDC_Layer_InitStruct.LTDC_HorizontalStop = 269;
	LTDC_Layer_InitStruct.LTDC_VerticalStart = 4;
	LTDC_Layer_InitStruct.LTDC_VerticalStop = 323;

	/* Pixel Format configuration*/
    LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
    /* Alpha constant (255 totally opaque) */
    LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; 
    /* Default Color configuration (configure A,R,G,B component values) */          
    LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0;        
    LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0;       
    LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0;         
    LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0;
	
    /* Configure blending factors */       
    LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA;    
    LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;


    /* the length of one line of pixels in bytes + 3 then :
    Line Lenth = Active high width x number of bytes per pixel + 3 
    Active high width         = LCD_PIXEL_WIDTH 
    number of bytes per pixel = 2    (pixel_format : RGB565) 
    */
	LTDC_Layer_InitStruct.LTDC_CFBLineLength = 240 * 2 + 3;
	
	/* the pitch is the increment from the start of one line of pixels to the 
    start of the next line in bytes, then :
    Pitch = Active high width x number of bytes per pixel     
    */ 
	LTDC_Layer_InitStruct.LTDC_CFBPitch = 240 * 2;
	/* Configure the number of lines */ 
	LTDC_Layer_InitStruct.LTDC_CFBLineNumber = 320;
	
	/* Start Address configuration : the LCD Frame buffer is defined on SDRAM */   
	LTDC_Layer_InitStruct.LTDC_CFBStartAdress = ILI9341_FRAME_BUFFER;
	/* Initialize Layer 1 */
	LTDC_LayerInit(LTDC_Layer1, &LTDC_Layer_InitStruct);

    /* Configure Layer2 */
    /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */  
	LTDC_Layer_InitStruct.LTDC_CFBStartAdress = ILI9341_FRAME_BUFFER + ILI9341_FRAME_OFFSET;
	
	/* Configure blending factors */ 
	LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;
	LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
	/* Initialize Layer 2 */
	LTDC_LayerInit(LTDC_Layer2, &LTDC_Layer_InitStruct);

	LTDC_ReloadConfig(LTDC_IMReload);
	/* Enable foreground & background Layers */
	LTDC_LayerCmd(LTDC_Layer1, ENABLE);
	LTDC_LayerCmd(LTDC_Layer2, ENABLE);
	LTDC_ReloadConfig(LTDC_IMReload);

	LTDC_DitherCmd(ENABLE);
	
	/* Display On */
	LTDC_Cmd(ENABLE);
	
	LTDC_LayerAlpha(LTDC_Layer1, 255);
	LTDC_LayerAlpha(LTDC_Layer2, 0);
	LTDC_ReloadConfig(LTDC_IMReload);
}
Exemplo n.º 6
0
void
GAME_Render()
{
	
	LCD_SetTextColor( LCD_COLOR_WHITE );
	draw_me(me1[0]);
	draw_boss(boss1[0]);
	
	LCD_SetTextColor( LCD_COLOR_RED );
	draw_bossbullet(boss_bullet[0]);
	draw_gun(boss1[0]);

	LCD_SetTextColor( LCD_COLOR_BLUE );
	draw_mybullet(my_bullet[0]);

	LTDC_LayerAlpha(LTDC_Layer1, SHOW);
	LTDC_LayerAlpha(LTDC_Layer2, HIDE);	
	LTDC_ReloadConfig(LTDC_VBReload);
	vTaskDelay( 2.5 );


	LCD_SetLayer(LCD_BACKGROUND_LAYER);
	LCD_SetTextColor( LCD_COLOR_BLACK );
	draw_me(me1[1]);
	draw_boss(boss1[1]);
	draw_gun(boss1[1]);
	draw_mybullet(my_bullet[1]);
	draw_bossbullet(boss_bullet[1]);


	LCD_SetTextColor( LCD_COLOR_WHITE );
	draw_me(me1[0]);
	draw_boss(boss1[0]);
	
	LCD_SetTextColor( LCD_COLOR_RED );
	draw_bossbullet(boss_bullet[0]);
	draw_gun(boss1[0]);

	LCD_SetTextColor( LCD_COLOR_BLUE );
	draw_mybullet(my_bullet[0]);


	LTDC_LayerAlpha(LTDC_Layer2, SHOW);			
	LTDC_LayerAlpha(LTDC_Layer1, HIDE);
	LTDC_ReloadConfig(LTDC_VBReload);
	vTaskDelay( 2.5 );

	LCD_SetLayer(LCD_FOREGROUND_LAYER);

	LCD_SetTextColor( LCD_COLOR_BLACK );

	draw_me(me1[0]);
	draw_boss(boss1[0]);
	draw_gun(boss1[0]);
	draw_mybullet(my_bullet[0]);
	draw_bossbullet(boss_bullet[0]);
	
	boss_bullet[1]=boss_bullet[0];
	my_bullet[1]=my_bullet[0];
	me1[1]=me1[0];
	boss1[1]=boss1[0];
}
Exemplo n.º 7
0
static void TM_LCD_INT_InitLayers(void) {
	LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct;
	
    /* Windowing configuration */
    /* Horizontal start = horizontal synchronization + Horizontal back porch = 43 
    Vertical start   = vertical synchronization + vertical back porch     = 12
    Horizontal stop = Horizontal start + LCD_PIXEL_WIDTH -1 
    Vertical stop   = Vertical start + LCD_PIXEL_HEIGHT -1        
    */      
    LTDC_Layer_InitStruct.LTDC_HorizontalStart = 144;
    LTDC_Layer_InitStruct.LTDC_HorizontalStop = (LCD.Width + 144 - 1); 
    LTDC_Layer_InitStruct.LTDC_VerticalStart = 35;
    LTDC_Layer_InitStruct.LTDC_VerticalStop = (LCD.Height + 35 - 1);
    
    /* Pixel Format configuration*/
    LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
    /* Alpha constant (255 totally opaque) */
    LTDC_Layer_InitStruct.LTDC_ConstantAlpha = 255; 
    /* Default Color configuration (configure A,R,G,B component values) */          
    LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = 0;        
    LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = 0;       
    LTDC_Layer_InitStruct.LTDC_DefaultColorRed = 0;         
    LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = 0;
    /* Configure blending factors */       
    LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA;    
    LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;
    
    /* the length of one line of pixels in bytes + 3 then :
    Line Lenth = Active high width x number of bytes per pixel + 3 
    Active high width         = LCD_PIXEL_WIDTH 
    number of bytes per pixel = 2    (pixel_format : RGB565) 
    */
    LTDC_Layer_InitStruct.LTDC_CFBLineLength = ((LCD.Width * 2) + 3);
    /* the pitch is the increment from the start of one line of pixels to the 
    start of the next line in bytes, then :
    Pitch = Active high width x number of bytes per pixel     
    */ 
    LTDC_Layer_InitStruct.LTDC_CFBPitch = (LCD.Width * 2);
    
    /* Configure the number of lines */  
    LTDC_Layer_InitStruct.LTDC_CFBLineNumber = LCD.Height;
    
    /* Start Address configuration : the LCD Frame buffer is defined on SDRAM */    
    LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD.FrameStart;
    
    LTDC_LayerInit(LTDC_Layer1, &LTDC_Layer_InitStruct);
    
    /* Configure Layer2 */
    /* Start Address configuration : the LCD Frame buffer is defined on SDRAM w/ Offset */     
    LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD.FrameStart + LCD.FrameOffset;
    
    /* Configure blending factors */   
    LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;    
    LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;  
    
    LTDC_LayerInit(LTDC_Layer2, &LTDC_Layer_InitStruct);
	
	LTDC_ReloadConfig(LTDC_IMReload);

	/* Enable foreground & background Layers */
	LTDC_LayerCmd(LTDC_Layer1, ENABLE);
	LTDC_LayerCmd(LTDC_Layer2, ENABLE);
	LTDC_ReloadConfig(LTDC_IMReload);
	
	/* Enable dithering */
	LTDC_DitherCmd(ENABLE);
	
	/* Set opacity */
	LTDC_LayerAlpha(LTDC_Layer1, 255);
	LTDC_LayerAlpha(LTDC_Layer2, 0);
	
	/* Immediate reload */
	LTDC_ReloadConfig(LTDC_IMReload);
}