Graham Bloice / EAQVGAOLED
Committer:
gbloice
Date:
Wed Feb 09 21:23:49 2011 +0000
Revision:
0:ae3d20db48fc
Updated description

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gbloice 0:ae3d20db48fc 1 /* mbed library for driving the EA QVGA 2.8" OLED
gbloice 0:ae3d20db48fc 2 * Copyright (c) Graham Bloice 2011
gbloice 0:ae3d20db48fc 3 *
gbloice 0:ae3d20db48fc 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
gbloice 0:ae3d20db48fc 5 * of this software and associated documentation files (the "Software"), to deal
gbloice 0:ae3d20db48fc 6 * in the Software without restriction, including without limitation the rights
gbloice 0:ae3d20db48fc 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
gbloice 0:ae3d20db48fc 8 * copies of the Software, and to permit persons to whom the Software is
gbloice 0:ae3d20db48fc 9 * furnished to do so, subject to the following conditions:
gbloice 0:ae3d20db48fc 10 *
gbloice 0:ae3d20db48fc 11 * The above copyright notice and this permission notice shall be included in
gbloice 0:ae3d20db48fc 12 * all copies or substantial portions of the Software.
gbloice 0:ae3d20db48fc 13 *
gbloice 0:ae3d20db48fc 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
gbloice 0:ae3d20db48fc 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
gbloice 0:ae3d20db48fc 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
gbloice 0:ae3d20db48fc 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
gbloice 0:ae3d20db48fc 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
gbloice 0:ae3d20db48fc 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
gbloice 0:ae3d20db48fc 20 * THE SOFTWARE.
gbloice 0:ae3d20db48fc 21 */
gbloice 0:ae3d20db48fc 22
gbloice 0:ae3d20db48fc 23 #include "EAQVGAOLED.h"
gbloice 0:ae3d20db48fc 24 #include "mbed.h"
gbloice 0:ae3d20db48fc 25
gbloice 0:ae3d20db48fc 26 // Constants
gbloice 0:ae3d20db48fc 27 const unsigned int EAQVGAOLED_ID = 0x63D6; // The display controller ID
gbloice 0:ae3d20db48fc 28
gbloice 0:ae3d20db48fc 29 // Local functions
gbloice 0:ae3d20db48fc 30 inline void orderCoords
gbloice 0:ae3d20db48fc 31 (
gbloice 0:ae3d20db48fc 32 const uint16_t x0,
gbloice 0:ae3d20db48fc 33 const uint16_t y0,
gbloice 0:ae3d20db48fc 34 const uint16_t x1,
gbloice 0:ae3d20db48fc 35 const uint16_t y1,
gbloice 0:ae3d20db48fc 36 uint16_t &startX,
gbloice 0:ae3d20db48fc 37 uint16_t &startY,
gbloice 0:ae3d20db48fc 38 uint16_t &endX,
gbloice 0:ae3d20db48fc 39 uint16_t &endY
gbloice 0:ae3d20db48fc 40 )
gbloice 0:ae3d20db48fc 41 {
gbloice 0:ae3d20db48fc 42 // Order the drawing co-ords
gbloice 0:ae3d20db48fc 43 if (x1 > x0) {
gbloice 0:ae3d20db48fc 44 startX = x0;
gbloice 0:ae3d20db48fc 45 endX = x1;
gbloice 0:ae3d20db48fc 46 }
gbloice 0:ae3d20db48fc 47 else {
gbloice 0:ae3d20db48fc 48 startX = x1;
gbloice 0:ae3d20db48fc 49 endX = x0;
gbloice 0:ae3d20db48fc 50 }
gbloice 0:ae3d20db48fc 51 if (y1 > y0) {
gbloice 0:ae3d20db48fc 52 startY = y0;
gbloice 0:ae3d20db48fc 53 endY = y1;
gbloice 0:ae3d20db48fc 54 }
gbloice 0:ae3d20db48fc 55 else {
gbloice 0:ae3d20db48fc 56 startY = y1;
gbloice 0:ae3d20db48fc 57 endY = y0;
gbloice 0:ae3d20db48fc 58 }
gbloice 0:ae3d20db48fc 59 }
gbloice 0:ae3d20db48fc 60
gbloice 0:ae3d20db48fc 61 EAQVGAOLED::EAQVGAOLED
gbloice 0:ae3d20db48fc 62 (
gbloice 0:ae3d20db48fc 63 PinName mosi,
gbloice 0:ae3d20db48fc 64 PinName miso,
gbloice 0:ae3d20db48fc 65 PinName sclk,
gbloice 0:ae3d20db48fc 66 PinName cs,
gbloice 0:ae3d20db48fc 67 PinName reset,
gbloice 0:ae3d20db48fc 68 PinName bl
gbloice 0:ae3d20db48fc 69 ) : _spi(mosi, miso, sclk), _cs(cs), _reset(reset), _bl(bl)
gbloice 0:ae3d20db48fc 70 {
gbloice 0:ae3d20db48fc 71 // Initialise the hardware
gbloice 0:ae3d20db48fc 72 initHardware();
gbloice 0:ae3d20db48fc 73
gbloice 0:ae3d20db48fc 74 // And reset the display
gbloice 0:ae3d20db48fc 75 resetDisplay();
gbloice 0:ae3d20db48fc 76 }
gbloice 0:ae3d20db48fc 77
gbloice 0:ae3d20db48fc 78 void EAQVGAOLED::pixel
gbloice 0:ae3d20db48fc 79 (
gbloice 0:ae3d20db48fc 80 int x,
gbloice 0:ae3d20db48fc 81 int y,
gbloice 0:ae3d20db48fc 82 int colour
gbloice 0:ae3d20db48fc 83 )
gbloice 0:ae3d20db48fc 84 {
gbloice 0:ae3d20db48fc 85 // Set the x and y positions via their registers, then the colour
gbloice 0:ae3d20db48fc 86 writeDataRegister(0x20, x);
gbloice 0:ae3d20db48fc 87 writeDataRegister(0x21, y);
gbloice 0:ae3d20db48fc 88 writeDataRegister(0x22, colour);
gbloice 0:ae3d20db48fc 89 }
gbloice 0:ae3d20db48fc 90
gbloice 0:ae3d20db48fc 91 void EAQVGAOLED::hLine
gbloice 0:ae3d20db48fc 92 (
gbloice 0:ae3d20db48fc 93 const uint16_t x0,
gbloice 0:ae3d20db48fc 94 const uint16_t y0,
gbloice 0:ae3d20db48fc 95 const uint16_t x1,
gbloice 0:ae3d20db48fc 96 const uint16_t colour
gbloice 0:ae3d20db48fc 97 )
gbloice 0:ae3d20db48fc 98 {
gbloice 0:ae3d20db48fc 99 // Make sure we are drawing in the correct direction
gbloice 0:ae3d20db48fc 100 uint16_t startPos;
gbloice 0:ae3d20db48fc 101 uint16_t length;
gbloice 0:ae3d20db48fc 102 if (x1 > x0) {
gbloice 0:ae3d20db48fc 103 startPos = x0;
gbloice 0:ae3d20db48fc 104 length = x1 - x0;
gbloice 0:ae3d20db48fc 105 }
gbloice 0:ae3d20db48fc 106 else {
gbloice 0:ae3d20db48fc 107 startPos = x1;
gbloice 0:ae3d20db48fc 108 length = x0 - x1;
gbloice 0:ae3d20db48fc 109 }
gbloice 0:ae3d20db48fc 110
gbloice 0:ae3d20db48fc 111 // Now draw the line, the display is set to auto increment in x
gbloice 0:ae3d20db48fc 112 movePen(startPos, y0);
gbloice 0:ae3d20db48fc 113 for (uint16_t i = 0; i < length; i++) {
gbloice 0:ae3d20db48fc 114 writeData(colour);
gbloice 0:ae3d20db48fc 115 }
gbloice 0:ae3d20db48fc 116 }
gbloice 0:ae3d20db48fc 117
gbloice 0:ae3d20db48fc 118 void EAQVGAOLED::vLine
gbloice 0:ae3d20db48fc 119 (
gbloice 0:ae3d20db48fc 120 uint16_t x0,
gbloice 0:ae3d20db48fc 121 uint16_t y0,
gbloice 0:ae3d20db48fc 122 uint16_t y1,
gbloice 0:ae3d20db48fc 123 uint16_t colour
gbloice 0:ae3d20db48fc 124 )
gbloice 0:ae3d20db48fc 125 {
gbloice 0:ae3d20db48fc 126 // Make sure we are drawing in the correct direction
gbloice 0:ae3d20db48fc 127 uint16_t startPos;
gbloice 0:ae3d20db48fc 128 uint16_t endPos;
gbloice 0:ae3d20db48fc 129 if (y1 > y0) {
gbloice 0:ae3d20db48fc 130 startPos = y0;
gbloice 0:ae3d20db48fc 131 endPos = y1;
gbloice 0:ae3d20db48fc 132 }
gbloice 0:ae3d20db48fc 133 else {
gbloice 0:ae3d20db48fc 134 startPos = y1;
gbloice 0:ae3d20db48fc 135 endPos = y0;
gbloice 0:ae3d20db48fc 136 }
gbloice 0:ae3d20db48fc 137
gbloice 0:ae3d20db48fc 138 // TODO This might be optimised by setting the Addressing mode bit AM to 1 (reg 03)
gbloice 0:ae3d20db48fc 139
gbloice 0:ae3d20db48fc 140 // Now draw the line
gbloice 0:ae3d20db48fc 141 for (uint16_t i = startPos; i < endPos; i++) {
gbloice 0:ae3d20db48fc 142 pixel(x0, i, colour);
gbloice 0:ae3d20db48fc 143 }
gbloice 0:ae3d20db48fc 144 }
gbloice 0:ae3d20db48fc 145
gbloice 0:ae3d20db48fc 146 void EAQVGAOLED::rectangle
gbloice 0:ae3d20db48fc 147 (
gbloice 0:ae3d20db48fc 148 const uint16_t x0,
gbloice 0:ae3d20db48fc 149 const uint16_t y0,
gbloice 0:ae3d20db48fc 150 const uint16_t x1,
gbloice 0:ae3d20db48fc 151 const uint16_t y1,
gbloice 0:ae3d20db48fc 152 uint16_t colour
gbloice 0:ae3d20db48fc 153 )
gbloice 0:ae3d20db48fc 154 {
gbloice 0:ae3d20db48fc 155 // Order the drawing co-ords
gbloice 0:ae3d20db48fc 156 uint16_t startX, startY, endX, endY;
gbloice 0:ae3d20db48fc 157 orderCoords(x0, y0, x1, y1, startX, startY, endX, endY);
gbloice 0:ae3d20db48fc 158
gbloice 0:ae3d20db48fc 159 // Now draw the 4 lines required
gbloice 0:ae3d20db48fc 160 hLine(startX, startY, endX, colour);
gbloice 0:ae3d20db48fc 161 vLine(endX, startY, endY, colour);
gbloice 0:ae3d20db48fc 162 hLine(startX, endY, endX, colour);
gbloice 0:ae3d20db48fc 163 vLine(startX, startY, endY, colour);
gbloice 0:ae3d20db48fc 164 }
gbloice 0:ae3d20db48fc 165
gbloice 0:ae3d20db48fc 166 void EAQVGAOLED::fillRectangle
gbloice 0:ae3d20db48fc 167 (
gbloice 0:ae3d20db48fc 168 const uint16_t x0,
gbloice 0:ae3d20db48fc 169 const uint16_t y0,
gbloice 0:ae3d20db48fc 170 const uint16_t x1,
gbloice 0:ae3d20db48fc 171 const uint16_t y1,
gbloice 0:ae3d20db48fc 172 uint16_t colour
gbloice 0:ae3d20db48fc 173 )
gbloice 0:ae3d20db48fc 174 {
gbloice 0:ae3d20db48fc 175 // Order the drawing co-ords
gbloice 0:ae3d20db48fc 176 uint16_t startX, startY, endX, endY;
gbloice 0:ae3d20db48fc 177 orderCoords(x0, y0, x1, y1, startX, startY, endX, endY);
gbloice 0:ae3d20db48fc 178
gbloice 0:ae3d20db48fc 179 // Now draw the all lines required
gbloice 0:ae3d20db48fc 180 for (uint16_t i = startY; i < endY; i++) {
gbloice 0:ae3d20db48fc 181 hLine(startX, i, endX, colour);
gbloice 0:ae3d20db48fc 182 }
gbloice 0:ae3d20db48fc 183 }
gbloice 0:ae3d20db48fc 184
gbloice 0:ae3d20db48fc 185 int EAQVGAOLED::_putc
gbloice 0:ae3d20db48fc 186 (
gbloice 0:ae3d20db48fc 187 int value
gbloice 0:ae3d20db48fc 188 )
gbloice 0:ae3d20db48fc 189 {
gbloice 0:ae3d20db48fc 190 switch (value) {
gbloice 0:ae3d20db48fc 191 case CURSOR_CLS: // Clear the screen
gbloice 0:ae3d20db48fc 192 cls();
gbloice 0:ae3d20db48fc 193 break;
gbloice 0:ae3d20db48fc 194 case CURSOR_UP:
gbloice 0:ae3d20db48fc 195 if (_row == 0)
gbloice 0:ae3d20db48fc 196 _row = rows();
gbloice 0:ae3d20db48fc 197 else {
gbloice 0:ae3d20db48fc 198 _row--;
gbloice 0:ae3d20db48fc 199 }
gbloice 0:ae3d20db48fc 200 break;
gbloice 0:ae3d20db48fc 201 case CURSOR_DOWN:
gbloice 0:ae3d20db48fc 202 if (_row == rows()) {
gbloice 0:ae3d20db48fc 203 _row = 0;
gbloice 0:ae3d20db48fc 204 }
gbloice 0:ae3d20db48fc 205 else {
gbloice 0:ae3d20db48fc 206 _row++;
gbloice 0:ae3d20db48fc 207 }
gbloice 0:ae3d20db48fc 208 break;
gbloice 0:ae3d20db48fc 209 case CURSOR_LEFT:
gbloice 0:ae3d20db48fc 210 if (_column == 0) {
gbloice 0:ae3d20db48fc 211 _column = columns();
gbloice 0:ae3d20db48fc 212 }
gbloice 0:ae3d20db48fc 213 else {
gbloice 0:ae3d20db48fc 214 _column--;
gbloice 0:ae3d20db48fc 215 }
gbloice 0:ae3d20db48fc 216 break;
gbloice 0:ae3d20db48fc 217 case CURSOR_RIGHT:
gbloice 0:ae3d20db48fc 218 if (_column == columns()) {
gbloice 0:ae3d20db48fc 219 _column = 0;
gbloice 0:ae3d20db48fc 220 }
gbloice 0:ae3d20db48fc 221 else {
gbloice 0:ae3d20db48fc 222 _column++;
gbloice 0:ae3d20db48fc 223 }
gbloice 0:ae3d20db48fc 224 break;
gbloice 0:ae3d20db48fc 225 default:
gbloice 0:ae3d20db48fc 226 GraphicsDisplay::_putc(value);
gbloice 0:ae3d20db48fc 227 break;
gbloice 0:ae3d20db48fc 228 }
gbloice 0:ae3d20db48fc 229
gbloice 0:ae3d20db48fc 230 return value;
gbloice 0:ae3d20db48fc 231 }
gbloice 0:ae3d20db48fc 232
gbloice 0:ae3d20db48fc 233 /****************************************************************************/
gbloice 0:ae3d20db48fc 234 /* */
gbloice 0:ae3d20db48fc 235 /* Private functions */
gbloice 0:ae3d20db48fc 236 /* */
gbloice 0:ae3d20db48fc 237 /****************************************************************************/
gbloice 0:ae3d20db48fc 238
gbloice 0:ae3d20db48fc 239 /**
gbloice 0:ae3d20db48fc 240 * Initialise the hardware required
gbloice 0:ae3d20db48fc 241 *
gbloice 0:ae3d20db48fc 242 */
gbloice 0:ae3d20db48fc 243 void EAQVGAOLED::initHardware(void)
gbloice 0:ae3d20db48fc 244 {
gbloice 0:ae3d20db48fc 245 // Activate the display reset line
gbloice 0:ae3d20db48fc 246 _reset = 0;
gbloice 0:ae3d20db48fc 247
gbloice 0:ae3d20db48fc 248 // Turn the chip select and backlight off
gbloice 0:ae3d20db48fc 249 _cs = 1;
gbloice 0:ae3d20db48fc 250 _bl = 0;
gbloice 0:ae3d20db48fc 251
gbloice 0:ae3d20db48fc 252 // Set the spi port for 8 bits, clk phase and polarity 0
gbloice 0:ae3d20db48fc 253 _spi.format(8, 0);
gbloice 0:ae3d20db48fc 254 // And frequency to 10MHz
gbloice 0:ae3d20db48fc 255 _spi.frequency(10000000);
gbloice 0:ae3d20db48fc 256
gbloice 0:ae3d20db48fc 257 // Wait for 10uS and release reset
gbloice 0:ae3d20db48fc 258 wait_us(10);
gbloice 0:ae3d20db48fc 259 _reset = 1;
gbloice 0:ae3d20db48fc 260
gbloice 0:ae3d20db48fc 261 // Wait for 10ms to allow access to controller
gbloice 0:ae3d20db48fc 262 wait_ms(10);
gbloice 0:ae3d20db48fc 263 }
gbloice 0:ae3d20db48fc 264
gbloice 0:ae3d20db48fc 265 /**
gbloice 0:ae3d20db48fc 266 * Reset the display controller
gbloice 0:ae3d20db48fc 267 *
gbloice 0:ae3d20db48fc 268 */
gbloice 0:ae3d20db48fc 269 bool EAQVGAOLED::resetDisplay(void)
gbloice 0:ae3d20db48fc 270 {
gbloice 0:ae3d20db48fc 271 // Ensure we are connected to the correct hardware
gbloice 0:ae3d20db48fc 272 unsigned int result = readDataRegister(0x0F);
gbloice 0:ae3d20db48fc 273 /* Doesn't seem to wrk ??
gbloice 0:ae3d20db48fc 274 if (EAQVGAOLED_ID != result)
gbloice 0:ae3d20db48fc 275 {
gbloice 0:ae3d20db48fc 276 return false;
gbloice 0:ae3d20db48fc 277 }
gbloice 0:ae3d20db48fc 278 */
gbloice 0:ae3d20db48fc 279
gbloice 0:ae3d20db48fc 280 // Set the entry mode values for addessing and increment
gbloice 0:ae3d20db48fc 281 writeDataRegister(0x03, 0x130);
gbloice 0:ae3d20db48fc 282
gbloice 0:ae3d20db48fc 283 // Set the standby off
gbloice 0:ae3d20db48fc 284 writeDataRegister(0x10, 0);
gbloice 0:ae3d20db48fc 285
gbloice 0:ae3d20db48fc 286 // Delay till the clocks come up
gbloice 0:ae3d20db48fc 287 wait_ms(100);
gbloice 0:ae3d20db48fc 288
gbloice 0:ae3d20db48fc 289 // Enable the backlight
gbloice 0:ae3d20db48fc 290 _bl = 1;
gbloice 0:ae3d20db48fc 291
gbloice 0:ae3d20db48fc 292 // Delay until power is steady
gbloice 0:ae3d20db48fc 293 wait_ms(40);
gbloice 0:ae3d20db48fc 294
gbloice 0:ae3d20db48fc 295 // Turn the display on
gbloice 0:ae3d20db48fc 296 writeDataRegister(0x05, 1);
gbloice 0:ae3d20db48fc 297
gbloice 0:ae3d20db48fc 298 return true;
gbloice 0:ae3d20db48fc 299 }
gbloice 0:ae3d20db48fc 300
gbloice 0:ae3d20db48fc 301 /**
gbloice 0:ae3d20db48fc 302 * Set the location of the pen
gbloice 0:ae3d20db48fc 303 *
gbloice 0:ae3d20db48fc 304 */
gbloice 0:ae3d20db48fc 305 void EAQVGAOLED::movePen
gbloice 0:ae3d20db48fc 306 (
gbloice 0:ae3d20db48fc 307 const uint16_t x,
gbloice 0:ae3d20db48fc 308 const uint16_t y
gbloice 0:ae3d20db48fc 309 )
gbloice 0:ae3d20db48fc 310 {
gbloice 0:ae3d20db48fc 311 // Set x & y pos and select GRAM register
gbloice 0:ae3d20db48fc 312 writeDataRegister(0x20, x);
gbloice 0:ae3d20db48fc 313 writeDataRegister(0x21, y);
gbloice 0:ae3d20db48fc 314 setRegisterIndex(0x22);
gbloice 0:ae3d20db48fc 315 }
gbloice 0:ae3d20db48fc 316
gbloice 0:ae3d20db48fc 317 /**
gbloice 0:ae3d20db48fc 318 * Read the value of a controller data register
gbloice 0:ae3d20db48fc 319 *
gbloice 0:ae3d20db48fc 320 * @param reg the register address to read
gbloice 0:ae3d20db48fc 321 */
gbloice 0:ae3d20db48fc 322 uint16_t EAQVGAOLED::readDataRegister
gbloice 0:ae3d20db48fc 323 (
gbloice 0:ae3d20db48fc 324 const uint8_t reg
gbloice 0:ae3d20db48fc 325 )
gbloice 0:ae3d20db48fc 326 {
gbloice 0:ae3d20db48fc 327 // Set the register index
gbloice 0:ae3d20db48fc 328 setRegisterIndex(reg);
gbloice 0:ae3d20db48fc 329
gbloice 0:ae3d20db48fc 330 // Read the response
gbloice 0:ae3d20db48fc 331 _cs = 0;
gbloice 0:ae3d20db48fc 332 _spi.write(0x71); // Command byte ID = 011100, RS = 0, R/W = 1
gbloice 0:ae3d20db48fc 333 uint8_t msb = _spi.write(0);
gbloice 0:ae3d20db48fc 334 uint8_t lsb = _spi.write(0);
gbloice 0:ae3d20db48fc 335 _cs = 1;
gbloice 0:ae3d20db48fc 336
gbloice 0:ae3d20db48fc 337 return (msb << 8) | lsb;
gbloice 0:ae3d20db48fc 338 }
gbloice 0:ae3d20db48fc 339
gbloice 0:ae3d20db48fc 340 /**
gbloice 0:ae3d20db48fc 341 * Write to a controller data register
gbloice 0:ae3d20db48fc 342 *
gbloice 0:ae3d20db48fc 343 * @param reg the register address to read
gbloice 0:ae3d20db48fc 344 * @param data the data to write
gbloice 0:ae3d20db48fc 345 */
gbloice 0:ae3d20db48fc 346 void EAQVGAOLED::writeDataRegister
gbloice 0:ae3d20db48fc 347 (
gbloice 0:ae3d20db48fc 348 const uint8_t reg,
gbloice 0:ae3d20db48fc 349 const uint16_t data
gbloice 0:ae3d20db48fc 350 )
gbloice 0:ae3d20db48fc 351 {
gbloice 0:ae3d20db48fc 352 // Set the register index
gbloice 0:ae3d20db48fc 353 setRegisterIndex(reg);
gbloice 0:ae3d20db48fc 354
gbloice 0:ae3d20db48fc 355 // Write the data
gbloice 0:ae3d20db48fc 356 writeData(data);
gbloice 0:ae3d20db48fc 357 }
gbloice 0:ae3d20db48fc 358
gbloice 0:ae3d20db48fc 359 inline void EAQVGAOLED::writeData
gbloice 0:ae3d20db48fc 360 (
gbloice 0:ae3d20db48fc 361 const uint16_t data
gbloice 0:ae3d20db48fc 362 )
gbloice 0:ae3d20db48fc 363 {
gbloice 0:ae3d20db48fc 364 // Write the data
gbloice 0:ae3d20db48fc 365 _cs = 0;
gbloice 0:ae3d20db48fc 366 _spi.write(0x72); // Command byte, ID = 011100, RS = 1, R/W = 0
gbloice 0:ae3d20db48fc 367 _spi.write(data >> 8);
gbloice 0:ae3d20db48fc 368 _spi.write(data & 0xFF);
gbloice 0:ae3d20db48fc 369 _cs = 1;
gbloice 0:ae3d20db48fc 370 }
gbloice 0:ae3d20db48fc 371
gbloice 0:ae3d20db48fc 372 /** Select a controller register
gbloice 0:ae3d20db48fc 373 *
gbloice 0:ae3d20db48fc 374 * @param reg register to select
gbloice 0:ae3d20db48fc 375 */
gbloice 0:ae3d20db48fc 376 inline void EAQVGAOLED::setRegisterIndex
gbloice 0:ae3d20db48fc 377 (
gbloice 0:ae3d20db48fc 378 const uint8_t reg
gbloice 0:ae3d20db48fc 379 )
gbloice 0:ae3d20db48fc 380 {
gbloice 0:ae3d20db48fc 381 // Write to the register selector (RS = 0)
gbloice 0:ae3d20db48fc 382 _cs = 0;
gbloice 0:ae3d20db48fc 383 _spi.write(0x70); // Command byte ID = 011100, RS = 0, R/W = 0
gbloice 0:ae3d20db48fc 384 _spi.write(0);
gbloice 0:ae3d20db48fc 385 _spi.write(reg);
gbloice 0:ae3d20db48fc 386 _cs = 1;
gbloice 0:ae3d20db48fc 387 }