From 967500ab8abefa6700941d589979176677ab0d72 Mon Sep 17 00:00:00 2001 From: EnricoGuccii Date: Mon, 22 Dec 2025 23:30:13 +0100 Subject: yyy --- lib/oled/oled.cpp | 116 +++++++++++++++++++++++++++--------------------------- lib/oled/oled.h | 36 ++++++++--------- 2 files changed, 76 insertions(+), 76 deletions(-) (limited to 'lib/oled') diff --git a/lib/oled/oled.cpp b/lib/oled/oled.cpp index 0127722..2054b8f 100644 --- a/lib/oled/oled.cpp +++ b/lib/oled/oled.cpp @@ -1,58 +1,58 @@ -#include -#include -#include -#include -#include "settings.h" -#include "oled.h" - -OLED::OLED() - : display(OLED_WIDTH, OLED_HEIGHT, &Wire, -1) {} - -void OLED::init() -{ - Wire.begin(SDA_PIN, SCL_PIN); - display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); - display.clearDisplay(); - display.setTextSize(1); - display.setTextColor(SSD1306_WHITE); -} - -void OLED::showMessage(const String &msg, int size, int x, int y) -{ - display.clearDisplay(); - display.setCursor(x, y); - display.setTextSize(size); - display.setTextColor(SSD1306_WHITE); - display.println(msg); - display.display(); -} - -void OLED::drawFullBitmap(const uint8_t *bitmap) -{ - display.clearDisplay(); - display.drawBitmap(0, 0, bitmap, OLED_WIDTH, OLED_HEIGHT, SSD1306_WHITE); - display.display(); -} - -void OLED::showAnimation(const byte *frames, int frameCount, int frameWidth, int frameHeight, int frameDelay) -{ - int x = 64 - (frameWidth / 2); - int y = 32 - (frameHeight / 2); - - for (int i = 0; i < frameCount; i++) - { - display.clearDisplay(); - display.drawBitmap( - x, y, - frames + i * (frameWidth * frameHeight / 8), - frameWidth, frameHeight, 1); - display.display(); - delay(frameDelay); - } -} - -void OLED::clear() -{ - display.clearDisplay(); - display.display(); -} +#include +#include +#include +#include +#include "settings.h" +#include "oled.h" + +OLED::OLED() + : display(OLED_WIDTH, OLED_HEIGHT, &Wire, -1) {} + +void OLED::init() +{ + Wire.begin(SDA_PIN, SCL_PIN); + display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); + display.clearDisplay(); + display.setTextSize(1); + display.setTextColor(SSD1306_WHITE); +} + +void OLED::showMessage(const String &msg, int size, int x, int y) +{ + display.clearDisplay(); + display.setCursor(x, y); + display.setTextSize(size); + display.setTextColor(SSD1306_WHITE); + display.println(msg); + display.display(); +} + +void OLED::drawFullBitmap(const uint8_t *bitmap) +{ + display.clearDisplay(); + display.drawBitmap(0, 0, bitmap, OLED_WIDTH, OLED_HEIGHT, SSD1306_WHITE); + display.display(); +} + +void OLED::showAnimation(const byte *frames, int frameCount, int frameWidth, int frameHeight, int frameDelay) +{ + int x = 64 - (frameWidth / 2); + int y = 32 - (frameHeight / 2); + + for (int i = 0; i < frameCount; i++) + { + display.clearDisplay(); + display.drawBitmap( + x, y, + frames + i * (frameWidth * frameHeight / 8), + frameWidth, frameHeight, 1); + display.display(); + delay(frameDelay); + } +} + +void OLED::clear() +{ + display.clearDisplay(); + display.display(); +} diff --git a/lib/oled/oled.h b/lib/oled/oled.h index b6fe7fa..2d5ff14 100644 --- a/lib/oled/oled.h +++ b/lib/oled/oled.h @@ -1,18 +1,18 @@ -#pragma once -#include -#include "settings.h" - - -class OLED { -public: - OLED(); - - void init(); - void showMessage(const String& msg,int size = 1 ,int x = 0, int y = 0); - void drawFullBitmap(const uint8_t* bitmap); - void showAnimation(const byte* frames, int frameCount, int frameWidth, int frameHeight, int frameDelay); - void clear(); - -private: - Adafruit_SSD1306 display; -}; +#pragma once +#include +#include "settings.h" + + +class OLED { +public: + OLED(); + + void init(); + void showMessage(const String& msg,int size = 1 ,int x = 0, int y = 0); + void drawFullBitmap(const uint8_t* bitmap); + void showAnimation(const byte* frames, int frameCount, int frameWidth, int frameHeight, int frameDelay); + void clear(); + +private: + Adafruit_SSD1306 display; +}; -- cgit v1.2.3