Goran Mahovlic
2 years ago
19 changed files with 13040 additions and 0 deletions
@ -0,0 +1,116 @@
|
||||
<!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 ST7789H2 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_2020.css" /> |
||||
<!--[if lt IE 9]> |
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> |
||||
<![endif]--> |
||||
<link rel="icon" type="image/x-icon" href="../../../../_htmresc/favicon.png" /> |
||||
</head> |
||||
<body> |
||||
<div class="row"> |
||||
<div class="col-sm-12 col-lg-4"> |
||||
<center> |
||||
<h1 id="release-notes-for">Release Notes for</h1> |
||||
<h1 id="st7789h2-component-drivers"><mark>ST7789H2 Component Drivers</mark></h1> |
||||
<p>Copyright © 2016 STMicroelectronics<br /> |
||||
</p> |
||||
<a href="https://www.st.com" class="logo"><img src="../../../../_htmresc/st_logo_2020.png" alt="ST logo" /></a> |
||||
</center> |
||||
<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 ST7789H2 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-section23" checked aria-hidden="true"> <label for="collapse-section23" aria-hidden="true">V1.1.4 / 29-January-2021</label> |
||||
<div> |
||||
<h2 id="main-changes">Main Changes</h2> |
||||
<ul> |
||||
<li>Remove useless assignment in ST7789H2_DrawHLine() and ST7789H2_DrawVLine() functions</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section22" aria-hidden="true"> <label for="collapse-section22" aria-hidden="true">V1.1.3 / 03-April-2019</label> |
||||
<div> |
||||
<h2 id="main-changes-1">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.2 / 31-August-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-section19" aria-hidden="true"> <label for="collapse-section19" aria-hidden="true">V1.1.1 / 29-December-2016</label> |
||||
<div> |
||||
<h2 id="main-changes-3">Main Changes</h2> |
||||
<ul> |
||||
<li>st7789h2.c/.h: |
||||
<ul> |
||||
<li>Change “\” by “/” in the include path to fix compilation issue under linux</li> |
||||
</ul></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.0 / 22-December-2016</label> |
||||
<div> |
||||
<h2 id="main-changes-4">Main Changes</h2> |
||||
<ul> |
||||
<li>st7789h2.c/.h: |
||||
<ul> |
||||
<li>Add 180° orientation support</li> |
||||
</ul></li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section18" aria-hidden="true"> <label for="collapse-section18" aria-hidden="true">V1.0.1 / 04-July-2016</label> |
||||
<div> |
||||
<h2 id="main-changes-5">Main Changes</h2> |
||||
<ul> |
||||
<li>st7789h2.c: |
||||
<ul> |
||||
<li>Update ST7789H2_DisplayOn()</li> |
||||
</ul></li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section17" aria-hidden="true"> <label for="collapse-section17" aria-hidden="true">V1.0.0 / 04-May-2016</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> |
@ -0,0 +1,707 @@
|
||||
/**
|
||||
****************************************************************************** |
||||
* @file st7789h2.c |
||||
* @author MCD Application Team |
||||
* @brief This file includes the LCD driver for st7789h2 LCD. |
||||
****************************************************************************** |
||||
* @attention |
||||
* |
||||
* <h2><center>© Copyright (c) 2016 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 "st7789h2.h" |
||||
|
||||
/** @addtogroup BSP
|
||||
* @{ |
||||
*/
|
||||
|
||||
/** @addtogroup Components
|
||||
* @{ |
||||
*/
|
||||
|
||||
/** @defgroup ST7789H2
|
||||
* @brief This file provides a set of functions needed to drive the
|
||||
* FRIDA FRD154BP2901 LCD. |
||||
* @{ |
||||
*/ |
||||
|
||||
/** @defgroup ST7789H2_Private_TypesDefinitions ST7789H2 Private TypesDefinitions
|
||||
* @{ |
||||
*/
|
||||
typedef struct { |
||||
uint8_t red; |
||||
uint8_t green; |
||||
uint8_t blue; |
||||
} ST7789H2_Rgb888; |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup ST7789H2_Private_Defines ST7789H2 Private Defines
|
||||
* @{ |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup ST7789H2_Private_Macros ST7789H2 Private Macros
|
||||
* @{ |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup ST7789H2_Private_Variables ST7789H2 Private Variables
|
||||
* @{ |
||||
*/
|
||||
LCD_DrvTypeDef ST7789H2_drv =
|
||||
{ |
||||
ST7789H2_Init, |
||||
ST7789H2_ReadID, |
||||
ST7789H2_DisplayOn, |
||||
ST7789H2_DisplayOff, |
||||
ST7789H2_SetCursor, |
||||
ST7789H2_WritePixel, |
||||
ST7789H2_ReadPixel, |
||||
ST7789H2_SetDisplayWindow, |
||||
ST7789H2_DrawHLine, |
||||
ST7789H2_DrawVLine, |
||||
ST7789H2_GetLcdPixelWidth, |
||||
ST7789H2_GetLcdPixelHeight, |
||||
ST7789H2_DrawBitmap, |
||||
ST7789H2_DrawRGBImage,
|
||||
}; |
||||
|
||||
static uint16_t WindowsXstart = 0; |
||||
static uint16_t WindowsYstart = 0; |
||||
static uint16_t WindowsXend = ST7789H2_LCD_PIXEL_WIDTH-1; |
||||
static uint16_t WindowsYend = ST7789H2_LCD_PIXEL_HEIGHT-1; |
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup ST7789H2_Private_FunctionPrototypes ST7789H2 Private FunctionPrototypes
|
||||
* @{ |
||||
*/ |
||||
static ST7789H2_Rgb888 ST7789H2_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos); |
||||
static void ST7789H2_DrawRGBHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint8_t *pdata); |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup ST7789H2_Private_Functions ST7789H2 Private Functions
|
||||
* @{ |
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Initialize the st7789h2 LCD Component. |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_Init(void) |
||||
{ |
||||
uint8_t parameter[14]; |
||||
|
||||
/* Initialize st7789h2 low level bus layer ----------------------------------*/ |
||||
LCD_IO_Init(); |
||||
/* Sleep In Command */
|
||||
ST7789H2_WriteReg(ST7789H2_SLEEP_IN, (uint8_t*)NULL, 0);
|
||||
/* Wait for 10ms */ |
||||
LCD_IO_Delay(10);
|
||||
|
||||
/* SW Reset Command */ |
||||
ST7789H2_WriteReg(0x01, (uint8_t*)NULL, 0);
|
||||
/* Wait for 200ms */ |
||||
LCD_IO_Delay(200); |
||||
|
||||
/* Sleep Out Command */ |
||||
ST7789H2_WriteReg(ST7789H2_SLEEP_OUT, (uint8_t*)NULL, 0);
|
||||
/* Wait for 120ms */ |
||||
LCD_IO_Delay(120);
|
||||
|
||||
/* Normal display for Driver Down side */ |
||||
parameter[0] = 0x00;
|
||||
ST7789H2_WriteReg(ST7789H2_NORMAL_DISPLAY, parameter, 1); |
||||
|
||||
/* Color mode 16bits/pixel */ |
||||
parameter[0] = 0x05;
|
||||
ST7789H2_WriteReg(ST7789H2_COLOR_MODE, parameter, 1); |
||||
|
||||
/* Display inversion On */ |
||||
ST7789H2_WriteReg(ST7789H2_DISPLAY_INVERSION, (uint8_t*)NULL, 0);
|
||||
|
||||
/* Set Column address CASET */
|
||||
parameter[0] = 0x00; |
||||
parameter[1] = 0x00; |
||||
parameter[2] = 0x00; |
||||
parameter[3] = 0xEF; |
||||
ST7789H2_WriteReg(ST7789H2_CASET, parameter, 4); |
||||
/* Set Row address RASET */
|
||||
parameter[0] = 0x00; |
||||
parameter[1] = 0x00; |
||||
parameter[2] = 0x00; |
||||
parameter[3] = 0xEF; |
||||
ST7789H2_WriteReg(ST7789H2_RASET, parameter, 4); |
||||
|
||||
/*--------------- ST7789H2 Frame rate setting -------------------------------*/ |
||||
/* PORCH control setting */
|
||||
parameter[0] = 0x0C; |
||||
parameter[1] = 0x0C; |
||||
parameter[2] = 0x00; |
||||
parameter[3] = 0x33; |
||||
parameter[4] = 0x33;
|
||||
ST7789H2_WriteReg(ST7789H2_PORCH_CTRL, parameter, 5); |
||||
|
||||
/* GATE control setting */ |
||||
parameter[0] = 0x35;
|
||||
ST7789H2_WriteReg(ST7789H2_GATE_CTRL, parameter, 1); |
||||
|
||||
/*--------------- ST7789H2 Power setting ------------------------------------*/ |
||||
/* VCOM setting */
|
||||
parameter[0] = 0x1F;
|
||||
ST7789H2_WriteReg(ST7789H2_VCOM_SET, parameter, 1);
|
||||
|
||||
/* LCM Control setting */
|
||||
parameter[0] = 0x2C;
|
||||
ST7789H2_WriteReg(ST7789H2_LCM_CTRL, parameter, 1); |
||||
|
||||
/* VDV and VRH Command Enable */
|
||||
parameter[0] = 0x01; |
||||
parameter[1] = 0xC3; |
||||
ST7789H2_WriteReg(ST7789H2_VDV_VRH_EN, parameter, 2); |
||||
|
||||
/* VDV Set */
|
||||
parameter[0] = 0x20;
|
||||
ST7789H2_WriteReg(ST7789H2_VDV_SET, parameter, 1);
|
||||
|
||||
/* Frame Rate Control in normal mode */
|
||||
parameter[0] = 0x0F;
|
||||
ST7789H2_WriteReg(ST7789H2_FR_CTRL, parameter, 1);
|
||||
|
||||
/* Power Control */
|
||||
parameter[0] = 0xA4; |
||||
parameter[1] = 0xA1; |
||||
ST7789H2_WriteReg(ST7789H2_POWER_CTRL, parameter, 2);
|
||||
|
||||
/*--------------- ST7789H2 Gamma setting ------------------------------------*/ |
||||
/* Positive Voltage Gamma Control */
|
||||
parameter[0] = 0xD0; |
||||
parameter[1] = 0x08; |
||||
parameter[2] = 0x11; |
||||
parameter[3] = 0x08; |
||||
parameter[4] = 0x0C; |
||||
parameter[5] = 0x15; |
||||
parameter[6] = 0x39; |
||||
parameter[7] = 0x33; |
||||
parameter[8] = 0x50; |
||||
parameter[9] = 0x36; |
||||
parameter[10] = 0x13; |
||||
parameter[11] = 0x14; |
||||
parameter[12] = 0x29; |
||||
parameter[13] = 0x2D; |
||||
ST7789H2_WriteReg(ST7789H2_PV_GAMMA_CTRL, parameter, 14);
|
||||
|
||||
/* Negative Voltage Gamma Control */
|
||||
parameter[0] = 0xD0; |
||||
parameter[1] = 0x08; |
||||
parameter[2] = 0x10; |
||||
parameter[3] = 0x08; |
||||
parameter[4] = 0x06; |
||||
parameter[5] = 0x06; |
||||
parameter[6] = 0x39; |
||||
parameter[7] = 0x44; |
||||
parameter[8] = 0x51; |
||||
parameter[9] = 0x0B; |
||||
parameter[10] = 0x16; |
||||
parameter[11] = 0x14; |
||||
parameter[12] = 0x2F; |
||||
parameter[13] = 0x31; |
||||
ST7789H2_WriteReg(ST7789H2_NV_GAMMA_CTRL, parameter, 14);
|
||||
|
||||
/* Display ON command */ |
||||
ST7789H2_DisplayOn();
|
||||
|
||||
/* Tearing Effect Line On: Option (00h:VSYNC Interface OFF, 01h:VSYNC Interface ON) */ |
||||
parameter[0] = 0x00;
|
||||
ST7789H2_WriteReg(ST7789H2_TEARING_EFFECT, parameter, 1); |
||||
|
||||
} |
||||
|
||||
/**
|
||||
* @brief Set the Display Orientation. |
||||
* @param orientation: ST7789H2_ORIENTATION_PORTRAIT, ST7789H2_ORIENTATION_LANDSCAPE |
||||
* or ST7789H2_ORIENTATION_LANDSCAPE_ROT180
|
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_SetOrientation(uint32_t orientation) |
||||
{ |
||||
uint8_t parameter[6]; |
||||
|
||||
if(orientation == ST7789H2_ORIENTATION_LANDSCAPE) |
||||
{ |
||||
parameter[0] = 0x00;
|
||||
} |
||||
else if(orientation == ST7789H2_ORIENTATION_LANDSCAPE_ROT180) |
||||
{ |
||||
/* Vertical Scrolling Definition */ |
||||
/* TFA describes the Top Fixed Area */ |
||||
parameter[0] = 0x00; |
||||
parameter[1] = 0x00; |
||||
/* VSA describes the height of the Vertical Scrolling Area */ |
||||
parameter[2] = 0x01; |
||||
parameter[3] = 0xF0; |
||||
/* BFA describes the Bottom Fixed Area */ |
||||
parameter[4] = 0x00; |
||||
parameter[5] = 0x00;
|
||||
ST7789H2_WriteReg(ST7789H2_VSCRDEF, parameter, 6); |
||||
|
||||
/* Vertical Scroll Start Address of RAM */ |
||||
/* GRAM row nbr (320) - Display row nbr (240) = 80 = 0x50 */ |
||||
parameter[0] = 0x00; |
||||
parameter[1] = 0x50; |
||||
ST7789H2_WriteReg(ST7789H2_VSCSAD, parameter, 2); |
||||
|
||||
parameter[0] = 0xC0;
|
||||
} |
||||
else |
||||
{ |
||||
parameter[0] = 0x60;
|
||||
} |
||||
ST7789H2_WriteReg(ST7789H2_NORMAL_DISPLAY, parameter, 1); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Enables the Display. |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_DisplayOn(void) |
||||
{ |
||||
/* Display ON command */ |
||||
ST7789H2_WriteReg(ST7789H2_DISPLAY_ON, (uint8_t*)NULL, 0); |
||||
|
||||
/* Sleep Out command */ |
||||
ST7789H2_WriteReg(ST7789H2_SLEEP_OUT, (uint8_t*)NULL, 0); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Disables the Display. |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_DisplayOff(void) |
||||
{ |
||||
uint8_t parameter[1]; |
||||
parameter[0] = 0xFE; |
||||
/* Display OFF command */ |
||||
ST7789H2_WriteReg(ST7789H2_DISPLAY_OFF, parameter, 1);
|
||||
/* Sleep In Command */ |
||||
ST7789H2_WriteReg(ST7789H2_SLEEP_IN, (uint8_t*)NULL, 0);
|
||||
/* Wait for 10ms */ |
||||
LCD_IO_Delay(10);
|
||||
} |
||||
|
||||
/**
|
||||
* @brief Get the LCD pixel Width. |
||||
* @param None |
||||
* @retval The Lcd Pixel Width |
||||
*/ |
||||
uint16_t ST7789H2_GetLcdPixelWidth(void) |
||||
{ |
||||
return (uint16_t)ST7789H2_LCD_PIXEL_WIDTH; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Get the LCD pixel Height. |
||||
* @param None |
||||
* @retval The Lcd Pixel Height |
||||
*/ |
||||
uint16_t ST7789H2_GetLcdPixelHeight(void) |
||||
{ |
||||
return (uint16_t)ST7789H2_LCD_PIXEL_HEIGHT; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Get the st7789h2 ID. |
||||
* @param None |
||||
* @retval The st7789h2 ID
|
||||
*/ |
||||
uint16_t ST7789H2_ReadID(void) |
||||
{ |
||||
LCD_IO_Init(); |
||||
|
||||
return ST7789H2_ReadReg(ST7789H2_LCD_ID); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Set Cursor position. |
||||
* @param Xpos: specifies the X position. |
||||
* @param Ypos: specifies the Y position. |
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_SetCursor(uint16_t Xpos, uint16_t Ypos) |
||||
{ |
||||
uint8_t parameter[4]; |
||||
/* CASET: Comumn Addrses Set */ |
||||
parameter[0] = 0x00;
|
||||
parameter[1] = 0x00 + Xpos; |
||||
parameter[2] = 0x00; |
||||
parameter[3] = 0xEF + Xpos; |
||||
ST7789H2_WriteReg(ST7789H2_CASET, parameter, 4); |
||||
/* RASET: Row Addrses Set */
|
||||
parameter[0] = 0x00; |
||||
parameter[1] = 0x00 + Ypos; |
||||
parameter[2] = 0x00; |
||||
parameter[3] = 0xEF + Ypos; |
||||
ST7789H2_WriteReg(ST7789H2_RASET, parameter, 4); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Write pixel.
|
||||
* @param Xpos: specifies the X position. |
||||
* @param Ypos: specifies the Y position. |
||||
* @param RGBCode: the RGB pixel color in RGB565 format |
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode) |
||||
{ |
||||
/* Set Cursor */ |
||||
ST7789H2_SetCursor(Xpos, Ypos); |
||||
|
||||
/* Prepare to write to LCD RAM */ |
||||
ST7789H2_WriteReg(ST7789H2_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */ |
||||
|
||||
/* Write RAM data */ |
||||
LCD_IO_WriteData(RGBCode); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Read pixel. |
||||
* @param Xpos: specifies the X position. |
||||
* @param Ypos: specifies the Y position. |
||||
* @retval The RGB pixel color in RGB565 format |
||||
*/ |
||||
uint16_t ST7789H2_ReadPixel(uint16_t Xpos, uint16_t Ypos) |
||||
{ |
||||
ST7789H2_Rgb888 rgb888; |
||||
uint8_t r, g, b; |
||||
uint16_t rgb565; |
||||
|
||||
/* Set Cursor */ |
||||
ST7789H2_SetCursor(Xpos, Ypos); |
||||
|
||||
/* Read RGB888 data from LCD RAM */ |
||||
rgb888 = ST7789H2_ReadPixel_rgb888(Xpos, Ypos); |
||||
|
||||
/* Convert RGB888 to RGB565 */ |
||||
r = ((rgb888.red & 0xF8) >> 3); /* Extract the red component 5 most significant bits */ |
||||
g = ((rgb888.green & 0xFC) >> 2); /* Extract the green component 6 most significant bits */ |
||||
b = ((rgb888.blue & 0xF8) >> 3); /* Extract the blue component 5 most significant bits */ |
||||
|
||||
rgb565 = ((uint16_t)(r) << 11) + ((uint16_t)(g) << 5) + ((uint16_t)(b) << 0); |
||||
|
||||
return (rgb565); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Writes to the selected LCD register. |
||||
* @param Command: command value (or register address as named in st7789h2 doc). |
||||
* @param Parameters: pointer on parameters value (if command uses one or several parameters). |
||||
* @param NbParameters: number of command parameters (0 if no parameter) |
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters) |
||||
{ |
||||
uint8_t i; |
||||
|
||||
/* Send command */ |
||||
LCD_IO_WriteReg(Command); |
||||
|
||||
/* Send command's parameters if any */ |
||||
for (i=0; i<NbParameters; i++) |
||||
{ |
||||
LCD_IO_WriteData(Parameters[i]); |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Reads the selected LCD Register. |
||||
* @param Command: command value (or register address as named in st7789h2 doc). |
||||
* @retval Register Value. |
||||
*/ |
||||
uint8_t ST7789H2_ReadReg(uint8_t Command) |
||||
{ |
||||
/* Send command */ |
||||
LCD_IO_WriteReg(Command); |
||||
|
||||
/* Read dummy data */ |
||||
LCD_IO_ReadData(); |
||||
|
||||
/* Read register value */ |
||||
return (LCD_IO_ReadData()); |
||||
} |
||||
|
||||
/**
|
||||
* @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 ST7789H2_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height) |
||||
{ |
||||
if (Xpos < ST7789H2_LCD_PIXEL_WIDTH) |
||||
{ |
||||
WindowsXstart = Xpos; |
||||
} |
||||
else |
||||
{ |
||||
WindowsXstart = 0; |
||||
} |
||||
|
||||
if (Ypos < ST7789H2_LCD_PIXEL_HEIGHT) |
||||
{ |
||||
WindowsYstart = Ypos; |
||||
} |
||||
else |
||||
{ |
||||
WindowsYstart = 0; |
||||
} |
||||
|
||||
if (Width + Xpos <= ST7789H2_LCD_PIXEL_WIDTH) |
||||
{ |
||||
WindowsXend = Width + Xpos - 1; |
||||
} |
||||
else |
||||
{ |
||||
WindowsXend = ST7789H2_LCD_PIXEL_WIDTH - 1; |
||||
} |
||||
|
||||
if (Height + Ypos <= ST7789H2_LCD_PIXEL_HEIGHT) |
||||
{ |
||||
WindowsYend = Height + Ypos - 1; |
||||
} |
||||
else |
||||
{ |
||||
WindowsYend = ST7789H2_LCD_PIXEL_HEIGHT-1; |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Draw vertical line. |
||||
* @param RGBCode: Specifies the RGB color in RGB565 format |
||||
* @param Xpos: specifies the X position. |
||||
* @param Ypos: specifies the Y position. |
||||
* @param Length: specifies the Line length.
|
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length) |
||||
{ |
||||
uint16_t counter; |
||||
|
||||
/* Set Cursor */ |
||||
ST7789H2_SetCursor(Xpos, Ypos);
|
||||
|
||||
/* Prepare to write to LCD RAM */ |
||||
ST7789H2_WriteReg(ST7789H2_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */ |
||||
|
||||
/* Sent a complete line */ |
||||
for(counter = 0; counter < Length; counter++) |
||||
{ |
||||
LCD_IO_WriteData(RGBCode); |
||||
}
|
||||
} |
||||
|
||||
/**
|
||||
* @brief Draw 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 ST7789H2_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length) |
||||
{ |
||||
uint16_t counter; |
||||
|
||||
/* Set Cursor */ |
||||
ST7789H2_SetCursor(Xpos, Ypos); |
||||
|
||||
/* Prepare to write to LCD RAM */ |
||||
ST7789H2_WriteReg(ST7789H2_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */ |
||||
|
||||
/* Fill a complete vertical line */ |
||||
for(counter = 0; counter < Length; counter++) |
||||
{ |
||||
ST7789H2_WritePixel(Xpos, Ypos + counter, RGBCode); |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Displays a bitmap picture. |
||||
* @param BmpAddress: Bmp picture address. |
||||
* @param Xpos: Bmp X position in the LCD |
||||
* @param Ypos: Bmp Y position in the LCD
|
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp) |
||||
{ |
||||
uint32_t index = 0, size = 0; |
||||
uint32_t posY; |
||||
uint32_t nb_line = 0; |
||||
uint16_t Xsize = WindowsXend - WindowsXstart + 1; |
||||
uint16_t Ysize = WindowsYend - WindowsYstart + 1; |
||||
|
||||
/* 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; |
||||
|
||||
for (posY = (Ypos + Ysize); posY > Ypos; posY--) /* In BMP files the line order is inverted */ |
||||
{ |
||||
/* Set Cursor */ |
||||
ST7789H2_SetCursor(Xpos, posY - 1); |
||||
|
||||
/* Draw one line of the picture */ |
||||
ST7789H2_DrawRGBHLine(Xpos, posY - 1, Xsize, (pbmp + (nb_line * Xsize * 2))); |
||||
nb_line++; |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Displays picture. |
||||
* @param pdata: picture address. |
||||
* @param Xpos: Image X position in the LCD |
||||
* @param Ypos: Image Y position in the LCD |
||||
* @param Xsize: Image X size in the LCD |
||||
* @param Ysize: Image Y size in the LCD |
||||
* @retval None |
||||
*/ |
||||
void ST7789H2_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata) |
||||
{ |
||||
uint32_t posY; |
||||
uint32_t nb_line = 0; |
||||
|
||||
for (posY = Ypos; posY < (Ypos + Ysize); posY ++) |
||||
{ |
||||
/* Set Cursor */ |
||||
ST7789H2_SetCursor(Xpos, posY); |
||||
|
||||
/* Draw one line of the picture */ |
||||
ST7789H2_DrawRGBHLine(Xpos, posY, Xsize, (pdata + (nb_line * Xsize * 2))); |
||||
nb_line++; |
||||
} |
||||
} |
||||
|
||||
|
||||
/******************************************************************************
|
||||
Static Functions |
||||
*******************************************************************************/ |
||||
|
||||
/**
|
||||
* @brief Read pixel from LCD RAM in RGB888 format |
||||
* @param Xpos: specifies the X position. |
||||
* @param Ypos: specifies the Y position. |
||||
* @retval Each RGB pixel color components in a structure |
||||
*/ |
||||
static ST7789H2_Rgb888 ST7789H2_ReadPixel_rgb888(uint16_t Xpos, uint16_t Ypos) |
||||
{ |
||||
ST7789H2_Rgb888 rgb888; |
||||
uint16_t rgb888_part1, rgb888_part2; |
||||
|
||||
/* In LCD RAM, pixels are 24 bits packed and read with 16 bits access
|
||||
* Here is the pixels components arrangement in memory : |
||||
* bits: 15 14 13 12 11 10 09 08 | 07 06 05 04 03 02 01 00 |
||||
* address 0 : red pixel 0 X X | green pixel 0 X X |
||||
* address 1 : blue pixel 0 X X | red pixel 1 X X |
||||
* address 2 : green pixel 1 X X | blue pixel 1 X X |
||||
*/ |
||||
|
||||
/* Set Cursor */ |
||||
ST7789H2_SetCursor(Xpos, Ypos); |
||||
/* Prepare to read LCD RAM */ |
||||
ST7789H2_WriteReg(ST7789H2_READ_RAM, (uint8_t*)NULL, 0); /* RAM read data command */ |
||||
/* Dummy read */ |
||||
LCD_IO_ReadData(); |
||||
/* Read first part of the RGB888 data */ |
||||
rgb888_part1 = LCD_IO_ReadData(); |
||||
/* Read first part of the RGB888 data */ |
||||
rgb888_part2 = LCD_IO_ReadData(); |
||||
|
||||
/* red component */ |
||||
rgb888.red = (rgb888_part1 & 0xFC00) >> 8; |
||||
/* green component */ |
||||
rgb888.green = (rgb888_part1 & 0x00FC) >> 0; |
||||
/* blue component */ |
||||
rgb888.blue = (rgb888_part2 & 0xFC00) >> 8; |
||||
|
||||
return rgb888; |
||||
} |
||||
|
||||
|
||||
/**
|
||||
* @brief Displays a single picture line. |
||||
* @param pdata: picture address. |
||||
* @param Xpos: Image X position in the LCD |
||||
* @param Ypos: Image Y position in the LCD |
||||
* @param Xsize: Image X size in the LCD |
||||
* @retval None |
||||
*/ |
||||
static void ST7789H2_DrawRGBHLine(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint8_t *pdata) |
||||
{ |
||||
uint32_t i = 0; |
||||
uint32_t posX; |
||||
uint16_t *rgb565 = (uint16_t*)pdata; |
||||
|
||||
/* Prepare to write to LCD RAM */ |
||||
ST7789H2_WriteReg(ST7789H2_WRITE_RAM, (uint8_t*)NULL, 0); /* RAM write data command */ |
||||
|
||||
for (posX = Xpos; posX < (Xsize + Xpos); posX++) |
||||
{ |
||||
if ((posX >= WindowsXstart) && (Ypos >= WindowsYstart) && /* Check we are in the defined window */ |
||||
(posX <= WindowsXend) && (Ypos <= WindowsYend)) |
||||
{ |
||||
if (posX != (Xsize + Xpos)) /* When writing last pixel when size is odd, the third part is not written */ |
||||
{ |
||||
LCD_IO_WriteData(rgb565[i]);
|
||||
}
|
||||
i++; |
||||
} |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,172 @@
|
||||
/**
|
||||
****************************************************************************** |
||||
* @file st7789h2.h |
||||
* @author MCD Application Team |
||||
* @brief This file contains all the functions prototypes for the st7789h2.c |
||||
* driver. |
||||
****************************************************************************** |
||||
* @attention |
||||
* |
||||
* <h2><center>© Copyright (c) 2016 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 __ST7789H2_H |
||||
#define __ST7789H2_H |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include <stdio.h> |
||||
#include "../Common/lcd.h" |
||||
|
||||
/** @addtogroup BSP
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup Components
|
||||
* @{ |
||||
*/
|
||||
|
||||
/** @addtogroup ST7789H2
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @defgroup ST7789H2_Exported_Types ST7789H2 Exported Types
|
||||
* @{ |
||||
*/ |
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/** @defgroup ST7789H2_Exported_Constants ST7789H2 Exported Constants
|
||||
* @{ |
||||
*/ |
||||
/**
|
||||
* @brief ST7789H2 ID
|
||||
*/ |
||||
#define ST7789H2_ID 0x85 |
||||
|
||||
/**
|
||||
* @brief ST7789H2 Size
|
||||
*/ |
||||
#define ST7789H2_LCD_PIXEL_WIDTH ((uint16_t)240) |
||||
#define ST7789H2_LCD_PIXEL_HEIGHT ((uint16_t)240) |
||||
|
||||
/**
|
||||
* @brief LCD_OrientationTypeDef |
||||
* Possible values of Display Orientation |
||||
*/ |
||||
#define ST7789H2_ORIENTATION_PORTRAIT ((uint32_t)0x00) /* Portrait orientation choice of LCD screen */ |
||||
#define ST7789H2_ORIENTATION_LANDSCAPE ((uint32_t)0x01) /* Landscape orientation choice of LCD screen */ |
||||
#define ST7789H2_ORIENTATION_LANDSCAPE_ROT180 ((uint32_t)0x02) /* Landscape rotated 180° orientation choice of LCD screen */ |
||||
|
||||
/**
|
||||
* @brief ST7789H2 Registers
|
||||
*/ |
||||
#define ST7789H2_LCD_ID 0x04 |
||||
#define ST7789H2_SLEEP_IN 0x10 |
||||
#define ST7789H2_SLEEP_OUT 0x11 |
||||
#define ST7789H2_PARTIAL_DISPLAY 0x12 |
||||
#define ST7789H2_DISPLAY_INVERSION 0x21 |
||||
#define ST7789H2_DISPLAY_ON 0x29 |
||||
#define ST7789H2_WRITE_RAM 0x2C |
||||
#define ST7789H2_READ_RAM 0x2E |
||||
#define ST7789H2_CASET 0x2A |
||||
#define ST7789H2_RASET 0x2B |
||||
#define ST7789H2_VSCRDEF 0x33 /* Vertical Scroll Definition */ |
||||
#define ST7789H2_VSCSAD 0x37 /* Vertical Scroll Start Address of RAM */ |
||||
#define ST7789H2_TEARING_EFFECT 0x35 |
||||
#define ST7789H2_NORMAL_DISPLAY 0x36 |
||||
#define ST7789H2_IDLE_MODE_OFF 0x38 |
||||
#define ST7789H2_IDLE_MODE_ON 0x39 |
||||
#define ST7789H2_COLOR_MODE 0x3A |
||||
#define ST7789H2_WRCABCMB 0x5E /* Write Content Adaptive Brightness Control */ |
||||
#define ST7789H2_RDCABCMB 0x5F /* Read Content Adaptive Brightness Control */ |
||||
#define ST7789H2_PORCH_CTRL 0xB2 |
||||
#define ST7789H2_GATE_CTRL 0xB7 |
||||
#define ST7789H2_VCOM_SET 0xBB |
||||
#define ST7789H2_DISPLAY_OFF 0xBD |
||||
#define ST7789H2_LCM_CTRL 0xC0 |
||||
#define ST7789H2_VDV_VRH_EN 0xC2 |
||||
#define ST7789H2_VDV_SET 0xC4 |
||||
#define ST7789H2_VCOMH_OFFSET_SET 0xC5 |
||||
#define ST7789H2_FR_CTRL 0xC6 |
||||
#define ST7789H2_POWER_CTRL 0xD0 |
||||
#define ST7789H2_PV_GAMMA_CTRL 0xE0 |
||||
#define ST7789H2_NV_GAMMA_CTRL 0xE1 |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/** @defgroup ST7789H2_Exported_Functions ST7789H2 Exported Functions
|
||||
* @{ |
||||
*/
|
||||
void ST7789H2_Init(void); |
||||
void ST7789H2_SetOrientation(uint32_t orientation); |
||||
uint16_t ST7789H2_ReadID(void); |
||||
void ST7789H2_WriteReg(uint8_t Command, uint8_t *Parameters, uint8_t NbParameters); |
||||
uint8_t ST7789H2_ReadReg(uint8_t Command); |
||||
|
||||
void ST7789H2_DisplayOn(void); |
||||
void ST7789H2_DisplayOff(void); |
||||
void ST7789H2_SetCursor(uint16_t Xpos, uint16_t Ypos); |
||||
void ST7789H2_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode); |
||||
uint16_t ST7789H2_ReadPixel(uint16_t Xpos, uint16_t Ypos); |
||||
|
||||
void ST7789H2_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length); |
||||
void ST7789H2_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length); |
||||
void ST7789H2_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp); |
||||
void ST7789H2_DrawRGBImage(uint16_t Xpos, uint16_t Ypos, uint16_t Xsize, uint16_t Ysize, uint8_t *pdata); |
||||
|
||||
void ST7789H2_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height); |
||||
|
||||
|
||||
uint16_t ST7789H2_GetLcdPixelWidth(void); |
||||
uint16_t ST7789H2_GetLcdPixelHeight(void); |
||||
|
||||
/* LCD driver structure */ |
||||
extern LCD_DrvTypeDef ST7789H2_drv; |
||||
|
||||
/* LCD IO functions */ |
||||
extern void LCD_IO_Init(void); |
||||
extern void LCD_IO_WriteMultipleData(uint16_t *pData, uint32_t Size); |
||||
extern void LCD_IO_WriteReg(uint8_t Reg); |
||||
extern void LCD_IO_WriteData(uint16_t RegValue); |
||||
extern uint16_t LCD_IO_ReadData(void); |
||||
extern void LCD_IO_Delay(uint32_t delay); |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* __ST7789H2_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,82 @@
|
||||
<!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 STM32Cube CPU Utilities Driver</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-stm32cube-cpu-utilities-driver"><small>Release Notes for</small> <mark>STM32Cube CPU Utilities Driver</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 driver for STM32Cube CPU Utilities.</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-section4" checked aria-hidden="true"> <label for="collapse-section4" aria-hidden="true">V1.1.2 / 30-October-2019</label> |
||||
<div> |
||||
<h2 id="changes">Changes</h2> |
||||
<ul> |
||||
<li>Update st_logo.png inclusion path in Release notes</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section3" checked aria-hidden="true"> <label for="collapse-section3" aria-hidden="true">V1.1.1 / 03-April-2019</label> |
||||
<div> |
||||
<h2 id="changes-1">Changes</h2> |
||||
<ul> |
||||
<li>Update header with new licensing format</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section2" aria-hidden="true"> <label for="collapse-section2" aria-hidden="true">V1.1.0 / 20-November-2014</label> |
||||
<div> |
||||
<h2 id="changes-2">Changes</h2> |
||||
<ul> |
||||
<li>Update some APIs to be in line with FreeRTOS V8.1.2</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section1" aria-hidden="true"> <label for="collapse-section1" aria-hidden="true">V1.0.0 / 18-February-2014</label> |
||||
<div> |
||||
<h2 id="changes-3">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> |
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 18 KiB |
@ -0,0 +1,126 @@
|
||||
/**
|
||||
****************************************************************************** |
||||
* @file cpu_utils.c |
||||
* @author MCD Application Team |
||||
* @brief Utilities for CPU Load calculation |
||||
****************************************************************************** |
||||
* @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 |
||||
* |
||||
****************************************************************************** |
||||
*/ |
||||
|
||||
/********************** NOTES **********************************************
|
||||
To use this module, the following steps should be followed : |
||||
|
||||
1- in the _OS_Config.h file (ex. FreeRTOSConfig.h) enable the following macros : |
||||
- #define configUSE_IDLE_HOOK 1 |
||||
- #define configUSE_TICK_HOOK 1 |
||||
|
||||
2- in the _OS_Config.h define the following macros : |
||||
- #define traceTASK_SWITCHED_IN() extern void StartIdleMonitor(void); \
|
||||
StartIdleMonitor() |
||||
- #define traceTASK_SWITCHED_OUT() extern void EndIdleMonitor(void); \
|
||||
EndIdleMonitor() |
||||
*******************************************************************************/ |
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "cpu_utils.h" |
||||
|
||||
/* Private typedef -----------------------------------------------------------*/ |
||||
/* Private define ------------------------------------------------------------*/ |
||||
/* Private macro -------------------------------------------------------------*/ |
||||
/* Private function prototypes -----------------------------------------------*/ |
||||
/* Private variables ---------------------------------------------------------*/ |
||||
|
||||
xTaskHandle xIdleHandle = NULL; |
||||
__IO uint32_t osCPU_Usage = 0; |
||||
uint32_t osCPU_IdleStartTime = 0; |
||||
uint32_t osCPU_IdleSpentTime = 0; |
||||
uint32_t osCPU_TotalIdleTime = 0; |
||||
|
||||
/* Private functions ---------------------------------------------------------*/ |
||||
/**
|
||||
* @brief Application Idle Hook |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void vApplicationIdleHook(void) |
||||
{ |
||||
if( xIdleHandle == NULL ) |
||||
{ |
||||
/* Store the handle to the idle task. */ |
||||
xIdleHandle = xTaskGetCurrentTaskHandle(); |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Application Idle Hook |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void vApplicationTickHook (void) |
||||
{ |
||||
static int tick = 0; |
||||
|
||||
if(tick ++ > CALCULATION_PERIOD) |
||||
{ |
||||
tick = 0; |
||||
|
||||
if(osCPU_TotalIdleTime > 1000) |
||||
{ |
||||
osCPU_TotalIdleTime = 1000; |
||||
} |
||||
osCPU_Usage = (100 - (osCPU_TotalIdleTime * 100) / CALCULATION_PERIOD); |
||||
osCPU_TotalIdleTime = 0; |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Start Idle monitor |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void StartIdleMonitor (void) |
||||
{ |
||||
if( xTaskGetCurrentTaskHandle() == xIdleHandle ) |
||||
{ |
||||
osCPU_IdleStartTime = xTaskGetTickCountFromISR(); |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Stop Idle monitor |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void EndIdleMonitor (void) |
||||
{ |
||||
if( xTaskGetCurrentTaskHandle() == xIdleHandle ) |
||||
{ |
||||
/* Store the handle to the idle task. */ |
||||
osCPU_IdleSpentTime = xTaskGetTickCountFromISR() - osCPU_IdleStartTime; |
||||
osCPU_TotalIdleTime += osCPU_IdleSpentTime; |
||||
} |
||||
} |
||||
|
||||
/**
|
||||
* @brief Stop Idle monitor |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
uint16_t osGetCPUUsage (void) |
||||
{ |
||||
return (uint16_t)osCPU_Usage; |
||||
} |
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,46 @@
|
||||
/**
|
||||
****************************************************************************** |
||||
* @file cpu_utils.h |
||||
* @author MCD Application Team |
||||
* @brief Header for cpu_utils module |
||||
****************************************************************************** |
||||
* @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 _CPU_UTILS_H__ |
||||
#define _CPU_UTILS_H__ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "main.h" |
||||
|
||||
/* Exported types ------------------------------------------------------------*/ |
||||
/* Exported constants --------------------------------------------------------*/ |
||||
/* Exported variables --------------------------------------------------------*/ |
||||
/* Exported macro ------------------------------------------------------------*/ |
||||
#define CALCULATION_PERIOD 1000 |
||||
|
||||
/* Exported functions ------------------------------------------------------- */ |
||||
uint16_t osGetCPUUsage (void); |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _CPU_UTILS_H__ */ |
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,64 @@
|
||||
<!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 STM32Cube Fonts Utilities Driver</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-stm32cube-fonts-utilities-driver"><small>Release Notes for</small> <mark>STM32Cube Fonts Utilities Driver</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 driver for STM32Cube Fonts Utilities.</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-section2" checked aria-hidden="true"> <label for="collapse-section2" aria-hidden="true">V1.0.1 / 03-April-2019</label> |
||||
<div> |
||||
<h2 id="changes">Changes</h2> |
||||
<ul> |
||||
<li>Update release notes to new format</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section1" aria-hidden="true"> <label for="collapse-section1" aria-hidden="true">V1.0.0 / 18-February-2014</label> |
||||
<div> |
||||
<h2 id="changes-1">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> |
@ -0,0 +1,116 @@
|
||||
/**
|
||||
****************************************************************************** |
||||
* @file fonts.h |
||||
* @author MCD Application Team |
||||
* @brief This file provides definition for fonts to be used for STM32 |
||||
* board's LCD 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 __FONTS_H |
||||
#define __FONTS_H |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include <stdint.h> |
||||
|
||||
/** @addtogroup Utilities
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup STM32_EVAL
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup Common
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup FONTS
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @defgroup FONTS_Exported_Types
|
||||
* @{ |
||||
*/ |
||||
typedef struct _tFont |
||||
{ |
||||
const uint8_t *table; |
||||
uint16_t Width; |
||||
uint16_t Height; |
||||
} sFONT; |
||||
|
||||
extern sFONT Font24; |
||||
extern sFONT Font20; |
||||
extern sFONT Font16; |
||||
extern sFONT Font12; |
||||
extern sFONT Font8; |
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/** @defgroup FONTS_Exported_Constants
|
||||
* @{ |
||||
*/ |
||||
#define LINE(x) ((x) * (((sFONT *)BSP_LCD_GetFont())->Height)) |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/** @defgroup FONTS_Exported_Macros
|
||||
* @{ |
||||
*/
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup FONTS_Exported_Functions
|
||||
* @{ |
||||
*/
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* __FONTS_H */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,78 @@
|
||||
<!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 STM32Cube Log Utilities Driver</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-stm32cube-log-utilities-driver"><small>Release Notes for</small> <mark>STM32Cube Log Utilities Driver</mark></h1> |
||||
<p>Copyright © 2016 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 driver for STM32Cube Log Utilities.</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-section3" checked aria-hidden="true"> <label for="collapse-section3" aria-hidden="true">V1.0.2 / 03-April-2019</label> |
||||
<div> |
||||
<h2 id="main-changes">Main Changes</h2> |
||||
<ul> |
||||
<li>Remove reference to RAISONANCE in Firmware package projects files</li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section2" aria-hidden="true"> <label for="collapse-section2" aria-hidden="true">V1.0.1 / 18-November-2016</label> |
||||
<div> |
||||
<h2 id="main-changes-1">Main Changes</h2> |
||||
<ul> |
||||
<li>Update the following macros implementation: |
||||
<ul> |
||||
<li>LCD_ErrLog(…)</li> |
||||
<li>LCD_UsrLog(…)</li> |
||||
<li>LCD_DbgLog(…)</li> |
||||
</ul></li> |
||||
</ul> |
||||
</div> |
||||
</div> |
||||
<div class="collapse"> |
||||
<input type="checkbox" id="collapse-section1" aria-hidden="true"> <label for="collapse-section1" aria-hidden="true">V1.0.0 / 18-February-2014</label> |
||||
<div> |
||||
<h2 id="main-changes-2">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> |
@ -0,0 +1,497 @@
|
||||
/**
|
||||
****************************************************************************** |
||||
* @file lcd_log.c |
||||
* @author MCD Application Team |
||||
* @brief This file provides all the LCD Log firmware functions. |
||||
*
|
||||
* The LCD Log module allows to automatically set a header and footer |
||||
* on any application using the LCD display and allows to dump user, |
||||
* debug and error messages by using the following macros: LCD_ErrLog(), |
||||
* LCD_UsrLog() and LCD_DbgLog(). |
||||
*
|
||||
* It supports also the scroll feature by embedding an internal software |
||||
* cache for display. This feature allows to dump message sequentially |
||||
* on the display even if the number of displayed lines is bigger than |
||||
* the total number of line allowed by the display. |
||||
*
|
||||
****************************************************************************** |
||||
* @attention |
||||
* |
||||
* <h2><center>© Copyright (c) 2016 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 <stdio.h> |
||||
#include "lcd_log.h" |
||||
|
||||
/** @addtogroup Utilities
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup STM32_EVAL
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup Common
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @defgroup LCD_LOG
|
||||
* @brief LCD Log LCD_Application module |
||||
* @{ |
||||
*/
|
||||
|
||||
/** @defgroup LCD_LOG_Private_Types
|
||||
* @{ |
||||
*/
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LCD_LOG_Private_Defines
|
||||
* @{ |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/* Define the display window settings */ |
||||
#define YWINDOW_MIN 4 |
||||
|
||||
/** @defgroup LCD_LOG_Private_Macros
|
||||
* @{ |
||||
*/
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LCD_LOG_Private_Variables
|
||||
* @{ |
||||
*/
|
||||
|
||||
LCD_LOG_line LCD_CacheBuffer [LCD_CACHE_DEPTH];
|
||||
uint32_t LCD_LineColor; |
||||
uint16_t LCD_CacheBuffer_xptr; |
||||
uint16_t LCD_CacheBuffer_yptr_top; |
||||
uint16_t LCD_CacheBuffer_yptr_bottom; |
||||
|
||||
uint16_t LCD_CacheBuffer_yptr_top_bak; |
||||
uint16_t LCD_CacheBuffer_yptr_bottom_bak; |
||||
|
||||
FunctionalState LCD_CacheBuffer_yptr_invert; |
||||
FunctionalState LCD_ScrollActive; |
||||
FunctionalState LCD_Lock; |
||||
FunctionalState LCD_Scrolled; |
||||
uint16_t LCD_ScrollBackStep; |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LCD_LOG_Private_FunctionPrototypes
|
||||
* @{ |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LCD_LOG_Private_Functions
|
||||
* @{ |
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initializes the LCD Log module
|
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
|
||||
void LCD_LOG_Init ( void) |
||||
{ |
||||
/* Deinit LCD cache */ |
||||
LCD_LOG_DeInit(); |
||||
|
||||
/* Clear the LCD */ |
||||
BSP_LCD_Clear(LCD_LOG_BACKGROUND_COLOR);
|
||||
} |
||||
|
||||
/**
|
||||
* @brief DeInitializes the LCD Log module.
|
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void LCD_LOG_DeInit(void) |
||||
{ |
||||
LCD_LineColor = LCD_LOG_TEXT_COLOR; |
||||
LCD_CacheBuffer_xptr = 0; |
||||
LCD_CacheBuffer_yptr_top = 0; |
||||
LCD_CacheBuffer_yptr_bottom = 0; |
||||
|
||||
LCD_CacheBuffer_yptr_top_bak = 0; |
||||
LCD_CacheBuffer_yptr_bottom_bak = 0; |
||||
|
||||
LCD_CacheBuffer_yptr_invert= ENABLE; |
||||
LCD_ScrollActive = DISABLE; |
||||
LCD_Lock = DISABLE; |
||||
LCD_Scrolled = DISABLE; |
||||
LCD_ScrollBackStep = 0; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Display the application header on the LCD screen
|
||||
* @param header: pointer to the string to be displayed |
||||
* @retval None |
||||
*/ |
||||
void LCD_LOG_SetHeader (uint8_t *header) |
||||
{ |
||||
/* Set the LCD Font */ |
||||
BSP_LCD_SetFont (&LCD_LOG_HEADER_FONT); |
||||
|
||||
BSP_LCD_SetTextColor(LCD_LOG_SOLID_BACKGROUND_COLOR); |
||||
BSP_LCD_FillRect(0, 0, BSP_LCD_GetXSize(), LCD_LOG_HEADER_FONT.Height * 3); |
||||
|
||||
/* Set the LCD Text Color */ |
||||
BSP_LCD_SetTextColor(LCD_LOG_SOLID_TEXT_COLOR); |
||||
BSP_LCD_SetBackColor(LCD_LOG_SOLID_BACKGROUND_COLOR); |
||||
|
||||
BSP_LCD_DisplayStringAt(0, LCD_LOG_HEADER_FONT.Height, header, CENTER_MODE); |
||||
|
||||
BSP_LCD_SetBackColor(LCD_LOG_BACKGROUND_COLOR); |
||||
BSP_LCD_SetTextColor(LCD_LOG_TEXT_COLOR); |
||||
BSP_LCD_SetFont (&LCD_LOG_TEXT_FONT); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Display the application footer on the LCD screen
|
||||
* @param footer: pointer to the string to be displayed |
||||
* @retval None |
||||
*/ |
||||
void LCD_LOG_SetFooter(uint8_t *footer) |
||||
{ |
||||
/* Set the LCD Font */ |
||||
BSP_LCD_SetFont (&LCD_LOG_FOOTER_FONT); |
||||
|
||||
BSP_LCD_SetTextColor(LCD_LOG_SOLID_BACKGROUND_COLOR); |
||||
BSP_LCD_FillRect(0, BSP_LCD_GetYSize() - LCD_LOG_FOOTER_FONT.Height - 4, BSP_LCD_GetXSize(), LCD_LOG_FOOTER_FONT.Height + 4); |
||||
|
||||
/* Set the LCD Text Color */ |
||||
BSP_LCD_SetTextColor(LCD_LOG_SOLID_TEXT_COLOR); |
||||
BSP_LCD_SetBackColor(LCD_LOG_SOLID_BACKGROUND_COLOR); |
||||
|
||||
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize() - LCD_LOG_FOOTER_FONT.Height, footer, CENTER_MODE); |
||||
|
||||
BSP_LCD_SetBackColor(LCD_LOG_BACKGROUND_COLOR); |
||||
BSP_LCD_SetTextColor(LCD_LOG_TEXT_COLOR); |
||||
BSP_LCD_SetFont (&LCD_LOG_TEXT_FONT); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Clear the Text Zone
|
||||
* @param None
|
||||
* @retval None |
||||
*/ |
||||
void LCD_LOG_ClearTextZone(void) |
||||
{ |
||||
uint8_t i=0; |
||||
|
||||
for (i= 0 ; i < YWINDOW_SIZE; i++) |
||||
{ |
||||
BSP_LCD_ClearStringLine(i + YWINDOW_MIN); |
||||
} |
||||
|
||||
LCD_LOG_DeInit(); |
||||
} |
||||
|
||||
/**
|
||||
* @brief Redirect the printf to the LCD |
||||
* @param c: character to be displayed |
||||
* @param f: output file pointer |
||||
* @retval None |
||||
*/ |
||||
LCD_LOG_PUTCHAR |
||||
{ |
||||
|
||||
sFONT *cFont = BSP_LCD_GetFont(); |
||||
uint32_t idx; |
||||
|
||||
if(LCD_Lock == DISABLE) |
||||
{ |
||||
if(LCD_ScrollActive == ENABLE) |
||||
{ |
||||
LCD_CacheBuffer_yptr_bottom = LCD_CacheBuffer_yptr_bottom_bak; |
||||
LCD_CacheBuffer_yptr_top = LCD_CacheBuffer_yptr_top_bak; |
||||
LCD_ScrollActive = DISABLE; |
||||
LCD_Scrolled = DISABLE; |
||||
LCD_ScrollBackStep = 0; |
||||
|
||||
} |
||||
|
||||
if(( LCD_CacheBuffer_xptr < (BSP_LCD_GetXSize()) /cFont->Width ) && ( ch != '\n')) |
||||
{ |
||||
LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = (uint16_t)ch; |
||||
}
|
||||
else
|
||||
{ |
||||
if(LCD_CacheBuffer_yptr_top >= LCD_CacheBuffer_yptr_bottom) |
||||
{ |
||||
|
||||
if(LCD_CacheBuffer_yptr_invert == DISABLE) |
||||
{ |
||||
LCD_CacheBuffer_yptr_top++; |
||||
|
||||
if(LCD_CacheBuffer_yptr_top == LCD_CACHE_DEPTH) |
||||
{ |
||||
LCD_CacheBuffer_yptr_top = 0;
|
||||
} |
||||
} |
||||
else |
||||
{ |
||||
LCD_CacheBuffer_yptr_invert= DISABLE; |
||||
} |
||||
} |
||||
|
||||
for(idx = LCD_CacheBuffer_xptr ; idx < (BSP_LCD_GetXSize()) /cFont->Width; idx++) |
||||
{ |
||||
LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = ' '; |
||||
}
|
||||
LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].color = LCD_LineColor;
|
||||
|
||||
LCD_CacheBuffer_xptr = 0; |
||||
|
||||
LCD_LOG_UpdateDisplay ();
|
||||
|
||||
LCD_CacheBuffer_yptr_bottom ++;
|
||||
|
||||
if (LCD_CacheBuffer_yptr_bottom == LCD_CACHE_DEPTH)
|
||||
{ |
||||
LCD_CacheBuffer_yptr_bottom = 0; |
||||
LCD_CacheBuffer_yptr_top = 1;
|
||||
LCD_CacheBuffer_yptr_invert = ENABLE; |
||||
} |
||||
|
||||
if( ch != '\n') |
||||
{ |
||||
LCD_CacheBuffer[LCD_CacheBuffer_yptr_bottom].line[LCD_CacheBuffer_xptr++] = (uint16_t)ch; |
||||
} |
||||
|
||||
} |
||||
} |
||||
return ch; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Update the text area display |
||||
* @param None |
||||
* @retval None |
||||
*/ |
||||
void LCD_LOG_UpdateDisplay (void) |
||||
{ |
||||
uint8_t cnt = 0 ; |
||||
uint16_t length = 0 ; |
||||
uint16_t ptr = 0, index = 0; |
||||
|
||||
if((LCD_CacheBuffer_yptr_bottom < (YWINDOW_SIZE -1)) &&
|
||||
(LCD_CacheBuffer_yptr_bottom >= LCD_CacheBuffer_yptr_top)) |
||||
{ |
||||
BSP_LCD_SetTextColor(LCD_CacheBuffer[cnt + LCD_CacheBuffer_yptr_bottom].color); |
||||
BSP_LCD_DisplayStringAtLine ((YWINDOW_MIN + LCD_CacheBuffer_yptr_bottom), |
||||
(uint8_t *)(LCD_CacheBuffer[cnt + LCD_CacheBuffer_yptr_bottom].line)); |
||||
} |
||||
else |
||||
{ |
||||
|
||||
if(LCD_CacheBuffer_yptr_bottom < LCD_CacheBuffer_yptr_top) |
||||
{ |
||||
/* Virtual length for rolling */ |
||||
length = LCD_CACHE_DEPTH + LCD_CacheBuffer_yptr_bottom ; |
||||
} |
||||
else |
||||
{ |
||||
length = LCD_CacheBuffer_yptr_bottom; |
||||
} |
||||
|
||||
ptr = length - YWINDOW_SIZE + 1; |
||||
|
||||
for (cnt = 0 ; cnt < YWINDOW_SIZE ; cnt ++) |
||||
{ |
||||
|
||||
index = (cnt + ptr )% LCD_CACHE_DEPTH ; |
||||
|
||||
BSP_LCD_SetTextColor(LCD_CacheBuffer[index].color); |
||||
BSP_LCD_DisplayStringAtLine ((cnt + YWINDOW_MIN),
|
||||
(uint8_t *)(LCD_CacheBuffer[index].line)); |
||||
|
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
#if( LCD_SCROLL_ENABLED == 1) |
||||
/**
|
||||
* @brief Display previous text frame |
||||
* @param None |
||||
* @retval Status |
||||
*/ |
||||
ErrorStatus LCD_LOG_ScrollBack(void) |
||||
{ |
||||
|
||||
if(LCD_ScrollActive == DISABLE) |
||||
{ |
||||
|
||||
LCD_CacheBuffer_yptr_bottom_bak = LCD_CacheBuffer_yptr_bottom; |
||||
LCD_CacheBuffer_yptr_top_bak = LCD_CacheBuffer_yptr_top; |
||||
|
||||
|
||||
if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
|
||||
{ |
||||
|
||||
if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) <= YWINDOW_SIZE) |
||||
{ |
||||
LCD_Lock = DISABLE; |
||||
return ERROR; |
||||
} |
||||
} |
||||
LCD_ScrollActive = ENABLE; |
||||
|
||||
if((LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)&& |
||||
(LCD_Scrolled == DISABLE )) |
||||
{ |
||||
LCD_CacheBuffer_yptr_bottom--; |
||||
LCD_Scrolled = ENABLE; |
||||
} |
||||
|
||||
} |
||||
|
||||
if(LCD_ScrollActive == ENABLE) |
||||
{ |
||||
LCD_Lock = ENABLE; |
||||
|
||||
if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
|
||||
{ |
||||
|
||||
if((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) < YWINDOW_SIZE ) |
||||
{ |
||||
LCD_Lock = DISABLE; |
||||
return ERROR; |
||||
} |
||||
|
||||
LCD_CacheBuffer_yptr_bottom --; |
||||
} |
||||
else if(LCD_CacheBuffer_yptr_bottom <= LCD_CacheBuffer_yptr_top) |
||||
{ |
||||
|
||||
if((LCD_CACHE_DEPTH - LCD_CacheBuffer_yptr_top + LCD_CacheBuffer_yptr_bottom) < YWINDOW_SIZE) |
||||
{ |
||||
LCD_Lock = DISABLE; |
||||
return ERROR; |
||||
} |
||||
LCD_CacheBuffer_yptr_bottom --; |
||||
|
||||
if(LCD_CacheBuffer_yptr_bottom == 0xFFFF) |
||||
{ |
||||
LCD_CacheBuffer_yptr_bottom = LCD_CACHE_DEPTH - 2; |
||||
} |
||||
} |
||||
LCD_ScrollBackStep++; |
||||
LCD_LOG_UpdateDisplay(); |
||||
LCD_Lock = DISABLE; |
||||
} |
||||
return SUCCESS; |
||||
} |
||||
|
||||
/**
|
||||
* @brief Display next text frame |
||||
* @param None |
||||
* @retval Status |
||||
*/ |
||||
ErrorStatus LCD_LOG_ScrollForward(void) |
||||
{ |
||||
|
||||
if(LCD_ScrollBackStep != 0) |
||||
{ |
||||
if(LCD_ScrollActive == DISABLE) |
||||
{ |
||||
|
||||
LCD_CacheBuffer_yptr_bottom_bak = LCD_CacheBuffer_yptr_bottom; |
||||
LCD_CacheBuffer_yptr_top_bak = LCD_CacheBuffer_yptr_top; |
||||
|
||||
if(LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)
|
||||
{ |
||||
|
||||
if ((LCD_CacheBuffer_yptr_bottom - LCD_CacheBuffer_yptr_top) <= YWINDOW_SIZE) |
||||
{ |
||||
LCD_Lock = DISABLE; |
||||
return ERROR; |
||||
} |
||||
} |
||||
LCD_ScrollActive = ENABLE; |
||||
|
||||
if((LCD_CacheBuffer_yptr_bottom > LCD_CacheBuffer_yptr_top)&& |
||||
(LCD_Scrolled == DISABLE )) |
||||
{ |
||||
LCD_CacheBuffer_yptr_bottom--; |
||||
LCD_Scrolled = ENABLE; |
||||
} |
||||
|
||||
} |
||||
|
||||
if(LCD_ScrollActive == ENABLE) |
||||
{ |
||||
LCD_Lock = ENABLE; |
||||
LCD_ScrollBackStep--; |
||||
|
||||
if(++LCD_CacheBuffer_yptr_bottom == LCD_CACHE_DEPTH) |
||||
{ |
||||
LCD_CacheBuffer_yptr_bottom = 0; |
||||
} |
||||
|
||||
LCD_LOG_UpdateDisplay(); |
||||
LCD_Lock = DISABLE; |
||||
|
||||
}
|
||||
return SUCCESS; |
||||
} |
||||
else // LCD_ScrollBackStep == 0
|
||||
{ |
||||
LCD_Lock = DISABLE; |
||||
return ERROR; |
||||
}
|
||||
} |
||||
#endif /* LCD_SCROLL_ENABLED */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,152 @@
|
||||
/**
|
||||
****************************************************************************** |
||||
* @file lcd_log.h |
||||
* @author MCD Application Team |
||||
* @brief header for the lcd_log.c file |
||||
****************************************************************************** |
||||
* @attention |
||||
* |
||||
* <h2><center>© Copyright (c) 2016 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 __LCD_LOG_H__ |
||||
#define __LCD_LOG_H__ |
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
|
||||
#include "lcd_log_conf.h" |
||||
|
||||
/** @addtogroup Utilities
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup STM32_EVAL
|
||||
* @{ |
||||
*/
|
||||
|
||||
/** @addtogroup Common
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @addtogroup LCD_LOG
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @defgroup LCD_LOG
|
||||
* @brief
|
||||
* @{ |
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LCD_LOG_Exported_Defines
|
||||
* @{ |
||||
*/
|
||||
|
||||
#if (LCD_SCROLL_ENABLED == 1) |
||||
#define LCD_CACHE_DEPTH (YWINDOW_SIZE + CACHE_SIZE) |
||||
#else |
||||
#define LCD_CACHE_DEPTH YWINDOW_SIZE |
||||
#endif |
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup LCD_LOG_Exported_Types
|
||||
* @{ |
||||
*/
|
||||
typedef struct _LCD_LOG_line |
||||
{ |
||||
uint8_t line[128]; |
||||
uint32_t color; |
||||
|
||||
}LCD_LOG_line; |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup LCD_LOG_Exported_Macros
|
||||
* @{ |
||||
*/
|
||||
#define LCD_ErrLog(...) do { \ |
||||
LCD_LineColor = LCD_COLOR_RED;\
|
||||
printf("ERROR: ") ;\
|
||||
printf(__VA_ARGS__);\
|
||||
LCD_LineColor = LCD_LOG_DEFAULT_COLOR;\
|
||||
}while (0) |
||||
|
||||
#define LCD_UsrLog(...) do { \ |
||||
LCD_LineColor = LCD_LOG_TEXT_COLOR;\
|
||||
printf(__VA_ARGS__);\
|
||||
} while (0) |
||||
|
||||
|
||||
#define LCD_DbgLog(...) do { \ |
||||
LCD_LineColor = LCD_COLOR_CYAN;\
|
||||
printf(__VA_ARGS__);\
|
||||
LCD_LineColor = LCD_LOG_DEFAULT_COLOR;\
|
||||
}while (0) |
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup LCD_LOG_Exported_Variables
|
||||
* @{ |
||||
*/
|
||||
extern uint32_t LCD_LineColor; |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup LCD_LOG_Exported_FunctionsPrototype
|
||||
* @{ |
||||
*/
|
||||
void LCD_LOG_Init(void); |
||||
void LCD_LOG_DeInit(void); |
||||
void LCD_LOG_SetHeader(uint8_t *Title); |
||||
void LCD_LOG_SetFooter(uint8_t *Status); |
||||
void LCD_LOG_ClearTextZone(void); |
||||
void LCD_LOG_UpdateDisplay (void); |
||||
|
||||
#if (LCD_SCROLL_ENABLED == 1) |
||||
ErrorStatus LCD_LOG_ScrollBack(void); |
||||
ErrorStatus LCD_LOG_ScrollForward(void); |
||||
#endif |
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
|
||||
#endif /* __LCD_LOG_H__ */ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/ |
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
@ -0,0 +1,127 @@
|
||||
/**
|
||||
****************************************************************************** |
||||
* @file lcd_log_conf_template.h |
||||
* @author MCD Application Team |
||||
* @brief lcd_log configuration template file. |
||||
* This file should be copied to the application folder and modified
|
||||
* as follows: |
||||
* - Rename it to 'lcd_log_conf.h'. |
||||
* - Update the name of the LCD driver's header file, depending on |
||||
* the EVAL board you are using, see line40 below (be default this
|
||||
* file will generate compile error unless you do this modification). |
||||
****************************************************************************** |
||||
* @attention |
||||
* |
||||
* <h2><center>© Copyright (c) 2016 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 __LCD_LOG_CONF_H__ |
||||
#define __LCD_LOG_CONF_H__ |
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/ |
||||
#include "stm32xxx_eval_lcd.h" /* replace 'stm32xxx' with your EVAL board name, ex: stm324x9i_eval_lcd.h */ |
||||
#include <stdio.h> |
||||
|
||||
|
||||
/** @addtogroup LCD_LOG
|
||||
* @{ |
||||
*/ |
||||
|
||||
/** @defgroup LCD_LOG
|
||||
* @brief This file is the
|
||||
* @{ |
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LCD_LOG_CONF_Exported_Defines
|
||||
* @{ |
||||
*/
|
||||
|
||||
/* Comment the line below to disable the scroll back and forward features */ |
||||
#define LCD_SCROLL_ENABLED 1 |
||||
|
||||
/* Define the Fonts */ |
||||
#define LCD_LOG_HEADER_FONT Font16 |
||||
#define LCD_LOG_FOOTER_FONT Font12 |
||||
#define LCD_LOG_TEXT_FONT Font12 |
||||
|
||||
/* Define the LCD LOG Color */ |
||||
#define LCD_LOG_BACKGROUND_COLOR LCD_COLOR_WHITE |
||||
#define LCD_LOG_TEXT_COLOR LCD_COLOR_DARKBLUE |
||||
|
||||
#define LCD_LOG_SOLID_BACKGROUND_COLOR LCD_COLOR_BLUE |
||||
#define LCD_LOG_SOLID_TEXT_COLOR LCD_COLOR_WHITE |
||||
|
||||
/* Define the cache depth */ |
||||
#define CACHE_SIZE 100 |
||||
#define YWINDOW_SIZE 17 |
||||
|
||||
#if (YWINDOW_SIZE > 17) |
||||
#error "Wrong YWINDOW SIZE" |
||||
#endif |
||||
|
||||
/* Redirect the printf to the LCD */ |
||||
#ifdef __GNUC__ |
||||
/* With GCC, small printf (option LD Linker->Libraries->Small printf
|
||||
set to 'Yes') calls __io_putchar() */ |
||||
#define LCD_LOG_PUTCHAR int __io_putchar(int ch) |
||||
#else |
||||
#define LCD_LOG_PUTCHAR int fputc(int ch, FILE *f) |
||||
#endif /* __GNUC__ */ |
||||
|
||||
/** @defgroup LCD_LOG_CONF_Exported_TypesDefinitions
|
||||
* @{ |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
|
||||
/** @defgroup LCD_LOG_Exported_Macros
|
||||
* @{ |
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup LCD_LOG_CONF_Exported_Variables
|
||||
* @{ |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/** @defgroup LCD_LOG_CONF_Exported_FunctionsPrototype
|
||||
* @{ |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
|
||||
#endif //__LCD_LOG_CONF_H__
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/**
|
||||
* @} |
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Loading…
Reference in new issue