Test for STM32F4

Dependents:   Nucleo_SSD1331

Fork of RGB_OLED_SSD1331 by Juergen M

Committer:
messi1
Date:
Tue Dec 22 21:44:31 2015 +0000
Revision:
14:961ce3497de1
Parent:
13:8dd215952d76
Add comment example for second spi port

Who changed what in which revision?

UserRevisionLine numberNew contents of line
messi1 0:6e810b5b40a3 1 /*
messi1 0:6e810b5b40a3 2 * SSD1331.h
messi1 0:6e810b5b40a3 3 * A library for RGB OLED module
messi1 0:6e810b5b40a3 4 *
messi1 3:af00512c9694 5 * Copyright (c) 2015 Juergen Messerer
messi1 0:6e810b5b40a3 6 * Copyright (c) 2014 seeed technology inc.
messi1 0:6e810b5b40a3 7 * Copyright (c) 2012, Adafruit Industries.
messi1 0:6e810b5b40a3 8 *
messi1 0:6e810b5b40a3 9 * All rights reserved.
messi1 0:6e810b5b40a3 10 *
messi1 0:6e810b5b40a3 11 * This library is based on Adafruit's SSD1331-OLED-Driver-Library. Thanks to
messi1 0:6e810b5b40a3 12 * their contribution to the code, we modify it and add more interface to
messi1 0:6e810b5b40a3 13 * support our Seeed's Xadow RGB OLED 96*64 module.
messi1 0:6e810b5b40a3 14 *
messi1 0:6e810b5b40a3 15 * Below is the introduction of Adafruit's Color OLED module, we add it to here
messi1 0:6e810b5b40a3 16 * to express our thanks to them.
messi1 0:6e810b5b40a3 17 *
messi1 0:6e810b5b40a3 18 * ****************************************************************************
messi1 0:6e810b5b40a3 19 * This is a library for the 0.96" 16-bit Color OLED with SSD1331 driver chip
messi1 0:6e810b5b40a3 20 *
messi1 0:6e810b5b40a3 21 * Pick one up today in the adafruit shop!
messi1 0:6e810b5b40a3 22 * ------> http://www.adafruit.com/products/684
messi1 0:6e810b5b40a3 23 *
messi1 0:6e810b5b40a3 24 * These displays use SPI to communicate.
messi1 0:6e810b5b40a3 25 *
messi1 0:6e810b5b40a3 26 * Adafruit invests time and resources providing this open source code,
messi1 0:6e810b5b40a3 27 * please support Adafruit and open-source hardware by purchasing
messi1 0:6e810b5b40a3 28 * products from Adafruit!
messi1 0:6e810b5b40a3 29 *
messi1 0:6e810b5b40a3 30 * Written by Limor Fried/Ladyada for Adafruit Industries.
messi1 0:6e810b5b40a3 31 * Modifed by lawliet for Seeed Studio's RGB OLED module.
messi1 0:6e810b5b40a3 32 * BSD license, all text above must be included in any redistribution
messi1 0:6e810b5b40a3 33 * ******************************************************************************
messi1 0:6e810b5b40a3 34 *
messi1 0:6e810b5b40a3 35 * Software License Agreement (BSD License)
messi1 0:6e810b5b40a3 36 *
messi1 0:6e810b5b40a3 37 * Redistribution and use in source and binary forms, with or without
messi1 0:6e810b5b40a3 38 * modification, are permitted provided that the following conditions are met:
messi1 0:6e810b5b40a3 39 * 1. Redistributions of source code must retain the above copyright
messi1 0:6e810b5b40a3 40 * notice, this list of conditions and the following disclaimer.
messi1 0:6e810b5b40a3 41 * 2. Redistributions in binary form must reproduce the above copyright
messi1 0:6e810b5b40a3 42 * notice, this list of conditions and the following disclaimer in the
messi1 0:6e810b5b40a3 43 * documentation and/or other materials provided with the distribution.
messi1 0:6e810b5b40a3 44 * 3. Neither the name of the copyright holders nor the
messi1 0:6e810b5b40a3 45 * names of its contributors may be used to endorse or promote products
messi1 0:6e810b5b40a3 46 * derived from this software without specific prior written permission.
messi1 0:6e810b5b40a3 47 *
messi1 0:6e810b5b40a3 48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
messi1 0:6e810b5b40a3 49 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
messi1 0:6e810b5b40a3 50 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
messi1 0:6e810b5b40a3 51 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
messi1 0:6e810b5b40a3 52 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
messi1 0:6e810b5b40a3 53 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
messi1 0:6e810b5b40a3 54 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
messi1 0:6e810b5b40a3 55 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
messi1 0:6e810b5b40a3 56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
messi1 0:6e810b5b40a3 57 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messi1 0:6e810b5b40a3 58 *
messi1 0:6e810b5b40a3 59 */
messi1 0:6e810b5b40a3 60
messi1 0:6e810b5b40a3 61 #ifndef _SSD1331_H_
messi1 0:6e810b5b40a3 62 #define _SSD1331_H_
messi1 5:9de43186f5ea 63
messi1 0:6e810b5b40a3 64 #include "DigitalOut.h"
messi1 0:6e810b5b40a3 65 #include "PinNames.h"
messi1 11:162aa3e801df 66 #include "SGL.cpp" // Because of the template class we have to include this cpp
messi1 2:e033aab5daad 67 #include "Stream.h"
messi1 0:6e810b5b40a3 68
messi1 0:6e810b5b40a3 69
messi1 0:6e810b5b40a3 70 #define RGB_OLED_WIDTH 96
messi1 0:6e810b5b40a3 71 #define RGB_OLED_HEIGHT 64
messi1 5:9de43186f5ea 72 #define RGB_OLED_XMAX RGB_OLED_WIDTH-1
messi1 5:9de43186f5ea 73 #define RGB_OLED_YMAX RGB_OLED_HEIGHT-1
messi1 0:6e810b5b40a3 74
messi1 0:6e810b5b40a3 75 #define CMD_DRAW_LINE 0x21
messi1 0:6e810b5b40a3 76 #define CMD_DRAW_RECTANGLE 0x22
messi1 0:6e810b5b40a3 77 #define CMD_COPY_WINDOW 0x23
messi1 0:6e810b5b40a3 78 #define CMD_DIM_WINDOW 0x24
messi1 0:6e810b5b40a3 79 #define CMD_CLEAR_WINDOW 0x25
messi1 0:6e810b5b40a3 80 #define CMD_FILL_WINDOW 0x26
messi1 1:b55525d2db34 81 #define DISABLE_FILL 0x00
messi1 1:b55525d2db34 82 #define ENABLE_FILL 0x01
messi1 0:6e810b5b40a3 83 #define CMD_CONTINUOUS_SCROLLING_SETUP 0x27
messi1 0:6e810b5b40a3 84 #define CMD_DEACTIVE_SCROLLING 0x2E
messi1 0:6e810b5b40a3 85 #define CMD_ACTIVE_SCROLLING 0x2F
messi1 0:6e810b5b40a3 86
messi1 0:6e810b5b40a3 87 #define CMD_SET_COLUMN_ADDRESS 0x15
messi1 0:6e810b5b40a3 88 #define CMD_SET_ROW_ADDRESS 0x75
messi1 0:6e810b5b40a3 89 #define CMD_SET_CONTRAST_A 0x81
messi1 0:6e810b5b40a3 90 #define CMD_SET_CONTRAST_B 0x82
messi1 0:6e810b5b40a3 91 #define CMD_SET_CONTRAST_C 0x83
messi1 0:6e810b5b40a3 92 #define CMD_MASTER_CURRENT_CONTROL 0x87
messi1 0:6e810b5b40a3 93 #define CMD_SET_PRECHARGE_SPEED_A 0x8A
messi1 0:6e810b5b40a3 94 #define CMD_SET_PRECHARGE_SPEED_B 0x8B
messi1 0:6e810b5b40a3 95 #define CMD_SET_PRECHARGE_SPEED_C 0x8C
messi1 0:6e810b5b40a3 96 #define CMD_SET_REMAP 0xA0
messi1 0:6e810b5b40a3 97 #define CMD_SET_DISPLAY_START_LINE 0xA1
messi1 0:6e810b5b40a3 98 #define CMD_SET_DISPLAY_OFFSET 0xA2
messi1 0:6e810b5b40a3 99 #define CMD_NORMAL_DISPLAY 0xA4
messi1 0:6e810b5b40a3 100 #define CMD_ENTIRE_DISPLAY_ON 0xA5
messi1 0:6e810b5b40a3 101 #define CMD_ENTIRE_DISPLAY_OFF 0xA6
messi1 0:6e810b5b40a3 102 #define CMD_INVERSE_DISPLAY 0xA7
messi1 0:6e810b5b40a3 103 #define CMD_SET_MULTIPLEX_RATIO 0xA8
messi1 0:6e810b5b40a3 104 #define CMD_DIM_MODE_SETTING 0xAB
messi1 0:6e810b5b40a3 105 #define CMD_SET_MASTER_CONFIGURE 0xAD
messi1 0:6e810b5b40a3 106 #define CMD_DIM_MODE_DISPLAY_ON 0xAC
messi1 0:6e810b5b40a3 107 #define CMD_DISPLAY_OFF 0xAE
messi1 0:6e810b5b40a3 108 #define CMD_NORMAL_BRIGHTNESS_DISPLAY_ON 0xAF
messi1 0:6e810b5b40a3 109 #define CMD_POWER_SAVE_MODE 0xB0
messi1 0:6e810b5b40a3 110 #define CMD_PHASE_PERIOD_ADJUSTMENT 0xB1
messi1 0:6e810b5b40a3 111 #define CMD_DISPLAY_CLOCK_DIV 0xB3
messi1 0:6e810b5b40a3 112 #define CMD_SET_GRAy_SCALE_TABLE 0xB8
messi1 0:6e810b5b40a3 113 #define CMD_ENABLE_LINEAR_GRAY_SCALE_TABLE 0xB9
messi1 0:6e810b5b40a3 114 #define CMD_SET_PRECHARGE_VOLTAGE 0xBB
messi1 0:6e810b5b40a3 115 #define CMD_SET_V_VOLTAGE 0xBE
messi1 0:6e810b5b40a3 116
messi1 0:6e810b5b40a3 117 #define LOW 0
messi1 0:6e810b5b40a3 118 #define HIGH 1
messi1 0:6e810b5b40a3 119
messi1 7:5250c825c7bb 120
messi1 7:5250c825c7bb 121 /* some 16bit RGB color definitions */
messi1 7:5250c825c7bb 122 enum Color{
messi1 7:5250c825c7bb 123 Black = 0x0000, /* 0, 0, 0 */
messi1 7:5250c825c7bb 124 Navy = 0x000F, /* 0, 0, 128 */
messi1 7:5250c825c7bb 125 DarkGreen = 0x03E0, /* 0, 128, 0 */
messi1 7:5250c825c7bb 126 DarkCyan = 0x03EF, /* 0, 128, 128 */
messi1 7:5250c825c7bb 127 Maroon = 0x7800, /* 128, 0, 0 */
messi1 7:5250c825c7bb 128 Purple = 0x780F, /* 128, 0, 128 */
messi1 7:5250c825c7bb 129 Olive = 0x7BE0, /* 128, 128, 0 */
messi1 7:5250c825c7bb 130 LightGrey = 0xC618, /* 192, 192, 192 */
messi1 7:5250c825c7bb 131 DarkGrey = 0x7BEF, /* 128, 128, 128 */
messi1 7:5250c825c7bb 132 Blue = 0x001F, /* 0, 0, 255 */
messi1 7:5250c825c7bb 133 Green = 0x07E0, /* 0, 255, 0 */
messi1 7:5250c825c7bb 134 Cyan = 0x07FF, /* 0, 255, 255 */
messi1 7:5250c825c7bb 135 Red = 0xF800, /* 255, 0, 0 */
messi1 7:5250c825c7bb 136 Magenta = 0xF81F, /* 255, 0, 255 */
messi1 7:5250c825c7bb 137 Yellow = 0xFFE0, /* 255, 255, 0 */
messi1 7:5250c825c7bb 138 White = 0xFFFF, /* 255, 255, 255 */
messi1 7:5250c825c7bb 139 Orange = 0xFD20, /* 255, 165, 0 */
messi1 7:5250c825c7bb 140 GreenYellow = 0xAFE5, /* 173, 255, 47 */
messi1 7:5250c825c7bb 141 Pink = 0xF81F
messi1 0:6e810b5b40a3 142 };
messi1 0:6e810b5b40a3 143
messi1 0:6e810b5b40a3 144 enum DisplayMode{
messi1 0:6e810b5b40a3 145 //reset the above effect and turn the data to ON at the corresponding gray level.
messi1 9:5a7bf0ce8518 146 DM_NormalDisplay = 0xA4,
messi1 0:6e810b5b40a3 147 //forces the entire display to be at "GS63"
messi1 9:5a7bf0ce8518 148 DM_DisplayOn = 0xA5,
messi1 0:6e810b5b40a3 149 //forces the entire display to be at gray level "GS0"
messi1 9:5a7bf0ce8518 150 DM_DisplayOff = 0xA6,
messi1 0:6e810b5b40a3 151 //swap the gray level of display data
messi1 9:5a7bf0ce8518 152 DM_InverseDisplay = 0xA7
messi1 0:6e810b5b40a3 153 };
messi1 0:6e810b5b40a3 154
messi1 9:5a7bf0ce8518 155 enum PowerMode{
messi1 10:ef7440718431 156 PM_SleepMode = 0xAE,
messi1 9:5a7bf0ce8518 157 PM_NormalMode = 0xAF
messi1 0:6e810b5b40a3 158 };
messi1 0:6e810b5b40a3 159
messi1 13:8dd215952d76 160 enum ScrollDirection{
messi1 9:5a7bf0ce8518 161 SD_Horizontal = 0x00,
messi1 9:5a7bf0ce8518 162 SD_Vertical = 0x01,
messi1 9:5a7bf0ce8518 163 SD_Diagonal = 0x02
messi1 9:5a7bf0ce8518 164 };
messi1 9:5a7bf0ce8518 165
messi1 9:5a7bf0ce8518 166 enum ScrollInterval{
messi1 9:5a7bf0ce8518 167 SI_6_Frames = 0x00,
messi1 9:5a7bf0ce8518 168 SI_10_Frames = 0x01,
messi1 9:5a7bf0ce8518 169 SI_100_Frames = 0x02,
messi1 9:5a7bf0ce8518 170 SI_200_Frames = 0x03
messi1 0:6e810b5b40a3 171 };
messi1 0:6e810b5b40a3 172
messi1 9:5a7bf0ce8518 173 /** The SSD1331 class drives via the SPI port oled displays with the SSD1331 chip such as the RGB oled from Seeedstudio
messi1 9:5a7bf0ce8518 174 *
messi1 9:5a7bf0ce8518 175 * The class supports various drawinf and scrolling fuctions
messi1 9:5a7bf0ce8518 176 *
messi1 9:5a7bf0ce8518 177 *
messi1 9:5a7bf0ce8518 178 * Example:
messi1 9:5a7bf0ce8518 179 * @code
messi1 9:5a7bf0ce8518 180 * // Draw a line at the rgb old of Seeedstudio
messi1 9:5a7bf0ce8518 181 *
messi1 9:5a7bf0ce8518 182 * #include "mbed.h"
messi1 9:5a7bf0ce8518 183 * #include "SSD1331.h"
messi1 9:5a7bf0ce8518 184 *
messi1 9:5a7bf0ce8518 185 * int main() {
messi1 9:5a7bf0ce8518 186 * SSD1331 oled(P0_15, NC, P0_4, P0_9, NC, P0_10);
messi1 14:961ce3497de1 187 * // or
messi1 14:961ce3497de1 188 * SSD1331 oled(P1_19, NC, P0_7, P0_21, NC, P1_15);
messi1 9:5a7bf0ce8518 189 * oled.drawLine(0, 0, 95, 0, Yellow);
messi1 9:5a7bf0ce8518 190 * }
messi1 9:5a7bf0ce8518 191 * @endcode
messi1 9:5a7bf0ce8518 192 */
messi1 11:162aa3e801df 193 class SSD1331 : public mbed::Stream, public virtual SGL<uint8_t>
messi1 3:af00512c9694 194 {
messi1 3:af00512c9694 195 public:
messi1 9:5a7bf0ce8518 196 /** Create a SPI master connected to the specified pins
messi1 9:5a7bf0ce8518 197 *
messi1 9:5a7bf0ce8518 198 *
messi1 9:5a7bf0ce8518 199 * mosi or miso can be specfied as NC if not used
messi1 9:5a7bf0ce8518 200 *
messi1 9:5a7bf0ce8518 201 * @param cs Chip select pin
messi1 9:5a7bf0ce8518 202 * @param rst Reset pin
messi1 9:5a7bf0ce8518 203 * @param dc Data / #Command pin
messi1 9:5a7bf0ce8518 204 * @param mosi SPI Master Out, Slave In pin
messi1 9:5a7bf0ce8518 205 * @param miso SPI Master In, Slave Out pin
messi1 9:5a7bf0ce8518 206 * @param sclk SPI Clock pin
messi1 9:5a7bf0ce8518 207 */
messi1 3:af00512c9694 208 SSD1331(PinName cs, PinName rst, PinName dc, PinName mosi, PinName miso, PinName sclk);
messi1 5:9de43186f5ea 209
messi1 9:5a7bf0ce8518 210 /** Draws a pixel in a given color on the screen. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 211 *
messi1 9:5a7bf0ce8518 212 * @param x Position x
messi1 9:5a7bf0ce8518 213 * @param y Position y
messi1 9:5a7bf0ce8518 214 * @param color 16bit Color of the pixel
messi1 9:5a7bf0ce8518 215 */
messi1 3:af00512c9694 216 virtual void drawPixel(uint8_t x, uint8_t y, uint16_t color);
messi1 9:5a7bf0ce8518 217
messi1 9:5a7bf0ce8518 218 /** Draws a line from one position to another position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 219 *
messi1 9:5a7bf0ce8518 220 * @param x0 Start Position x
messi1 9:5a7bf0ce8518 221 * @param y0 Start Position y
messi1 9:5a7bf0ce8518 222 * @param x1 End Position x
messi1 9:5a7bf0ce8518 223 * @param y1 End Position y
messi1 9:5a7bf0ce8518 224 * @param color 16bit Color of the pixel
messi1 9:5a7bf0ce8518 225 */
messi1 4:1707ca53e7d5 226 virtual void drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint16_t color);
messi1 9:5a7bf0ce8518 227
messi1 9:5a7bf0ce8518 228 /** Draws a rectangle with no filling. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 229 *
messi1 9:5a7bf0ce8518 230 * @param left Position x
messi1 9:5a7bf0ce8518 231 * @param top Position y
messi1 9:5a7bf0ce8518 232 * @param width Width of the rectangle
messi1 9:5a7bf0ce8518 233 * @param height Height of the rectangle
messi1 9:5a7bf0ce8518 234 * @param color 16bit Color of the rectangle lines
messi1 9:5a7bf0ce8518 235 */
messi1 9:5a7bf0ce8518 236 virtual void drawRect(uint8_t left, uint8_t top, uint8_t width, uint8_t height, uint16_t color);
messi1 9:5a7bf0ce8518 237
messi1 9:5a7bf0ce8518 238 /** Draws a filled rectangle with a seperate border line. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 239 *
messi1 9:5a7bf0ce8518 240 * @param left_x Position x
messi1 9:5a7bf0ce8518 241 * @param top_y Position y
messi1 9:5a7bf0ce8518 242 * @param right_x Position x
messi1 9:5a7bf0ce8518 243 * @param bottom_y Position y
messi1 9:5a7bf0ce8518 244 * @param frameColor 16bit Color of the rectangle lines
messi1 9:5a7bf0ce8518 245 * @param fillColor 16bit Color of the filling
messi1 9:5a7bf0ce8518 246 */
messi1 9:5a7bf0ce8518 247 void drawRect(uint8_t left_x, uint8_t top_y, uint8_t righ_x, uint8_t bottom_y, uint16_t borderColor, uint16_t fillColor);
messi1 9:5a7bf0ce8518 248
messi1 9:5a7bf0ce8518 249 /** Copys an area from a given position to a certain position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 250 *
messi1 9:5a7bf0ce8518 251 * @param x0 Position x top left corner
messi1 9:5a7bf0ce8518 252 * @param y0 Position y top left corner
messi1 9:5a7bf0ce8518 253 * @param x1 Position x bottom right corner
messi1 9:5a7bf0ce8518 254 * @param y1 Position y bottom right corner
messi1 9:5a7bf0ce8518 255 * @param x2 New Position x topleft corner
messi1 9:5a7bf0ce8518 256 * @param y2 New Position y topleft corner
messi1 9:5a7bf0ce8518 257 */
messi1 5:9de43186f5ea 258 void copyArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
messi1 9:5a7bf0ce8518 259
messi1 9:5a7bf0ce8518 260 /** Dims an area from a given start position to a given end position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 261 *
messi1 9:5a7bf0ce8518 262 * @param x0 Position x top left corner
messi1 9:5a7bf0ce8518 263 * @param y0 Position y top left corner
messi1 9:5a7bf0ce8518 264 * @param x1 Position x bottom right corner
messi1 9:5a7bf0ce8518 265 * @param y1 Position y bottom right corner
messi1 9:5a7bf0ce8518 266 */
messi1 5:9de43186f5ea 267 void dimArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
messi1 9:5a7bf0ce8518 268
messi1 9:5a7bf0ce8518 269 /** Clears an area from a given start position to a given end position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 270 *
messi1 9:5a7bf0ce8518 271 * @param x0 Position x top left corner
messi1 9:5a7bf0ce8518 272 * @param y0 Position y top left corner
messi1 9:5a7bf0ce8518 273 * @param x1 Position x bottom right corner
messi1 9:5a7bf0ce8518 274 * @param y1 Position y bottom right corner
messi1 9:5a7bf0ce8518 275 */
messi1 5:9de43186f5ea 276 void clearArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1);
messi1 9:5a7bf0ce8518 277
messi1 9:5a7bf0ce8518 278 /** Moves an area from a given start position to a given end position. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 279 *
messi1 9:5a7bf0ce8518 280 * @param x0 Position x top left corner
messi1 9:5a7bf0ce8518 281 * @param y0 Position y top left corner
messi1 9:5a7bf0ce8518 282 * @param x1 Position x bottom right corner
messi1 9:5a7bf0ce8518 283 * @param y1 Position y bottom right corner
messi1 9:5a7bf0ce8518 284 */
messi1 6:06c211302c93 285 void moveArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
messi1 9:5a7bf0ce8518 286
messi1 9:5a7bf0ce8518 287 /** Fills the screen with a given color. Larger coordinates than the screen will be set to RGB_OLED_XMAX and RGB_OLED_YMAX
messi1 9:5a7bf0ce8518 288 *
messi1 9:5a7bf0ce8518 289 * @param x0 Position x top left corner
messi1 9:5a7bf0ce8518 290 * @param y0 Position y top left corner
messi1 9:5a7bf0ce8518 291 * @param x1 Position x bottom right corner
messi1 9:5a7bf0ce8518 292 * @param y1 Position y bottom right corner
messi1 9:5a7bf0ce8518 293 */
messi1 8:ff74bd4d94d6 294 virtual void fillScreen(uint16_t color);
messi1 9:5a7bf0ce8518 295
messi1 9:5a7bf0ce8518 296 /** Sets the direction and starts the scrolling of the display content.
messi1 9:5a7bf0ce8518 297 *
messi1 9:5a7bf0ce8518 298 * @param direction Direction of the scrolling SD_Horizontal, SD_Vertical or SD_Diagonal
messi1 9:5a7bf0ce8518 299 * @param rowAddr Position y top left corner
messi1 9:5a7bf0ce8518 300 * @param rowNum Position x bottom right corner
messi1 9:5a7bf0ce8518 301 * @param interval Speed of the scrolling either 6, 10 100 or 200 frames
messi1 9:5a7bf0ce8518 302 */
messi1 13:8dd215952d76 303 void setScrolling(ScrollDirection dir, uint8_t rowAddr, uint8_t rowNum, ScrollInterval interval);
messi1 9:5a7bf0ce8518 304
messi1 9:5a7bf0ce8518 305 /** Enables or disables the scrolling
messi1 9:5a7bf0ce8518 306 *
messi1 9:5a7bf0ce8518 307 * @param enable Set true or flase for enabling or disabling the scrolling
messi1 9:5a7bf0ce8518 308 */
messi1 13:8dd215952d76 309 void enableScrolling(bool enable);
messi1 9:5a7bf0ce8518 310
messi1 9:5a7bf0ce8518 311 /** Sets the display mode of the oled screen
messi1 9:5a7bf0ce8518 312 *
messi1 9:5a7bf0ce8518 313 * @param mode DM_NormalDisplay, DM_DisplayOn, DM_DisplayOff or DM_InverseDisplay
messi1 9:5a7bf0ce8518 314 */
messi1 3:af00512c9694 315 void setDisplayMode(DisplayMode mode);
messi1 9:5a7bf0ce8518 316
messi1 9:5a7bf0ce8518 317 /** Sets the power mode of the display
messi1 9:5a7bf0ce8518 318 *
messi1 9:5a7bf0ce8518 319 * @param mode PM_SleepMode or PM_NormalMode
messi1 9:5a7bf0ce8518 320 */
messi1 9:5a7bf0ce8518 321 void setPowerMode(PowerMode mode);
messi1 3:af00512c9694 322
messi1 3:af00512c9694 323 protected:
messi1 3:af00512c9694 324 // Stream implementation functions
messi1 3:af00512c9694 325 virtual int _putc( int c );
messi1 3:af00512c9694 326 virtual int _getc();
messi1 3:af00512c9694 327
messi1 3:af00512c9694 328 private:
messi1 5:9de43186f5ea 329 void init(void);
messi1 3:af00512c9694 330 void sendCmd(uint8_t cmd);
messi1 3:af00512c9694 331 void sendCmd(uint8_t cmd, uint8_t arg1);
messi1 3:af00512c9694 332 void sendCmd(uint8_t cmd, uint8_t arg1, uint8_t arg2);
messi1 3:af00512c9694 333 void sendCmd(uint8_t *cmd, uint8_t count);
messi1 3:af00512c9694 334 void sendData(uint16_t data);
messi1 3:af00512c9694 335
messi1 3:af00512c9694 336 private:
messi1 3:af00512c9694 337 mbed::DigitalOut _cs;
messi1 3:af00512c9694 338 mbed::DigitalOut _dc;
messi1 3:af00512c9694 339 mbed::SPI _spiPort;
messi1 0:6e810b5b40a3 340 };
messi1 0:6e810b5b40a3 341
messi1 0:6e810b5b40a3 342 #endif