1 /*! 2 * \file display-board.h 3 * 4 * \brief Target board OLED low level driver implementation 5 * 6 * \remarks Some snippets of these drivers are based on the Adafruit_GFX library. 7 * https://github.com/adafruit/Adafruit-GFX-Library 8 * Please take a look at their LICENSE.TXT file. 9 * Copyright (c) 2012 Adafruit Industries. All rights reserved. 10 * 11 * \copyright Revised BSD License, see section \ref LICENSE. 12 * 13 * \code 14 * ______ _ 15 * / _____) _ | | 16 * ( (____ _____ ____ _| |_ _____ ____| |__ 17 * \____ \| ___ | (_ _) ___ |/ ___) _ \ 18 * _____) ) ____| | | || |_| ____( (___| | | | 19 * (______/|_____)_|_|_| \__)_____)\____)_| |_| 20 * (C)2013-2017 Semtech 21 * 22 * \endcode 23 * 24 * \author Miguel Luis ( Semtech ) 25 * 26 * \author Gregory Cristian ( Semtech ) 27 */ 28 #ifndef __DISPLAY_BOARD_H__ 29 #define __DISPLAY_BOARD_H__ 30 31 #ifdef __cplusplus 32 extern "C" 33 { 34 #endif 35 36 #include <stdint.h> 37 #include <stdbool.h> 38 39 /*! 40 * \brief Display colors enumeration 41 */ 42 typedef enum 43 { 44 DISPLAY_BLACK, 45 DISPLAY_WHITE, 46 DISPLAY_INVERSE, 47 }DisplayColor_t; 48 49 /*! 50 * \brief Initializes the display 51 */ 52 void DisplayInit( void ); 53 54 /*! 55 * \brief Resets the display 56 */ 57 void DisplayReset( void ); 58 59 /*! 60 * \brief Sends a command to the display 61 * 62 * \param cmd Command to be sent 63 */ 64 void DisplaySendCommand( uint8_t cmd ); 65 66 /*! 67 * \brief Sends a data buffer to the display 68 * 69 * \param buffer Buffer to be sent 70 * \param size Buffer size to be sent 71 */ 72 void DisplaySendData( uint8_t *buffer, uint16_t size ); 73 74 /*! 75 * \brief Enables the display 76 */ 77 void DisplayOn( void ); 78 79 /*! 80 * \brief Disables the display 81 */ 82 void DisplayOff( void ); 83 84 /*! 85 * \brief Clears the display 86 */ 87 void DisplayClear( void ); 88 89 /*! 90 * \brief Inverts colors of the display 91 * 92 * \param invert [true: invert, false: normal] 93 */ 94 void DisplayInvertColors( bool invert ); 95 96 /*! 97 * \brief Updates the display with MCU RAM copy 98 */ 99 void DisplayUpdate( void ); 100 101 /*! 102 * \brief Sets the cursor at coordinates (x,y) 103 * 104 * \param x X coordinate 105 * \param y Y coordinate 106 */ 107 void DisplaySetCursor( int16_t x, int16_t y ); 108 109 /*! 110 * \brief Gets current X coordinate of the cursor 111 * 112 * \retval x X coordinate 113 */ 114 int16_t DisplayGetCursorX( void ); 115 116 /*! 117 * \brief Gets current Y coordinate of the cursor 118 * 119 * \retval y Y coordinate 120 */ 121 int16_t DisplayGetCursorY( void ); 122 123 /*! 124 * \brief Sets text size 125 * 126 * \param s New text size 127 */ 128 void DisplaySetTextSize( uint8_t s ); 129 130 /*! 131 * \brief Sets text color 132 * 133 * \param color New text color 134 */ 135 void DisplaySetTextColor( DisplayColor_t color ); 136 137 /*! 138 * \brief Sets foreground and background color 139 * 140 * \param fg Foreground color 141 * \param bg Background color 142 */ 143 void DisplaySetFgAndBg( DisplayColor_t fg, DisplayColor_t bg ); 144 145 /*! 146 * \brief Enables/Disable text wrapping 147 * 148 * \param w [true: wrap ON, false: wrap OFF] 149 */ 150 void DisplaySetTextWrap( bool w ); 151 152 /*! 153 * \brief Gets current display rotation 154 * 155 * \retval rotation Display rotation (Vertical/Horizontal) 156 */ 157 uint8_t DisplayGetRotation( void ); 158 159 /*! 160 * \brief Sets current display rotation 161 * 162 * \param x Display rotation (Vertical/Horizontal) 163 */ 164 void DisplaySetRotation( uint8_t x ); 165 166 /*! 167 * \brief Draws a pixel of color at coordinates (x,y) 168 * 169 * \param x X coordinate 170 * \param y Y coordinate 171 * \param color Pixel color 172 */ 173 void DisplayDrawPixel( int16_t x, int16_t y, DisplayColor_t color ); 174 175 /*! 176 * \brief Draws a line starting at coordinates (x0,y0) ending at 177 * coordinates (x1,y1) of color 178 * 179 * \param x0 X0 coordinate 180 * \param y0 Y0 coordinate 181 * \param x1 X1 coordinate 182 * \param y1 Y1 coordinate 183 * \param color Line color 184 */ 185 void DisplayDrawLine( int16_t x0, int16_t y0, int16_t x1, int16_t y1, DisplayColor_t color ); 186 187 /*! 188 * \brief Draws a vertical line starting at coordinates (x,y) with given height 189 * 190 * \param x X coordinate 191 * \param y Y coordinate 192 * \param h Line height 193 * \param color Line color 194 */ 195 void DisplayDrawVerticalLine( int16_t x, int16_t y, int16_t h, DisplayColor_t color ); 196 197 /*! 198 * \brief Draws an Horizontal line starting at coordinates (x,y) with given width 199 * 200 * \param x X coordinate 201 * \param y Y coordinate 202 * \param w Line width 203 * \param color Line color 204 */ 205 void DisplayDrawHorizontalLine( int16_t x, int16_t y, int16_t w, DisplayColor_t color ); 206 207 /*! 208 * \brief Draws a rectangle at coordinates (x,y) with given width and height 209 * 210 * \param x X coordinate 211 * \param y Y coordinate 212 * \param w Line width 213 * \param h Line height 214 * \param color Line color 215 */ 216 void DisplayDrawRect( int16_t x, int16_t y, int16_t w, int16_t h, DisplayColor_t color ); 217 218 /*! 219 * \brief Draws a filled rectangle at coordinates (x,y) with given width and height 220 * 221 * \param x X coordinate 222 * \param y Y coordinate 223 * \param w Line width 224 * \param h Line height 225 * \param color Fill color 226 */ 227 void DisplayFillRect( int16_t x, int16_t y, int16_t w, int16_t h, DisplayColor_t color ); 228 229 /*! 230 * \brief Fills all display with pixels of color 231 * 232 * \param color Fill color 233 */ 234 void DisplayFillScreen( DisplayColor_t color ); 235 236 /*! 237 * \brief Draws a triangle by giving the 3 vertices coordinates 238 * 239 * \param x0 X0 coordinate 240 * \param y0 Y0 coordinate 241 * \param x1 X1 coordinate 242 * \param y1 Y1 coordinate 243 * \param x2 X2 coordinate 244 * \param y2 Y2 coordinate 245 * \param color Line color 246 */ 247 void DisplayDrawTriangle( int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, DisplayColor_t color ); 248 249 /*! 250 * \brief Draws a filled triangle by giving the 3 vertices coordinates 251 * 252 * \param x0 X0 coordinate 253 * \param y0 Y0 coordinate 254 * \param x1 X1 coordinate 255 * \param y1 Y1 coordinate 256 * \param x2 X2 coordinate 257 * \param y2 Y2 coordinate 258 * \param color Fill color 259 */ 260 void DisplayFillTriangle( int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, DisplayColor_t color ) ; 261 262 /*! 263 * \brief Draws a character at given coordinates 264 * 265 * \param x X coordinate 266 * \param y Y coordinate 267 * \param c Character 268 * \param color Character color 269 * \param bg Background color 270 * \param size Character size 271 */ 272 void DisplayDrawChar( int16_t x, int16_t y, unsigned char c, DisplayColor_t color, DisplayColor_t bg, uint8_t size ); 273 274 /*! 275 * \brief Display putc function. (Mimics standard C putc function) 276 * 277 * \param c Character 278 */ 279 void DisplayPutc( uint8_t c ); 280 281 /*! 282 * \brief Sets cursor at line 283 * 284 * \param line Line number 285 */ 286 void DisplaySetLine( uint8_t line ); 287 288 /*! 289 * \brief Display print function. Prints the given string 290 */ 291 void DisplayPrint( const char *string ); 292 293 /*! 294 * \brief Display printf function. (Mimics standard C printf function) 295 */ 296 void DisplayPrintf( const char *format, ... ); 297 298 #ifdef __cplusplus 299 } 300 #endif 301 302 #endif // __DISPLAY_BOARD_H__ 303