add P4 & P5
This commit is contained in:
109
P5_SETR2/Components/st7735/Release_Notes.html
Normal file
109
P5_SETR2/Components/st7735/Release_Notes.html
Normal file
@@ -0,0 +1,109 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="generator" content="pandoc" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
|
||||
<title>Release Notes for ST7735 Component Drivers</title>
|
||||
<style type="text/css">
|
||||
code{white-space: pre-wrap;}
|
||||
span.smallcaps{font-variant: small-caps;}
|
||||
span.underline{text-decoration: underline;}
|
||||
div.column{display: inline-block; vertical-align: top; width: 50%;}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../../../../_htmresc/mini-st.css" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-4">
|
||||
<div class="card fluid">
|
||||
<div class="sectione dark">
|
||||
<center>
|
||||
<h1 id="release-notes-for-st7735-component-drivers"><small>Release Notes for</small> <mark>ST7735 Component Drivers</mark></h1>
|
||||
<p>Copyright © 2014 STMicroelectronics<br />
|
||||
</p>
|
||||
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo.png" alt="ST logo" /></a>
|
||||
</center>
|
||||
</div>
|
||||
</div>
|
||||
<h1 id="license">License</h1>
|
||||
<p>Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:</p>
|
||||
<p><a href="https://opensource.org/licenses/BSD-3-Clause">https://opensource.org/licenses/BSD-3-Clause</a></p>
|
||||
<h1 id="purpose">Purpose</h1>
|
||||
<p>This directory contains the ST7735 component drivers.</p>
|
||||
</div>
|
||||
<div class="col-sm-12 col-lg-8">
|
||||
<h1 id="update-history">Update History</h1>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section22" checked aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.5 / 03-April-2019</label>
|
||||
<div>
|
||||
<h2 id="main-changes">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Update release notes format</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section20" aria-hidden="true"> <label for="collapse-section20" aria-hidden="true">V1.1.4 / 17-December-2018</label>
|
||||
<div>
|
||||
<h2 id="main-changes-1">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Fix “Back to Release page” link</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.3 / 25-October-2018</label>
|
||||
<div>
|
||||
<h2 id="main-changes-2">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Reformat the BSD 3-Clause license declaration in the files header (replace license terms by a web reference to OSI website where those terms lie)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section185" aria-hidden="true"> <label for="collapse-section185" aria-hidden="true">V1.1.2 / 06-June-2017</label>
|
||||
<div>
|
||||
<h2 id="main-changes-3">Main Changes</h2>
|
||||
<ul>
|
||||
<li>Update comments to be used for PDSC generation</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.1.1 / 24-November-2014</label>
|
||||
<div>
|
||||
<h2 id="main-changes-4">Main Changes</h2>
|
||||
<ul>
|
||||
<li>st7735.h: change “\” by “/” in the include path to fix compilation issues under Linux</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.1.0 / 22-July-2014</label>
|
||||
<div>
|
||||
<h2 id="main-changes-5">Main Changes</h2>
|
||||
<ul>
|
||||
<li>LCD Component driver update in order to harmonize all LCD controllers Link usage (Change LCD_IO_WriteData to LCD_IO_WriteMultipleData)</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse">
|
||||
<input type="checkbox" id="collapse-section16" aria-hidden="true"> <label for="collapse-section16" aria-hidden="true">V1.0.0 / 22-April-2014</label>
|
||||
<div>
|
||||
<h2 id="main-changes-6">Main Changes</h2>
|
||||
<ul>
|
||||
<li>First official release</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="sticky">
|
||||
For complete documentation on <mark>STM32 Microcontrollers</mark> , visit: <a href="http://www.st.com/STM32">http://www.st.com/STM32</a>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
453
P5_SETR2/Components/st7735/st7735.c
Normal file
453
P5_SETR2/Components/st7735/st7735.c
Normal file
@@ -0,0 +1,453 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file st7735.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file includes the driver for ST7735 LCD mounted on the Adafruit
|
||||
* 1.8" TFT LCD shield (reference ID 802).
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2014 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "st7735.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Components
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ST7735
|
||||
* @brief This file provides a set of functions needed to drive the
|
||||
* ST7735 LCD.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ST7735_Private_TypesDefinitions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ST7735_Private_Defines
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ST7735_Private_Macros
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ST7735_Private_Variables
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
LCD_DrvTypeDef st7735_drv =
|
||||
{
|
||||
st7735_Init,
|
||||
0,
|
||||
st7735_DisplayOn,
|
||||
st7735_DisplayOff,
|
||||
st7735_SetCursor,
|
||||
st7735_WritePixel,
|
||||
0,
|
||||
st7735_SetDisplayWindow,
|
||||
st7735_DrawHLine,
|
||||
st7735_DrawVLine,
|
||||
st7735_GetLcdPixelWidth,
|
||||
st7735_GetLcdPixelHeight,
|
||||
st7735_DrawBitmap,
|
||||
};
|
||||
|
||||
static uint16_t ArrayRGB[320] = {0};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ST7735_Private_FunctionPrototypes
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ST7735_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize the ST7735 LCD Component.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_Init(void)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
|
||||
/* Initialize ST7735 low level bus layer -----------------------------------*/
|
||||
LCD_IO_Init();
|
||||
/* Out of sleep mode, 0 args, no delay */
|
||||
st7735_WriteReg(LCD_REG_17, 0x00);
|
||||
/* Frame rate ctrl - normal mode, 3 args:Rate = fosc/(1x2+40) * (LINE+2C+2D)*/
|
||||
LCD_IO_WriteReg(LCD_REG_177);
|
||||
data = 0x01;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = 0x2C;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = 0x2D;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
/* Frame rate control - idle mode, 3 args:Rate = fosc/(1x2+40) * (LINE+2C+2D) */
|
||||
st7735_WriteReg(LCD_REG_178, 0x01);
|
||||
st7735_WriteReg(LCD_REG_178, 0x2C);
|
||||
st7735_WriteReg(LCD_REG_178, 0x2D);
|
||||
/* Frame rate ctrl - partial mode, 6 args: Dot inversion mode, Line inversion mode */
|
||||
st7735_WriteReg(LCD_REG_179, 0x01);
|
||||
st7735_WriteReg(LCD_REG_179, 0x2C);
|
||||
st7735_WriteReg(LCD_REG_179, 0x2D);
|
||||
st7735_WriteReg(LCD_REG_179, 0x01);
|
||||
st7735_WriteReg(LCD_REG_179, 0x2C);
|
||||
st7735_WriteReg(LCD_REG_179, 0x2D);
|
||||
/* Display inversion ctrl, 1 arg, no delay: No inversion */
|
||||
st7735_WriteReg(LCD_REG_180, 0x07);
|
||||
/* Power control, 3 args, no delay: -4.6V , AUTO mode */
|
||||
st7735_WriteReg(LCD_REG_192, 0xA2);
|
||||
st7735_WriteReg(LCD_REG_192, 0x02);
|
||||
st7735_WriteReg(LCD_REG_192, 0x84);
|
||||
/* Power control, 1 arg, no delay: VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD */
|
||||
st7735_WriteReg(LCD_REG_193, 0xC5);
|
||||
/* Power control, 2 args, no delay: Opamp current small, Boost frequency */
|
||||
st7735_WriteReg(LCD_REG_194, 0x0A);
|
||||
st7735_WriteReg(LCD_REG_194, 0x00);
|
||||
/* Power control, 2 args, no delay: BCLK/2, Opamp current small & Medium low */
|
||||
st7735_WriteReg(LCD_REG_195, 0x8A);
|
||||
st7735_WriteReg(LCD_REG_195, 0x2A);
|
||||
/* Power control, 2 args, no delay */
|
||||
st7735_WriteReg(LCD_REG_196, 0x8A);
|
||||
st7735_WriteReg(LCD_REG_196, 0xEE);
|
||||
/* Power control, 1 arg, no delay */
|
||||
st7735_WriteReg(LCD_REG_197, 0x0E);
|
||||
/* Don't invert display, no args, no delay */
|
||||
LCD_IO_WriteReg(LCD_REG_32);
|
||||
/* Set color mode, 1 arg, no delay: 16-bit color */
|
||||
st7735_WriteReg(LCD_REG_58, 0x05);
|
||||
/* Column addr set, 4 args, no delay: XSTART = 0, XEND = 127 */
|
||||
LCD_IO_WriteReg(LCD_REG_42);
|
||||
data = 0x00;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = 0x7F;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
/* Row addr set, 4 args, no delay: YSTART = 0, YEND = 159 */
|
||||
LCD_IO_WriteReg(LCD_REG_43);
|
||||
data = 0x00;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = 0x9F;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
/* Magical unicorn dust, 16 args, no delay */
|
||||
st7735_WriteReg(LCD_REG_224, 0x02);
|
||||
st7735_WriteReg(LCD_REG_224, 0x1c);
|
||||
st7735_WriteReg(LCD_REG_224, 0x07);
|
||||
st7735_WriteReg(LCD_REG_224, 0x12);
|
||||
st7735_WriteReg(LCD_REG_224, 0x37);
|
||||
st7735_WriteReg(LCD_REG_224, 0x32);
|
||||
st7735_WriteReg(LCD_REG_224, 0x29);
|
||||
st7735_WriteReg(LCD_REG_224, 0x2d);
|
||||
st7735_WriteReg(LCD_REG_224, 0x29);
|
||||
st7735_WriteReg(LCD_REG_224, 0x25);
|
||||
st7735_WriteReg(LCD_REG_224, 0x2B);
|
||||
st7735_WriteReg(LCD_REG_224, 0x39);
|
||||
st7735_WriteReg(LCD_REG_224, 0x00);
|
||||
st7735_WriteReg(LCD_REG_224, 0x01);
|
||||
st7735_WriteReg(LCD_REG_224, 0x03);
|
||||
st7735_WriteReg(LCD_REG_224, 0x10);
|
||||
/* Sparkles and rainbows, 16 args, no delay */
|
||||
st7735_WriteReg(LCD_REG_225, 0x03);
|
||||
st7735_WriteReg(LCD_REG_225, 0x1d);
|
||||
st7735_WriteReg(LCD_REG_225, 0x07);
|
||||
st7735_WriteReg(LCD_REG_225, 0x06);
|
||||
st7735_WriteReg(LCD_REG_225, 0x2E);
|
||||
st7735_WriteReg(LCD_REG_225, 0x2C);
|
||||
st7735_WriteReg(LCD_REG_225, 0x29);
|
||||
st7735_WriteReg(LCD_REG_225, 0x2D);
|
||||
st7735_WriteReg(LCD_REG_225, 0x2E);
|
||||
st7735_WriteReg(LCD_REG_225, 0x2E);
|
||||
st7735_WriteReg(LCD_REG_225, 0x37);
|
||||
st7735_WriteReg(LCD_REG_225, 0x3F);
|
||||
st7735_WriteReg(LCD_REG_225, 0x00);
|
||||
st7735_WriteReg(LCD_REG_225, 0x00);
|
||||
st7735_WriteReg(LCD_REG_225, 0x02);
|
||||
st7735_WriteReg(LCD_REG_225, 0x10);
|
||||
/* Normal display on, no args, no delay */
|
||||
st7735_WriteReg(LCD_REG_19, 0x00);
|
||||
/* Main screen turn on, no delay */
|
||||
st7735_WriteReg(LCD_REG_41, 0x00);
|
||||
/* Memory access control: MY = 1, MX = 1, MV = 0, ML = 0 */
|
||||
st7735_WriteReg(LCD_REG_54, 0xC0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enables the Display.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_DisplayOn(void)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
LCD_IO_WriteReg(LCD_REG_19);
|
||||
LCD_Delay(10);
|
||||
LCD_IO_WriteReg(LCD_REG_41);
|
||||
LCD_Delay(10);
|
||||
LCD_IO_WriteReg(LCD_REG_54);
|
||||
data = 0xC0;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disables the Display.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_DisplayOff(void)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
LCD_IO_WriteReg(LCD_REG_19);
|
||||
LCD_Delay(10);
|
||||
LCD_IO_WriteReg(LCD_REG_40);
|
||||
LCD_Delay(10);
|
||||
LCD_IO_WriteReg(LCD_REG_54);
|
||||
data = 0xC0;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets Cursor position.
|
||||
* @param Xpos: specifies the X position.
|
||||
* @param Ypos: specifies the Y position.
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
LCD_IO_WriteReg(LCD_REG_42);
|
||||
data = (Xpos) >> 8;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = (Xpos) & 0xFF;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
LCD_IO_WriteReg(LCD_REG_43);
|
||||
data = (Ypos) >> 8;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = (Ypos) & 0xFF;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
LCD_IO_WriteReg(LCD_REG_44);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes pixel.
|
||||
* @param Xpos: specifies the X position.
|
||||
* @param Ypos: specifies the Y position.
|
||||
* @param RGBCode: the RGB pixel color
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
if((Xpos >= ST7735_LCD_PIXEL_WIDTH) || (Ypos >= ST7735_LCD_PIXEL_HEIGHT))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set Cursor */
|
||||
st7735_SetCursor(Xpos, Ypos);
|
||||
|
||||
data = RGBCode >> 8;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = RGBCode;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Writes to the selected LCD register.
|
||||
* @param LCDReg: Address of the selected register.
|
||||
* @param LCDRegValue: value to write to the selected register.
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue)
|
||||
{
|
||||
LCD_IO_WriteReg(LCDReg);
|
||||
LCD_IO_WriteMultipleData(&LCDRegValue, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a display window
|
||||
* @param Xpos: specifies the X bottom left position.
|
||||
* @param Ypos: specifies the Y bottom left position.
|
||||
* @param Height: display window height.
|
||||
* @param Width: display window width.
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height)
|
||||
{
|
||||
uint8_t data = 0;
|
||||
/* Column addr set, 4 args, no delay: XSTART = Xpos, XEND = (Xpos + Width - 1) */
|
||||
LCD_IO_WriteReg(LCD_REG_42);
|
||||
data = (Xpos) >> 8;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = (Xpos) & 0xFF;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = (Xpos + Width - 1) >> 8;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = (Xpos + Width - 1) & 0xFF;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
/* Row addr set, 4 args, no delay: YSTART = Ypos, YEND = (Ypos + Height - 1) */
|
||||
LCD_IO_WriteReg(LCD_REG_43);
|
||||
data = (Ypos) >> 8;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = (Ypos) & 0xFF;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = (Ypos + Height - 1) >> 8;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
data = (Ypos + Height - 1) & 0xFF;
|
||||
LCD_IO_WriteMultipleData(&data, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draws horizontal line.
|
||||
* @param RGBCode: Specifies the RGB color
|
||||
* @param Xpos: specifies the X position.
|
||||
* @param Ypos: specifies the Y position.
|
||||
* @param Length: specifies the line length.
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
|
||||
{
|
||||
uint8_t counter = 0;
|
||||
|
||||
if(Xpos + Length > ST7735_LCD_PIXEL_WIDTH) return;
|
||||
|
||||
/* Set Cursor */
|
||||
st7735_SetCursor(Xpos, Ypos);
|
||||
|
||||
for(counter = 0; counter < Length; counter++)
|
||||
{
|
||||
ArrayRGB[counter] = RGBCode;
|
||||
}
|
||||
LCD_IO_WriteMultipleData((uint8_t*)&ArrayRGB[0], Length * 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Draws vertical line.
|
||||
* @param RGBCode: Specifies the RGB color
|
||||
* @param Xpos: specifies the X position.
|
||||
* @param Ypos: specifies the Y position.
|
||||
* @param Length: specifies the line length.
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
|
||||
{
|
||||
uint8_t counter = 0;
|
||||
|
||||
if(Ypos + Length > ST7735_LCD_PIXEL_HEIGHT) return;
|
||||
for(counter = 0; counter < Length; counter++)
|
||||
{
|
||||
st7735_WritePixel(Xpos, Ypos + counter, RGBCode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the LCD pixel Width.
|
||||
* @param None
|
||||
* @retval The Lcd Pixel Width
|
||||
*/
|
||||
uint16_t st7735_GetLcdPixelWidth(void)
|
||||
{
|
||||
return ST7735_LCD_PIXEL_WIDTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the LCD pixel Height.
|
||||
* @param None
|
||||
* @retval The Lcd Pixel Height
|
||||
*/
|
||||
uint16_t st7735_GetLcdPixelHeight(void)
|
||||
{
|
||||
return ST7735_LCD_PIXEL_HEIGHT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Displays a bitmap picture loaded in the internal Flash.
|
||||
* @param BmpAddress: Bmp picture address in the internal Flash.
|
||||
* @retval None
|
||||
*/
|
||||
void st7735_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp)
|
||||
{
|
||||
uint32_t index = 0, size = 0;
|
||||
|
||||
/* Read bitmap size */
|
||||
size = *(volatile uint16_t *) (pbmp + 2);
|
||||
size |= (*(volatile uint16_t *) (pbmp + 4)) << 16;
|
||||
/* Get bitmap data address offset */
|
||||
index = *(volatile uint16_t *) (pbmp + 10);
|
||||
index |= (*(volatile uint16_t *) (pbmp + 12)) << 16;
|
||||
size = (size - index)/2;
|
||||
pbmp += index;
|
||||
|
||||
/* Set GRAM write direction and BGR = 0 */
|
||||
/* Memory access control: MY = 0, MX = 1, MV = 0, ML = 0 */
|
||||
st7735_WriteReg(LCD_REG_54, 0x40);
|
||||
|
||||
/* Set Cursor */
|
||||
st7735_SetCursor(Xpos, Ypos);
|
||||
|
||||
LCD_IO_WriteMultipleData((uint8_t*)pbmp, size*2);
|
||||
|
||||
/* Set GRAM write direction and BGR = 0 */
|
||||
/* Memory access control: MY = 1, MX = 1, MV = 0, ML = 0 */
|
||||
st7735_WriteReg(LCD_REG_54, 0xC0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
196
P5_SETR2/Components/st7735/st7735.h
Normal file
196
P5_SETR2/Components/st7735/st7735.h
Normal file
@@ -0,0 +1,196 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file st7735.h
|
||||
* @author MCD Application Team
|
||||
* @brief This file contains all the functions prototypes for the st7735.c
|
||||
* driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2014 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __ST7735_H
|
||||
#define __ST7735_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "../Common/lcd.h"
|
||||
|
||||
/** @addtogroup BSP
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup Components
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @addtogroup ST7735
|
||||
* @{
|
||||
*/
|
||||
|
||||
/** @defgroup ST7735_Exported_Types
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ST7735_Exported_Constants
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief ST7735 Size
|
||||
*/
|
||||
#define ST7735_LCD_PIXEL_WIDTH ((uint16_t)128)
|
||||
#define ST7735_LCD_PIXEL_HEIGHT ((uint16_t)160)
|
||||
|
||||
/**
|
||||
* @brief ST7735 Registers
|
||||
*/
|
||||
#define LCD_REG_0 0x00 /* No Operation: NOP */
|
||||
#define LCD_REG_1 0x01 /* Software reset: SWRESET */
|
||||
#define LCD_REG_4 0x04 /* Read Display ID: RDDID */
|
||||
#define LCD_REG_9 0x09 /* Read Display Statu: RDDST */
|
||||
#define LCD_REG_10 0x0A /* Read Display Power: RDDPM */
|
||||
#define LCD_REG_11 0x0B /* Read Display: RDDMADCTL */
|
||||
#define LCD_REG_12 0x0C /* Read Display Pixel: RDDCOLMOD */
|
||||
#define LCD_REG_13 0x0D /* Read Display Image: RDDIM */
|
||||
#define LCD_REG_14 0x0E /* Read Display Signal: RDDSM */
|
||||
#define LCD_REG_16 0x10 /* Sleep in & booster off: SLPIN */
|
||||
#define LCD_REG_17 0x11 /* Sleep out & booster on: SLPOUT */
|
||||
#define LCD_REG_18 0x12 /* Partial mode on: PTLON */
|
||||
#define LCD_REG_19 0x13 /* Partial off (Normal): NORON */
|
||||
#define LCD_REG_32 0x20 /* Display inversion off: INVOFF */
|
||||
#define LCD_REG_33 0x21 /* Display inversion on: INVON */
|
||||
#define LCD_REG_38 0x26 /* Gamma curve select: GAMSET */
|
||||
#define LCD_REG_40 0x28 /* Display off: DISPOFF */
|
||||
#define LCD_REG_41 0x29 /* Display on: DISPON */
|
||||
#define LCD_REG_42 0x2A /* Column address set: CASET */
|
||||
#define LCD_REG_43 0x2B /* Row address set: RASET */
|
||||
#define LCD_REG_44 0x2C /* Memory write: RAMWR */
|
||||
#define LCD_REG_45 0x2D /* LUT for 4k,65k,262k color: RGBSET */
|
||||
#define LCD_REG_46 0x2E /* Memory read: RAMRD*/
|
||||
#define LCD_REG_48 0x30 /* Partial start/end address set: PTLAR */
|
||||
#define LCD_REG_52 0x34 /* Tearing effect line off: TEOFF */
|
||||
#define LCD_REG_53 0x35 /* Tearing effect mode set & on: TEON */
|
||||
#define LCD_REG_54 0x36 /* Memory data access control: MADCTL */
|
||||
#define LCD_REG_56 0x38 /* Idle mode off: IDMOFF */
|
||||
#define LCD_REG_57 0x39 /* Idle mode on: IDMON */
|
||||
#define LCD_REG_58 0x3A /* Interface pixel format: COLMOD */
|
||||
#define LCD_REG_177 0xB1 /* In normal mode (Full colors): FRMCTR1 */
|
||||
#define LCD_REG_178 0xB2 /* In Idle mode (8-colors): FRMCTR2 */
|
||||
#define LCD_REG_179 0xB3 /* In partial mode + Full colors: FRMCTR3 */
|
||||
#define LCD_REG_180 0xB4 /* Display inversion control: INVCTR */
|
||||
#define LCD_REG_192 0xC0 /* Power control setting: PWCTR1 */
|
||||
#define LCD_REG_193 0xC1 /* Power control setting: PWCTR2 */
|
||||
#define LCD_REG_194 0xC2 /* In normal mode (Full colors): PWCTR3 */
|
||||
#define LCD_REG_195 0xC3 /* In Idle mode (8-colors): PWCTR4 */
|
||||
#define LCD_REG_196 0xC4 /* In partial mode + Full colors: PWCTR5 */
|
||||
#define LCD_REG_197 0xC5 /* VCOM control 1: VMCTR1 */
|
||||
#define LCD_REG_199 0xC7 /* Set VCOM offset control: VMOFCTR */
|
||||
#define LCD_REG_209 0xD1 /* Set LCM version code: WRID2 */
|
||||
#define LCD_REG_210 0xD2 /* Customer Project code: WRID3 */
|
||||
#define LCD_REG_217 0xD9 /* NVM control status: NVCTR1 */
|
||||
#define LCD_REG_218 0xDA /* Read ID1: RDID1 */
|
||||
#define LCD_REG_219 0xDB /* Read ID2: RDID2 */
|
||||
#define LCD_REG_220 0xDC /* Read ID3: RDID3 */
|
||||
#define LCD_REG_222 0xDE /* NVM Read Command: NVCTR2 */
|
||||
#define LCD_REG_223 0xDF /* NVM Write Command: NVCTR3 */
|
||||
#define LCD_REG_224 0xE0 /* Set Gamma adjustment (+ polarity): GAMCTRP1 */
|
||||
#define LCD_REG_225 0xE1 /* Set Gamma adjustment (- polarity): GAMCTRN1 */
|
||||
|
||||
/**
|
||||
* @brief LCD Lines depending on the chosen fonts.
|
||||
*/
|
||||
#define LCD_LINE_0 LINE(0)
|
||||
#define LCD_LINE_1 LINE(1)
|
||||
#define LCD_LINE_2 LINE(2)
|
||||
#define LCD_LINE_3 LINE(3)
|
||||
#define LCD_LINE_4 LINE(4)
|
||||
#define LCD_LINE_5 LINE(5)
|
||||
#define LCD_LINE_6 LINE(6)
|
||||
#define LCD_LINE_7 LINE(7)
|
||||
#define LCD_LINE_8 LINE(8)
|
||||
#define LCD_LINE_9 LINE(9)
|
||||
#define LCD_LINE_10 LINE(10)
|
||||
#define LCD_LINE_11 LINE(11)
|
||||
#define LCD_LINE_12 LINE(12)
|
||||
#define LCD_LINE_13 LINE(13)
|
||||
#define LCD_LINE_14 LINE(14)
|
||||
#define LCD_LINE_15 LINE(15)
|
||||
#define LCD_LINE_16 LINE(16)
|
||||
#define LCD_LINE_17 LINE(17)
|
||||
#define LCD_LINE_18 LINE(18)
|
||||
#define LCD_LINE_19 LINE(19)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/** @defgroup ADAFRUIT_SPI_LCD_Exported_Functions
|
||||
* @{
|
||||
*/
|
||||
void st7735_Init(void);
|
||||
uint16_t st7735_ReadID(void);
|
||||
|
||||
void st7735_DisplayOn(void);
|
||||
void st7735_DisplayOff(void);
|
||||
void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos);
|
||||
void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
|
||||
void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue);
|
||||
uint8_t st7735_ReadReg(uint8_t LCDReg);
|
||||
|
||||
void st7735_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
|
||||
void st7735_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
|
||||
void st7735_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
|
||||
|
||||
uint16_t st7735_GetLcdPixelWidth(void);
|
||||
uint16_t st7735_GetLcdPixelHeight(void);
|
||||
void st7735_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
|
||||
|
||||
/* LCD driver structure */
|
||||
extern LCD_DrvTypeDef st7735_drv;
|
||||
|
||||
/* LCD IO functions */
|
||||
void LCD_IO_Init(void);
|
||||
void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size);
|
||||
void LCD_IO_WriteReg(uint8_t Reg);
|
||||
void LCD_Delay(uint32_t delay);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ST7735_H */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
Reference in New Issue
Block a user