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