treci test iz PIMa
Dependents: 19E042PIM_T3_2020_0247
Diff: Adafruit_SSD1306.h
- Revision:
- 6:1be3e3b46eb7
- Parent:
- 3:969ca9fe5e2b
- Child:
- 7:779204e24db4
diff -r 315de3647c9f -r 1be3e3b46eb7 Adafruit_SSD1306.h --- a/Adafruit_SSD1306.h Thu Oct 16 23:18:25 2014 -0500 +++ b/Adafruit_SSD1306.h Sat Oct 18 11:47:17 2014 -0500 @@ -43,6 +43,9 @@ -----------------------------------------------------------------------*/ //#define SSD1306_128_64 #define SSD1306_128_32 + +#define SSD_USES_SPI +//#define SSD_USES_I2C /*=========================================================================*/ #if defined SSD1306_128_64 && defined SSD1306_128_32 @@ -61,6 +64,19 @@ #define SSD1306_LCDHEIGHT 32 #endif +#if defined SSD_USES_SPI && defined SSD_USES_I2C + #error "Only one communication mode can be specified at once in SSD1306.h" +#endif +#if !defined SSD_USES_SPI && !defined SSD_USES_I2C + #error "At least one communication mode must be specified in SSD1306.h" +#endif + +//#define WITHOUT_SPLASH +#define I2C_ADDRESS 0x78 + +#define SSD_Command_Mode 0x00 +#define SSD_Data_Mode 0x40 + #define SSD1306_SETCONTRAST 0x81 #define SSD1306_DISPLAYALLON_RESUME 0xA4 #define SSD1306_DISPLAYALLON 0xA5 @@ -98,7 +114,11 @@ class Adafruit_SSD1306 : public Adafruit_GFX { public: +#ifdef SSD_USES_SPI Adafruit_SSD1306(SPI &spi, PinName DC, PinName RST, PinName CS); +#elif defined SSD_USES_I2C + Adafruit_SSD1306(I2C &i2c, PinName RST); +#endif void begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC); void ssd1306_command(uint8_t c); void ssd1306_data(uint8_t c); @@ -110,8 +130,15 @@ virtual void drawPixel(int16_t x, int16_t y, uint16_t color); private: - DigitalOut2 rst,cs,dc; + + Serial pc; + DigitalOut2 rst; +#ifdef SSD_USES_SPI SPI &mspi; + DigitalOut2 cs,dc; +#elif defined SSD_USES_I2C + I2C &mi2c; +#endif // the memory buffer for the LCD uint8_t buffer[SSD1306_LCDHEIGHT * SSD1306_LCDWIDTH / 8]; };