Class to drive the LCD Glass display (GH08172T device) present on DISCO_L476VG board.

Dependents:   DISCO_L476VG_GlassLCD DISCO_L476VG_UART DISCO_L476VG_leds_buttons_carter DISCO_L476VG_ ... more

Committer:
bcostm
Date:
Fri Aug 28 13:03:25 2015 +0000
Revision:
0:6ac2ed34f595
First release.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:6ac2ed34f595 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
bcostm 0:6ac2ed34f595 2 *
bcostm 0:6ac2ed34f595 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
bcostm 0:6ac2ed34f595 4 * and associated documentation files (the "Software"), to deal in the Software without
bcostm 0:6ac2ed34f595 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
bcostm 0:6ac2ed34f595 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
bcostm 0:6ac2ed34f595 7 * Software is furnished to do so, subject to the following conditions:
bcostm 0:6ac2ed34f595 8 *
bcostm 0:6ac2ed34f595 9 * The above copyright notice and this permission notice shall be included in all copies or
bcostm 0:6ac2ed34f595 10 * substantial portions of the Software.
bcostm 0:6ac2ed34f595 11 *
bcostm 0:6ac2ed34f595 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
bcostm 0:6ac2ed34f595 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bcostm 0:6ac2ed34f595 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
bcostm 0:6ac2ed34f595 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bcostm 0:6ac2ed34f595 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bcostm 0:6ac2ed34f595 17 */
bcostm 0:6ac2ed34f595 18
bcostm 0:6ac2ed34f595 19 #ifndef __LCD_DISCO_L476VG_H
bcostm 0:6ac2ed34f595 20 #define __LCD_DISCO_L476VG_H
bcostm 0:6ac2ed34f595 21
bcostm 0:6ac2ed34f595 22 #ifdef TARGET_DISCO_L476VG
bcostm 0:6ac2ed34f595 23
bcostm 0:6ac2ed34f595 24 #include "mbed.h"
bcostm 0:6ac2ed34f595 25 #include "stm32l476g_discovery_glass_lcd.h"
bcostm 0:6ac2ed34f595 26
bcostm 0:6ac2ed34f595 27 /*
bcostm 0:6ac2ed34f595 28 Class to drive the LCD Glass display (GH08172T device)
bcostm 0:6ac2ed34f595 29 present on DISCO_L476VG board.
bcostm 0:6ac2ed34f595 30
bcostm 0:6ac2ed34f595 31 Usage:
bcostm 0:6ac2ed34f595 32
bcostm 0:6ac2ed34f595 33 #include "mbed.h"
bcostm 0:6ac2ed34f595 34 #include "LCD_DISCO_L476VG.h"
bcostm 0:6ac2ed34f595 35
bcostm 0:6ac2ed34f595 36 LCD_DISCO_L476VG lcd;
bcostm 0:6ac2ed34f595 37
bcostm 0:6ac2ed34f595 38 int main()
bcostm 0:6ac2ed34f595 39 {
bcostm 0:6ac2ed34f595 40 uint32_t temp = 0;
bcostm 0:6ac2ed34f595 41 uint8_t stemp[7] = {0};
bcostm 0:6ac2ed34f595 42
bcostm 0:6ac2ed34f595 43 lcd.Clear();
bcostm 0:6ac2ed34f595 44 lcd.DisplayString((uint8_t *)"Hello");
bcostm 0:6ac2ed34f595 45
bcostm 0:6ac2ed34f595 46 while(1)
bcostm 0:6ac2ed34f595 47 {
bcostm 0:6ac2ed34f595 48 sprintf((char *)stemp, "val=%d", temp);
bcostm 0:6ac2ed34f595 49 lcd.DisplayString(stemp);
bcostm 0:6ac2ed34f595 50 lcd.BarLevelConfig((uint8_t)temp);
bcostm 0:6ac2ed34f595 51 temp++;
bcostm 0:6ac2ed34f595 52 if (temp > 4) temp = 0;
bcostm 0:6ac2ed34f595 53 wait(1);
bcostm 0:6ac2ed34f595 54 }
bcostm 0:6ac2ed34f595 55 }
bcostm 0:6ac2ed34f595 56 */
bcostm 0:6ac2ed34f595 57 class LCD_DISCO_L476VG
bcostm 0:6ac2ed34f595 58 {
bcostm 0:6ac2ed34f595 59 public:
bcostm 0:6ac2ed34f595 60 //! Constructor
bcostm 0:6ac2ed34f595 61 LCD_DISCO_L476VG();
bcostm 0:6ac2ed34f595 62
bcostm 0:6ac2ed34f595 63 //! Destructor
bcostm 0:6ac2ed34f595 64 ~LCD_DISCO_L476VG();
bcostm 0:6ac2ed34f595 65
bcostm 0:6ac2ed34f595 66 /**
bcostm 0:6ac2ed34f595 67 * @brief Initialize the LCD GLASS relative GPIO port IOs and LCD peripheral.
bcostm 0:6ac2ed34f595 68 * @retval None
bcostm 0:6ac2ed34f595 69 */
bcostm 0:6ac2ed34f595 70 void Init(void);
bcostm 0:6ac2ed34f595 71
bcostm 0:6ac2ed34f595 72 /**
bcostm 0:6ac2ed34f595 73 * @brief DeInitialize the LCD GLASS relative GPIO port IOs and LCD peripheral.
bcostm 0:6ac2ed34f595 74 * @retval None
bcostm 0:6ac2ed34f595 75 */
bcostm 0:6ac2ed34f595 76 void DeInit(void);
bcostm 0:6ac2ed34f595 77
bcostm 0:6ac2ed34f595 78 /**
bcostm 0:6ac2ed34f595 79 * @brief Configure the LCD Blink mode and Blink frequency.
bcostm 0:6ac2ed34f595 80 * @param BlinkMode: specifies the LCD blink mode.
bcostm 0:6ac2ed34f595 81 * This parameter can be one of the following values:
bcostm 0:6ac2ed34f595 82 * @arg LCD_BLINKMODE_OFF: Blink disabled
bcostm 0:6ac2ed34f595 83 * @arg LCD_BLINKMODE_SEG0_COM0: Blink enabled on SEG[0], COM[0] (1 pixel)
bcostm 0:6ac2ed34f595 84 * @arg LCD_BLINKMODE_SEG0_ALLCOM: Blink enabled on SEG[0], all COM (up to 8
bcostm 0:6ac2ed34f595 85 * pixels according to the programmed duty)
bcostm 0:6ac2ed34f595 86 * @arg LCD_BLINKMODE_ALLSEG_ALLCOM: Blink enabled on all SEG and all COM
bcostm 0:6ac2ed34f595 87 * (all pixels)
bcostm 0:6ac2ed34f595 88 * @param BlinkFrequency: specifies the LCD blink frequency.
bcostm 0:6ac2ed34f595 89 * @arg LCD_BLINKFREQUENCY_DIV8: The Blink frequency = fLcd/8
bcostm 0:6ac2ed34f595 90 * @arg LCD_BLINKFREQUENCY_DIV16: The Blink frequency = fLcd/16
bcostm 0:6ac2ed34f595 91 * @arg LCD_BLINKFREQUENCY_DIV32: The Blink frequency = fLcd/32
bcostm 0:6ac2ed34f595 92 * @arg LCD_BLINKFREQUENCY_DIV64: The Blink frequency = fLcd/64
bcostm 0:6ac2ed34f595 93 * @arg LCD_BLINKFREQUENCY_DIV128: The Blink frequency = fLcd/128
bcostm 0:6ac2ed34f595 94 * @arg LCD_BLINKFREQUENCY_DIV256: The Blink frequency = fLcd/256
bcostm 0:6ac2ed34f595 95 * @arg LCD_BLINKFREQUENCY_DIV512: The Blink frequency = fLcd/512
bcostm 0:6ac2ed34f595 96 * @arg LCD_BLINKFREQUENCY_DIV1024: The Blink frequency = fLcd/1024
bcostm 0:6ac2ed34f595 97 * @retval None
bcostm 0:6ac2ed34f595 98 */
bcostm 0:6ac2ed34f595 99 void BlinkConfig(uint32_t BlinkMode, uint32_t BlinkFrequency);
bcostm 0:6ac2ed34f595 100
bcostm 0:6ac2ed34f595 101 /**
bcostm 0:6ac2ed34f595 102 * @brief Configure the LCD contrast.
bcostm 0:6ac2ed34f595 103 * @param Contrast: specifies the LCD contrast value.
bcostm 0:6ac2ed34f595 104 * This parameter can be one of the following values:
bcostm 0:6ac2ed34f595 105 * @arg LCD_CONTRASTLEVEL_0: Maximum Voltage = 2.60V
bcostm 0:6ac2ed34f595 106 * @arg LCD_CONTRASTLEVEL_1: Maximum Voltage = 2.73V
bcostm 0:6ac2ed34f595 107 * @arg LCD_CONTRASTLEVEL_2: Maximum Voltage = 2.86V
bcostm 0:6ac2ed34f595 108 * @arg LCD_CONTRASTLEVEL_3: Maximum Voltage = 2.99V
bcostm 0:6ac2ed34f595 109 * @arg LCD_CONTRASTLEVEL_4: Maximum Voltage = 3.12V
bcostm 0:6ac2ed34f595 110 * @arg LCD_CONTRASTLEVEL_5: Maximum Voltage = 3.25V
bcostm 0:6ac2ed34f595 111 * @arg LCD_CONTRASTLEVEL_6: Maximum Voltage = 3.38V
bcostm 0:6ac2ed34f595 112 * @arg LCD_CONTRASTLEVEL_7: Maximum Voltage = 3.51V
bcostm 0:6ac2ed34f595 113 * @retval None
bcostm 0:6ac2ed34f595 114 */
bcostm 0:6ac2ed34f595 115 void Contrast(uint32_t Contrast);
bcostm 0:6ac2ed34f595 116
bcostm 0:6ac2ed34f595 117 /**
bcostm 0:6ac2ed34f595 118 * @brief Write a character in the LCD RAM buffer.
bcostm 0:6ac2ed34f595 119 * @param ch: The character to display.
bcostm 0:6ac2ed34f595 120 * @param Point: A point to add in front of char.
bcostm 0:6ac2ed34f595 121 * This parameter can be one of the following values:
bcostm 0:6ac2ed34f595 122 * @arg POINT_OFF: No point to add in front of char.
bcostm 0:6ac2ed34f595 123 * @arg POINT_ON: Add a point in front of char.
bcostm 0:6ac2ed34f595 124 * @param Colon: Flag indicating if a colon character has to be added in front
bcostm 0:6ac2ed34f595 125 * of displayed character.
bcostm 0:6ac2ed34f595 126 * This parameter can be one of the following values:
bcostm 0:6ac2ed34f595 127 * @arg DOUBLEPOINT_OFF: No colon to add in back of char.
bcostm 0:6ac2ed34f595 128 * @arg DOUBLEPOINT_ON: Add an colon in back of char.
bcostm 0:6ac2ed34f595 129 * @param Position: Position in the LCD of the character to write.
bcostm 0:6ac2ed34f595 130 * This parameter can be any value in range [1:6].
bcostm 0:6ac2ed34f595 131 * @retval None
bcostm 0:6ac2ed34f595 132 * @note Required preconditions: The LCD should be cleared before to start the
bcostm 0:6ac2ed34f595 133 * write operation.
bcostm 0:6ac2ed34f595 134 */
bcostm 0:6ac2ed34f595 135 void DisplayChar(uint8_t* ch, Point_Typedef Point, DoublePoint_Typedef Column, DigitPosition_Typedef Position);
bcostm 0:6ac2ed34f595 136
bcostm 0:6ac2ed34f595 137 /**
bcostm 0:6ac2ed34f595 138 * @brief Write a character string in the LCD RAM buffer.
bcostm 0:6ac2ed34f595 139 * @param ptr: Pointer to string to display on the LCD Glass.
bcostm 0:6ac2ed34f595 140 * @retval None
bcostm 0:6ac2ed34f595 141 */
bcostm 0:6ac2ed34f595 142 void DisplayString(uint8_t* ptr);
bcostm 0:6ac2ed34f595 143
bcostm 0:6ac2ed34f595 144 /**
bcostm 0:6ac2ed34f595 145 * @brief Write a character string with decimal point in the LCD RAM buffer.
bcostm 0:6ac2ed34f595 146 * @param ptr: Pointer to string to display on the LCD Glass.
bcostm 0:6ac2ed34f595 147 * @retval None
bcostm 0:6ac2ed34f595 148 * @note Required preconditions: Char is ASCCI value "ORed" with decimal point or Colon flag
bcostm 0:6ac2ed34f595 149 */
bcostm 0:6ac2ed34f595 150 void DisplayStrDeci(uint16_t* ptr);
bcostm 0:6ac2ed34f595 151
bcostm 0:6ac2ed34f595 152 /**
bcostm 0:6ac2ed34f595 153 * @brief Display a string in scrolling mode
bcostm 0:6ac2ed34f595 154 * @param ptr: Pointer to string to display on the LCD Glass.
bcostm 0:6ac2ed34f595 155 * @param nScroll: Specifies how many time the message will be scrolled
bcostm 0:6ac2ed34f595 156 * @param ScrollSpeed : Specifies the speed of the scroll, low value gives
bcostm 0:6ac2ed34f595 157 * higher speed
bcostm 0:6ac2ed34f595 158 * @retval None
bcostm 0:6ac2ed34f595 159 * @note Required preconditions: The LCD should be cleared before to start the
bcostm 0:6ac2ed34f595 160 * write operation.
bcostm 0:6ac2ed34f595 161 */
bcostm 0:6ac2ed34f595 162 void ScrollSentence(uint8_t* ptr, uint16_t nScroll, uint16_t ScrollSpeed);
bcostm 0:6ac2ed34f595 163
bcostm 0:6ac2ed34f595 164 /**
bcostm 0:6ac2ed34f595 165 * @brief Display one or several bar in LCD frame buffer.
bcostm 0:6ac2ed34f595 166 * @param BarId: specifies the LCD GLASS Bar to display
bcostm 0:6ac2ed34f595 167 * This parameter can be one of the following values:
bcostm 0:6ac2ed34f595 168 * @arg BAR0: LCD GLASS Bar 0
bcostm 0:6ac2ed34f595 169 * @arg BAR0: LCD GLASS Bar 1
bcostm 0:6ac2ed34f595 170 * @arg BAR0: LCD GLASS Bar 2
bcostm 0:6ac2ed34f595 171 * @arg BAR0: LCD GLASS Bar 3
bcostm 0:6ac2ed34f595 172 * @retval None
bcostm 0:6ac2ed34f595 173 */
bcostm 0:6ac2ed34f595 174 void DisplayBar(uint32_t BarId);
bcostm 0:6ac2ed34f595 175
bcostm 0:6ac2ed34f595 176 /**
bcostm 0:6ac2ed34f595 177 * @brief Clear one or several bar in LCD frame buffer.
bcostm 0:6ac2ed34f595 178 * @param BarId: specifies the LCD GLASS Bar to display
bcostm 0:6ac2ed34f595 179 * This parameter can be combination of one of the following values:
bcostm 0:6ac2ed34f595 180 * @arg LCD_BAR_0: LCD GLASS Bar 0
bcostm 0:6ac2ed34f595 181 * @arg LCD_BAR_1: LCD GLASS Bar 1
bcostm 0:6ac2ed34f595 182 * @arg LCD_BAR_2: LCD GLASS Bar 2
bcostm 0:6ac2ed34f595 183 * @arg LCD_BAR_3: LCD GLASS Bar 3
bcostm 0:6ac2ed34f595 184 * @retval None
bcostm 0:6ac2ed34f595 185 */
bcostm 0:6ac2ed34f595 186 void ClearBar(uint32_t BarId);
bcostm 0:6ac2ed34f595 187
bcostm 0:6ac2ed34f595 188 /**
bcostm 0:6ac2ed34f595 189 * @brief Configure the bar level on LCD by writing bar value in LCD frame buffer.
bcostm 0:6ac2ed34f595 190 * @param BarLevel: specifies the LCD GLASS Battery Level.
bcostm 0:6ac2ed34f595 191 * This parameter can be one of the following values:
bcostm 0:6ac2ed34f595 192 * @arg BATTERYLEVEL_OFF: LCD GLASS Battery Empty
bcostm 0:6ac2ed34f595 193 * @arg BATTERYLEVEL_1_4: LCD GLASS Battery 1/4 Full
bcostm 0:6ac2ed34f595 194 * @arg BATTERYLEVEL_1_2: LCD GLASS Battery 1/2 Full
bcostm 0:6ac2ed34f595 195 * @arg BATTERYLEVEL_3_4: LCD GLASS Battery 3/4 Full
bcostm 0:6ac2ed34f595 196 * @arg BATTERYLEVEL_FULL: LCD GLASS Battery Full
bcostm 0:6ac2ed34f595 197 * @retval None
bcostm 0:6ac2ed34f595 198 */
bcostm 0:6ac2ed34f595 199 void BarLevelConfig(uint8_t BarLevel);
bcostm 0:6ac2ed34f595 200
bcostm 0:6ac2ed34f595 201 /**
bcostm 0:6ac2ed34f595 202 * @brief Clear the whole LCD RAM buffer.
bcostm 0:6ac2ed34f595 203 * @retval None
bcostm 0:6ac2ed34f595 204 */
bcostm 0:6ac2ed34f595 205 void Clear(void);
bcostm 0:6ac2ed34f595 206
bcostm 0:6ac2ed34f595 207 private:
bcostm 0:6ac2ed34f595 208
bcostm 0:6ac2ed34f595 209 };
bcostm 0:6ac2ed34f595 210
bcostm 0:6ac2ed34f595 211 #else
bcostm 0:6ac2ed34f595 212 #error "This class must be used with DISCO_L476VG board only."
bcostm 0:6ac2ed34f595 213 #endif // TARGET_DISCO_L476VG
bcostm 0:6ac2ed34f595 214
bcostm 0:6ac2ed34f595 215 #endif