diff --git a/README.md b/README.md index 4f04d4ef..c2276d9e 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/OLEDDisplay.cpp b/src/OLEDDisplay.cpp index 2c0c72a9..7edaa3da 100644 --- a/src/OLEDDisplay.cpp +++ b/src/OLEDDisplay.cpp @@ -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; } diff --git a/src/OLEDDisplay.h b/src/OLEDDisplay.h index ddf80bd4..f6c505c5 100644 --- a/src/OLEDDisplay.h +++ b/src/OLEDDisplay.h @@ -34,6 +34,10 @@ #include #include "OLEDDisplayFonts.h" +#ifndef OLEDDISPLAY_DEFAULTFONT +#define OLEDDISPLAY_DEFAULTFONT ArialMT_Plain_10 +#endif + //#define DEBUG_OLEDDISPLAY(...) Serial.printf( __VA_ARGS__ ) #ifndef DEBUG_OLEDDISPLAY @@ -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(); @@ -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); @@ -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; diff --git a/src/OLEDDisplayUi.h b/src/OLEDDisplayUi.h index 2cabf300..0f0e35a1 100644 --- a/src/OLEDDisplayUi.h +++ b/src/OLEDDisplayUi.h @@ -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); };