diff options
| author | EnricoGuccii <partyka.003@gmail.com> | 2025-05-13 12:49:37 +0200 |
|---|---|---|
| committer | EnricoGuccii <partyka.003@gmail.com> | 2025-05-13 12:49:37 +0200 |
| commit | 86ba591615dde725833b2a024c79f9611326d8eb (patch) | |
| tree | 836c8c2a13ec883da1d1f790bf04bfa7838e8c45 /lib/oled | |
| parent | 4f96161a387c3bc32ee084f14095e50ab9716b5e (diff) | |
oled changes
Diffstat (limited to 'lib/oled')
| -rw-r--r-- | lib/oled/oled.cpp | 33 | ||||
| -rw-r--r-- | lib/oled/oled.h | 4 |
2 files changed, 25 insertions, 12 deletions
diff --git a/lib/oled/oled.cpp b/lib/oled/oled.cpp index 6036c70..0127722 100644 --- a/lib/oled/oled.cpp +++ b/lib/oled/oled.cpp @@ -5,11 +5,11 @@ #include "settings.h" #include "oled.h" - OLED::OLED() -: display(OLED_WIDTH, OLED_HEIGHT, &Wire, -1) {} + : display(OLED_WIDTH, OLED_HEIGHT, &Wire, -1) {} -void OLED::init() { +void OLED::init() +{ Wire.begin(SDA_PIN, SCL_PIN); display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR); display.clearDisplay(); @@ -17,7 +17,8 @@ void OLED::init() { display.setTextColor(SSD1306_WHITE); } -void OLED::showMessage(const String& msg, int size, int x, int y) { +void OLED::showMessage(const String &msg, int size, int x, int y) +{ display.clearDisplay(); display.setCursor(x, y); display.setTextSize(size); @@ -26,20 +27,32 @@ void OLED::showMessage(const String& msg, int size, int x, int y) { display.display(); } -void OLED::drawBitmap(const uint8_t* bitmap) { +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 uint8_t* animation[], int frames, int delayTime) { - for (int i = 0; i < frames; i++) { - drawBitmap(animation[i]); - delay(delayTime); +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() { +void OLED::clear() +{ display.clearDisplay(); display.display(); } diff --git a/lib/oled/oled.h b/lib/oled/oled.h index 4873285..b6fe7fa 100644 --- a/lib/oled/oled.h +++ b/lib/oled/oled.h @@ -9,8 +9,8 @@ public: void init(); void showMessage(const String& msg,int size = 1 ,int x = 0, int y = 0); - void drawBitmap(const uint8_t* bitmap); - void showAnimation(const uint8_t* animation[], int frames, int delayTime); + void drawFullBitmap(const uint8_t* bitmap); + void showAnimation(const byte* frames, int frameCount, int frameWidth, int frameHeight, int frameDelay); void clear(); private: |