Mbed port of Stm32f4Cube LCD LOG for STM32F429I-DISCO

Dependents:   DISCO-F429ZI_ExportTemplate1

Usage example: DISCO-F429ZI_ExportTemplate1

/media/uploads/icis4/lcdlog1.png

Committer:
icis4
Date:
Sat Dec 26 09:53:21 2015 +0000
Revision:
1:b88758065c40
Parent:
0:098e992daf30
License update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
icis4 0:098e992daf30 1 /**
icis4 0:098e992daf30 2 ******************************************************************************
icis4 0:098e992daf30 3 * @file lcd_log.c
icis4 0:098e992daf30 4 * @author MCD Application Team
icis4 0:098e992daf30 5 * @version V1.0.0
icis4 0:098e992daf30 6 * @date 18-February-2014
icis4 0:098e992daf30 7 * @brief This file provides all the LCD Log firmware functions.
icis4 0:098e992daf30 8 *
icis4 0:098e992daf30 9 * The LCD Log module allows to automatically set a header and footer
icis4 0:098e992daf30 10 * on any application using the LCD display and allows to dump user,
icis4 0:098e992daf30 11 * debug and error messages by using the following macros: LCD_ErrLog(),
icis4 0:098e992daf30 12 * LCD_UsrLog() and LCD_DbgLog().
icis4 0:098e992daf30 13 *
icis4 0:098e992daf30 14 * It supports also the scroll feature by embedding an internal software
icis4 0:098e992daf30 15 * cache for display. This feature allows to dump message sequentially
icis4 0:098e992daf30 16 * on the display even if the number of displayed lines is bigger than
icis4 0:098e992daf30 17 * the total number of line allowed by the display.
icis4 0:098e992daf30 18 *
icis4 0:098e992daf30 19 ******************************************************************************
icis4 0:098e992daf30 20 * @attention
icis4 0:098e992daf30 21 *
icis4 0:098e992daf30 22 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
icis4 0:098e992daf30 23 *
icis4 0:098e992daf30 24 * Redistribution and use in source and binary forms, with or without modification,
icis4 0:098e992daf30 25 * are permitted provided that the following conditions are met:
icis4 0:098e992daf30 26 * 1. Redistributions of source code must retain the above copyright notice,
icis4 0:098e992daf30 27 * this list of conditions and the following disclaimer.
icis4 0:098e992daf30 28 * 2. Redistributions in binary form must reproduce the above copyright notice,
icis4 0:098e992daf30 29 * this list of conditions and the following disclaimer in the documentation
icis4 0:098e992daf30 30 * and/or other materials provided with the distribution.
icis4 0:098e992daf30 31 * 3. Neither the name of STMicroelectronics nor the names of its contributors
icis4 0:098e992daf30 32 * may be used to endorse or promote products derived from this software
icis4 0:098e992daf30 33 * without specific prior written permission.
icis4 0:098e992daf30 34 *
icis4 0:098e992daf30 35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
icis4 0:098e992daf30 36 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
icis4 0:098e992daf30 37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
icis4 0:098e992daf30 38 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
icis4 0:098e992daf30 39 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
icis4 0:098e992daf30 40 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
icis4 0:098e992daf30 41 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
icis4 0:098e992daf30 42 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
icis4 0:098e992daf30 43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
icis4 0:098e992daf30 44 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
icis4 0:098e992daf30 45 *
icis4 0:098e992daf30 46 ******************************************************************************
icis4 0:098e992daf30 47 */
icis4 0:098e992daf30 48
icis4 0:098e992daf30 49 /* Includes ------------------------------------------------------------------*/
icis4 0:098e992daf30 50 #include <stdio.h>
icis4 0:098e992daf30 51 #include "lcd_log.h"
icis4 0:098e992daf30 52
icis4 0:098e992daf30 53 /** @addtogroup Utilities
icis4 0:098e992daf30 54 * @{
icis4 0:098e992daf30 55 */
icis4 0:098e992daf30 56
icis4 0:098e992daf30 57 /** @addtogroup STM32_EVAL
icis4 0:098e992daf30 58 * @{
icis4 0:098e992daf30 59 */
icis4 0:098e992daf30 60
icis4 0:098e992daf30 61 /** @addtogroup Common
icis4 0:098e992daf30 62 * @{
icis4 0:098e992daf30 63 */
icis4 0:098e992daf30 64
icis4 0:098e992daf30 65 /** @defgroup LCD_LOG
icis4 0:098e992daf30 66 * @brief LCD Log LCD_Application module
icis4 0:098e992daf30 67 * @{
icis4 0:098e992daf30 68 */
icis4 0:098e992daf30 69
icis4 0:098e992daf30 70 /** @defgroup LCD_LOG_Private_Types
icis4 0:098e992daf30 71 * @{
icis4 0:098e992daf30 72 */
icis4 0:098e992daf30 73 /**
icis4 0:098e992daf30 74 * @}
icis4 0:098e992daf30 75 */
icis4 0:098e992daf30 76
icis4 0:098e992daf30 77
icis4 0:098e992daf30 78 /** @defgroup LCD_LOG_Private_Defines
icis4 0:098e992daf30 79 * @{
icis4 0:098e992daf30 80 */
icis4 0:098e992daf30 81
icis4 0:098e992daf30 82 /**
icis4 0:098e992daf30 83 * @}
icis4 0:098e992daf30 84 */
icis4 0:098e992daf30 85
icis4 0:098e992daf30 86 /* Define the display window settings */
icis4 0:098e992daf30 87 #define YWINDOW_MIN 2
icis4 0:098e992daf30 88
icis4 0:098e992daf30 89 /** @defgroup LCD_LOG_Private_Macros
icis4 0:098e992daf30 90 * @{
icis4 0:098e992daf30 91 */
icis4 0:098e992daf30 92 /**
icis4 0:098e992daf30 93 * @}
icis4 0:098e992daf30 94 */
icis4 0:098e992daf30 95
icis4 0:098e992daf30 96
icis4 0:098e992daf30 97 /** @defgroup LCD_LOG_Private_Variables
icis4 0:098e992daf30 98 * @{
icis4 0:098e992daf30 99 */
icis4 0:098e992daf30 100
icis4 0:098e992daf30 101 LCD_LOG_line LCD_CacheBuffer [LCD_CACHE_DEPTH];
icis4 0:098e992daf30 102 uint32_t LCD_LineColor;
icis4 0:098e992daf30 103 uint16_t LCD_CacheBuffer_xptr;
icis4 0:098e992daf30 104 uint16_t LCD_CacheBuffer_yptr_top;
icis4 0:098e992daf30 105 uint16_t LCD_CacheBuffer_yptr_bottom;
icis4 0:098e992daf30 106
icis4 0:098e992daf30 107 uint16_t LCD_CacheBuffer_yptr_top_bak;
icis4 0:098e992daf30 108 uint16_t LCD_CacheBuffer_yptr_bottom_bak;
icis4 0:098e992daf30 109
icis4 0:098e992daf30 110 FunctionalState LCD_CacheBuffer_yptr_invert;
icis4 0:098e992daf30 111 FunctionalState LCD_ScrollActive;
icis4 0:098e992daf30 112 FunctionalState LCD_Lock;
icis4 0:098e992daf30 113 FunctionalState LCD_Scrolled;
icis4 0:098e992daf30 114 uint16_t LCD_ScrollBackStep;
icis4 0:098e992daf30 115
icis4 0:098e992daf30 116 /**
icis4 0:098e992daf30 117 * @}
icis4 0:098e992daf30 118 */
icis4 0:098e992daf30 119
icis4 0:098e992daf30 120
icis4 0:098e992daf30 121 /** @defgroup LCD_LOG_Private_FunctionPrototypes
icis4 0:098e992daf30 122 * @{
icis4 0:098e992daf30 123 */
icis4 0:098e992daf30 124
icis4 0:098e992daf30 125 /**
icis4 0:098e992daf30 126 * @}
icis4 0:098e992daf30 127 */
icis4 0:098e992daf30 128
icis4 0:098e992daf30 129
icis4 0:098e992daf30 130 /** @defgroup LCD_LOG_Private_Functions
icis4 0:098e992daf30 131 * @{
icis4 0:098e992daf30 132 */
icis4 0:098e992daf30 133
icis4 0:098e992daf30 134
icis4 0:098e992daf30 135 /**
icis4 0:098e992daf30 136 * @brief Initializes the LCD Log module
icis4 0:098e992daf30 137 * @param None
icis4 0:098e992daf30 138 * @retval None
icis4 0:098e992daf30 139 */
icis4 0:098e992daf30 140
icis4 0:098e992daf30 141 void LCD_LOG_Init ( void)
icis4 0:098e992daf30 142 {
icis4 0:098e992daf30 143 /* Deinit LCD cache */
icis4 0:098e992daf30 144 LCD_LOG_DeInit();
icis4 0:098e992daf30 145
icis4 0:098e992daf30 146 /* Clear the LCD */
icis4 0:098e992daf30 147 BSP_LCD_Clear(LCD_LOG_BACKGROUND_COLOR);
icis4 0:098e992daf30 148 }
icis4 0:098e992daf30 149
icis4 0:098e992daf30 150 /**
icis4 0:098e992daf30 151 * @brief DeInitializes the LCD Log module.
icis4 0:098e992daf30 152 * @param None
icis4 0:098e992daf30 153 * @retval None
icis4 0:098e992daf30 154 */
icis4 0:098e992daf30 155 void LCD_LOG_DeInit(void)
icis4 0:098e992daf30 156 {
icis4 0:098e992daf30 157 LCD_LineColor = LCD_LOG_TEXT_COLOR;
icis4 0:098e992daf30 158 LCD_CacheBuffer_xptr = 0;
icis4 0:098e992daf30 159 LCD_CacheBuffer_yptr_top = 0;
icis4 0:098e992daf30 160 LCD_CacheBuffer_yptr_bottom = 0;
icis4 0:098e992daf30 161
icis4 0:098e992daf30 162 LCD_CacheBuffer_yptr_top_bak = 0;
icis4 0:098e992daf30 163 LCD_CacheBuffer_yptr_bottom_bak = 0;
icis4 0:098e992daf30 164
icis4 0:098e992daf30 165 LCD_CacheBuffer_yptr_invert= ENABLE;
icis4 0:098e992daf30 166 LCD_ScrollActive = DISABLE;
icis4 0:098e992daf30 167 LCD_Lock = DISABLE;
icis4 0:098e992daf30 168 LCD_Scrolled = DISABLE;
icis4 0:098e992daf30 169 LCD_ScrollBackStep = 0;
icis4 0:098e992daf30 170 }
icis4 0:098e992daf30 171
icis4 0:098e992daf30 172 /**
icis4 0:098e992daf30 173 * @brief Display the application header on the LCD screen
icis4 0:098e992daf30 174 * @param header: pointer to the string to be displayed
icis4 0:098e992daf30 175 * @retval None
icis4 0:098e992daf30 176 */
icis4 0:098e992daf30 177 void LCD_LOG_SetHeader (uint8_t *header)
icis4 0:098e992daf30 178 {
icis4 0:098e992daf30 179 /* Set the LCD Font */
icis4 0:098e992daf30 180 BSP_LCD_SetFont (&LCD_LOG_HEADER_FONT);
icis4 0:098e992daf30 181
icis4 0:098e992daf30 182 BSP_LCD_SetTextColor(LCD_LOG_SOLID_BACKGROUND_COLOR);
icis4 0:098e992daf30 183 BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), LCD_LOG_HEADER_FONT.Height + 8);
icis4 0:098e992daf30 184
icis4 0:098e992daf30 185 /* Set the LCD Text Color */
icis4 0:098e992daf30 186 BSP_LCD_SetTextColor(LCD_LOG_SOLID_TEXT_COLOR);
icis4 0:098e992daf30 187 BSP_LCD_SetBackColor(LCD_LOG_SOLID_BACKGROUND_COLOR);
icis4 0:098e992daf30 188
icis4 0:098e992daf30 189 BSP_LCD_DisplayStringAt(0, LCD_LOG_HEADER_FONT.Height / 2, header, CENTER_MODE);
icis4 0:098e992daf30 190
icis4 0:098e992daf30 191 BSP_LCD_SetBackColor(LCD_LOG_BACKGROUND_COLOR);
icis4 0:098e992daf30 192 BSP_LCD_SetTextColor(LCD_LOG_TEXT_COLOR);
icis4 0:098e992daf30 193 BSP_LCD_SetFont (&LCD_LOG_TEXT_FONT);
icis4 0:098e992daf30 194 }
icis4 0:098e992daf30 195
icis4 0:098e992daf30 196 /**
icis4 0:098e992daf30 197 * @brief Display the application footer on the LCD screen
icis4 0:098e992daf30 198 * @param footer: pointer to the string to be displayed
icis4 0:098e992daf30 199 * @retval None
icis4 0:098e992daf30 200 */
icis4 0:098e992daf30 201 void LCD_LOG_SetFooter(uint8_t *footer)
icis4 0:098e992daf30 202 {
icis4 0:098e992daf30 203 /* Set the LCD Font */
icis4 0:098e992daf30 204 BSP_LCD_SetFont (&LCD_LOG_FOOTER_FONT);
icis4 0:098e992daf30 205
icis4 0:098e992daf30 206 BSP_LCD_SetTextColor(LCD_LOG_SOLID_BACKGROUND_COLOR);
icis4 0:098e992daf30 207 BSP_LCD_FillRect(0, BSP_LCD_GetYSize() - LCD_LOG_FOOTER_FONT.Height - 4, BSP_LCD_GetXSize(), LCD_LOG_FOOTER_FONT.Height + 4);
icis4 0:098e992daf30 208
icis4 0:098e992daf30 209 /* Set the LCD Text Color */
icis4 0:098e992daf30 210 BSP_LCD_SetTextColor(LCD_LOG_SOLID_TEXT_COLOR);
icis4 0:098e992daf30 211 BSP_LCD_SetBackColor(LCD_LOG_SOLID_BACKGROUND_COLOR);
icis4 0:098e992daf30 212
icis4 0:098e992daf30 213 BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - LCD_LOG_FOOTER_FONT.Height, footer, CENTER_MODE);
icis4 0:098e992daf30 214
icis4 0:098e992daf30 215 BSP_LCD_SetBackColor(LCD_LOG_BACKGROUND_COLOR);
icis4 0:098e992daf30 216 BSP_LCD_SetTextColor(LCD_LOG_TEXT_COLOR);
icis4 0:098e992daf30 217 BSP_LCD_SetFont (&LCD_LOG_TEXT_FONT);
icis4 0:098e992daf30 218 }
icis4 0:098e992daf30 219
icis4 0:098e992daf30 220 /**
icis4 0:098e992daf30 221 * @brief Clear the Text Zone
icis4 0:098e992daf30 222 * @param None
icis4 0:098e992daf30 223 * @retval None
icis4 0:098e992daf30 224 */
icis4 0:098e992daf30 225 void LCD_LOG_ClearTextZone(void)
icis4 0:098e992daf30 226 {
icis4 0:098e992daf30 227 uint8_t i=0;
icis4 0:098e992daf30 228
icis4 0:098e992daf30 229 for (i= 0 ; i < YWINDOW_SIZE; i++)
icis4 0:098e992daf30 230 {
icis4 0:098e992daf30 231 BSP_LCD_ClearStringLine(i + YWINDOW_MIN);
icis4 0:098e992daf30 232 }
icis4 0:098e992daf30 233
icis4 0:098e992daf30 234 LCD_LOG_DeInit();
icis4 0:098e992daf30 235 }
icis4 0:098e992daf30 236
icis4 0:098e992daf30 237 /**
icis4 0:098e992daf30 238 * @brief Redirect the printf to the LCD
icis4 0:098e992daf30 239 * @param c: character to be displayed
icis4 0:098e992daf30 240 * @param f: output file pointer
icis4 0:098e992daf30 241 * @retval None
icis4 0:098e992daf30 242 */
icis4 0:098e992daf30 243 LCD_LOG_PUTCHAR
icis4 0:098e992daf30 244 {
icis4 0:098e992daf30 245
icis4 0:098e992daf30 246 sFONT *cFont = BSP_LCD_GetFont();
icis4 0:098e992daf30 247 uint32_t idx;
icis4 0:098e992daf30 248
icis4 0:098e992daf30 249 if(LCD_Lock == DISABLE)
icis4 0:098e992daf30 250 {
icis4 0:098e992daf30 251 if(LCD_ScrollActive == ENABLE)
icis4 0:098e992daf30 252 {
icis4 0:098e992daf30 253 LCD_CacheBuffer_yptr_bottom = LCD_CacheBuffer_yptr_bottom_bak;
icis4 0:098e992daf30 254 LCD_CacheBuffer_yptr_top = LCD_CacheBuffer_yptr_top_bak;
icis4 0:098e992daf30 255 LCD_ScrollActive = DISABLE;
icis4 0:098e992daf30 256 LCD_Scrolled = DISABLE;
icis4 0:098e992daf30 257 LCD_ScrollBackStep = 0;
icis4 0:098e992daf30 258
icis4 0:098e992daf30 259 }
icis4 0:098e992daf30 260
icis4 0:098e992daf30 261 if(( LCD_CacheBuffer_xptr < (BSP_LCD_GetXSize()) /cFont->Width ) && ( ch != '\n'))
icis4 0:098e992daf30 262 {
icis4 0:098e992daf30 263 LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = (uint16_t)ch;
icis4 0:098e992daf30 264 }
icis4 0:098e992daf30 265 else
icis4 0:098e992daf30 266 {
icis4 0:098e992daf30 267 if(LCD_CacheBuffer_yptr_top >= LCD_CacheBuffer_yptr_bottom)
icis4 0:098e992daf30 268 {
icis4 0:098e992daf30 269
icis4 0:098e992daf30 270 if(LCD_CacheBuffer_yptr_invert == DISABLE)
icis4 0:098e992daf30 271 {
icis4 0:098e992daf30 272 LCD_CacheBuffer_yptr_top++;
icis4 0:098e992daf30 273
icis4 0:098e992daf30 274 if(LCD_CacheBuffer_yptr_top == LCD_CACHE_DEPTH)
icis4 0:098e992daf30 275 {
icis4 0:098e992daf30 276 LCD_CacheBuffer_yptr_top = 0;
icis4 0:098e992daf30 277 }
icis4 0:098e992daf30 278 }
icis4 0:098e992daf30 279 else
icis4 0:098e992daf30 280 {
icis4 0:098e992daf30 281 LCD_CacheBuffer_yptr_invert= DISABLE;
icis4 0:098e992daf30 282 }
icis4 0:098e992daf30 283 }
icis4 0:098e992daf30 284
icis4 0:098e992daf30 285 for(idx = LCD_CacheBuffer_xptr ; idx < (BSP_LCD_GetXSize()) /cFont->Width; idx++)
icis4 0:098e992daf30 286 {
icis4 0:098e992daf30 287 LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = ' ';
icis4 0:098e992daf30 288 }
icis4 0:098e992daf30 289 LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].color = LCD_LineColor;
icis4 0:098e992daf30 290
icis4 0:098e992daf30 291 LCD_CacheBuffer_xptr = 0;
icis4 0:098e992daf30 292
icis4 0:098e992daf30 293 LCD_LOG_UpdateDisplay ();
icis4 0:098e992daf30 294
icis4 0:098e992daf30 295 LCD_CacheBuffer_yptr_bottom ++;
icis4 0:098e992daf30 296
icis4 0:098e992daf30 297 if (LCD_CacheBuffer_yptr_bottom == LCD_CACHE_DEPTH)
icis4 0:098e992daf30 298 {
icis4 0:098e992daf30 299 LCD_CacheBuffer_yptr_bottom = 0;
icis4 0:098e992daf30 300 LCD_CacheBuffer_yptr_top = 1;
icis4 0:098e992daf30 301 LCD_CacheBuffer_yptr_invert = ENABLE;
icis4 0:098e992daf30 302 }
icis4 0:098e992daf30 303
icis4 0:098e992daf30 304 if( ch != '\n')
icis4 0:098e992daf30 305 {
icis4 0:098e992daf30 306 LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = (uint16_t)ch;
icis4 0:098e992daf30 307 }
icis4 0:098e992daf30 308
icis4 0:098e992daf30 309 }
icis4 0:098e992daf30 310 }
icis4 0:098e992daf30 311 return ch;
icis4 0:098e992daf30 312 }
icis4 0:098e992daf30 313
icis4 0:098e992daf30 314 /**
icis4 0:098e992daf30 315 * @brief Update the text area display
icis4 0:098e992daf30 316 * @param None
icis4 0:098e992daf30 317 * @retval None
icis4 0:098e992daf30 318 */
icis4 0:098e992daf30 319 void LCD_LOG_UpdateDisplay (void)
icis4 0:098e992daf30 320 {
icis4 0:098e992daf30 321 uint8_t cnt = 0 ;
icis4 0:098e992daf30 322 uint16_t length = 0 ;
icis4 0:098e992daf30 323 uint16_t ptr = 0, index = 0;
icis4 0:098e992daf30 324
icis4 0:098e992daf30 325 if((LCD_CacheBuffer_yptr_bottom < (YWINDOW_SIZE -1)) &&
icis4 0:098e992daf30 326 (LCD_CacheBuffer_yptr_bottom >= LCD_CacheBuffer_yptr_top))
icis4 0:098e992daf30 327 {
icis4 0:098e992daf30 328 BSP_LCD_SetTextColor(LCD_CacheBuffer[cnt + LCD_CacheBuffer_yptr_bottom].color);
icis4 0:098e992daf30 329 BSP_LCD_DisplayStringAtLine ((YWINDOW_MIN + LCD_CacheBuffer_yptr_bottom),
icis4 0:098e992daf30 330 (uint8_t *)(LCD_CacheBuffer[cnt + LCD_CacheBuffer_yptr_bottom].line));
icis4 0:098e992daf30 331 }
icis4 0:098e992daf30 332 else
icis4 0:098e992daf30 333 {
icis4 0:098e992daf30 334
icis4 0:098e992daf30 335 if(LCD_CacheBuffer_yptr_bottom < LCD_CacheBuffer_yptr_top)
icis4 0:098e992daf30 336 {
icis4 0:098e992daf30 337 /* Virtual length for rolling */
icis4 0:098e992daf30 338 length = LCD_CACHE_DEPTH + LCD_CacheBuffer_yptr_bottom ;
icis4 0:098e992daf30 339 }
icis4 0:098e992daf30 340 else
icis4 0:098e992daf30 341 {
icis4 0:098e992daf30 342 length = LCD_CacheBuffer_yptr_bottom;
icis4 0:098e992daf30 343 }
icis4 0:098e992daf30 344
icis4 0:098e992daf30 345 ptr = length - YWINDOW_SIZE + 1;
icis4 0:098e992daf30 346
icis4 0:098e992daf30 347 for (cnt = 0 ; cnt < YWINDOW_SIZE ; cnt ++)
icis4 0:098e992daf30 348 {
icis4 0:098e992daf30 349
icis4 0:098e992daf30 350 index = (cnt + ptr )% LCD_CACHE_DEPTH ;
icis4 0:098e992daf30 351
icis4 0:098e992daf30 352 BSP_LCD_SetTextColor(LCD_CacheBuffer[index].color);
icis4 0:098e992daf30 353 BSP_LCD_DisplayStringAtLine ((cnt + YWINDOW_MIN),
icis4 0:098e992daf30 354 (uint8_t *)(LCD_CacheBuffer[index].line));
icis4 0:098e992daf30 355
icis4 0:098e992daf30 356 }
icis4 0:098e992daf30 357 }
icis4 0:098e992daf30 358
icis4 0:098e992daf30 359 }
icis4 0:098e992daf30 360
icis4 0:098e992daf30 361 #if( LCD_SCROLL_ENABLED == 1)
icis4 0:098e992daf30 362 /**
icis4 0:098e992daf30 363 * @brief Display previous text frame
icis4 0:098e992daf30 364 * @param None
icis4 0:098e992daf30 365 * @retval Status
icis4 0:098e992daf30 366 */
icis4 0:098e992daf30 367 ErrorStatus LCD_LOG_ScrollBack(void)
icis4 0:098e992daf30 368 {
icis4 0:098e992daf30 369
icis4 0:098e992daf30 370 if(LCD_ScrollActive == DISABLE)
icis4 0:098e992daf30 371 {
icis4 0:098e992daf30 372
icis4 0:098e992daf30 373 LCD_CacheBuffer_yptr_bottom_bak = LCD_CacheBuffer_yptr_bottom;
icis4 0:098e992daf30 374 LCD_CacheBuffer_yptr_top_bak = LCD_CacheBuffer_yptr_top;
icis4 0:098e992daf30 375
icis4 0:098e992daf30 376
icis4 0:098e992daf30 377 if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
icis4 0:098e992daf30 378 {
icis4 0:098e992daf30 379
icis4 0:098e992daf30 380 if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) <= YWINDOW_SIZE)
icis4 0:098e992daf30 381 {
icis4 0:098e992daf30 382 LCD_Lock = DISABLE;
icis4 0:098e992daf30 383 return ERROR;
icis4 0:098e992daf30 384 }
icis4 0:098e992daf30 385 }
icis4 0:098e992daf30 386 LCD_ScrollActive = ENABLE;
icis4 0:098e992daf30 387
icis4 0:098e992daf30 388 if((LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)&&
icis4 0:098e992daf30 389 (LCD_Scrolled == DISABLE ))
icis4 0:098e992daf30 390 {
icis4 0:098e992daf30 391 LCD_CacheBuffer_yptr_bottom--;
icis4 0:098e992daf30 392 LCD_Scrolled = ENABLE;
icis4 0:098e992daf30 393 }
icis4 0:098e992daf30 394
icis4 0:098e992daf30 395 }
icis4 0:098e992daf30 396
icis4 0:098e992daf30 397 if(LCD_ScrollActive == ENABLE)
icis4 0:098e992daf30 398 {
icis4 0:098e992daf30 399 LCD_Lock = ENABLE;
icis4 0:098e992daf30 400
icis4 0:098e992daf30 401 if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
icis4 0:098e992daf30 402 {
icis4 0:098e992daf30 403
icis4 0:098e992daf30 404 if((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) < YWINDOW_SIZE )
icis4 0:098e992daf30 405 {
icis4 0:098e992daf30 406 LCD_Lock = DISABLE;
icis4 0:098e992daf30 407 return ERROR;
icis4 0:098e992daf30 408 }
icis4 0:098e992daf30 409
icis4 0:098e992daf30 410 LCD_CacheBuffer_yptr_bottom --;
icis4 0:098e992daf30 411 }
icis4 0:098e992daf30 412 else if(LCD_CacheBuffer_yptr_bottom <= LCD_CacheBuffer_yptr_top)
icis4 0:098e992daf30 413 {
icis4 0:098e992daf30 414
icis4 0:098e992daf30 415 if((LCD_CACHE_DEPTH - LCD_CacheBuffer_yptr_top + LCD_CacheBuffer_yptr_bottom) < YWINDOW_SIZE)
icis4 0:098e992daf30 416 {
icis4 0:098e992daf30 417 LCD_Lock = DISABLE;
icis4 0:098e992daf30 418 return ERROR;
icis4 0:098e992daf30 419 }
icis4 0:098e992daf30 420 LCD_CacheBuffer_yptr_bottom --;
icis4 0:098e992daf30 421
icis4 0:098e992daf30 422 if(LCD_CacheBuffer_yptr_bottom == 0xFFFF)
icis4 0:098e992daf30 423 {
icis4 0:098e992daf30 424 LCD_CacheBuffer_yptr_bottom = LCD_CACHE_DEPTH - 2;
icis4 0:098e992daf30 425 }
icis4 0:098e992daf30 426 }
icis4 0:098e992daf30 427 LCD_ScrollBackStep++;
icis4 0:098e992daf30 428 LCD_LOG_UpdateDisplay();
icis4 0:098e992daf30 429 LCD_Lock = DISABLE;
icis4 0:098e992daf30 430 }
icis4 0:098e992daf30 431 return SUCCESS;
icis4 0:098e992daf30 432 }
icis4 0:098e992daf30 433
icis4 0:098e992daf30 434 /**
icis4 0:098e992daf30 435 * @brief Display next text frame
icis4 0:098e992daf30 436 * @param None
icis4 0:098e992daf30 437 * @retval Status
icis4 0:098e992daf30 438 */
icis4 0:098e992daf30 439 ErrorStatus LCD_LOG_ScrollForward(void)
icis4 0:098e992daf30 440 {
icis4 0:098e992daf30 441
icis4 0:098e992daf30 442 if(LCD_ScrollBackStep != 0)
icis4 0:098e992daf30 443 {
icis4 0:098e992daf30 444 if(LCD_ScrollActive == DISABLE)
icis4 0:098e992daf30 445 {
icis4 0:098e992daf30 446
icis4 0:098e992daf30 447 LCD_CacheBuffer_yptr_bottom_bak = LCD_CacheBuffer_yptr_bottom;
icis4 0:098e992daf30 448 LCD_CacheBuffer_yptr_top_bak = LCD_CacheBuffer_yptr_top;
icis4 0:098e992daf30 449
icis4 0:098e992daf30 450 if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
icis4 0:098e992daf30 451 {
icis4 0:098e992daf30 452
icis4 0:098e992daf30 453 if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) <= YWINDOW_SIZE)
icis4 0:098e992daf30 454 {
icis4 0:098e992daf30 455 LCD_Lock = DISABLE;
icis4 0:098e992daf30 456 return ERROR;
icis4 0:098e992daf30 457 }
icis4 0:098e992daf30 458 }
icis4 0:098e992daf30 459 LCD_ScrollActive = ENABLE;
icis4 0:098e992daf30 460
icis4 0:098e992daf30 461 if((LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)&&
icis4 0:098e992daf30 462 (LCD_Scrolled == DISABLE ))
icis4 0:098e992daf30 463 {
icis4 0:098e992daf30 464 LCD_CacheBuffer_yptr_bottom--;
icis4 0:098e992daf30 465 LCD_Scrolled = ENABLE;
icis4 0:098e992daf30 466 }
icis4 0:098e992daf30 467
icis4 0:098e992daf30 468 }
icis4 0:098e992daf30 469
icis4 0:098e992daf30 470 if(LCD_ScrollActive == ENABLE)
icis4 0:098e992daf30 471 {
icis4 0:098e992daf30 472 LCD_Lock = ENABLE;
icis4 0:098e992daf30 473 LCD_ScrollBackStep--;
icis4 0:098e992daf30 474
icis4 0:098e992daf30 475 if(++LCD_CacheBuffer_yptr_bottom == LCD_CACHE_DEPTH)
icis4 0:098e992daf30 476 {
icis4 0:098e992daf30 477 LCD_CacheBuffer_yptr_bottom = 0;
icis4 0:098e992daf30 478 }
icis4 0:098e992daf30 479
icis4 0:098e992daf30 480 LCD_LOG_UpdateDisplay();
icis4 0:098e992daf30 481 LCD_Lock = DISABLE;
icis4 0:098e992daf30 482
icis4 0:098e992daf30 483 }
icis4 0:098e992daf30 484 return SUCCESS;
icis4 0:098e992daf30 485 }
icis4 0:098e992daf30 486 else // LCD_ScrollBackStep == 0
icis4 0:098e992daf30 487 {
icis4 0:098e992daf30 488 LCD_Lock = DISABLE;
icis4 0:098e992daf30 489 return ERROR;
icis4 0:098e992daf30 490 }
icis4 0:098e992daf30 491 }
icis4 0:098e992daf30 492 #endif /* LCD_SCROLL_ENABLED */
icis4 0:098e992daf30 493
icis4 0:098e992daf30 494 /**
icis4 0:098e992daf30 495 * @}
icis4 0:098e992daf30 496 */
icis4 0:098e992daf30 497
icis4 0:098e992daf30 498 /**
icis4 0:098e992daf30 499 * @}
icis4 0:098e992daf30 500 */
icis4 0:098e992daf30 501
icis4 0:098e992daf30 502 /**
icis4 0:098e992daf30 503 * @}
icis4 0:098e992daf30 504 */
icis4 0:098e992daf30 505
icis4 0:098e992daf30 506 /**
icis4 0:098e992daf30 507 * @}
icis4 0:098e992daf30 508 */
icis4 0:098e992daf30 509
icis4 0:098e992daf30 510 /**
icis4 0:098e992daf30 511 * @}
icis4 0:098e992daf30 512 */
icis4 0:098e992daf30 513
icis4 0:098e992daf30 514
icis4 0:098e992daf30 515 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
icis4 0:098e992daf30 516
icis4 0:098e992daf30 517