Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ Going from 3.x version to 4.0 a lot of internals changed and compatibility for m
Fonts are defined in a proprietary but open format. You can create new font files by choosing from a given list
of open sourced Fonts from this web app: http://oleddisplay.squix.ch
Choose the font family, style and size, check the preview image and if you like what you see click the "Create" button. This will create the font array in a text area form where you can copy and paste it into a new or existing header file.
```C++
#include "YOUR_FONT.h"
#define OLEDDISPLAYFONTS_h //Exclude the default fonts file if not required to save memory
#define OLEDDISPLAY_DEFAULTFONT YOUR_FONT_ARRAY //Change the default ArialMT_Plane_10 to your own choice of font
```


![FontTool](https://github.com/squix78/esp8266-oled-ssd1306/raw/master/resources/FontTool.png)
Expand Down
4 changes: 2 additions & 2 deletions src/OLEDDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,11 @@ void OLEDDisplay::drawLogBuffer(uint16_t xMove, uint16_t yMove) {
}
}

uint16_t OLEDDisplay::getWidth(void) {
uint16_t OLEDDisplay::getWidth() {
return displayWidth;
}

uint16_t OLEDDisplay::getHeight(void) {
uint16_t OLEDDisplay::getHeight() {
return displayHeight;
}

Expand Down
14 changes: 9 additions & 5 deletions src/OLEDDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
#include <Arduino.h>
#include "OLEDDisplayFonts.h"

#ifndef OLEDDISPLAY_DEFAULTFONT
#define OLEDDISPLAY_DEFAULTFONT ArialMT_Plain_10
#endif

//#define DEBUG_OLEDDISPLAY(...) Serial.printf( __VA_ARGS__ )

#ifndef DEBUG_OLEDDISPLAY
Expand Down Expand Up @@ -118,8 +122,8 @@ class OLEDDisplay : public Print {
public:
virtual ~OLEDDisplay();

const uint16_t width(void) const { return displayWidth; };
const uint16_t height(void) const { return displayHeight; };
const uint16_t width(void) { return displayWidth; };
const uint16_t height(void) { return displayHeight; };

// Initialize the display
bool init();
Expand Down Expand Up @@ -251,8 +255,8 @@ class OLEDDisplay : public Print {
void drawLogBuffer(uint16_t x, uint16_t y);

// Get screen geometry
uint16_t getWidth(void);
uint16_t getHeight(void);
uint16_t getWidth();
uint16_t getHeight();

// Implement needed function to be compatible with Print class
size_t write(uint8_t c);
Expand All @@ -278,7 +282,7 @@ class OLEDDisplay : public Print {
OLEDDISPLAY_TEXT_ALIGNMENT textAlignment = TEXT_ALIGN_LEFT;
OLEDDISPLAY_COLOR color = WHITE;

const uint8_t *fontData = ArialMT_Plain_10;
const uint8_t *fontData = OLEDDISPLAY_DEFAULTFONT;

// State values for logBuffer
uint16_t logBufferSize = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/OLEDDisplayUi.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class OLEDDisplayUi {
// Loading screen
LoadingDrawFunction loadingDrawFunction = [](OLEDDisplay *display, LoadingStage* stage, uint8_t progress) {
display->setTextAlignment(TEXT_ALIGN_CENTER);
display->setFont(ArialMT_Plain_10);
display->setFont(OLEDDISPLAY_DEFAULTFONT);
display->drawString(64, 18, stage->process);
display->drawProgressBar(4, 32, 120, 8, progress);
};
Expand Down