Code for the Hexiwear sensor system. Requires an Air Quality Click, Carbon Monoxide Click, and Buzzer Click for full functionality. Currently only reads values and displays to the OLED while testing and alerting the user of present threats. Future goals are to incorporate button presses with separate screens to display the data as well as using the KW40 drivers to transmit the data. Still in early stages of development, many unnecessary files will be removed and cleaned up once final product is completed within the next month. Driver.cpp is the main driver for the program and was written for purposes of this project. All other headers and functions were found on mbed.org from other developers repositories or provided by NXP Semiconductors for purposes of this project.

Dependencies:   Hexi_KW40Z images

Committer:
Gfolker
Date:
Wed Mar 15 19:14:55 2017 +0000
Revision:
0:f70b1d60f794
v1.0 of Hexiwear Sensor system. Currently able to detect air quality and carbon monoxide and display to the screen with alerts on the PWM buzzer click module and RGB LED.

Who changed what in which revision?

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