@@ -26,10 +26,133 @@ The SSD1306Demo is a very comprehensive example demonstrating the most important
...
@@ -26,10 +26,133 @@ The SSD1306Demo is a very comprehensive example demonstrating the most important
Fonts are defined in a proprietary but open format. I wrote a program that converts any TrueType font into this format. Once the code is useful enough I will publish it or make it available as Webapplication (SaaS), where you can make any font you like available to the library.
Fonts are defined in a proprietary but open format. I wrote a program that converts any TrueType font into this format. Once the code is useful enough I will publish it or make it available as Webapplication (SaaS), where you can make any font you like available to the library.
## Demo
## API
### Display Control
```C++
// Create the display object connected to pin sda and sdc
SSD1306(int i2cAddress, int sda, int sdc);
// Initialize the display
void init();
// Cycle through the initialization
void resetDisplay(void);
// Connect again to the display through I2C
void reconnect(void);
// Turn the display on
void displayOn(void);
// Turn the display offs
void displayOff(void);
// Clear the local pixel buffer
void clear(void);
// Write the buffer to the display memory
void display(void);
// Set display contrast
void setContrast(char contrast);
// Turn the display upside down
void flipScreenVertically();
// Send a command to the display (low level function)
void sendCommand(unsigned char com);
// Send all the init commands
void sendInitCommands(void);
```
## Pixel drawing
```C++
// Draw a pixel at given position
void setPixel(int x, int y);
// Draw 8 bits at the given position
void setChar(int x, int y, unsigned char data);
// Draw the border of a rectangle at the given location
void drawRect(int x, int y, int width, int height);
// Fill the rectangle
void fillRect(int x, int y, int width, int height);
// Draw a bitmap with the given dimensions
void drawBitmap(int x, int y, int width, int height, const char *bitmap);
// Draw an XBM image with the given dimensions
void drawXbm(int x, int y, int width, int height, const char *xbm);
// Sets the color of all pixel operations
void setColor(int color);
```
## Text operations
``` C++
// Draws a string at the given location
void drawString(int x, int y, String text);
// Draws a String with a maximum width at the given location.
// If the given String is wider than the specified width
// The text will be wrapped to the next line at a space or dash
void drawStringMaxWidth(int x, int y, int maxLineWidth, String text);
// Returns the width of the String with the current