Hexiwear OLED

Dependents:   Hexi

Fork of Hexi_OLED_SSD1351 by Hexiwear

Committer:
tdh50
Date:
Wed Apr 12 21:01:40 2017 +0000
Revision:
9:18d4eb6328eb
Parent:
7:9961c525e249
Added GetPower() Function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
khuang 5:a5b4b36a1aed 1 /** OLED Display Driver for Hexiwear
khuang 3:4121d3cd9f60 2 * This file contains OLED driver functionality for drawing images and text
khuang 2:fc06b5b5bf6a 3 *
khuang 2:fc06b5b5bf6a 4 * Redistribution and use in source and binary forms, with or without modification,
khuang 2:fc06b5b5bf6a 5 * are permitted provided that the following conditions are met:
khuang 2:fc06b5b5bf6a 6 *
khuang 2:fc06b5b5bf6a 7 * Redistributions of source code must retain the above copyright notice, this list
khuang 5:a5b4b36a1aed 8 * of conditions and the following disclaimer.
khuang 2:fc06b5b5bf6a 9 *
khuang 2:fc06b5b5bf6a 10 * Redistributions in binary form must reproduce the above copyright notice, this
khuang 5:a5b4b36a1aed 11 * list of conditions and the following disclaimer in the documentation and/or
khuang 5:a5b4b36a1aed 12 * other materials provided with the distribution.
khuang 2:fc06b5b5bf6a 13 *
khuang 2:fc06b5b5bf6a 14 * Neither the name of NXP, nor the names of its
khuang 5:a5b4b36a1aed 15 * contributors may be used to endorse or promote products derived from this
khuang 5:a5b4b36a1aed 16 * software without specific prior written permission.
khuang 2:fc06b5b5bf6a 17 *
khuang 2:fc06b5b5bf6a 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
khuang 2:fc06b5b5bf6a 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
khuang 2:fc06b5b5bf6a 20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
khuang 2:fc06b5b5bf6a 21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
khuang 2:fc06b5b5bf6a 22 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
khuang 2:fc06b5b5bf6a 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
khuang 2:fc06b5b5bf6a 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
khuang 2:fc06b5b5bf6a 25 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
khuang 2:fc06b5b5bf6a 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
khuang 2:fc06b5b5bf6a 27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
khuang 2:fc06b5b5bf6a 28 *
khuang 2:fc06b5b5bf6a 29 * visit: http://www.mikroe.com and http://www.nxp.com
khuang 2:fc06b5b5bf6a 30 *
khuang 2:fc06b5b5bf6a 31 * get support at: http://www.mikroe.com/forum and https://community.nxp.com
khuang 2:fc06b5b5bf6a 32 *
khuang 2:fc06b5b5bf6a 33 * Project HEXIWEAR, 2015
khuang 2:fc06b5b5bf6a 34 */
khuang 2:fc06b5b5bf6a 35
khuang 3:4121d3cd9f60 36 #ifndef HG_HEXI_OLED_SSD1351
khuang 3:4121d3cd9f60 37 #define HG_HEXI_OLED_SSD1351
khuang 1:3b5be0ee5f0c 38
khuang 1:3b5be0ee5f0c 39 #include "mbed.h"
khuang 1:3b5be0ee5f0c 40 #include "OLED_types.h"
khuang 1:3b5be0ee5f0c 41 #include "OLED_info.h"
khuang 1:3b5be0ee5f0c 42
khuang 1:3b5be0ee5f0c 43
khuang 3:4121d3cd9f60 44 /** OLED Display Driver for Hexiwear
khuang 3:4121d3cd9f60 45 */
khuang 1:3b5be0ee5f0c 46 class SSD1351{
khuang 1:3b5be0ee5f0c 47
khuang 1:3b5be0ee5f0c 48 public:
khuang 1:3b5be0ee5f0c 49
khuang 3:4121d3cd9f60 50 /**
khuang 3:4121d3cd9f60 51 * Create a Hexiwear OLED Driver connected to the specified pins
khuang 3:4121d3cd9f60 52 *
khuang 3:4121d3cd9f60 53 * @param mosiPin SPI Master Out, Slave In Pin
khuang 3:4121d3cd9f60 54 * @param sclkPin SPI CLock Pin
khuang 3:4121d3cd9f60 55 * @param pwrPin OLED Power Pin
khuang 3:4121d3cd9f60 56 * @param csPin OLED Chip Select Pin
khuang 3:4121d3cd9f60 57 * @param rstPin OLED Reset Pin
khuang 3:4121d3cd9f60 58 * @param dcPin OLED DC Pin
khuang 7:9961c525e249 59 *
khuang 7:9961c525e249 60 * @note Default TextProperties
khuang 7:9961c525e249 61 *
khuang 7:9961c525e249 62 * .font = OpenSans_10x15_Regular,
khuang 7:9961c525e249 63 * .fontColor = COLOR_WHITE,
khuang 7:9961c525e249 64 * .alignParam = OLED_TEXT_ALIGN_CENTER,
khuang 7:9961c525e249 65 * .background = NULL
khuang 7:9961c525e249 66 *
khuang 3:4121d3cd9f60 67 */
khuang 3:4121d3cd9f60 68 SSD1351(PinName mosiPin,PinName sclkPin,PinName pwrPin, PinName csPin,PinName rstPin, PinName dcPin);
khuang 1:3b5be0ee5f0c 69
khuang 3:4121d3cd9f60 70 /**
khuang 3:4121d3cd9f60 71 * Destroy the Hexiwear instance
khuang 3:4121d3cd9f60 72 */
khuang 1:3b5be0ee5f0c 73 ~SSD1351();
khuang 1:3b5be0ee5f0c 74
khuang 1:3b5be0ee5f0c 75 /**
khuang 1:3b5be0ee5f0c 76 * Send the command to OLED
khuang 1:3b5be0ee5f0c 77 * @param cmd OLED command from the datasheet
khuang 1:3b5be0ee5f0c 78 * @param isFirst designate if this is the first byte in the command
khuang 1:3b5be0ee5f0c 79 */
khuang 1:3b5be0ee5f0c 80 void SendCmd(uint32_t cmd,
khuang 1:3b5be0ee5f0c 81 uint8_t isFirst);
khuang 1:3b5be0ee5f0c 82
khuang 1:3b5be0ee5f0c 83
khuang 1:3b5be0ee5f0c 84 /**
khuang 1:3b5be0ee5f0c 85 * Send data to OLED
khuang 1:3b5be0ee5f0c 86 * @param dataToSend data to send to OLED
khuang 1:3b5be0ee5f0c 87 * @param dataSize data-size
khuang 1:3b5be0ee5f0c 88 */
khuang 1:3b5be0ee5f0c 89 void SendData ( const uint8_t* dataToSend,
khuang 1:3b5be0ee5f0c 90 uint32_t dataSize);
khuang 1:3b5be0ee5f0c 91
khuang 1:3b5be0ee5f0c 92 /**
khuang 1:3b5be0ee5f0c 93 * draw box on OLED
khuang 1:3b5be0ee5f0c 94 * @param xCrd x-coordinate for box's uper left corner
khuang 1:3b5be0ee5f0c 95 * @param yCrd y-coordinate for box's uper left corner
khuang 1:3b5be0ee5f0c 96 * @param width box's width
khuang 1:3b5be0ee5f0c 97 * @param height box's height
khuang 1:3b5be0ee5f0c 98 * @param color color of the box
khuang 1:3b5be0ee5f0c 99 * @return status flag
khuang 1:3b5be0ee5f0c 100 */
khuang 1:3b5be0ee5f0c 101 oled_status_t DrawBox (
khuang 6:0060ffa3f4dc 102 int8_t xCrd,
khuang 6:0060ffa3f4dc 103 int8_t yCrd,
khuang 6:0060ffa3f4dc 104 uint8_t width,
khuang 6:0060ffa3f4dc 105 uint8_t height,
khuang 1:3b5be0ee5f0c 106 uint16_t color
khuang 1:3b5be0ee5f0c 107 );
khuang 1:3b5be0ee5f0c 108
khuang 1:3b5be0ee5f0c 109 /**
khuang 1:3b5be0ee5f0c 110 * Fill the entire screen with specified color
khuang 1:3b5be0ee5f0c 111 * @param color color to fill with
khuang 1:3b5be0ee5f0c 112 */
khuang 1:3b5be0ee5f0c 113 void FillScreen( uint16_t color );
khuang 1:3b5be0ee5f0c 114
khuang 1:3b5be0ee5f0c 115
khuang 1:3b5be0ee5f0c 116
khuang 1:3b5be0ee5f0c 117 /**
khuang 1:3b5be0ee5f0c 118 * Draw a single pixel
khuang 1:3b5be0ee5f0c 119 * @param xCrd pixel's x coordinate
khuang 1:3b5be0ee5f0c 120 * @param yCrd pixel's y coordinate
khuang 1:3b5be0ee5f0c 121 * @param color pixel's color
khuang 1:3b5be0ee5f0c 122 * @return status flag
khuang 1:3b5be0ee5f0c 123 */
khuang 1:3b5be0ee5f0c 124 oled_status_t DrawPixel (
khuang 6:0060ffa3f4dc 125 int8_t xCrd,
khuang 6:0060ffa3f4dc 126 int8_t yCrd,
khuang 1:3b5be0ee5f0c 127 uint16_t color
khuang 1:3b5be0ee5f0c 128 );
khuang 1:3b5be0ee5f0c 129
khuang 1:3b5be0ee5f0c 130
khuang 1:3b5be0ee5f0c 131 /**
khuang 1:3b5be0ee5f0c 132 * Draw the whole screen
khuang 1:3b5be0ee5f0c 133 * @param image image to draw
khuang 1:3b5be0ee5f0c 134 * @param xCrd image x-coordinate
khuang 1:3b5be0ee5f0c 135 * @param yCrd image y-coordinate
khuang 1:3b5be0ee5f0c 136 * @param width image width
khuang 1:3b5be0ee5f0c 137 * @param height image height
khuang 1:3b5be0ee5f0c 138 * @param transition transition style for the new image arrival
khuang 1:3b5be0ee5f0c 139 * @return status flag
khuang 1:3b5be0ee5f0c 140 */
khuang 1:3b5be0ee5f0c 141 oled_status_t DrawScreen (
khuang 1:3b5be0ee5f0c 142 const uint8_t* image,
khuang 6:0060ffa3f4dc 143 int8_t xCrd,
khuang 6:0060ffa3f4dc 144 int8_t yCrd,
khuang 1:3b5be0ee5f0c 145 uint8_t width,
khuang 1:3b5be0ee5f0c 146 uint8_t height,
khuang 1:3b5be0ee5f0c 147 oled_transition_t transition
khuang 1:3b5be0ee5f0c 148 );
khuang 1:3b5be0ee5f0c 149
khuang 1:3b5be0ee5f0c 150
khuang 1:3b5be0ee5f0c 151 /**
khuang 1:3b5be0ee5f0c 152 * Set the font to use
khuang 1:3b5be0ee5f0c 153 * @param newFont desired font
khuang 1:3b5be0ee5f0c 154 * @param newColor desired color
khuang 1:3b5be0ee5f0c 155 * @return status flag
khuang 1:3b5be0ee5f0c 156 */
khuang 1:3b5be0ee5f0c 157 oled_status_t SetFont(
khuang 1:3b5be0ee5f0c 158 const uint8_t* newFont,
khuang 1:3b5be0ee5f0c 159 uint16_t newColor
khuang 1:3b5be0ee5f0c 160 );
khuang 1:3b5be0ee5f0c 161
khuang 1:3b5be0ee5f0c 162
khuang 1:3b5be0ee5f0c 163 /**
khuang 1:3b5be0ee5f0c 164 * Set OLED dynamic area
khuang 1:3b5be0ee5f0c 165 * @param dynamic_area data-structure with desired values
khuang 1:3b5be0ee5f0c 166 */
khuang 1:3b5be0ee5f0c 167 void SetDynamicArea(oled_dynamic_area_t *dynamic_area);
khuang 1:3b5be0ee5f0c 168
khuang 1:3b5be0ee5f0c 169 /**
khuang 1:3b5be0ee5f0c 170 * Destroy current OLED dynamic area
khuang 1:3b5be0ee5f0c 171 */
khuang 1:3b5be0ee5f0c 172 void DestroyDynamicArea();
khuang 1:3b5be0ee5f0c 173
khuang 1:3b5be0ee5f0c 174
khuang 1:3b5be0ee5f0c 175 /**
khuang 7:9961c525e249 176 * Set OLED class text properties from parameter
khuang 1:3b5be0ee5f0c 177 * @param textProperties data-structure with desired properties
khuang 1:3b5be0ee5f0c 178 */
khuang 1:3b5be0ee5f0c 179 void SetTextProperties(oled_text_properties_t *textProperties);
khuang 1:3b5be0ee5f0c 180
khuang 7:9961c525e249 181 /**
khuang 7:9961c525e249 182 * Copy OLED class text properties to parameter
khuang 7:9961c525e249 183 * @param textProperties destination data-structure
khuang 7:9961c525e249 184 */
khuang 7:9961c525e249 185 void GetTextProperties(oled_text_properties_t *textProperties);
khuang 1:3b5be0ee5f0c 186
khuang 1:3b5be0ee5f0c 187 /**
khuang 1:3b5be0ee5f0c 188 * Return the width in [px] required for the given string to be displayed
khuang 1:3b5be0ee5f0c 189 * @param text desired string
khuang 1:3b5be0ee5f0c 190 * @return required text width in [px]
khuang 1:3b5be0ee5f0c 191 */
khuang 1:3b5be0ee5f0c 192 uint8_t GetTextWidth(const uint8_t* text);
khuang 1:3b5be0ee5f0c 193
khuang 1:3b5be0ee5f0c 194
khuang 1:3b5be0ee5f0c 195 /**
khuang 1:3b5be0ee5f0c 196 * Count the characters
khuang 1:3b5be0ee5f0c 197 * @param width text width
khuang 1:3b5be0ee5f0c 198 * @param font text font
khuang 1:3b5be0ee5f0c 199 * @param text given text string
khuang 1:3b5be0ee5f0c 200 * @param length text length
khuang 1:3b5be0ee5f0c 201 * @return character count
khuang 1:3b5be0ee5f0c 202 */
khuang 1:3b5be0ee5f0c 203 uint8_t CharCount(uint8_t width, const uint8_t* font, const uint8_t* text, uint8_t length);
khuang 1:3b5be0ee5f0c 204
khuang 1:3b5be0ee5f0c 205 /**
khuang 1:3b5be0ee5f0c 206 * Add text to the main screen buffer at position x,y.
khuang 3:4121d3cd9f60 207 * @param text text to add
khuang 1:3b5be0ee5f0c 208 * @param xCrd x-coordinate for the given text
khuang 1:3b5be0ee5f0c 209 * @param yCrd y-coordinate for the given text
khuang 3:4121d3cd9f60 210 * @return status flag
khuang 1:3b5be0ee5f0c 211 */
khuang 6:0060ffa3f4dc 212 oled_status_t AddText( const uint8_t* text,int8_t xCrd, int8_t yCrd );
khuang 1:3b5be0ee5f0c 213 /**
khuang 1:3b5be0ee5f0c 214 * Add text to the main screen buffer. Used with SetDynamicArea() Function.
khuang 1:3b5be0ee5f0c 215 * @param text text to add
khuang 1:3b5be0ee5f0c 216 * @return status flag
khuang 1:3b5be0ee5f0c 217 */
khuang 1:3b5be0ee5f0c 218 oled_status_t AddText( const uint8_t* text);
khuang 3:4121d3cd9f60 219
khuang 1:3b5be0ee5f0c 220 /**
khuang 1:3b5be0ee5f0c 221 * Write text on OLED at position set in Dynamic Area Field. Used with SetDynamicArea() Function.
khuang 1:3b5be0ee5f0c 222 * @param text desired text
khuang 1:3b5be0ee5f0c 223 *
khuang 1:3b5be0ee5f0c 224 */
khuang 1:3b5be0ee5f0c 225 oled_status_t DrawText ( const uint8_t* text);
khuang 1:3b5be0ee5f0c 226
khuang 1:3b5be0ee5f0c 227 /**
khuang 1:3b5be0ee5f0c 228 * Return the dimensions of image
khuang 1:3b5be0ee5f0c 229 * @param width given image's width
khuang 1:3b5be0ee5f0c 230 * @param height given image's height
khuang 1:3b5be0ee5f0c 231 * @param image desired image
khuang 1:3b5be0ee5f0c 232 */
khuang 1:3b5be0ee5f0c 233 void GetImageDimensions(uint8_t *width, uint8_t *height, const uint8_t* image);
khuang 1:3b5be0ee5f0c 234
khuang 1:3b5be0ee5f0c 235 /**
khuang 1:3b5be0ee5f0c 236 * Add image to the main screen buffer.Used with SetDynamicArea() Function.
khuang 1:3b5be0ee5f0c 237 * @param image desired image
khuang 1:3b5be0ee5f0c 238 * @return status flag
khuang 1:3b5be0ee5f0c 239 */
khuang 1:3b5be0ee5f0c 240 oled_status_t AddImage ( const uint8_t* image );
khuang 1:3b5be0ee5f0c 241
khuang 1:3b5be0ee5f0c 242 /**
khuang 1:3b5be0ee5f0c 243 * Add image to the main screen buffer at position x,y
khuang 1:3b5be0ee5f0c 244 * @param image desired image
khuang 3:4121d3cd9f60 245 * @param xCrd image x-coordinate
khuang 3:4121d3cd9f60 246 * @param yCrd image y-coordinate
khuang 1:3b5be0ee5f0c 247 * @return status flag
khuang 1:3b5be0ee5f0c 248 */
khuang 6:0060ffa3f4dc 249 oled_status_t AddImage ( const uint8_t* image, int8_t xCrd, int8_t yCrd );
khuang 1:3b5be0ee5f0c 250
khuang 1:3b5be0ee5f0c 251 /**
khuang 3:4121d3cd9f60 252 * Send image to OLED GRAM.Used with SetDynamicArea() Function for positioning image.
khuang 1:3b5be0ee5f0c 253 * @param image desired image
khuang 1:3b5be0ee5f0c 254 * @return status flag
khuang 1:3b5be0ee5f0c 255 */
khuang 1:3b5be0ee5f0c 256 oled_status_t DrawImage ( const uint8_t* image );
khuang 1:3b5be0ee5f0c 257 /**
khuang 3:4121d3cd9f60 258 * Send image to OLED GRAM at position x,y.
khuang 1:3b5be0ee5f0c 259 * @param image desired image
khuang 3:4121d3cd9f60 260 * @param xCrd image x-coordinate
khuang 3:4121d3cd9f60 261 * @param yCrd image y-coordinate
khuang 1:3b5be0ee5f0c 262 * @return status flag
khuang 1:3b5be0ee5f0c 263 */
khuang 6:0060ffa3f4dc 264 oled_status_t DrawImage ( const uint8_t* image, int8_t xCrd, int8_t yCrd );
khuang 1:3b5be0ee5f0c 265
khuang 1:3b5be0ee5f0c 266 /**
khuang 1:3b5be0ee5f0c 267 * Dim OLED screen on
khuang 1:3b5be0ee5f0c 268 */
khuang 1:3b5be0ee5f0c 269 void DimScreenON();
khuang 1:3b5be0ee5f0c 270
khuang 1:3b5be0ee5f0c 271 /**
khuang 1:3b5be0ee5f0c 272 * Return OLED back to full contrast
khuang 1:3b5be0ee5f0c 273 */
khuang 1:3b5be0ee5f0c 274 void DimScreenOFF();
khuang 1:3b5be0ee5f0c 275
khuang 1:3b5be0ee5f0c 276 /**
khuang 1:3b5be0ee5f0c 277 * Swap image's bytes per pixel to obtain the correct color format
khuang 1:3b5be0ee5f0c 278 * @param imgDst desired image
khuang 1:3b5be0ee5f0c 279 * @param imgSrc original image
khuang 1:3b5be0ee5f0c 280 * @param imgSize image's size
khuang 1:3b5be0ee5f0c 281 */
khuang 1:3b5be0ee5f0c 282 void Swap(
khuang 1:3b5be0ee5f0c 283 oled_pixel_t imgDst,
khuang 1:3b5be0ee5f0c 284 const uint8_t* imgSrc,
khuang 1:3b5be0ee5f0c 285 uint16_t imgSize
khuang 1:3b5be0ee5f0c 286 );
khuang 1:3b5be0ee5f0c 287
khuang 1:3b5be0ee5f0c 288
khuang 1:3b5be0ee5f0c 289 /**
khuang 1:3b5be0ee5f0c 290 * Turn on Power for OLED Display
khuang 1:3b5be0ee5f0c 291 */
khuang 1:3b5be0ee5f0c 292 void PowerON();
khuang 1:3b5be0ee5f0c 293
khuang 1:3b5be0ee5f0c 294 /**
khuang 1:3b5be0ee5f0c 295 * Turn off Power for OLED Display
khuang 1:3b5be0ee5f0c 296 */
khuang 1:3b5be0ee5f0c 297 void PowerOFF();
tdh50 9:18d4eb6328eb 298 /**
tdh50 9:18d4eb6328eb 299 * Gets value of Power
tdh50 9:18d4eb6328eb 300 */
tdh50 9:18d4eb6328eb 301 bool GetPower();
khuang 1:3b5be0ee5f0c 302
khuang 1:3b5be0ee5f0c 303 /**
khuang 1:3b5be0ee5f0c 304 * update the main screen buffer
khuang 1:3b5be0ee5f0c 305 * with the given image
khuang 1:3b5be0ee5f0c 306
khuang 1:3b5be0ee5f0c 307 * @param xCrd image x-coordinate
khuang 1:3b5be0ee5f0c 308 * @param yCrd image y-coordinate
khuang 1:3b5be0ee5f0c 309 * @param width image width
khuang 1:3b5be0ee5f0c 310 * @param height image height
khuang 1:3b5be0ee5f0c 311 * @param image image for buffer
khuang 1:3b5be0ee5f0c 312 */
khuang 1:3b5be0ee5f0c 313 void UpdateBuffer (
khuang 6:0060ffa3f4dc 314 int8_t xCrd,
khuang 6:0060ffa3f4dc 315 int8_t yCrd,
khuang 1:3b5be0ee5f0c 316 uint8_t width,
khuang 1:3b5be0ee5f0c 317 uint8_t height,
khuang 1:3b5be0ee5f0c 318 const uint8_t* image
khuang 1:3b5be0ee5f0c 319 );
khuang 1:3b5be0ee5f0c 320
khuang 1:3b5be0ee5f0c 321
khuang 3:4121d3cd9f60 322 /**
khuang 3:4121d3cd9f60 323 * Write text on OLED at position x,y. Recommended for Static Text.
khuang 3:4121d3cd9f60 324 * @param text desired text
khuang 3:4121d3cd9f60 325 * @param xCrd x-coordinate for the given text
khuang 3:4121d3cd9f60 326 * @param yCrd y-coordinate for the given text
khuang 3:4121d3cd9f60 327 */
khuang 3:4121d3cd9f60 328
khuang 3:4121d3cd9f60 329 oled_status_t Label(const uint8_t* text,
khuang 6:0060ffa3f4dc 330 int8_t xCrd,
khuang 6:0060ffa3f4dc 331 int8_t yCrd );
khuang 3:4121d3cd9f60 332
khuang 3:4121d3cd9f60 333 /**
khuang 3:4121d3cd9f60 334 * Create a text box of width,height at position x,y. Recommended for Dynamic Text.
khuang 3:4121d3cd9f60 335 * Text is aligned in textbox accordingly to the align parameter set by SetTextProperties().
khuang 3:4121d3cd9f60 336 * @param text desired text
khuang 3:4121d3cd9f60 337 * @param xCrd x-coordinate for the textbox
khuang 3:4121d3cd9f60 338 * @param yCrd y-coordinate for the textbox
khuang 3:4121d3cd9f60 339 * @param width width of the textbox
khuang 3:4121d3cd9f60 340 * @param height height of the textbox
khuang 3:4121d3cd9f60 341 */
khuang 3:4121d3cd9f60 342
khuang 3:4121d3cd9f60 343 oled_status_t TextBox(const uint8_t* text,
khuang 6:0060ffa3f4dc 344 int8_t xCrd,
khuang 6:0060ffa3f4dc 345 int8_t yCrd,
khuang 3:4121d3cd9f60 346 uint8_t width,
khuang 3:4121d3cd9f60 347 uint8_t height);
khuang 3:4121d3cd9f60 348
khuang 1:3b5be0ee5f0c 349
khuang 1:3b5be0ee5f0c 350 private:
khuang 1:3b5be0ee5f0c 351
khuang 1:3b5be0ee5f0c 352 SPI spi;
khuang 1:3b5be0ee5f0c 353 DigitalOut power;
khuang 1:3b5be0ee5f0c 354 DigitalOut cs;
khuang 1:3b5be0ee5f0c 355 DigitalOut rst;
khuang 1:3b5be0ee5f0c 356 DigitalOut dc;
khuang 1:3b5be0ee5f0c 357
khuang 1:3b5be0ee5f0c 358
khuang 1:3b5be0ee5f0c 359 const uint8_t* selectedFont;
khuang 1:3b5be0ee5f0c 360
khuang 1:3b5be0ee5f0c 361 uint8_t
khuang 1:3b5be0ee5f0c 362 currentChar_width,
khuang 1:3b5be0ee5f0c 363 currentChar_height,
khuang 1:3b5be0ee5f0c 364 screenBuf[OLED_GRAM_SIZE];
khuang 1:3b5be0ee5f0c 365
khuang 1:3b5be0ee5f0c 366 uint16_t
khuang 1:3b5be0ee5f0c 367 selectedFont_color,
khuang 7:9961c525e249 368 selectedFont_firstChar, /* first character in the font table */
khuang 7:9961c525e249 369 selectedFont_lastChar, /* last character in the font table */
khuang 1:3b5be0ee5f0c 370 selectedFont_height,
khuang 1:3b5be0ee5f0c 371 colorMask;
khuang 1:3b5be0ee5f0c 372
khuang 1:3b5be0ee5f0c 373 oled_dynamic_area_t oled_dynamic_area;
khuang 1:3b5be0ee5f0c 374 oled_text_properties_t oled_text_properties;
khuang 1:3b5be0ee5f0c 375
khuang 1:3b5be0ee5f0c 376
khuang 7:9961c525e249 377 /* Internal Functions */
khuang 1:3b5be0ee5f0c 378 void Transpose( oled_pixel_t transImage, const oled_pixel_t image, uint8_t width, uint8_t height );
khuang 6:0060ffa3f4dc 379 oled_status_t TopDown ( const uint8_t* image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
khuang 6:0060ffa3f4dc 380 oled_status_t DownTop ( const uint8_t* image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
khuang 6:0060ffa3f4dc 381 oled_status_t LeftRight ( const uint8_t* image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
khuang 6:0060ffa3f4dc 382 oled_status_t RightLeft ( const uint8_t* image, int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
khuang 6:0060ffa3f4dc 383 void SetBorders( int8_t xCrd, int8_t yCrd, uint8_t width, uint8_t height );
khuang 1:3b5be0ee5f0c 384 oled_status_t CreateTextBackground();
khuang 1:3b5be0ee5f0c 385 void WriteCharToBuf( uint16_t charToWrite, oled_pixel_t* chrBuf );
khuang 1:3b5be0ee5f0c 386 oled_status_t AddCharToTextArea( oled_pixel_t chrPtr, uint8_t chrWidth, uint8_t chrHeight, oled_pixel_t copyAddr, uint8_t imgWidth );
khuang 1:3b5be0ee5f0c 387 void* AllocateDynamicArea( uint32_t area );
khuang 1:3b5be0ee5f0c 388 oled_status_t DestroyDynamicArea(void * ptr);
khuang 1:3b5be0ee5f0c 389
khuang 1:3b5be0ee5f0c 390 };
khuang 1:3b5be0ee5f0c 391
khuang 1:3b5be0ee5f0c 392 #endif