#ifndef __SS_OLED_H__
#define __SS_OLED_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "BitBang_I2C.h"
typedef struct ssoleds
{
uint8_t oled_addr; // requested address or 0xff for automatic detection
uint8_t oled_wrap, oled_flip, oled_type;
uint8_t *ucScreen;
uint8_t iCursorX, iCursorY;
uint8_t oled_x, oled_y;
int iScreenOffset;
BBI2C bbi2c;
} SSOLED;
// Make the Linux library interface C instead of C++
#if defined(_LINUX_) && defined(__cplusplus)
extern "C" {
#endif
// These are defined the same in my SPI_LCD library
#ifndef SPI_LCD_H
// 4 possible font sizes: 8x8, 16x32, 6x8, 16x16 (stretched from 8x8)
enum {
FONT_6x8 = 0,
FONT_8x8,
FONT_12x16,
FONT_16x16,
FONT_16x32
};
#define FONT_NORMAL FONT_8x8
#define FONT_SMALL FONT_6x8
#define FONT_LARGE FONT_16x32
#define FONT_STRETCHED FONT_16x16
#endif
// OLED type for init function
enum {
OLED_128x128 = 1,
OLED_128x32,
OLED_128x64,
OLED_132x64,
OLED_64x32,
OLED_96x16,
OLED_72x40
};
// Rotation and flip angles to draw tiles
enum {
ANGLE_0=0,
ANGLE_90,
ANGLE_180,
ANGLE_270,
ANGLE_FLIPX,
ANGLE_FLIPY
};
// Return value from oledInit()
enum {
OLED_NOT_FOUND = -1, // no display found
OLED_SSD1306_3C, // SSD1306 found at 0x3C
OLED_SSD1306_3D, // SSD1306 found at 0x3D
OLED_SH1106_3C, // SH1106 found at 0x3C
OLED_SH1106_3D, // SH1106 found at 0x3D
OLED_SH1107_3C, // SH1107
OLED_SH1107_3D
};
//
// Initializes the OLED controller into "page mode" on I2C
// If SDAPin and SCLPin are not -1, then bit bang I2C on those pins
// Otherwise use the Wire library.
// If you don't need to use a separate reset pin, set it to -1
//
int oledInit(SSOLED *pOLED, int iType, int iAddr, int bFlip, int bInvert, int bWire, int iSDAPin, int iSCLPin, int iResetPin, int32_t iSpeed);
//
// Initialize an SPI version of the display
//
void oledSPIInit(int iType, int iDC, int iCS, int iReset, int bFlip, int bInvert, int32_t iSpeed);
//
// Provide or revoke a back buffer for your OLED graphics
// This allows you to manage the RAM used by ss_oled on tiny
// embedded platforms like the ATmega series
// Pass NULL to revoke the buffer. Make sure you provide a buffer
// large enough for your display (e.g. 128x64 needs 1K - 1024 bytes)
//
void oledSetBackBuffer(SSOLED *pOLED, uint8_t *pBuffer);
//
// Sets the brightness (0=off, 255=brightest)
//
void oledSetContrast(SSOLED *pOLED, unsigned char ucContrast);
//
// Load a 128x64 1-bpp Windows bitmap
// Pass the pointer to the beginning of the BMP file
// First pass version assumes a full screen bitmap
//
int oledLoadBMP(SSOLED *pOLED, uint8_t *pBMP, int bInvert, int bRender);
//
// Power up/down the display
// useful for low power situations
//
void oledPower(SSOLED *pOLED, uint8_t bOn);
//
// Set the current cursor position
// The column represents the pixel column (0-127)
// The row represents the text row (0-7)
//
void oledSetCursor(SSOLED *pOLED, int x, int y);
//
// Turn text wrap on or off for the oldWriteString() function
//
void oledSetTextWrap(SSOLED *pOLED, int bWrap);
//
// Draw a string of normal (8x8), small (6x8) or large (16x32) characters
// At the given col+row with the given scroll offset. The scroll offset allows you to
// horizontally scroll text which does not fit on the width of the display. The offset
// represents the pixels to skip when drawing the text. An offset of 0 starts at the beginning
// of the text.
// The system remembers where the last text was written (the cursor position)
// To continue writing from the last position, set the x,y values to -1
// The text can optionally wrap around to the next line by calling oledSetTextWrap(true);
// otherwise text which would go off the right edge will not be drawn and the cursor will
// be left "off screen" until set to a new position explicitly
//
// Returns 0 for success, -1 for invalid parameter
//
int oledWriteString(SSOLED *pOLED, int iScrollX, int x