⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text_overlay.c

📁 BlackFin DSP(ADSP) LCD 文字overlay 显示源码
💻 C
字号:
/*********************************************************************************

Copyright(c) 2005 Analog Devices, Inc. All Rights Reserved.

This software is proprietary and confidential.  By using this software you agree
to the terms of the associated Analog Devices License Agreement.

Description:	EZ-Kit Text and Graphics overlay routines.  This file contains a 
				collection of functions that automate typical text and graphic 
				overlay calls.  
				
Usage:			A simple method for mapping pixel points is achieved using Microsoft
				Paint program.  Pixel coordinates are obtain by opening the original
				BMP file with Microsoft Pain, moving the mouse over the desired pixel
				location and the obtaining the pixel (x,y) information from the lower 
				right corner of the Microsoft Paint window.
				Be aware that the SRGP pixel origin is located at the lower left 
				corner of the LCD image.  However BMP's in Microsoft Paint have an 
				origin at the upper left corner.  This example file has been created 
				such that these origin mappings are accounted for.  Use the LCD User 
				space #defines to provide the Windows Paint version of pixel mapping.  
				The	user space code translates it to the SRGP mapping.

Note:			With the included SRGP library set, X offsets 
				are in 4 byte increments, and not 2 byte as you would expect with 
				16-bit RGB pixel widths.  This effectively halfs the X axis resolution.
				For example, if trying to access the middle pixel of a 640x480 LCD 
				use (X,Y) = (160,240).. NOT (320,240)!
				
	  							
*********************************************************************************/

#include "main.h" 
#include "srgp.h"
#include "adi_graph_font.h"
#include "adi_graph.h"
#include "Text_Overlay.h"

#include <services/services.h>
#include <drivers/adi_dev.h>
#include <drivers/adi_ppi.h>
#include <ezkitutilities.h>

// SRGP Primative that re-targets canvas pointer
extern ADI_sGraphPrim gp;

/*********************************************************************************
  Initialize Canvas - only called during initialization sequence.
  Avoid adding customized code to this section unles you're sure what you are doing
*********************************************************************************/
int Overlay_init (char  *Frame)
{
	SetVideoBufferBaseAddress(Frame);
	SRGP_begin ( NULL, LCD_NUM_COLUMNS, LCD_NUM_LINES, 0, FALSE );
	SRGP_ADI_loadFont ( 0, ( void * ) &ADI_font_UTRG__10);
	SRGP_ADI_loadFont ( 1, ( void * ) &ADI_font_UTRG__12);
	SRGP_ADI_loadFont ( 2, ( void * ) &ADI_font_UTRG__14);
	SRGP_ADI_loadFont ( 3, ( void * ) &ADI_font_UTRG__18);
	SRGP_ADI_loadFont ( 4, ( void * ) &ADI_font_UTRG__24);

	return (FALSE);
}
/*********************************************************************************
  Drawing Text and Graphics Function
*********************************************************************************/
int Overlay_main (char  *Frame, char *buf)
{
	const int button_color = 2;
	const int button_dark  = 4;
						
	// Color table
	// Example SRGP_loadColorTable ( 2.. <- the '2' indicates starting with index #2
	// therefore, to load color (2, 3, 4, 5, 6 ... etc)
	unsigned short r[] = {224,255,157,  0,255};
	unsigned short g[] = {223,251,157,  0,255};
	unsigned short b[] = {227,240,161,255,  0};

	SRGP_loadColorTable ( 2, sizeof ( r ) / sizeof ( unsigned short ), r, g, b );
	
	// Update Canvas Pointer to Current Frame
	gp.canvas = Frame - LCD_OFFSET;	

	// *************************************************************************
	// Draw Start Button	
	// *************************************************************************
	if(ezIsButtonPushed(EZ_LAST_BUTTON) == FALSE)
	{
		SRGP_setColor (button_color);
	}else{
		SRGP_setColor (button_dark);
	}
	SRGP_fillEllipse ( SRGP_defRectangle ( (Start_Button_X/2), LCD_NUM_LINES - Start_Button_Y, (Start_Button_X/2)+(Start_Button_W/2), LCD_NUM_LINES - Start_Button_Y+Start_Button_H ));
	SRGP_setColor (5);
	SRGP_ellipse ( SRGP_defRectangle ( (Start_Button_X/2), LCD_NUM_LINES - Start_Button_Y, (Start_Button_X/2)+(Start_Button_W/2), LCD_NUM_LINES - Start_Button_Y+Start_Button_H ));

	// *************************************************************************
	// Draw Test Button	
	// *************************************************************************
	if(ezIsButtonPushed(EZ_FIRST_BUTTON) == FALSE)
	{
		SRGP_setColor (button_color);
	}else{
		SRGP_setColor (button_dark);
	}
	SRGP_fillEllipse ( SRGP_defRectangle ( (Test_Button_X/2), LCD_NUM_LINES - Test_Button_Y, (Test_Button_X/2)+(Test_Button_W/2) , LCD_NUM_LINES - Test_Button_Y+Test_Button_H ));
	SRGP_setColor (5);
	SRGP_ellipse ( SRGP_defRectangle ( (Test_Button_X/2), LCD_NUM_LINES - Test_Button_Y, (Test_Button_X/2)+(Test_Button_W/2), LCD_NUM_LINES - Test_Button_Y+Test_Button_H ));

	// *************************************************************************
	// Draw White box with Black boarder on which to overwrite with text
	// *************************************************************************
	SRGP_setColor ( SRGPBLACK );
	SRGP_fillRectangle ( SRGP_defRectangle ( (TEXTBOX_X/2)-1, LCD_NUM_LINES - TEXTBOX_Y-2, (TEXTBOX_X/2) + (TEXTBOX_W/2) + 1, LCD_NUM_LINES - TEXTBOX_Y + TEXTBOX_H + 2 ));
	
	
	SRGP_setColor ( SRGPWHITE );
	SRGP_fillRectangle ( SRGP_defRectangle ( (TEXTBOX_X/2), LCD_NUM_LINES - TEXTBOX_Y, (TEXTBOX_X/2) + (TEXTBOX_W/2), LCD_NUM_LINES - TEXTBOX_Y + TEXTBOX_H ));

	// *************************************************************************
	// Draw Distance Text
	// *************************************************************************
	SRGP_setColor (SRGPBLACK);
	SRGP_setFont (3);
	SRGP_text ( SRGP_defPoint ( Distance_Text_X / 2, LCD_NUM_LINES - Distance_Text_Y), "0" );		

	// *************************************************************************
	// Draw Time Text
	// *************************************************************************
	SRGP_setColor (SRGPBLACK);
	SRGP_setFont (3);
	SRGP_text ( SRGP_defPoint ( Time_Text_X / 2, LCD_NUM_LINES - Time_Text_Y), buf );		

	// *************************************************************************
	// Draw Heart Rate Text
	// *************************************************************************
	SRGP_setColor (SRGPBLACK);
	SRGP_setFont (1);
	SRGP_text ( SRGP_defPoint ( HeartR_Text_X / 2, LCD_NUM_LINES - HeartR_Text_Y), "--" );	
	
	// *************************************************************************
	// Draw Calories Text
	// *************************************************************************
	SRGP_setColor (SRGPBLACK);
	SRGP_setFont (3);
	SRGP_text ( SRGP_defPoint ( Calories_Text_X / 2, LCD_NUM_LINES - Calories_Text_Y), "67" );		

	// *************************************************************************
	// Draw Speed Text
	// *************************************************************************
	SRGP_setColor (SRGPBLACK);
	SRGP_setFont (4);
	SRGP_text ( SRGP_defPoint ( Speed_Text_X / 2, LCD_NUM_LINES - Speed_Text_Y), "0.0" );		

	return (FALSE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -