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

📄 lcd.c

📁 FreeRTOS - V5.1.1 Last Update: Nov 20 2008 http://sourceforge.net/projects/freertos/
💻 C
📖 第 1 页 / 共 4 页
字号:
*
*  @warning    The (0x0) point in on the low left corner.
*
**/
/******************************************************************************/
void LCD_DrawPixel( u8 XPos, u8 YPos, u16 Color )
   {
   /* Select LCD screen area. */
   LCD_SetRect_For_Cmd( XPos, YPos, 1, 1 );

   /* Send LCD RAM write command. */
   LCD_SendLCDCmd( ST7637_RAMWR );

   // Draw pixel.
   LCD_SendLCDData( Color );
   LCD_SendLCDData( Color >> 8 );
   }

/*******************************************************************************
*
*                                LCD_RectRead
*
*******************************************************************************/
/**
*
*  Save the pixels of a rectangle part of the LCD into a RAM variable.
*
*  @param[in]  x        The horizontal coordinate of the rectangle low left corner.
*  @param[in]  y        The vertical coordinate of the rectangle low left corner.
*  @param[in]  width    The rectangle width in pixels.
*  @param[in]  height   The rectangle height in pixels.
*  @param[out] bmp      The variable to store the read data into.
*
*  @warning    One pixel weights 2 bytes.
*  @warning    The (0x0) point in on the low left corner.
*
**/
/******************************************************************************/
void LCD_RectRead( u16 x, u16 y, u16 width, u16 height, u8* bmp )
   {
   int i;
   int bytesize = (width * height) *2; // 2 bytes per pixel.

   /* Select LCD screen area. */
   LCD_SetRect_For_Cmd( x, y, width, height );

   /* Send LCD RAM write command. */
   LCD_SendLCDCmd(ST7637_RAMRD);

   // First read byte is dummy!
   LCD_ReadLCDData();

   // Read pixels from LCD screen.
   for( i = 0; i < bytesize; i++ )
      {
      *bmp++ = LCD_ReadLCDData();
      }
   }

/*******************************************************************************
*
*                                LCD_GetPixel
*
*******************************************************************************/
/**
*
*  Read the RGB color of the pixel the coordinate are provided in parameter.
*
*  @param[in]  x        The horizontal coordinate of the pixel.
*  @param[in]  y        The vertical coordinate of the pixel.
*  @return              An unsigned 16 bit word containing the RGB color of the pixel.
*
*  @warning    The (0x0) point in on the low left corner.
*  @see        LCD_RectRead
*
**/
/******************************************************************************/
u16 LCD_GetPixel( u8 x, u8 y )
   {
   u16 val;

   LCD_RectRead( x, y, 1, 1, (u8*)&val );

   return val;
   }

/*******************************************************************************
*
*                                LCD_DisplayChar
*
*******************************************************************************/
/**
*
*  Display at provided coordinates the provided ASCII character with the provided
*  text and background colors and with the provided magnify coefficient.
*
*  @param[in]  x              The horizontal coordinate of the character.
*  @param[in]  y              The vertical coordinate of the character.
*  @param[in]  Ascii          The ASCII code of the character to display.
*                             @n Ascii must be higher than 31 and lower than 127.
*  @param[in]  TextColor      The color used to draw the character.
*  @param[in]  BGndColor      The background color of the drawn character.
*  @param[in]  CharMagniCoeff The magnify coefficient used to draw the character.
*
*  @warning    The (0x0) point in on the low left corner.
*
**/
/******************************************************************************/
void LCD_DisplayChar( u8 x, u8 y, u8 Ascii, u16 TextColor, u16 BGndColor, u16 CharMagniCoeff)
   {
   // Display the selected bitmap according to the provided ASCII character.
   LCD_DrawChar( x, y, 7, (u8*)&AsciiDotsTable[ (Ascii-32) * 14 ], TextColor, BGndColor, CharMagniCoeff );
   }

/*******************************************************************************
*
*                                LCD_SetRect_For_Cmd
*
*******************************************************************************/
/**
*
*  Define the rectangle for the next command to be applied.
*
*  @param[in]  x        The horizontal coordinate of the rectangle low left corner.
*  @param[in]  y        The vertical coordinate of the rectangle low left corner.
*  @param[in]  width    The rectangle width in pixels.
*  @param[in]  height   The rectangle height in pixels.
*
*  @warning    The (0x0) point in on the low left corner.
*
**/
/******************************************************************************/
void LCD_SetRect_For_Cmd( s16 x, s16 y, s16 width, s16 height )
   {
   LCD_SendLCDCmd( ST7637_CASET );
   LCD_SendLCDData( y + OrientationOffsetX[ CurrentScreenOrientation ] );
   LCD_SendLCDData( y + OrientationOffsetX[ CurrentScreenOrientation ] + height - 1 );

   LCD_SendLCDCmd( ST7637_RASET );
   LCD_SendLCDData( x + OrientationOffsetY[ CurrentScreenOrientation ] );
   LCD_SendLCDData( x + OrientationOffsetY[ CurrentScreenOrientation ] + width - 1 );
   }

/*******************************************************************************
*
*                                LCD_SetBackLight
*
*******************************************************************************/
/**
*
*  Modify the PWM rate. Any value below BACKLIGHTMIN reset the value to the
*  default value (DEFAULT_CCR_BACKLIGHTSTART).
*
*  @param[in]  newBacklightStart The new PWM rate.
*
**/
/******************************************************************************/
void LCD_SetBackLight( u32 newBacklightStart )
   {
   if( newBacklightStart >= BACKLIGHTMIN )
      {
      Current_CCR_BackLightStart = newBacklightStart;
      }
   else
      {
      Current_CCR_BackLightStart = DEFAULT_CCR_BACKLIGHTSTART;
      }
   }

/*******************************************************************************
*
*                                LCD_SetBackLightOff
*
*******************************************************************************/
/**
*
*  Switch the LCD back light off.
*
**/
/******************************************************************************/
void LCD_SetBackLightOff( void )
   {
   Current_CCR_BackLightStart = 0;
   }

/*******************************************************************************
*
*                                LCD_SetBackLightOn
*
*******************************************************************************/
/**
*
*  Switch the LCD back light on.
*
**/
/******************************************************************************/
void LCD_SetBackLightOn( void )
   {
   Current_CCR_BackLightStart = DEFAULT_CCR_BACKLIGHTSTART;
   }

/*******************************************************************************
*
*                                LCD_GetBackLight
*
*******************************************************************************/
/**
*
*  Returns le LCD PWM rate.
*
*  @return The current LCD PWM rate.
*
**/
/******************************************************************************/
u32 LCD_GetBackLight( void )
   {
   return Current_CCR_BackLightStart;
   }

/*******************************************************************************
*
*                                LCD_SetRotateScreen
*
*******************************************************************************/
/**
*
*  Enable or disable the ability of the screen display to rotate according to
*  the MEMs information.
*
*  @param[in]  RotateScreen 0 to disable screen rotation and 1 to enable.
*
**/
/******************************************************************************/
void LCD_SetRotateScreen( u8 RotateScreen)
   {
   CurrentRotateScreen = RotateScreen;
   }

/*******************************************************************************
*
*                                LCD_GetRotateScreen
*
*******************************************************************************/
/**
*
*  Return the screen rotation mode.
*
*  @retval 0 screen rotation is disabled.
*  @retval 1 screen rotation is enabled.
*
**/
/******************************************************************************/
u8 LCD_GetRotateScreen( void )
   {
   return CurrentRotateScreen;
   }

/*******************************************************************************
*
*                                LCD_SetScreenOrientation
*
*******************************************************************************/
/**
*
*  Set the screen orientation.
*
*  @param[in]  ScreenOrientation The new screen orientation.
*
**/
/******************************************************************************/
void LCD_SetScreenOrientation( Rotate_H12_V_Match_TypeDef ScreenOrientation )
   {
   CurrentScreenOrientation = ScreenOrientation;

   LCD_DisplayRotate( CurrentScreenOrientation );
   }

/*******************************************************************************
*
*                                LCD_GetScreenOrientation
*
*******************************************************************************/
/**
*
*  Return current screen orientation.
*
*  @return   A Rotate_H12_V_Match_TypeDef telling the current screen orientation.
*
**/
/******************************************************************************/
Rotate_H12_V_Match_TypeDef LCD_GetScreenOrientation( void )
   {
   return CurrentScreenOrientation;
   }

⌨️ 快捷键说明

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