Driver for the Seeedstudio RGB OLED module for the xadow M0

Committer:
messi1
Date:
Thu Nov 12 23:23:33 2015 +0000
Revision:
3:af00512c9694
Parent:
2:e033aab5daad
Child:
4:1707ca53e7d5
Replaced unsigned char with uint8_t

Who changed what in which revision?

UserRevisionLine numberNew contents of line
messi1 0:6e810b5b40a3 1 /*
messi1 0:6e810b5b40a3 2 * SSD1331.cpp
messi1 0:6e810b5b40a3 3 * A library for RGB OLED module
messi1 0:6e810b5b40a3 4 *
messi1 0:6e810b5b40a3 5 * Copyright (c) 2014 seeed technology inc.
messi1 0:6e810b5b40a3 6 * Copyright (c) 2012, Adafruit Industries.
messi1 0:6e810b5b40a3 7 *
messi1 0:6e810b5b40a3 8 * All rights reserved.
messi1 0:6e810b5b40a3 9 *
messi1 0:6e810b5b40a3 10 * This library is based on Adafruit's SSD1331-OLED-Driver-Library. Thanks to
messi1 0:6e810b5b40a3 11 * their contribution to the code, we modify it and add more interface to
messi1 0:6e810b5b40a3 12 * support our Seeed's Xadow RGB OLED 96*64 module.
messi1 0:6e810b5b40a3 13 *
messi1 0:6e810b5b40a3 14 * Below is the introduction of Adafruit's Color OLED module, we add it to here
messi1 0:6e810b5b40a3 15 * to express our thanks to them.
messi1 0:6e810b5b40a3 16 *
messi1 0:6e810b5b40a3 17 * ****************************************************************************
messi1 0:6e810b5b40a3 18 * This is a library for the 0.96" 16-bit Color OLED with SSD1331 driver chip
messi1 0:6e810b5b40a3 19 *
messi1 0:6e810b5b40a3 20 * Pick one up today in the adafruit shop!
messi1 0:6e810b5b40a3 21 * ------> http://www.adafruit.com/products/684
messi1 0:6e810b5b40a3 22 *
messi1 0:6e810b5b40a3 23 * These displays use SPI to communicate.
messi1 0:6e810b5b40a3 24 *
messi1 0:6e810b5b40a3 25 * Adafruit invests time and resources providing this open source code,
messi1 0:6e810b5b40a3 26 * please support Adafruit and open-source hardware by purchasing
messi1 0:6e810b5b40a3 27 * products from Adafruit!
messi1 0:6e810b5b40a3 28 *
messi1 0:6e810b5b40a3 29 * Written by Limor Fried/Ladyada for Adafruit Industries.
messi1 0:6e810b5b40a3 30 * Modifed by lawliet for Seeed Studio's RGB OLED module.
messi1 0:6e810b5b40a3 31 * BSD license, all text above must be included in any redistribution
messi1 0:6e810b5b40a3 32 * ******************************************************************************
messi1 0:6e810b5b40a3 33 *
messi1 0:6e810b5b40a3 34 * Software License Agreement (BSD License)
messi1 0:6e810b5b40a3 35 *
messi1 0:6e810b5b40a3 36 * Redistribution and use in source and binary forms, with or without
messi1 0:6e810b5b40a3 37 * modification, are permitted provided that the following conditions are met:
messi1 0:6e810b5b40a3 38 * 1. Redistributions of source code must retain the above copyright
messi1 0:6e810b5b40a3 39 * notice, this list of conditions and the following disclaimer.
messi1 0:6e810b5b40a3 40 * 2. Redistributions in binary form must reproduce the above copyright
messi1 0:6e810b5b40a3 41 * notice, this list of conditions and the following disclaimer in the
messi1 0:6e810b5b40a3 42 * documentation and/or other materials provided with the distribution.
messi1 0:6e810b5b40a3 43 * 3. Neither the name of the copyright holders nor the
messi1 0:6e810b5b40a3 44 * names of its contributors may be used to endorse or promote products
messi1 0:6e810b5b40a3 45 * derived from this software without specific prior written permission.
messi1 0:6e810b5b40a3 46 *
messi1 0:6e810b5b40a3 47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
messi1 0:6e810b5b40a3 48 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
messi1 0:6e810b5b40a3 49 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
messi1 0:6e810b5b40a3 50 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
messi1 0:6e810b5b40a3 51 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
messi1 0:6e810b5b40a3 52 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
messi1 0:6e810b5b40a3 53 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
messi1 0:6e810b5b40a3 54 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
messi1 0:6e810b5b40a3 55 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
messi1 0:6e810b5b40a3 56 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
messi1 0:6e810b5b40a3 57 *
messi1 0:6e810b5b40a3 58 */
messi1 0:6e810b5b40a3 59 #include "DigitalOut.h"
messi1 0:6e810b5b40a3 60 #include "SPI.h"
messi1 0:6e810b5b40a3 61 #include "SSD1331.h"
messi1 0:6e810b5b40a3 62
messi1 2:e033aab5daad 63 SSD1331::SSD1331(PinName cs, PinName rst, PinName dc, PinName mosi, PinName miso, PinName sclk)
messi1 2:e033aab5daad 64 :SGL(RGB_OLED_WIDTH, RGB_OLED_HEIGHT), _cs(cs), _dc(dc), _spiPort(mosi, miso, sclk)
messi1 0:6e810b5b40a3 65 {
messi1 2:e033aab5daad 66 _spiPort.format(8,3); //8bit frame and POL=1 /PHA=1(UpEdge Sampled)
messi1 2:e033aab5daad 67 _spiPort.frequency(25000000); // modify later
messi1 2:e033aab5daad 68
messi1 2:e033aab5daad 69 init();
messi1 0:6e810b5b40a3 70 };
messi1 0:6e810b5b40a3 71
messi1 3:af00512c9694 72 void SSD1331::sendCmd(uint8_t cmd)
messi1 2:e033aab5daad 73 {
messi1 2:e033aab5daad 74 _dc = 0;
messi1 2:e033aab5daad 75 _cs = 0;
messi1 2:e033aab5daad 76 _spiPort.write(cmd);
messi1 2:e033aab5daad 77 _cs = 1;
messi1 2:e033aab5daad 78 }
messi1 2:e033aab5daad 79
messi1 3:af00512c9694 80 void SSD1331::sendCmd(uint8_t cmd, uint8_t arg1)
messi1 2:e033aab5daad 81 {
messi1 2:e033aab5daad 82 _dc = 0;
messi1 2:e033aab5daad 83 _cs = 0;
messi1 2:e033aab5daad 84 _spiPort.write(cmd);
messi1 2:e033aab5daad 85 _spiPort.write(arg1);
messi1 2:e033aab5daad 86 _cs = 1;
messi1 2:e033aab5daad 87 }
messi1 2:e033aab5daad 88
messi1 3:af00512c9694 89 void SSD1331::sendCmd(uint8_t cmd, uint8_t arg1, uint8_t arg2)
messi1 0:6e810b5b40a3 90 {
messi1 2:e033aab5daad 91 _dc = 0;
messi1 2:e033aab5daad 92 _cs = 0;
messi1 2:e033aab5daad 93 _spiPort.write(cmd);
messi1 2:e033aab5daad 94 _spiPort.write(arg1);
messi1 2:e033aab5daad 95 _spiPort.write(arg2);
messi1 2:e033aab5daad 96 _cs = 1;
messi1 2:e033aab5daad 97 }
messi1 2:e033aab5daad 98
messi1 3:af00512c9694 99 void SSD1331::sendCmd(uint8_t *cmd, uint8_t count)
messi1 2:e033aab5daad 100 {
messi1 2:e033aab5daad 101 if(!cmd) return;
messi1 2:e033aab5daad 102
messi1 2:e033aab5daad 103 _dc = 0;
messi1 2:e033aab5daad 104 _cs = 0;
messi1 3:af00512c9694 105 for(uint8_t i=0; i<count; ++i)
messi1 2:e033aab5daad 106 _spiPort.write(*cmd++);
messi1 2:e033aab5daad 107 _cs = 1;
messi1 2:e033aab5daad 108 }
messi1 2:e033aab5daad 109
messi1 2:e033aab5daad 110 void SSD1331::sendData(uint16_t data)
messi1 2:e033aab5daad 111 {
messi1 2:e033aab5daad 112 _dc = HIGH;
messi1 2:e033aab5daad 113 _cs = LOW;
messi1 2:e033aab5daad 114 _spiPort.write(data >> 8);
messi1 2:e033aab5daad 115 _spiPort.write((data & 0x00ff));
messi1 2:e033aab5daad 116 _cs = HIGH;
messi1 2:e033aab5daad 117 }
messi1 2:e033aab5daad 118
messi1 2:e033aab5daad 119 int SSD1331::_getc()
messi1 2:e033aab5daad 120 {
messi1 2:e033aab5daad 121 return -1;
messi1 2:e033aab5daad 122 }
messi1 2:e033aab5daad 123
messi1 2:e033aab5daad 124 int SSD1331::_putc( int c )
messi1 2:e033aab5daad 125 {
messi1 2:e033aab5daad 126 return -1;
messi1 0:6e810b5b40a3 127 }
messi1 0:6e810b5b40a3 128
messi1 0:6e810b5b40a3 129 void SSD1331::init(void)
messi1 0:6e810b5b40a3 130 {
messi1 2:e033aab5daad 131 // initialize sequence
messi1 2:e033aab5daad 132 sendCmd(CMD_DISPLAY_OFF); //OLED display OFF
messi1 2:e033aab5daad 133
messi1 2:e033aab5daad 134 //Row Address
messi1 2:e033aab5daad 135 sendCmd(CMD_SET_ROW_ADDRESS, 0x00, 0x3f); //Set Row Address with start=0,end=63
messi1 2:e033aab5daad 136 sendCmd(CMD_SET_COLUMN_ADDRESS, 0x00, 0x5f); //Set Column Address with start=0,end=95
messi1 2:e033aab5daad 137
messi1 2:e033aab5daad 138 //Contrast
messi1 2:e033aab5daad 139 sendCmd(CMD_SET_REMAP, 0x76); //Set remap & data format 0111 0000 // 65k Color/8bit buswidth/format1
messi1 2:e033aab5daad 140 sendCmd(CMD_SET_DISPLAY_START_LINE, 0x00); //Set display start row RAM
messi1 2:e033aab5daad 141 sendCmd(CMD_SET_DISPLAY_OFFSET, 0x00); //Set dispaly offset
messi1 2:e033aab5daad 142 sendCmd(CMD_NORMAL_DISPLAY); //Set Display Mode
messi1 2:e033aab5daad 143 sendCmd(CMD_SET_MULTIPLEX_RATIO, 0x3f); //Set Multiplex Ratio
messi1 2:e033aab5daad 144 sendCmd(CMD_SET_MASTER_CONFIGURE, 0x8f); //Set Master Configuration (External VCC Supply Selected)
messi1 2:e033aab5daad 145 sendCmd(CMD_POWER_SAVE_MODE, 0x1a); //Set Power Saving Mode
messi1 2:e033aab5daad 146 sendCmd(CMD_PHASE_PERIOD_ADJUSTMENT, 0x74);//Set Phase 1 & 2 Period Adjustment
messi1 2:e033aab5daad 147 sendCmd(CMD_DISPLAY_CLOCK_DIV, 0xd0); //Set Display Clock Divide Ratio / Oscillator Frequency
messi1 2:e033aab5daad 148 sendCmd(CMD_SET_PRECHARGE_SPEED_A, 0x81); //Set Second Pre-charge Speed of Color A
messi1 2:e033aab5daad 149 sendCmd(CMD_SET_PRECHARGE_SPEED_B, 0x82); //Set Second Pre-charge Speed of Color B
messi1 2:e033aab5daad 150 sendCmd(CMD_SET_PRECHARGE_SPEED_C, 0x83); //Set Second Pre-charge Speed of Color C
messi1 2:e033aab5daad 151 sendCmd(CMD_SET_PRECHARGE_VOLTAGE, 0x3e); //Set Pre-charge Level
messi1 2:e033aab5daad 152 sendCmd(CMD_SET_V_VOLTAGE, 0x3e); //Set VCOMH
messi1 2:e033aab5daad 153 sendCmd(CMD_MASTER_CURRENT_CONTROL, 0x0f); //Set Master Current Control
messi1 2:e033aab5daad 154 sendCmd(CMD_SET_CONTRAST_A, 0x80); //Set Contrast Control for Color &#129;gA&#129;h
messi1 2:e033aab5daad 155 sendCmd(CMD_SET_CONTRAST_B, 0x80); //Set Contrast Control for Color &#129;gB&#129;h
messi1 2:e033aab5daad 156 sendCmd(CMD_SET_CONTRAST_C, 0x80); //Set Contrast Control for Color &#129;gC&#129;h
messi1 2:e033aab5daad 157
messi1 2:e033aab5daad 158 fillRectangle(0,0, RGB_OLED_WIDTH, RGB_OLED_HEIGHT, 0x0);
messi1 2:e033aab5daad 159 sendCmd(CMD_NORMAL_BRIGHTNESS_DISPLAY_ON); //display ON
messi1 0:6e810b5b40a3 160
messi1 2:e033aab5daad 161 // sendCmd(CMD_DISPLAY_OFF); //Display Off
messi1 2:e033aab5daad 162 // sendCmd(CMD_SET_CONTRAST_A); //Set contrast for color A
messi1 2:e033aab5daad 163 // sendCmd(0x91); //145
messi1 2:e033aab5daad 164 // sendCmd(CMD_SET_CONTRAST_B); //Set contrast for color B
messi1 2:e033aab5daad 165 // sendCmd(0x50); //80
messi1 2:e033aab5daad 166 // sendCmd(CMD_SET_CONTRAST_C); //Set contrast for color C
messi1 2:e033aab5daad 167 // sendCmd(0x7D); //125
messi1 2:e033aab5daad 168 // sendCmd(CMD_MASTER_CURRENT_CONTROL);//master current control
messi1 2:e033aab5daad 169 // sendCmd(0x06); //6
messi1 2:e033aab5daad 170 // sendCmd(CMD_SET_PRECHARGE_SPEED_A);//Set Second Pre-change Speed For ColorA
messi1 2:e033aab5daad 171 // sendCmd(0x64); //100
messi1 2:e033aab5daad 172 // sendCmd(CMD_SET_PRECHARGE_SPEED_B);//Set Second Pre-change Speed For ColorB
messi1 2:e033aab5daad 173 // sendCmd(0x78); //120
messi1 2:e033aab5daad 174 // sendCmd(CMD_SET_PRECHARGE_SPEED_C);//Set Second Pre-change Speed For ColorC
messi1 2:e033aab5daad 175 // sendCmd(0x64); //100
messi1 2:e033aab5daad 176 // sendCmd(CMD_SET_REMAP); //set remap & data format
messi1 2:e033aab5daad 177 // sendCmd(0x72); //0x72
messi1 2:e033aab5daad 178 // sendCmd(CMD_SET_DISPLAY_START_LINE);//Set display Start Line
messi1 2:e033aab5daad 179 // sendCmd(0x0);
messi1 2:e033aab5daad 180 // sendCmd(CMD_SET_DISPLAY_OFFSET); //Set display offset
messi1 2:e033aab5daad 181 // sendCmd(0x0);
messi1 2:e033aab5daad 182 // sendCmd(CMD_NORMAL_DISPLAY); //Set display mode
messi1 2:e033aab5daad 183 // sendCmd(CMD_SET_MULTIPLEX_RATIO); //Set multiplex ratio
messi1 2:e033aab5daad 184 // sendCmd(0x3F);
messi1 2:e033aab5daad 185 // sendCmd(CMD_SET_MASTER_CONFIGURE); //Set master configuration
messi1 2:e033aab5daad 186 // sendCmd(0x8E);
messi1 2:e033aab5daad 187 // sendCmd(CMD_POWER_SAVE_MODE); //Set Power Save Mode
messi1 2:e033aab5daad 188 // sendCmd(0x00); //0x00
messi1 2:e033aab5daad 189 // sendCmd(CMD_PHASE_PERIOD_ADJUSTMENT);//phase 1 and 2 period adjustment
messi1 2:e033aab5daad 190 // sendCmd(0x31); //0x31
messi1 2:e033aab5daad 191 // sendCmd(CMD_DISPLAY_CLOCK_DIV); //display clock divider/oscillator frequency
messi1 2:e033aab5daad 192 // sendCmd(0xF0);
messi1 2:e033aab5daad 193 // sendCmd(CMD_SET_PRECHARGE_VOLTAGE);//Set Pre-Change Level
messi1 2:e033aab5daad 194 // sendCmd(0x3A);
messi1 2:e033aab5daad 195 // sendCmd(CMD_SET_V_VOLTAGE); //Set vcomH
messi1 2:e033aab5daad 196 // sendCmd(0x3E);
messi1 2:e033aab5daad 197 // sendCmd(CMD_DEACTIVE_SCROLLING); //disable scrolling
messi1 2:e033aab5daad 198 // sendCmd(CMD_NORMAL_BRIGHTNESS_DISPLAY_ON);//set display on
messi1 0:6e810b5b40a3 199 }
messi1 0:6e810b5b40a3 200
messi1 3:af00512c9694 201 void SSD1331::drawPixel(uint8_t x, uint8_t y, uint16_t color)
messi1 0:6e810b5b40a3 202 {
messi1 0:6e810b5b40a3 203 if ((x >= RGB_OLED_WIDTH) || (y >= RGB_OLED_HEIGHT))
messi1 0:6e810b5b40a3 204 return;
messi1 2:e033aab5daad 205
messi1 3:af00512c9694 206 // set column point set row point
messi1 3:af00512c9694 207 uint8_t cmd[7] = {CMD_SET_COLUMN_ADDRESS, x, x, CMD_SET_ROW_ADDRESS, y, y, 0x00};
messi1 3:af00512c9694 208 sendCmd(cmd, 6);
messi1 2:e033aab5daad 209
messi1 0:6e810b5b40a3 210 //fill 16bit colour
messi1 2:e033aab5daad 211 sendData(color);
messi1 0:6e810b5b40a3 212 }
messi1 0:6e810b5b40a3 213
messi1 2:e033aab5daad 214 //-------------------------------------------------------------------------
messi1 0:6e810b5b40a3 215 void SSD1331::drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color)
messi1 0:6e810b5b40a3 216 {
messi1 0:6e810b5b40a3 217 if (x0 >= RGB_OLED_WIDTH) x0 = RGB_OLED_WIDTH - 1;
messi1 0:6e810b5b40a3 218 if (y0 >= RGB_OLED_HEIGHT) y0 = RGB_OLED_HEIGHT - 1;
messi1 0:6e810b5b40a3 219 if (x1 >= RGB_OLED_WIDTH) x1 = RGB_OLED_WIDTH - 1;
messi1 0:6e810b5b40a3 220 if (y1 >= RGB_OLED_HEIGHT) y1 = RGB_OLED_HEIGHT - 1;
messi1 0:6e810b5b40a3 221
messi1 2:e033aab5daad 222 sendCmd(CMD_DRAW_LINE);//draw line
messi1 2:e033aab5daad 223 sendCmd(x0);//start column
messi1 2:e033aab5daad 224 sendCmd(y0);//start row
messi1 2:e033aab5daad 225 sendCmd(x1);//end column
messi1 2:e033aab5daad 226 sendCmd(y1);//end row
messi1 2:e033aab5daad 227 sendCmd((uint8_t)((color>>11)&0x1F));//R
messi1 2:e033aab5daad 228 sendCmd((uint8_t)((color>>5)&0x3F));//G
messi1 2:e033aab5daad 229 sendCmd((uint8_t)(color&0x1F));//B
messi1 0:6e810b5b40a3 230 }
messi1 0:6e810b5b40a3 231
messi1 0:6e810b5b40a3 232 void SSD1331::drawFrame(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t outColor, uint16_t fillColor)
messi1 0:6e810b5b40a3 233 {
messi1 0:6e810b5b40a3 234 if (x0 >= RGB_OLED_WIDTH) x0 = RGB_OLED_WIDTH - 1;
messi1 0:6e810b5b40a3 235 if (y0 >= RGB_OLED_HEIGHT) y0 = RGB_OLED_HEIGHT - 1;
messi1 0:6e810b5b40a3 236 if (x1 >= RGB_OLED_WIDTH) x1 = RGB_OLED_WIDTH - 1;
messi1 0:6e810b5b40a3 237 if (y1 >= RGB_OLED_HEIGHT) y1 = RGB_OLED_HEIGHT - 1;
messi1 0:6e810b5b40a3 238
messi1 2:e033aab5daad 239 sendCmd(CMD_FILL_WINDOW);//fill window
messi1 2:e033aab5daad 240 sendCmd(ENABLE_FILL);
messi1 2:e033aab5daad 241 sendCmd(CMD_DRAW_RECTANGLE);//draw rectangle
messi1 2:e033aab5daad 242 sendCmd(x0);//start column
messi1 2:e033aab5daad 243 sendCmd(y0);//start row
messi1 2:e033aab5daad 244 sendCmd(x1);//end column
messi1 2:e033aab5daad 245 sendCmd(y1);//end row
messi1 2:e033aab5daad 246 sendCmd((uint8_t)((outColor>>11)&0x1F));//R
messi1 2:e033aab5daad 247 sendCmd((uint8_t)((outColor>>5)&0x3F));//G
messi1 2:e033aab5daad 248 sendCmd((uint8_t)(outColor&0x1F));//B
messi1 2:e033aab5daad 249 sendCmd((uint8_t)((fillColor>>11)&0x1F));//R
messi1 2:e033aab5daad 250 sendCmd((uint8_t)((fillColor>>5)&0x3F));//G
messi1 2:e033aab5daad 251 sendCmd((uint8_t)(fillColor&0x1F));//B
messi1 0:6e810b5b40a3 252 }
messi1 0:6e810b5b40a3 253
messi1 0:6e810b5b40a3 254 void SSD1331::copyWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,uint16_t x2, uint16_t y2)
messi1 0:6e810b5b40a3 255 {
messi1 2:e033aab5daad 256 sendCmd(CMD_COPY_WINDOW);//copy window
messi1 2:e033aab5daad 257 sendCmd(x0);//start column
messi1 2:e033aab5daad 258 sendCmd(y0);//start row
messi1 2:e033aab5daad 259 sendCmd(x1);//end column
messi1 2:e033aab5daad 260 sendCmd(y1);//end row
messi1 2:e033aab5daad 261 sendCmd(x2);//new column
messi1 2:e033aab5daad 262 sendCmd(y2);//new row
messi1 0:6e810b5b40a3 263 }
messi1 0:6e810b5b40a3 264
messi1 0:6e810b5b40a3 265 void SSD1331::dimWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
messi1 0:6e810b5b40a3 266 {
messi1 2:e033aab5daad 267 sendCmd(CMD_DIM_WINDOW);//copy area
messi1 2:e033aab5daad 268 sendCmd(x0);//start column
messi1 2:e033aab5daad 269 sendCmd(y0);//start row
messi1 2:e033aab5daad 270 sendCmd(x1);//end column
messi1 2:e033aab5daad 271 sendCmd(y1);//end row
messi1 0:6e810b5b40a3 272 }
messi1 0:6e810b5b40a3 273
messi1 0:6e810b5b40a3 274 void SSD1331::clearWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
messi1 0:6e810b5b40a3 275 {
messi1 2:e033aab5daad 276 sendCmd(CMD_CLEAR_WINDOW);//clear window
messi1 2:e033aab5daad 277 sendCmd(x0);//start column
messi1 2:e033aab5daad 278 sendCmd(y0);//start row
messi1 2:e033aab5daad 279 sendCmd(x1);//end column
messi1 2:e033aab5daad 280 sendCmd(y1);//end row
messi1 0:6e810b5b40a3 281 }
messi1 0:6e810b5b40a3 282
messi1 0:6e810b5b40a3 283 void SSD1331::setScolling(ScollingDirection direction, uint8_t rowAddr, uint8_t rowNum, uint8_t timeInterval)
messi1 0:6e810b5b40a3 284 {
messi1 0:6e810b5b40a3 285 uint8_t scolling_horizontal = 0x0;
messi1 0:6e810b5b40a3 286 uint8_t scolling_vertical = 0x0;
messi1 0:6e810b5b40a3 287 switch(direction){
messi1 0:6e810b5b40a3 288 case Horizontal:
messi1 0:6e810b5b40a3 289 scolling_horizontal = 0x01;
messi1 0:6e810b5b40a3 290 scolling_vertical = 0x00;
messi1 0:6e810b5b40a3 291 break;
messi1 0:6e810b5b40a3 292 case Vertical:
messi1 0:6e810b5b40a3 293 scolling_horizontal = 0x00;
messi1 0:6e810b5b40a3 294 scolling_vertical = 0x01;
messi1 0:6e810b5b40a3 295 break;
messi1 0:6e810b5b40a3 296 case Diagonal:
messi1 0:6e810b5b40a3 297 scolling_horizontal = 0x01;
messi1 0:6e810b5b40a3 298 scolling_vertical = 0x01;
messi1 0:6e810b5b40a3 299 break;
messi1 0:6e810b5b40a3 300 default:
messi1 0:6e810b5b40a3 301 break;
messi1 0:6e810b5b40a3 302 }
messi1 2:e033aab5daad 303 sendCmd(CMD_CONTINUOUS_SCROLLING_SETUP);
messi1 2:e033aab5daad 304 sendCmd(scolling_horizontal);
messi1 2:e033aab5daad 305 sendCmd(rowAddr);
messi1 2:e033aab5daad 306 sendCmd(rowNum);
messi1 2:e033aab5daad 307 sendCmd(scolling_vertical);
messi1 2:e033aab5daad 308 sendCmd(timeInterval);
messi1 2:e033aab5daad 309 sendCmd(CMD_ACTIVE_SCROLLING);
messi1 0:6e810b5b40a3 310 }
messi1 0:6e810b5b40a3 311
messi1 0:6e810b5b40a3 312 void SSD1331::enableScolling(bool enable)
messi1 0:6e810b5b40a3 313 {
messi1 0:6e810b5b40a3 314 if(enable)
messi1 2:e033aab5daad 315 sendCmd(CMD_ACTIVE_SCROLLING);
messi1 0:6e810b5b40a3 316 else
messi1 2:e033aab5daad 317 sendCmd(CMD_DEACTIVE_SCROLLING);
messi1 0:6e810b5b40a3 318 }
messi1 0:6e810b5b40a3 319
messi1 0:6e810b5b40a3 320 void SSD1331::setDisplayMode(DisplayMode mode)
messi1 0:6e810b5b40a3 321 {
messi1 2:e033aab5daad 322 sendCmd(mode);
messi1 0:6e810b5b40a3 323 }
messi1 0:6e810b5b40a3 324
messi1 0:6e810b5b40a3 325 void SSD1331::setDisplayPower(DisplayPower power)
messi1 0:6e810b5b40a3 326 {
messi1 2:e033aab5daad 327 sendCmd(power);
messi1 0:6e810b5b40a3 328 }