ADAFRUIT GP9002 VFD Driver, requires GFX-Library
Adafruit_GP9002.h@0:e760d4cfabe4, 2016-05-07 (annotated)
- Committer:
- oliverb
- Date:
- Sat May 07 12:53:09 2016 +0000
- Revision:
- 0:e760d4cfabe4
Converted to Library, moved the examples out
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
oliverb | 0:e760d4cfabe4 | 1 | #ifndef _ADAFRUIT_GP9002_H |
oliverb | 0:e760d4cfabe4 | 2 | #define _ADAFRUIT_GP9002_H |
oliverb | 0:e760d4cfabe4 | 3 | |
oliverb | 0:e760d4cfabe4 | 4 | #include "mbed.h" |
oliverb | 0:e760d4cfabe4 | 5 | |
oliverb | 0:e760d4cfabe4 | 6 | #include "Adafruit_GFX.h" |
oliverb | 0:e760d4cfabe4 | 7 | |
oliverb | 0:e760d4cfabe4 | 8 | #define BLACK 0 |
oliverb | 0:e760d4cfabe4 | 9 | #define WHITE 1 |
oliverb | 0:e760d4cfabe4 | 10 | |
oliverb | 0:e760d4cfabe4 | 11 | #define GP9002_DISPLAYSOFF 0x00 |
oliverb | 0:e760d4cfabe4 | 12 | #define GP9002_DISPLAY1ON 0x01 |
oliverb | 0:e760d4cfabe4 | 13 | #define GP9002_DISPLAY2ON 0x02 |
oliverb | 0:e760d4cfabe4 | 14 | #define GP9002_ADDRINCR 0x04 |
oliverb | 0:e760d4cfabe4 | 15 | #define GP9002_ADDRHELD 0x05 |
oliverb | 0:e760d4cfabe4 | 16 | #define GP9002_CLEARSCREEN 0x06 |
oliverb | 0:e760d4cfabe4 | 17 | #define GP9002_CONTROLPOWER 0x07 |
oliverb | 0:e760d4cfabe4 | 18 | #define GP9002_DATAWRITE 0x08 |
oliverb | 0:e760d4cfabe4 | 19 | #define GP9002_DATAREAD 0x09 |
oliverb | 0:e760d4cfabe4 | 20 | #define GP9002_LOWERADDR1 0x0A |
oliverb | 0:e760d4cfabe4 | 21 | #define GP9002_HIGHERADDR1 0x0B |
oliverb | 0:e760d4cfabe4 | 22 | #define GP9002_LOWERADDR2 0x0C |
oliverb | 0:e760d4cfabe4 | 23 | #define GP9002_HIGHERADDR2 0x0D |
oliverb | 0:e760d4cfabe4 | 24 | #define GP9002_ADDRL 0x0E |
oliverb | 0:e760d4cfabe4 | 25 | #define GP9002_ADDRH 0x0F |
oliverb | 0:e760d4cfabe4 | 26 | #define GP9002_OR 0x10 |
oliverb | 0:e760d4cfabe4 | 27 | #define GP9002_XOR 0x11 |
oliverb | 0:e760d4cfabe4 | 28 | #define GP9002_AND 0x12 |
oliverb | 0:e760d4cfabe4 | 29 | #define GP9002_BRIGHT 0x13 |
oliverb | 0:e760d4cfabe4 | 30 | #define GP9002_DISPLAY 0x14 |
oliverb | 0:e760d4cfabe4 | 31 | #define GP9002_DISPLAY_MONOCHROME 0x10 |
oliverb | 0:e760d4cfabe4 | 32 | #define GP9002_DISPLAY_GRAYSCALE 0x14 |
oliverb | 0:e760d4cfabe4 | 33 | #define GP9002_INTMODE 0x15 |
oliverb | 0:e760d4cfabe4 | 34 | #define GP9002_DRAWCHAR 0x20 |
oliverb | 0:e760d4cfabe4 | 35 | #define GP9002_CHARRAM 0x21 |
oliverb | 0:e760d4cfabe4 | 36 | #define GP9002_CHARSIZE 0x22 |
oliverb | 0:e760d4cfabe4 | 37 | #define GP9002_CHARBRIGHT 0x24 |
oliverb | 0:e760d4cfabe4 | 38 | |
oliverb | 0:e760d4cfabe4 | 39 | |
oliverb | 0:e760d4cfabe4 | 40 | class Adafruit_GP9002 : public Adafruit_GFX { |
oliverb | 0:e760d4cfabe4 | 41 | public: |
oliverb | 0:e760d4cfabe4 | 42 | /* Adafruit_GP9002(int8_t SCLK, int8_t MISO, int8_t MOSI, |
oliverb | 0:e760d4cfabe4 | 43 | int8_t CS, int8_t DC); |
oliverb | 0:e760d4cfabe4 | 44 | */ |
oliverb | 0:e760d4cfabe4 | 45 | Adafruit_GP9002(SPI &SPIport, PinName CS, PinName DC); |
oliverb | 0:e760d4cfabe4 | 46 | |
oliverb | 0:e760d4cfabe4 | 47 | // particular to this display |
oliverb | 0:e760d4cfabe4 | 48 | void begin(void); |
oliverb | 0:e760d4cfabe4 | 49 | // uint8_t slowSPIread(); |
oliverb | 0:e760d4cfabe4 | 50 | // uint8_t fastSPIread(); |
oliverb | 0:e760d4cfabe4 | 51 | // void slowSPIwrite(uint8_t); |
oliverb | 0:e760d4cfabe4 | 52 | // void fastSPIwrite(uint8_t); |
oliverb | 0:e760d4cfabe4 | 53 | |
oliverb | 0:e760d4cfabe4 | 54 | void command(uint8_t c); |
oliverb | 0:e760d4cfabe4 | 55 | void dataWrite(uint8_t c); |
oliverb | 0:e760d4cfabe4 | 56 | uint8_t dataRead(void); |
oliverb | 0:e760d4cfabe4 | 57 | void setBrightness(uint8_t val); |
oliverb | 0:e760d4cfabe4 | 58 | void invert(bool i); |
oliverb | 0:e760d4cfabe4 | 59 | |
oliverb | 0:e760d4cfabe4 | 60 | void displayOn(); |
oliverb | 0:e760d4cfabe4 | 61 | void displayOff(); |
oliverb | 0:e760d4cfabe4 | 62 | void clearDisplay(void); |
oliverb | 0:e760d4cfabe4 | 63 | |
oliverb | 0:e760d4cfabe4 | 64 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color); |
oliverb | 0:e760d4cfabe4 | 65 | virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); |
oliverb | 0:e760d4cfabe4 | 66 | |
oliverb | 0:e760d4cfabe4 | 67 | private: |
oliverb | 0:e760d4cfabe4 | 68 | // int8_t _miso, _mosi, _sclk, _dc, _cs; |
oliverb | 0:e760d4cfabe4 | 69 | SPI _spi; |
oliverb | 0:e760d4cfabe4 | 70 | DigitalOut _dc, _cs; |
oliverb | 0:e760d4cfabe4 | 71 | |
oliverb | 0:e760d4cfabe4 | 72 | // volatile uint8_t *mosiport, *misopin, *clkport, *csport, *dcport; |
oliverb | 0:e760d4cfabe4 | 73 | // uint8_t mosipinmask, misopinmask, clkpinmask, cspinmask, dcpinmask; |
oliverb | 0:e760d4cfabe4 | 74 | |
oliverb | 0:e760d4cfabe4 | 75 | // bool hwSPI; |
oliverb | 0:e760d4cfabe4 | 76 | |
oliverb | 0:e760d4cfabe4 | 77 | void spiwrite(uint8_t c); |
oliverb | 0:e760d4cfabe4 | 78 | }; |
oliverb | 0:e760d4cfabe4 | 79 | |
oliverb | 0:e760d4cfabe4 | 80 | #endif |