ADAFRUIT GP9002 VFD Driver supporting grayscale display, requires GFX-Library Note no "invert" function, also fixed timing issue in "begin"

Dependencies:   bitreversetable256

Dependents:   GP9002af_gray

Fork of Adafruit-GP9002-Graphic-VFD-Library by Oliver Broad

Committer:
oliverb
Date:
Sun May 08 13:47:58 2016 +0000
Revision:
1:09dc95ba8711
Parent:
0:e760d4cfabe4
Child:
2:ecf13e85f0fa
First working version, enables use of three intensity values instead of pixel on/off

Who changed what in which revision?

UserRevisionLine numberNew contents of line
oliverb 0:e760d4cfabe4 1 /*#include <avr/pgmspace.h>
oliverb 0:e760d4cfabe4 2 #include <util/delay.h>
oliverb 0:e760d4cfabe4 3 #include <stdlib.h>*/
oliverb 0:e760d4cfabe4 4
oliverb 0:e760d4cfabe4 5 #include "Adafruit_GFX.h"
oliverb 0:e760d4cfabe4 6 #include "Adafruit_GP9002.h"
oliverb 0:e760d4cfabe4 7 #include "glcdfont.c"
oliverb 0:e760d4cfabe4 8
oliverb 0:e760d4cfabe4 9 extern const unsigned char BitReverseTable256[] =
oliverb 0:e760d4cfabe4 10 {
oliverb 0:e760d4cfabe4 11 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0, 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
oliverb 0:e760d4cfabe4 12 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8, 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
oliverb 0:e760d4cfabe4 13 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4, 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
oliverb 0:e760d4cfabe4 14 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC, 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
oliverb 0:e760d4cfabe4 15 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2, 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
oliverb 0:e760d4cfabe4 16 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA, 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
oliverb 0:e760d4cfabe4 17 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6, 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
oliverb 0:e760d4cfabe4 18 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE, 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
oliverb 0:e760d4cfabe4 19 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1, 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
oliverb 0:e760d4cfabe4 20 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9, 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
oliverb 0:e760d4cfabe4 21 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5, 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
oliverb 0:e760d4cfabe4 22 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED, 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
oliverb 0:e760d4cfabe4 23 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3, 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
oliverb 0:e760d4cfabe4 24 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB, 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
oliverb 0:e760d4cfabe4 25 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7, 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
oliverb 0:e760d4cfabe4 26 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF, 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
oliverb 0:e760d4cfabe4 27 };
oliverb 0:e760d4cfabe4 28
oliverb 0:e760d4cfabe4 29
oliverb 0:e760d4cfabe4 30 /*
oliverb 0:e760d4cfabe4 31 Adafruit_GP9002::Adafruit_GP9002(int8_t SCLK, int8_t MISO, int8_t MOSI,
oliverb 0:e760d4cfabe4 32 int8_t CS, int8_t DC) : Adafruit_GFX(128, 64) {
oliverb 0:e760d4cfabe4 33 _sclk = SCLK;
oliverb 0:e760d4cfabe4 34 _miso = MISO;
oliverb 0:e760d4cfabe4 35 _mosi = MOSI;
oliverb 0:e760d4cfabe4 36 _cs = CS;
oliverb 0:e760d4cfabe4 37 _dc = DC;
oliverb 0:e760d4cfabe4 38 hwSPI = false;
oliverb 0:e760d4cfabe4 39 }
oliverb 0:e760d4cfabe4 40
oliverb 0:e760d4cfabe4 41 Adafruit_GP9002::Adafruit_GP9002(int8_t CS, int8_t DC) :
oliverb 0:e760d4cfabe4 42 Adafruit_GFX(128, 64) {
oliverb 0:e760d4cfabe4 43 _sclk = -1;
oliverb 0:e760d4cfabe4 44 _miso = -1;
oliverb 0:e760d4cfabe4 45 _mosi = -1;
oliverb 0:e760d4cfabe4 46 _cs = CS;
oliverb 0:e760d4cfabe4 47 _dc = DC;
oliverb 0:e760d4cfabe4 48 hwSPI = true;
oliverb 0:e760d4cfabe4 49 }
oliverb 0:e760d4cfabe4 50 */
oliverb 0:e760d4cfabe4 51 Adafruit_GP9002::Adafruit_GP9002(SPI &SPIport, PinName CS, PinName DC): Adafruit_GFX(128, 64), _spi(SPIport), _dc(DC), _cs(CS,1){} ;
oliverb 0:e760d4cfabe4 52
oliverb 0:e760d4cfabe4 53
oliverb 0:e760d4cfabe4 54 void Adafruit_GP9002::begin(void) {
oliverb 0:e760d4cfabe4 55 // set pin directions
oliverb 0:e760d4cfabe4 56 // pinMode(_dc, OUTPUT);
oliverb 0:e760d4cfabe4 57 // pinMode(_cs, OUTPUT);
oliverb 0:e760d4cfabe4 58
oliverb 0:e760d4cfabe4 59 /* if (! hwSPI) {
oliverb 0:e760d4cfabe4 60 pinMode(_mosi, OUTPUT);
oliverb 0:e760d4cfabe4 61 pinMode(_miso, INPUT);
oliverb 0:e760d4cfabe4 62 pinMode(_sclk, OUTPUT);
oliverb 0:e760d4cfabe4 63
oliverb 0:e760d4cfabe4 64 clkport = portOutputRegister(digitalPinToPort(_sclk));
oliverb 0:e760d4cfabe4 65 clkpinmask = digitalPinToBitMask(_sclk);
oliverb 0:e760d4cfabe4 66 mosiport = portOutputRegister(digitalPinToPort(_mosi));
oliverb 0:e760d4cfabe4 67 mosipinmask = digitalPinToBitMask(_mosi);
oliverb 0:e760d4cfabe4 68 misopin = portInputRegister(digitalPinToPort(_miso));
oliverb 0:e760d4cfabe4 69 misopinmask = digitalPinToBitMask(_miso);
oliverb 0:e760d4cfabe4 70 } else {
oliverb 0:e760d4cfabe4 71 */
oliverb 0:e760d4cfabe4 72 //SPI.begin();
oliverb 0:e760d4cfabe4 73 // SPI.setClockDivider(SPI_CLOCK_DIV4);
oliverb 0:e760d4cfabe4 74 // SPI.setBitOrder(MSBFIRST);
oliverb 0:e760d4cfabe4 75 //SPI.setDataMode(SPI_MODE0);
oliverb 0:e760d4cfabe4 76 _spi.format(8,3); // I'm sure this is a mode 3 device
oliverb 0:e760d4cfabe4 77 _spi.frequency(2000000); //
oliverb 0:e760d4cfabe4 78 // }
oliverb 0:e760d4cfabe4 79 /*
oliverb 0:e760d4cfabe4 80 csport = portOutputRegister(digitalPinToPort(_cs));
oliverb 0:e760d4cfabe4 81 cspinmask = digitalPinToBitMask(_cs);
oliverb 0:e760d4cfabe4 82 dcport = portOutputRegister(digitalPinToPort(_dc));
oliverb 0:e760d4cfabe4 83 dcpinmask = digitalPinToBitMask(_dc);
oliverb 0:e760d4cfabe4 84 */
oliverb 0:e760d4cfabe4 85
oliverb 1:09dc95ba8711 86 command(GP9002_DISPLAYSOFF);
oliverb 1:09dc95ba8711 87 // command(GP9002_DISPLAY1ON); //defer till display clear
oliverb 0:e760d4cfabe4 88 command(GP9002_DISPLAY);
oliverb 1:09dc95ba8711 89 dataWrite(GP9002_DISPLAY_GRAYSCALE);
oliverb 0:e760d4cfabe4 90 command(GP9002_LOWERADDR1);
oliverb 0:e760d4cfabe4 91 dataWrite(0x0);
oliverb 0:e760d4cfabe4 92 command(GP9002_HIGHERADDR1);
oliverb 0:e760d4cfabe4 93 dataWrite(0x0);
oliverb 1:09dc95ba8711 94 // command(GP9002_LOWERADDR2);
oliverb 1:09dc95ba8711 95 // dataWrite(0x0);
oliverb 1:09dc95ba8711 96 // command(GP9002_HIGHERADDR2);
oliverb 1:09dc95ba8711 97 // dataWrite(0x4);
oliverb 1:09dc95ba8711 98 // command(GP9002_OR); //contradicted by display1on, so no
oliverb 0:e760d4cfabe4 99 command(GP9002_CLEARSCREEN);
oliverb 1:09dc95ba8711 100 wait_us(500);
oliverb 0:e760d4cfabe4 101 command(GP9002_DISPLAY1ON);
oliverb 0:e760d4cfabe4 102
oliverb 0:e760d4cfabe4 103 // hold the address so we can read and then write
oliverb 0:e760d4cfabe4 104 command(GP9002_ADDRHELD);
oliverb 0:e760d4cfabe4 105 }
oliverb 0:e760d4cfabe4 106
oliverb 0:e760d4cfabe4 107
oliverb 0:e760d4cfabe4 108
oliverb 0:e760d4cfabe4 109 // updated high speed drawing!
oliverb 0:e760d4cfabe4 110 void Adafruit_GP9002::drawFastVLine(int16_t x, int16_t orig_y, int16_t h, uint16_t color) {
oliverb 0:e760d4cfabe4 111 if ((x < 0) || (x >= width()) || (orig_y >= height())) return;
oliverb 0:e760d4cfabe4 112 //if ((orig_y+h) >= height())
oliverb 0:e760d4cfabe4 113 // h = height() - orig_y -1;
oliverb 0:e760d4cfabe4 114
oliverb 0:e760d4cfabe4 115 //drawLine(x, orig_y, x, orig_y+h, color); return;
oliverb 0:e760d4cfabe4 116
oliverb 0:e760d4cfabe4 117 while (h) {
oliverb 1:09dc95ba8711 118 if ((h >= 4) && ((orig_y) % 4 == 0))
oliverb 0:e760d4cfabe4 119 break;
oliverb 0:e760d4cfabe4 120 drawPixel(x, orig_y, color);
oliverb 0:e760d4cfabe4 121 orig_y++;
oliverb 0:e760d4cfabe4 122 h--;
oliverb 0:e760d4cfabe4 123 }
oliverb 0:e760d4cfabe4 124
oliverb 1:09dc95ba8711 125 if (h >= 4) {
oliverb 0:e760d4cfabe4 126 // calculate addr
oliverb 0:e760d4cfabe4 127 uint16_t addr = 0;
oliverb 1:09dc95ba8711 128 addr = x*16;
oliverb 0:e760d4cfabe4 129 // uint16_t y = orig_y+h-8;
oliverb 0:e760d4cfabe4 130 uint16_t y=orig_y;
oliverb 0:e760d4cfabe4 131 // y = 63 - y; //why?
oliverb 1:09dc95ba8711 132 addr += y/4;
oliverb 0:e760d4cfabe4 133
oliverb 0:e760d4cfabe4 134 // Serial.println(addr, HEX); ///debug line ?
oliverb 0:e760d4cfabe4 135 command(GP9002_ADDRINCR);
oliverb 0:e760d4cfabe4 136 command(GP9002_ADDRL);
oliverb 0:e760d4cfabe4 137 dataWrite(addr & 0xFF);
oliverb 0:e760d4cfabe4 138 command(GP9002_ADDRH);
oliverb 0:e760d4cfabe4 139 dataWrite(addr >> 8);
oliverb 0:e760d4cfabe4 140 command(GP9002_DATAWRITE);
oliverb 0:e760d4cfabe4 141
oliverb 1:09dc95ba8711 142 while (h >= 4) {
oliverb 0:e760d4cfabe4 143 // draw 8 pixels at once!
oliverb 0:e760d4cfabe4 144 if (color)
oliverb 1:09dc95ba8711 145 dataWrite(0b01010101 * (color & 3));
oliverb 0:e760d4cfabe4 146 else
oliverb 0:e760d4cfabe4 147 dataWrite(0x00);
oliverb 1:09dc95ba8711 148 h -= 4;
oliverb 1:09dc95ba8711 149 orig_y += 4;
oliverb 0:e760d4cfabe4 150 }
oliverb 0:e760d4cfabe4 151 }
oliverb 0:e760d4cfabe4 152 while (h+1) {
oliverb 0:e760d4cfabe4 153 drawPixel(x, orig_y-1, color);
oliverb 0:e760d4cfabe4 154 orig_y++;
oliverb 0:e760d4cfabe4 155 h--;
oliverb 0:e760d4cfabe4 156 }
oliverb 0:e760d4cfabe4 157
oliverb 0:e760d4cfabe4 158 }
oliverb 0:e760d4cfabe4 159
oliverb 0:e760d4cfabe4 160 // the most basic function, set a single pixel
oliverb 0:e760d4cfabe4 161 void Adafruit_GP9002::drawPixel(int16_t x, int16_t y, uint16_t color) {
oliverb 0:e760d4cfabe4 162 if ((x < 0) || (x >= width()) || (y < 0) || (y >= height()))
oliverb 0:e760d4cfabe4 163 return;
oliverb 0:e760d4cfabe4 164
oliverb 0:e760d4cfabe4 165 uint8_t p;
oliverb 0:e760d4cfabe4 166
oliverb 0:e760d4cfabe4 167 // calculate addr
oliverb 0:e760d4cfabe4 168 uint16_t addr = 0;
oliverb 1:09dc95ba8711 169 addr = x*16;
oliverb 0:e760d4cfabe4 170 // y = 63 - y; //why
oliverb 1:09dc95ba8711 171 addr += y/4;
oliverb 0:e760d4cfabe4 172
oliverb 0:e760d4cfabe4 173 command(GP9002_ADDRHELD);
oliverb 0:e760d4cfabe4 174 command(GP9002_ADDRL);
oliverb 0:e760d4cfabe4 175 dataWrite(addr & 0xFF);
oliverb 0:e760d4cfabe4 176 command(GP9002_ADDRH);
oliverb 0:e760d4cfabe4 177 dataWrite(addr >> 8);
oliverb 0:e760d4cfabe4 178 command(GP9002_DATAREAD);
oliverb 0:e760d4cfabe4 179 dataRead();
oliverb 0:e760d4cfabe4 180 p = dataRead();
oliverb 1:09dc95ba8711 181 y=0xc0>>((y & 3) <<1);
oliverb 1:09dc95ba8711 182 color*=0b01010101;
oliverb 0:e760d4cfabe4 183 //Serial.println(p, HEX);
oliverb 1:09dc95ba8711 184 p &= ~y;
oliverb 0:e760d4cfabe4 185
oliverb 1:09dc95ba8711 186 p |= color&y;
oliverb 1:09dc95ba8711 187
oliverb 0:e760d4cfabe4 188 command(GP9002_DATAWRITE);
oliverb 0:e760d4cfabe4 189 dataWrite(p);
oliverb 0:e760d4cfabe4 190 }
oliverb 0:e760d4cfabe4 191
oliverb 0:e760d4cfabe4 192
oliverb 1:09dc95ba8711 193 /* forbidden
oliverb 0:e760d4cfabe4 194 void Adafruit_GP9002::invert(bool i) {
oliverb 0:e760d4cfabe4 195 // This is kinda clumsy but it does work
oliverb 0:e760d4cfabe4 196 // fill the opposite screen with all on pixels so we can invert!
oliverb 0:e760d4cfabe4 197 uint16_t addr = 0x400;
oliverb 0:e760d4cfabe4 198
oliverb 0:e760d4cfabe4 199 command(GP9002_ADDRINCR);
oliverb 0:e760d4cfabe4 200 command(GP9002_ADDRL);
oliverb 0:e760d4cfabe4 201 dataWrite(addr & 0xFF);
oliverb 0:e760d4cfabe4 202 command(GP9002_ADDRH);
oliverb 0:e760d4cfabe4 203 dataWrite(addr >> 8);
oliverb 0:e760d4cfabe4 204 command(GP9002_DATAWRITE);
oliverb 0:e760d4cfabe4 205
oliverb 0:e760d4cfabe4 206 if (i) {
oliverb 0:e760d4cfabe4 207 while (addr < 0x0800) {
oliverb 0:e760d4cfabe4 208 dataWrite(0xFF);
oliverb 0:e760d4cfabe4 209 addr++;
oliverb 0:e760d4cfabe4 210 }
oliverb 0:e760d4cfabe4 211 command(GP9002_XOR);
oliverb 0:e760d4cfabe4 212 } else {
oliverb 0:e760d4cfabe4 213 while (addr < 0x0800) {
oliverb 0:e760d4cfabe4 214 dataWrite(0x00);
oliverb 0:e760d4cfabe4 215 addr++;
oliverb 0:e760d4cfabe4 216 }
oliverb 0:e760d4cfabe4 217 command(GP9002_OR);
oliverb 0:e760d4cfabe4 218 }
oliverb 0:e760d4cfabe4 219 command(GP9002_ADDRHELD);
oliverb 0:e760d4cfabe4 220
oliverb 0:e760d4cfabe4 221 }
oliverb 1:09dc95ba8711 222 */
oliverb 0:e760d4cfabe4 223 /*
oliverb 0:e760d4cfabe4 224 void Adafruit_GP9002::slowSPIwrite(uint8_t d) {
oliverb 0:e760d4cfabe4 225 for (uint8_t i=0; i<8; i++) {
oliverb 0:e760d4cfabe4 226 digitalWrite(_sclk, LOW);
oliverb 0:e760d4cfabe4 227 if (d & _BV(i)) {
oliverb 0:e760d4cfabe4 228 digitalWrite(_mosi, HIGH);
oliverb 0:e760d4cfabe4 229 } else {
oliverb 0:e760d4cfabe4 230 digitalWrite(_mosi, LOW);
oliverb 0:e760d4cfabe4 231 }
oliverb 0:e760d4cfabe4 232 digitalWrite(_sclk, HIGH);
oliverb 0:e760d4cfabe4 233 }
oliverb 0:e760d4cfabe4 234 }
oliverb 0:e760d4cfabe4 235 */
oliverb 0:e760d4cfabe4 236 /*
oliverb 0:e760d4cfabe4 237 inline void Adafruit_GP9002::fastSPIwrite(uint8_t d) {
oliverb 0:e760d4cfabe4 238 if (hwSPI) {
oliverb 0:e760d4cfabe4 239 SPDR = d;
oliverb 0:e760d4cfabe4 240 while(!(SPSR & _BV(SPIF)));
oliverb 0:e760d4cfabe4 241 return;
oliverb 0:e760d4cfabe4 242 }
oliverb 0:e760d4cfabe4 243 for(uint8_t bit = 0x1; bit != 0x00; bit <<= 1) {
oliverb 0:e760d4cfabe4 244 *clkport &= ~clkpinmask;
oliverb 0:e760d4cfabe4 245 if(d & bit) *mosiport |= mosipinmask;
oliverb 0:e760d4cfabe4 246 else *mosiport &= ~mosipinmask;
oliverb 0:e760d4cfabe4 247 *clkport |= clkpinmask;
oliverb 0:e760d4cfabe4 248 }
oliverb 0:e760d4cfabe4 249 }
oliverb 0:e760d4cfabe4 250 */
oliverb 0:e760d4cfabe4 251 /*
oliverb 0:e760d4cfabe4 252 uint8_t Adafruit_GP9002::slowSPIread(void) {
oliverb 0:e760d4cfabe4 253 uint8_t reply = 0;
oliverb 0:e760d4cfabe4 254 for (uint8_t i=0; i<8; i++) {
oliverb 0:e760d4cfabe4 255 digitalWrite(_sclk, LOW);
oliverb 0:e760d4cfabe4 256
oliverb 0:e760d4cfabe4 257 digitalWrite(_sclk, HIGH);
oliverb 0:e760d4cfabe4 258 if (digitalRead(_miso))
oliverb 0:e760d4cfabe4 259 reply |= _BV(i);
oliverb 0:e760d4cfabe4 260 }
oliverb 0:e760d4cfabe4 261 return reply;
oliverb 0:e760d4cfabe4 262 }
oliverb 0:e760d4cfabe4 263
oliverb 0:e760d4cfabe4 264 inline uint8_t Adafruit_GP9002::fastSPIread(void) {
oliverb 0:e760d4cfabe4 265 uint8_t reply = 0;
oliverb 0:e760d4cfabe4 266 for (uint8_t i=0; i<8; i++) {
oliverb 0:e760d4cfabe4 267 *clkport &= ~clkpinmask;
oliverb 0:e760d4cfabe4 268
oliverb 0:e760d4cfabe4 269 *clkport |= clkpinmask;
oliverb 0:e760d4cfabe4 270 if ((*misopin) & misopinmask)
oliverb 0:e760d4cfabe4 271 reply |= _BV(i);
oliverb 0:e760d4cfabe4 272 }
oliverb 0:e760d4cfabe4 273 return reply;
oliverb 0:e760d4cfabe4 274 }
oliverb 0:e760d4cfabe4 275 */
oliverb 0:e760d4cfabe4 276
oliverb 0:e760d4cfabe4 277 void Adafruit_GP9002::command(uint8_t d) {
oliverb 0:e760d4cfabe4 278 /*
oliverb 0:e760d4cfabe4 279 *dcport |= dcpinmask;
oliverb 0:e760d4cfabe4 280 *csport &= ~cspinmask;
oliverb 0:e760d4cfabe4 281 fastSPIwrite(d);
oliverb 0:e760d4cfabe4 282 *csport |= cspinmask;
oliverb 0:e760d4cfabe4 283 delayMicroseconds(1); // should be 400ns actually
oliverb 0:e760d4cfabe4 284 */
oliverb 0:e760d4cfabe4 285 _dc=1;
oliverb 0:e760d4cfabe4 286 _cs=0;
oliverb 0:e760d4cfabe4 287 _spi.write(BitReverseTable256[d]);
oliverb 0:e760d4cfabe4 288 _cs=1;
oliverb 0:e760d4cfabe4 289 wait_us(1);
oliverb 0:e760d4cfabe4 290 }
oliverb 0:e760d4cfabe4 291
oliverb 0:e760d4cfabe4 292 inline void Adafruit_GP9002::dataWrite(uint8_t d) {
oliverb 0:e760d4cfabe4 293 /*
oliverb 0:e760d4cfabe4 294 *dcport &= ~dcpinmask;
oliverb 0:e760d4cfabe4 295 *csport &= ~cspinmask;
oliverb 0:e760d4cfabe4 296
oliverb 0:e760d4cfabe4 297 fastSPIwrite(d);
oliverb 0:e760d4cfabe4 298
oliverb 0:e760d4cfabe4 299 *csport |= cspinmask;
oliverb 0:e760d4cfabe4 300 delayMicroseconds(1); // should be 600ns actually
oliverb 0:e760d4cfabe4 301 */
oliverb 0:e760d4cfabe4 302 _dc=0;
oliverb 0:e760d4cfabe4 303 _cs=0;
oliverb 0:e760d4cfabe4 304 _spi.write(BitReverseTable256[d]);
oliverb 0:e760d4cfabe4 305 _cs=1;
oliverb 0:e760d4cfabe4 306 wait_us(1);
oliverb 0:e760d4cfabe4 307 }
oliverb 0:e760d4cfabe4 308
oliverb 0:e760d4cfabe4 309 inline uint8_t Adafruit_GP9002::dataRead() {
oliverb 0:e760d4cfabe4 310 uint8_t r;
oliverb 0:e760d4cfabe4 311 /*
oliverb 0:e760d4cfabe4 312 *dcport &= ~dcpinmask;
oliverb 0:e760d4cfabe4 313 *csport &= ~cspinmask;
oliverb 0:e760d4cfabe4 314
oliverb 0:e760d4cfabe4 315 r = fastSPIread();
oliverb 0:e760d4cfabe4 316
oliverb 0:e760d4cfabe4 317 *csport |= cspinmask;
oliverb 0:e760d4cfabe4 318 delayMicroseconds(1);
oliverb 0:e760d4cfabe4 319 */
oliverb 0:e760d4cfabe4 320
oliverb 0:e760d4cfabe4 321 _dc=0;
oliverb 0:e760d4cfabe4 322 _cs=0;
oliverb 0:e760d4cfabe4 323 r=BitReverseTable256[_spi.write(0)&0xFF];
oliverb 0:e760d4cfabe4 324 _cs=1;
oliverb 0:e760d4cfabe4 325 wait_us(1);
oliverb 0:e760d4cfabe4 326
oliverb 0:e760d4cfabe4 327
oliverb 0:e760d4cfabe4 328 return r;
oliverb 0:e760d4cfabe4 329 }
oliverb 0:e760d4cfabe4 330
oliverb 0:e760d4cfabe4 331 void Adafruit_GP9002::setBrightness(uint8_t val) {
oliverb 0:e760d4cfabe4 332
oliverb 0:e760d4cfabe4 333 }
oliverb 0:e760d4cfabe4 334
oliverb 0:e760d4cfabe4 335 // clear everything
oliverb 0:e760d4cfabe4 336 void Adafruit_GP9002::clearDisplay(void) {
oliverb 0:e760d4cfabe4 337 command(GP9002_CLEARSCREEN);
oliverb 0:e760d4cfabe4 338
oliverb 1:09dc95ba8711 339 wait_us(500);
oliverb 0:e760d4cfabe4 340 }
oliverb 0:e760d4cfabe4 341
oliverb 0:e760d4cfabe4 342 void Adafruit_GP9002::displayOff(void) {
oliverb 0:e760d4cfabe4 343 command(GP9002_DISPLAYSOFF);
oliverb 0:e760d4cfabe4 344 }
oliverb 0:e760d4cfabe4 345 void Adafruit_GP9002::displayOn(void) {
oliverb 0:e760d4cfabe4 346 command(GP9002_DISPLAY1ON);
oliverb 0:e760d4cfabe4 347 }
oliverb 0:e760d4cfabe4 348
oliverb 0:e760d4cfabe4 349