WILLY BAYOT / stm32_adafruit

Dependents:   TDEMNucleo

Committer:
willybayot
Date:
Mon Jan 05 16:07:19 2015 +0000
Revision:
3:d685bfd3ba5f
Parent:
0:4db361f2e6d5
v

Who changed what in which revision?

UserRevisionLine numberNew contents of line
willybayot 0:4db361f2e6d5 1 /**
willybayot 0:4db361f2e6d5 2 ******************************************************************************
willybayot 0:4db361f2e6d5 3 * @file st7735.c
willybayot 0:4db361f2e6d5 4 * @author MCD Application Team
willybayot 0:4db361f2e6d5 5 * @version V1.0.0
willybayot 0:4db361f2e6d5 6 * @date 22-April-2014
willybayot 0:4db361f2e6d5 7 * @brief This file includes the driver for ST7735 LCD mounted on the Adafruit
willybayot 0:4db361f2e6d5 8 * 1.8" TFT LCD shield (reference ID 802).
willybayot 0:4db361f2e6d5 9 ******************************************************************************
willybayot 0:4db361f2e6d5 10 * @attention
willybayot 0:4db361f2e6d5 11 *
willybayot 0:4db361f2e6d5 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
willybayot 0:4db361f2e6d5 13 *
willybayot 0:4db361f2e6d5 14 * Redistribution and use in source and binary forms, with or without modification,
willybayot 0:4db361f2e6d5 15 * are permitted provided that the following conditions are met:
willybayot 0:4db361f2e6d5 16 * 1. Redistributions of source code must retain the above copyright notice,
willybayot 0:4db361f2e6d5 17 * this list of conditions and the following disclaimer.
willybayot 0:4db361f2e6d5 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
willybayot 0:4db361f2e6d5 19 * this list of conditions and the following disclaimer in the documentation
willybayot 0:4db361f2e6d5 20 * and/or other materials provided with the distribution.
willybayot 0:4db361f2e6d5 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
willybayot 0:4db361f2e6d5 22 * may be used to endorse or promote products derived from this software
willybayot 0:4db361f2e6d5 23 * without specific prior written permission.
willybayot 0:4db361f2e6d5 24 *
willybayot 0:4db361f2e6d5 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
willybayot 0:4db361f2e6d5 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
willybayot 0:4db361f2e6d5 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
willybayot 0:4db361f2e6d5 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
willybayot 0:4db361f2e6d5 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
willybayot 0:4db361f2e6d5 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
willybayot 0:4db361f2e6d5 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
willybayot 0:4db361f2e6d5 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
willybayot 0:4db361f2e6d5 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
willybayot 0:4db361f2e6d5 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
willybayot 0:4db361f2e6d5 35 *
willybayot 0:4db361f2e6d5 36 ******************************************************************************
willybayot 0:4db361f2e6d5 37 */
willybayot 0:4db361f2e6d5 38
willybayot 0:4db361f2e6d5 39 /* Includes ------------------------------------------------------------------*/
willybayot 0:4db361f2e6d5 40 #include "st7735.h"
willybayot 0:4db361f2e6d5 41
willybayot 0:4db361f2e6d5 42 /** @addtogroup BSP
willybayot 0:4db361f2e6d5 43 * @{
willybayot 0:4db361f2e6d5 44 */
willybayot 0:4db361f2e6d5 45
willybayot 0:4db361f2e6d5 46 /** @addtogroup Components
willybayot 0:4db361f2e6d5 47 * @{
willybayot 0:4db361f2e6d5 48 */
willybayot 0:4db361f2e6d5 49
willybayot 0:4db361f2e6d5 50 /** @addtogroup ST7735
willybayot 0:4db361f2e6d5 51 * @brief This file provides a set of functions needed to drive the
willybayot 0:4db361f2e6d5 52 * ST7735 LCD.
willybayot 0:4db361f2e6d5 53 * @{
willybayot 0:4db361f2e6d5 54 */
willybayot 0:4db361f2e6d5 55
willybayot 0:4db361f2e6d5 56 /** @defgroup ST7735_Private_TypesDefinitions
willybayot 0:4db361f2e6d5 57 * @{
willybayot 0:4db361f2e6d5 58 */
willybayot 0:4db361f2e6d5 59
willybayot 0:4db361f2e6d5 60 /**
willybayot 0:4db361f2e6d5 61 * @}
willybayot 0:4db361f2e6d5 62 */
willybayot 0:4db361f2e6d5 63
willybayot 0:4db361f2e6d5 64 /** @defgroup ST7735_Private_Defines
willybayot 0:4db361f2e6d5 65 * @{
willybayot 0:4db361f2e6d5 66 */
willybayot 0:4db361f2e6d5 67
willybayot 0:4db361f2e6d5 68 /**
willybayot 0:4db361f2e6d5 69 * @}
willybayot 0:4db361f2e6d5 70 */
willybayot 0:4db361f2e6d5 71
willybayot 0:4db361f2e6d5 72 /** @defgroup ST7735_Private_Macros
willybayot 0:4db361f2e6d5 73 * @{
willybayot 0:4db361f2e6d5 74 */
willybayot 0:4db361f2e6d5 75
willybayot 0:4db361f2e6d5 76 /**
willybayot 0:4db361f2e6d5 77 * @}
willybayot 0:4db361f2e6d5 78 */
willybayot 0:4db361f2e6d5 79
willybayot 0:4db361f2e6d5 80 /** @defgroup ST7735_Private_Variables
willybayot 0:4db361f2e6d5 81 * @{
willybayot 0:4db361f2e6d5 82 */
willybayot 0:4db361f2e6d5 83
willybayot 0:4db361f2e6d5 84
willybayot 0:4db361f2e6d5 85 LCD_DrvTypeDef st7735_drv =
willybayot 0:4db361f2e6d5 86 {
willybayot 0:4db361f2e6d5 87 st7735_Init,
willybayot 0:4db361f2e6d5 88 0,
willybayot 0:4db361f2e6d5 89 st7735_DisplayOn,
willybayot 0:4db361f2e6d5 90 st7735_DisplayOff,
willybayot 0:4db361f2e6d5 91 st7735_SetCursor,
willybayot 0:4db361f2e6d5 92 st7735_WritePixel,
willybayot 0:4db361f2e6d5 93 0,
willybayot 0:4db361f2e6d5 94 0,
willybayot 0:4db361f2e6d5 95 st7735_DrawHLine,
willybayot 0:4db361f2e6d5 96 st7735_DrawVLine,
willybayot 0:4db361f2e6d5 97 st7735_GetLcdPixelWidth,
willybayot 0:4db361f2e6d5 98 st7735_GetLcdPixelHeight,
willybayot 0:4db361f2e6d5 99 0,
willybayot 0:4db361f2e6d5 100 };
willybayot 0:4db361f2e6d5 101
willybayot 0:4db361f2e6d5 102 /**
willybayot 0:4db361f2e6d5 103 * @}
willybayot 0:4db361f2e6d5 104 */
willybayot 0:4db361f2e6d5 105
willybayot 0:4db361f2e6d5 106 /** @defgroup ST7735_Private_FunctionPrototypes
willybayot 0:4db361f2e6d5 107 * @{
willybayot 0:4db361f2e6d5 108 */
willybayot 0:4db361f2e6d5 109
willybayot 0:4db361f2e6d5 110 /**
willybayot 0:4db361f2e6d5 111 * @}
willybayot 0:4db361f2e6d5 112 */
willybayot 0:4db361f2e6d5 113
willybayot 0:4db361f2e6d5 114 /** @defgroup ST7735_Private_Functions
willybayot 0:4db361f2e6d5 115 * @{
willybayot 0:4db361f2e6d5 116 */
willybayot 0:4db361f2e6d5 117
willybayot 0:4db361f2e6d5 118 /**
willybayot 0:4db361f2e6d5 119 * @brief Initialize the ST7735 LCD Component.
willybayot 0:4db361f2e6d5 120 * @param None
willybayot 0:4db361f2e6d5 121 * @retval None
willybayot 0:4db361f2e6d5 122 */
willybayot 0:4db361f2e6d5 123 void st7735_Init(void)
willybayot 0:4db361f2e6d5 124 {
willybayot 0:4db361f2e6d5 125 /* Initialize ST7735 low level bus layer -----------------------------------*/
willybayot 0:4db361f2e6d5 126 LCD_IO_Init();
willybayot 0:4db361f2e6d5 127 /* Out of sleep mode, 0 args, no delay */
willybayot 0:4db361f2e6d5 128 st7735_WriteReg(LCD_REG_17, 0x00);
willybayot 0:4db361f2e6d5 129 /* Frame rate ctrl - normal mode, 3 args:Rate = fosc/(1x2+40) * (LINE+2C+2D)*/
willybayot 0:4db361f2e6d5 130 LCD_IO_WriteReg(LCD_REG_177);
willybayot 0:4db361f2e6d5 131 LCD_IO_WriteData(0x01);
willybayot 0:4db361f2e6d5 132 LCD_IO_WriteData(0x2C);
willybayot 0:4db361f2e6d5 133 LCD_IO_WriteData(0x2D);
willybayot 0:4db361f2e6d5 134 /* Frame rate control - idle mode, 3 args:Rate = fosc/(1x2+40) * (LINE+2C+2D) */
willybayot 0:4db361f2e6d5 135 st7735_WriteReg(LCD_REG_178, 0x01);
willybayot 0:4db361f2e6d5 136 st7735_WriteReg(LCD_REG_178, 0x2C);
willybayot 0:4db361f2e6d5 137 st7735_WriteReg(LCD_REG_178, 0x2D);
willybayot 0:4db361f2e6d5 138 /* Frame rate ctrl - partial mode, 6 args: Dot inversion mode, Line inversion mode */
willybayot 0:4db361f2e6d5 139 st7735_WriteReg(LCD_REG_179, 0x01);
willybayot 0:4db361f2e6d5 140 st7735_WriteReg(LCD_REG_179, 0x2C);
willybayot 0:4db361f2e6d5 141 st7735_WriteReg(LCD_REG_179, 0x2D);
willybayot 0:4db361f2e6d5 142 st7735_WriteReg(LCD_REG_179, 0x01);
willybayot 0:4db361f2e6d5 143 st7735_WriteReg(LCD_REG_179, 0x2C);
willybayot 0:4db361f2e6d5 144 st7735_WriteReg(LCD_REG_179, 0x2D);
willybayot 0:4db361f2e6d5 145 /* Display inversion ctrl, 1 arg, no delay: No inversion */
willybayot 0:4db361f2e6d5 146 st7735_WriteReg(LCD_REG_180, 0x07);
willybayot 0:4db361f2e6d5 147 /* Power control, 3 args, no delay: -4.6V , AUTO mode */
willybayot 0:4db361f2e6d5 148 st7735_WriteReg(LCD_REG_192, 0xA2);
willybayot 0:4db361f2e6d5 149 st7735_WriteReg(LCD_REG_192, 0x02);
willybayot 0:4db361f2e6d5 150 st7735_WriteReg(LCD_REG_192, 0x84);
willybayot 0:4db361f2e6d5 151 /* Power control, 1 arg, no delay: VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD */
willybayot 0:4db361f2e6d5 152 st7735_WriteReg(LCD_REG_193, 0xC5);
willybayot 0:4db361f2e6d5 153 /* Power control, 2 args, no delay: Opamp current small, Boost frequency */
willybayot 0:4db361f2e6d5 154 st7735_WriteReg(LCD_REG_194, 0x0A);
willybayot 0:4db361f2e6d5 155 st7735_WriteReg(LCD_REG_194, 0x00);
willybayot 0:4db361f2e6d5 156 /* Power control, 2 args, no delay: BCLK/2, Opamp current small & Medium low */
willybayot 0:4db361f2e6d5 157 st7735_WriteReg(LCD_REG_195, 0x8A);
willybayot 0:4db361f2e6d5 158 st7735_WriteReg(LCD_REG_195, 0x2A);
willybayot 0:4db361f2e6d5 159 /* Power control, 2 args, no delay */
willybayot 0:4db361f2e6d5 160 st7735_WriteReg(LCD_REG_196, 0x8A);
willybayot 0:4db361f2e6d5 161 st7735_WriteReg(LCD_REG_196, 0xEE);
willybayot 0:4db361f2e6d5 162 /* Power control, 1 arg, no delay */
willybayot 0:4db361f2e6d5 163 st7735_WriteReg(LCD_REG_197, 0x0E);
willybayot 0:4db361f2e6d5 164 /* Don't invert display, no args, no delay */
willybayot 0:4db361f2e6d5 165 LCD_IO_WriteReg(LCD_REG_32);
willybayot 0:4db361f2e6d5 166 /* Memory access control (directions), 1 arg: row addr/col addr, bottom to top refresh */
willybayot 0:4db361f2e6d5 167 st7735_WriteReg(LCD_REG_54, 0xC8);
willybayot 0:4db361f2e6d5 168 /* Set color mode, 1 arg, no delay: 16-bit color */
willybayot 0:4db361f2e6d5 169 st7735_WriteReg(LCD_REG_58, 0x05);
willybayot 0:4db361f2e6d5 170 /* Column addr set, 4 args, no delay: XSTART = 0, XEND = 127 */
willybayot 0:4db361f2e6d5 171 st7735_WriteReg(LCD_REG_42, 0x00);
willybayot 0:4db361f2e6d5 172 st7735_WriteReg(LCD_REG_42, 0x00);
willybayot 0:4db361f2e6d5 173 st7735_WriteReg(LCD_REG_42, 0x00);
willybayot 0:4db361f2e6d5 174 st7735_WriteReg(LCD_REG_42, 0x7F);
willybayot 0:4db361f2e6d5 175 /* Row addr set, 4 args, no delay: YSTART = 0, YEND = 159 */
willybayot 0:4db361f2e6d5 176 st7735_WriteReg(LCD_REG_43, 0x00);
willybayot 0:4db361f2e6d5 177 st7735_WriteReg(LCD_REG_43, 0x00);
willybayot 0:4db361f2e6d5 178 st7735_WriteReg(LCD_REG_43, 0x00);
willybayot 0:4db361f2e6d5 179 st7735_WriteReg(LCD_REG_43, 0x9F);
willybayot 0:4db361f2e6d5 180 /* Magical unicorn dust, 16 args, no delay */
willybayot 0:4db361f2e6d5 181 st7735_WriteReg(LCD_REG_224, 0x02);
willybayot 0:4db361f2e6d5 182 st7735_WriteReg(LCD_REG_224, 0x1c);
willybayot 0:4db361f2e6d5 183 st7735_WriteReg(LCD_REG_224, 0x07);
willybayot 0:4db361f2e6d5 184 st7735_WriteReg(LCD_REG_224, 0x12);
willybayot 0:4db361f2e6d5 185 st7735_WriteReg(LCD_REG_224, 0x37);
willybayot 0:4db361f2e6d5 186 st7735_WriteReg(LCD_REG_224, 0x32);
willybayot 0:4db361f2e6d5 187 st7735_WriteReg(LCD_REG_224, 0x29);
willybayot 0:4db361f2e6d5 188 st7735_WriteReg(LCD_REG_224, 0x2d);
willybayot 0:4db361f2e6d5 189 st7735_WriteReg(LCD_REG_224, 0x29);
willybayot 0:4db361f2e6d5 190 st7735_WriteReg(LCD_REG_224, 0x25);
willybayot 0:4db361f2e6d5 191 st7735_WriteReg(LCD_REG_224, 0x2B);
willybayot 0:4db361f2e6d5 192 st7735_WriteReg(LCD_REG_224, 0x39);
willybayot 0:4db361f2e6d5 193 st7735_WriteReg(LCD_REG_224, 0x00);
willybayot 0:4db361f2e6d5 194 st7735_WriteReg(LCD_REG_224, 0x01);
willybayot 0:4db361f2e6d5 195 st7735_WriteReg(LCD_REG_224, 0x03);
willybayot 0:4db361f2e6d5 196 st7735_WriteReg(LCD_REG_224, 0x10);
willybayot 0:4db361f2e6d5 197 /* Sparkles and rainbows, 16 args, no delay */
willybayot 0:4db361f2e6d5 198 st7735_WriteReg(LCD_REG_225, 0x03);
willybayot 0:4db361f2e6d5 199 st7735_WriteReg(LCD_REG_225, 0x1d);
willybayot 0:4db361f2e6d5 200 st7735_WriteReg(LCD_REG_225, 0x07);
willybayot 0:4db361f2e6d5 201 st7735_WriteReg(LCD_REG_225, 0x06);
willybayot 0:4db361f2e6d5 202 st7735_WriteReg(LCD_REG_225, 0x2E);
willybayot 0:4db361f2e6d5 203 st7735_WriteReg(LCD_REG_225, 0x2C);
willybayot 0:4db361f2e6d5 204 st7735_WriteReg(LCD_REG_225, 0x29);
willybayot 0:4db361f2e6d5 205 st7735_WriteReg(LCD_REG_225, 0x2D);
willybayot 0:4db361f2e6d5 206 st7735_WriteReg(LCD_REG_225, 0x2E);
willybayot 0:4db361f2e6d5 207 st7735_WriteReg(LCD_REG_225, 0x2E);
willybayot 0:4db361f2e6d5 208 st7735_WriteReg(LCD_REG_225, 0x37);
willybayot 0:4db361f2e6d5 209 st7735_WriteReg(LCD_REG_225, 0x3F);
willybayot 0:4db361f2e6d5 210 st7735_WriteReg(LCD_REG_225, 0x00);
willybayot 0:4db361f2e6d5 211 st7735_WriteReg(LCD_REG_225, 0x00);
willybayot 0:4db361f2e6d5 212 st7735_WriteReg(LCD_REG_225, 0x02);
willybayot 0:4db361f2e6d5 213 st7735_WriteReg(LCD_REG_225, 0x10);
willybayot 0:4db361f2e6d5 214 /* Normal display on, no args, no delay */
willybayot 0:4db361f2e6d5 215 st7735_WriteReg(LCD_REG_19, 0x00);
willybayot 0:4db361f2e6d5 216 /* Main screen turn on, no delay */
willybayot 0:4db361f2e6d5 217 st7735_WriteReg(LCD_REG_41, 0x00);
willybayot 0:4db361f2e6d5 218 st7735_WriteReg(LCD_REG_54, 0xC0);
willybayot 0:4db361f2e6d5 219 }
willybayot 0:4db361f2e6d5 220
willybayot 0:4db361f2e6d5 221 /**
willybayot 0:4db361f2e6d5 222 * @brief Enables the Display.
willybayot 0:4db361f2e6d5 223 * @param None
willybayot 0:4db361f2e6d5 224 * @retval None
willybayot 0:4db361f2e6d5 225 */
willybayot 0:4db361f2e6d5 226 void st7735_DisplayOn(void)
willybayot 0:4db361f2e6d5 227 {
willybayot 0:4db361f2e6d5 228 LCD_IO_WriteReg(LCD_REG_19);
willybayot 0:4db361f2e6d5 229 LCD_Delay(10);
willybayot 0:4db361f2e6d5 230 LCD_IO_WriteReg(LCD_REG_41);
willybayot 0:4db361f2e6d5 231 LCD_Delay(10);
willybayot 0:4db361f2e6d5 232 LCD_IO_WriteReg(LCD_REG_54);
willybayot 0:4db361f2e6d5 233 LCD_IO_WriteData(0xC0);
willybayot 0:4db361f2e6d5 234 }
willybayot 0:4db361f2e6d5 235
willybayot 0:4db361f2e6d5 236 /**
willybayot 0:4db361f2e6d5 237 * @brief Disables the Display.
willybayot 0:4db361f2e6d5 238 * @param None
willybayot 0:4db361f2e6d5 239 * @retval None
willybayot 0:4db361f2e6d5 240 */
willybayot 0:4db361f2e6d5 241 void st7735_DisplayOff(void)
willybayot 0:4db361f2e6d5 242 {
willybayot 0:4db361f2e6d5 243 LCD_IO_WriteReg(LCD_REG_19);
willybayot 0:4db361f2e6d5 244 LCD_Delay(10);
willybayot 0:4db361f2e6d5 245 LCD_IO_WriteReg(LCD_REG_40);
willybayot 0:4db361f2e6d5 246 LCD_Delay(10);
willybayot 0:4db361f2e6d5 247 LCD_IO_WriteReg(LCD_REG_54);
willybayot 0:4db361f2e6d5 248 LCD_IO_WriteData(0xC0);
willybayot 0:4db361f2e6d5 249 }
willybayot 0:4db361f2e6d5 250
willybayot 0:4db361f2e6d5 251 /**
willybayot 0:4db361f2e6d5 252 * @brief Sets Cursor position.
willybayot 0:4db361f2e6d5 253 * @param Xpos: specifies the X position.
willybayot 0:4db361f2e6d5 254 * @param Ypos: specifies the Y position.
willybayot 0:4db361f2e6d5 255 * @retval None
willybayot 0:4db361f2e6d5 256 */
willybayot 0:4db361f2e6d5 257 void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos)
willybayot 0:4db361f2e6d5 258 {
willybayot 0:4db361f2e6d5 259 LCD_IO_WriteReg(LCD_REG_42);
willybayot 0:4db361f2e6d5 260 LCD_IO_WriteData(Xpos);
willybayot 0:4db361f2e6d5 261 LCD_IO_WriteData(Xpos);
willybayot 0:4db361f2e6d5 262 LCD_IO_WriteReg(LCD_REG_43);
willybayot 0:4db361f2e6d5 263 LCD_IO_WriteData(Ypos);
willybayot 0:4db361f2e6d5 264 LCD_IO_WriteData(Ypos);
willybayot 0:4db361f2e6d5 265 LCD_IO_WriteReg(LCD_REG_44);
willybayot 0:4db361f2e6d5 266 }
willybayot 0:4db361f2e6d5 267
willybayot 0:4db361f2e6d5 268 /**
willybayot 0:4db361f2e6d5 269 * @brief Writes pixel.
willybayot 0:4db361f2e6d5 270 * @param Xpos: specifies the X position.
willybayot 0:4db361f2e6d5 271 * @param Ypos: specifies the Y position.
willybayot 0:4db361f2e6d5 272 * @param RGBCode: the RGB pixel color
willybayot 0:4db361f2e6d5 273 * @retval None
willybayot 0:4db361f2e6d5 274 */
willybayot 0:4db361f2e6d5 275 void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code)
willybayot 0:4db361f2e6d5 276 {
willybayot 0:4db361f2e6d5 277 if((Xpos >= ST7735_LCD_PIXEL_WIDTH) || (Ypos >= ST7735_LCD_PIXEL_HEIGHT))
willybayot 0:4db361f2e6d5 278 {
willybayot 0:4db361f2e6d5 279 return;
willybayot 0:4db361f2e6d5 280 }
willybayot 0:4db361f2e6d5 281
willybayot 0:4db361f2e6d5 282 /* Set Cursor */
willybayot 0:4db361f2e6d5 283 st7735_SetCursor(Xpos, Ypos);
willybayot 0:4db361f2e6d5 284
willybayot 0:4db361f2e6d5 285 LCD_IO_WriteData(RGB_Code >> 8);
willybayot 0:4db361f2e6d5 286 LCD_IO_WriteData(RGB_Code);
willybayot 0:4db361f2e6d5 287 }
willybayot 0:4db361f2e6d5 288
willybayot 0:4db361f2e6d5 289
willybayot 0:4db361f2e6d5 290 /**
willybayot 0:4db361f2e6d5 291 * @brief Writes to the selected LCD register.
willybayot 0:4db361f2e6d5 292 * @param LCDReg: Address of the selected register.
willybayot 0:4db361f2e6d5 293 * @param LCDRegValue: value to write to the selected register.
willybayot 0:4db361f2e6d5 294 * @retval None
willybayot 0:4db361f2e6d5 295 */
willybayot 0:4db361f2e6d5 296 void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue)
willybayot 0:4db361f2e6d5 297 {
willybayot 0:4db361f2e6d5 298 LCD_IO_WriteReg(LCDReg);
willybayot 0:4db361f2e6d5 299
willybayot 0:4db361f2e6d5 300 LCD_IO_WriteData(LCDRegValue);
willybayot 0:4db361f2e6d5 301 }
willybayot 0:4db361f2e6d5 302
willybayot 0:4db361f2e6d5 303 /**
willybayot 0:4db361f2e6d5 304 * @brief Draws horizontal line.
willybayot 0:4db361f2e6d5 305 * @param RGBCode: Specifies the RGB color
willybayot 0:4db361f2e6d5 306 * @param Xpos: specifies the X position.
willybayot 0:4db361f2e6d5 307 * @param Ypos: specifies the Y position.
willybayot 0:4db361f2e6d5 308 * @param Length: specifies the line length.
willybayot 0:4db361f2e6d5 309 * @retval None
willybayot 0:4db361f2e6d5 310 */
willybayot 0:4db361f2e6d5 311 void st7735_DrawHLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
willybayot 0:4db361f2e6d5 312 {
willybayot 0:4db361f2e6d5 313 uint8_t counter = 0;
willybayot 0:4db361f2e6d5 314
willybayot 0:4db361f2e6d5 315 if(Xpos + Length > ST7735_LCD_PIXEL_WIDTH) return;
willybayot 0:4db361f2e6d5 316
willybayot 0:4db361f2e6d5 317 for(counter = 0; counter < Length; counter++)
willybayot 0:4db361f2e6d5 318 {
willybayot 0:4db361f2e6d5 319 st7735_WritePixel(Xpos + counter, Ypos, RGB_Code);
willybayot 0:4db361f2e6d5 320 }
willybayot 0:4db361f2e6d5 321 }
willybayot 0:4db361f2e6d5 322
willybayot 0:4db361f2e6d5 323 /**
willybayot 0:4db361f2e6d5 324 * @brief Draws vertical line.
willybayot 0:4db361f2e6d5 325 * @param RGBCode: Specifies the RGB color
willybayot 0:4db361f2e6d5 326 * @param Xpos: specifies the X position.
willybayot 0:4db361f2e6d5 327 * @param Ypos: specifies the Y position.
willybayot 0:4db361f2e6d5 328 * @param Length: specifies the line length.
willybayot 0:4db361f2e6d5 329 * @retval None
willybayot 0:4db361f2e6d5 330 */
willybayot 0:4db361f2e6d5 331 void st7735_DrawVLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length)
willybayot 0:4db361f2e6d5 332 {
willybayot 0:4db361f2e6d5 333 uint8_t counter = 0;
willybayot 0:4db361f2e6d5 334
willybayot 0:4db361f2e6d5 335 if(Ypos + Length > ST7735_LCD_PIXEL_HEIGHT) return;
willybayot 0:4db361f2e6d5 336 for(counter = 0; counter < Length; counter++)
willybayot 0:4db361f2e6d5 337 {
willybayot 0:4db361f2e6d5 338 st7735_WritePixel(Xpos, Ypos + counter, RGB_Code);
willybayot 0:4db361f2e6d5 339 }
willybayot 0:4db361f2e6d5 340 }
willybayot 0:4db361f2e6d5 341
willybayot 0:4db361f2e6d5 342 /**
willybayot 0:4db361f2e6d5 343 * @brief Gets the LCD pixel Width.
willybayot 0:4db361f2e6d5 344 * @param None
willybayot 0:4db361f2e6d5 345 * @retval The Lcd Pixel Width
willybayot 0:4db361f2e6d5 346 */
willybayot 0:4db361f2e6d5 347 uint16_t st7735_GetLcdPixelWidth(void)
willybayot 0:4db361f2e6d5 348 {
willybayot 0:4db361f2e6d5 349 return ST7735_LCD_PIXEL_WIDTH;
willybayot 0:4db361f2e6d5 350 }
willybayot 0:4db361f2e6d5 351
willybayot 0:4db361f2e6d5 352 /**
willybayot 0:4db361f2e6d5 353 * @brief Gets the LCD pixel Height.
willybayot 0:4db361f2e6d5 354 * @param None
willybayot 0:4db361f2e6d5 355 * @retval The Lcd Pixel Height
willybayot 0:4db361f2e6d5 356 */
willybayot 0:4db361f2e6d5 357 uint16_t st7735_GetLcdPixelHeight(void)
willybayot 0:4db361f2e6d5 358 {
willybayot 0:4db361f2e6d5 359 return ST7735_LCD_PIXEL_HEIGHT;
willybayot 0:4db361f2e6d5 360 }
willybayot 0:4db361f2e6d5 361
willybayot 0:4db361f2e6d5 362 /**
willybayot 0:4db361f2e6d5 363 * @}
willybayot 0:4db361f2e6d5 364 */
willybayot 0:4db361f2e6d5 365
willybayot 0:4db361f2e6d5 366 /**
willybayot 0:4db361f2e6d5 367 * @}
willybayot 0:4db361f2e6d5 368 */
willybayot 0:4db361f2e6d5 369
willybayot 0:4db361f2e6d5 370 /**
willybayot 0:4db361f2e6d5 371 * @}
willybayot 0:4db361f2e6d5 372 */
willybayot 0:4db361f2e6d5 373
willybayot 0:4db361f2e6d5 374 /**
willybayot 0:4db361f2e6d5 375 * @}
willybayot 0:4db361f2e6d5 376 */
willybayot 0:4db361f2e6d5 377
willybayot 0:4db361f2e6d5 378 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
willybayot 0:4db361f2e6d5 379