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

📄 draw.c

📁 FreeRTOS is a portable, open source, mini Real Time Kernel - a free to download and royalty free RTO
💻 C
📖 第 1 页 / 共 2 页
字号:
/********************* (C) COPYRIGHT 2007 RAISONANCE S.A.S. *******************/
/**
*
* @file     draw.c
* @brief    Various utilities for drawings (characters, ..)
* @author   FL
* @author   IB
* @date     07/2007
*
**/
/******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "circle.h"

/// @cond Internal

/* Private define ------------------------------------------------------------*/
#define V9_MADCTRVAL    0x90
#define V12_MADCTRVAL   0x30
#define V3_MADCTRVAL    0x50
#define V6_MADCTRVAL    0xF0

#define ROTATE_DIVISER  500

/* Private variables ---------------------------------------------------------*/

static u16 CharMagniCoeff = 1;   /*!< Current character magnify coefficient.  */
static u16 BGndColor;            /*!< Current background color.               */
static u16 TextColor;            /*!< Current text color.                     */

int fDisplayTime = 0;
u16 BatState;
u16 OldBatState;
u32 OldTHH;
u32 OldTMM;
u32 OldTSS;
u32 OldTemp;   //FL071107
u16 xBat;
u16 yBat;
u16 widthBat;
u16 heightBat;
u8 UsbState,OldUsbState;
static int divider_coord = 0;

// Screen orientation management
int                        rotate_counter             = 0;
Rotate_H12_V_Match_TypeDef previous_H12               = V9;
Rotate_H12_V_Match_TypeDef previous_previous_H12      = V9;
Rotate_H12_V_Match_TypeDef H12;
Rotate_H12_V_Match_TypeDef CurrentScreenOrientation;
int                        CurrentRotateScreen        = 1;

extern s16 XInit;
extern s16 YInit;

/* Private functions ---------------------------------------------------------*/

/*******************************************************************************
*
*                                vbattoa
*
*******************************************************************************/
/**
*
*  This function convert an u16 in ascii radix 10
*
*  @param[out] ptr   A pointer to a string where the converted value will be put.
*  @param[in]  X     The value to convert.
*
*  @see  DRAW_DisplayVbat
*
**/
/******************************************************************************/
static void vbattoa( char* ptr, u16 X )
   {
   u8 c;
   u16 r = 0;

   // 1 000 digit
   c = ((X-r)/1000);
   r = r + (c*1000);
   *ptr++ = c + 0x30;

   // dot
   *ptr++ = '.';

   // 100 digit
   c = ((X-r)/100);
   r = r + (c*100);
   *ptr++ = c + 0x30;

   // 10 digit
   c = ((X-r)/10);
   r = r + (c*10);
   *ptr++ = c + 0x30;

   // Volt
   *ptr++ = 'V';
   *ptr++ = 0;
   }

/*******************************************************************************
*
*                                DRAW_DisplayStringWithMode
*
*******************************************************************************/
/**
*
*  This function is used to display a 17char max string of
*  characters on the LCD display on the selected line.
*  Note:
*  this function is the user interface to use the LCD driver.
*
*  @param[in]  x     The horizontal screen coordinate where to draw the string.
*  @param[in]  y     The vertical screen coordinate where to draw the string.
*  @param[in]  ptr   Pointer to string to display.
*  @param[in]  len   String size.
*  @param[in]  mode  Display mode: 0 normal, 1 inverted colors.
*
*  @warning       The (0x0) point in on the low left corner.
*
*  @see           DRAW_DisplayString
*  @see           DRAW_DisplayStringInverted
*
**/
/******************************************************************************/
static void DRAW_DisplayStringWithMode( u8 x, u8 y, const u8* ptr, u8 len, int mode )
   {
   u8 ref_x = x, i = 0;

   /* Send the string character by character on LCD */
   while ((*ptr!=0)&&(i<18))
      {
      /* Display one character on LCD */
      LCD_DisplayChar( ref_x, y, *ptr, mode ? BGndColor : TextColor,  mode ? TextColor : BGndColor, CharMagniCoeff );

      /* Increment the column position by 7 */
      ref_x+= (7*CharMagniCoeff);

      /* Point on the next character */
      ptr++;

      /* Increment the character counter */
      i++;
      /* If we reach the maximum Line character */
      }

   while ( i < len )
      {
      /* Display one character on LCD */
      LCD_DisplayChar( ref_x, y, ' ', mode ? BGndColor : TextColor, mode ? TextColor : BGndColor, CharMagniCoeff );

      /* Increment the column position by 7 */
      ref_x += ( 7 * CharMagniCoeff );

      /* Increment the character counter */
      i++;
      }
   }

/* Public functions for CircleOS ---------------------------------------------*/

/*******************************************************************************
*
*                                DRAW_Init
*
*******************************************************************************/
/**
*
*  Initialize GUI drawing. Called at CircleOS startup.
*
*  @attention  This function must <b>NOT</b> be called by the user.
*
**/
/******************************************************************************/
void DRAW_Init( void )
   {
   LCD_Init();
#ifdef _MEMS
   MEMS_GetRotation( &CurrentScreenOrientation );
#endif
   LCD_SetScreenOrientation( CurrentScreenOrientation );

   xBat        = 98;
   yBat        = 3;
   OldBatState = 10;
   OldTSS      = 100;
   OldTMM      = 100;
   OldTHH      = 100;
   OldTemp     = -1;

   // Clear LCD and draw black and white logo
   DRAW_SetDefaultColor();
	LCD_FillRect( 0, 0, CHIP_SCREEN_WIDTH, CHIP_SCREEN_HEIGHT, BGndColor );
//   POINTER_Init();
   }




/* Public functions ----------------------------------------------------------*/

/*******************************************************************************
*
*                                DRAW_SetCharMagniCoeff
*
*******************************************************************************/
/**
*
*  Set the magnifying value for the characters (should be 1 or 2)
*
*  @param[in]  Coeff The new magnifying coefficent.
*
**/
/******************************************************************************/
void DRAW_SetCharMagniCoeff( u16 Coeff )
   {
   CharMagniCoeff = Coeff;
   }

 /******************************************************************************
*
*                                DRAW_GetCharMagniCoeff
*
*******************************************************************************/
/**
*
*  Return the current magnifying value for the characters
*
*  @return  Current magnifying value.
*
**/
/******************************************************************************/
u16 DRAW_GetCharMagniCoeff( void )
   {
   return CharMagniCoeff;
   }

 /******************************************************************************
*
*                                DRAW_GetTextColor
*
*******************************************************************************/
/**
*
*  Return current text color.
*
*  @return  The current RGB color used to draw text.
*
**/
/******************************************************************************/
u16 DRAW_GetTextColor( void )
   {
   return TextColor;
   }

/*******************************************************************************
*
*                                DRAW_SetTextColor
*
*******************************************************************************/
/**
*
*  Set current text color.
*
*  @param[in]  Color The new RGB color used when drawing text.
*
**/
/******************************************************************************/
void DRAW_SetTextColor( u16 Color )
   {
   TextColor = Color ;

⌨️ 快捷键说明

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