diff --git a/README.md b/README.md index b10af3c..8f95f23 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ - # og3x-oled +# og3x-oled This is simple OLED support for the [og3](https://github.com/chl33/og3) library for ESP projects using the Arduino framework with [Platformio](https://platformio.org/). diff --git a/include/og3/oled.h b/include/og3/oled.h index 7909b12..6fab08f 100644 --- a/include/og3/oled.h +++ b/include/og3/oled.h @@ -18,9 +18,13 @@ class Oled : public Module { kTenPt = 0, kSixteenPt = 1, }; + enum class Orientation { + kDefault = 0, + kFlipVertical = 1, + }; Oled(const char* name, ModuleSystem* updater, const char* initial_txt, - FontSize font_size = kSixteenPt); + FontSize font_size = kSixteenPt, Orientation orientation = Orientation::kFlipVertical); void setup(); void clear(); @@ -32,6 +36,7 @@ class Oled : public Module { SSD1306Wire m_display; #endif const char* m_initial_txt; + const Orientation m_orientation; FontSize m_font_size; int m_start = 0; bool m_ok = false; diff --git a/include/og3/oled_display_ring.h b/include/og3/oled_display_ring.h index 7d8c10c..123a05a 100644 --- a/include/og3/oled_display_ring.h +++ b/include/og3/oled_display_ring.h @@ -20,7 +20,8 @@ class OledDisplayRing : public Oled { static const char* kName; OledDisplayRing(ModuleSystem* updater, const char* initial_txt, unsigned switch_time_msec, - FontSize font_size = kSixteenPt); + FontSize font_size = kSixteenPt, + Orientation orientation = Orientation::kFlipVertical); // Add the callback which will be called when it is its turn. using CallbackFn = std::function; diff --git a/library.json b/library.json index 4885fb2..39e73c8 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "og3x-oled", - "version": "0.1.0", + "version": "0.1.2", "description": "Add support for SSD1306 OLED to chl33/og3", "keywords": "esp32, esp8266, oled", "authors": [ diff --git a/platformio.ini b/platformio.ini index 9ed12ce..92487ec 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,6 +16,6 @@ build_flags = '-Wall' '-Wno-deprecated' lib_deps = - og3@0.0.1 + og3@0.1.0 lib_ldf_mode = deep check_tool = clangtidy diff --git a/src/oled.cpp b/src/oled.cpp index 6969709..235809f 100644 --- a/src/oled.cpp +++ b/src/oled.cpp @@ -6,12 +6,13 @@ namespace og3 { Oled::Oled(const char* name, ModuleSystem* modules, const char* initial_txt, - Oled::FontSize font_size) + Oled::FontSize font_size, Oled::Orientation orientation) : Module(name, modules), #ifndef NATIVE m_display(0x3c, SDA, SCL, GEOMETRY_128_32), #endif m_initial_txt(initial_txt), + m_orientation(orientation), m_font_size(font_size) { add_init_fn([this]() { setup(); }); } @@ -27,7 +28,9 @@ void Oled::setup() { } #ifndef NATIVE m_display.clear(); - m_display.flipScreenVertically(); + if (m_orientation == Orientation::kFlipVertical) { + m_display.flipScreenVertically(); + } m_display.setTextAlignment(TEXT_ALIGN_LEFT); m_display.setFont(ArialMT_Plain_16); m_display.drawString(0, 0, m_initial_txt); diff --git a/src/oled_display_ring.cpp b/src/oled_display_ring.cpp index c24fcee..94d0d32 100644 --- a/src/oled_display_ring.cpp +++ b/src/oled_display_ring.cpp @@ -8,8 +8,9 @@ namespace og3 { const char* OledDisplayRing::kName = "oled_ring"; OledDisplayRing::OledDisplayRing(ModuleSystem* modules, const char* initial_txt, - unsigned switch_time_msec, FontSize font_size) - : Oled(kName, modules, initial_txt, font_size), + unsigned switch_time_msec, FontSize font_size, + Orientation orientation) + : Oled(kName, modules, initial_txt, font_size, orientation), m_switch_time_msec(switch_time_msec), m_scheduler( 1, m_switch_time_msec, [this]() { timerCallback(); }, nullptr) {