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