feat(display): add display class

This commit is contained in:
2026-04-24 15:46:48 +02:00
parent dd643c1c10
commit fb7fbfe6c4
2 changed files with 32 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#include <Arduino.h>
#include <U8g2lib.h>
/*
* A helper class to facilitate drawing on the SSD1306 OLED display using the U8g2 library.
*/
class Display {
public:
Display();
bool begin();
private:
U8G2_SSD1306_128X64_NONAME_F_HW_I2C oled;
};
+17
View File
@@ -0,0 +1,17 @@
#include "display.hpp"
// Initialize the OLED display with the appropriate settings for the SSD1306 128x64 display utilizing hardware I2C.
// The constructor initializes the U8g2 library with the correct parameters for the display and communication method.
Display::Display() : oled(U8G2_R0, U8X8_PIN_NONE) {}
// Try to initialize the OLED display. If initialization fails, print an error message to the serial console and return false.
// Otherwise, set the default font and return true.
bool Display::begin() {
if (!oled.begin()) {
Serial.println("Failed to initialize OLED display");
return false;
}
oled.setFont(u8g2_font_profont22_mn);
return true;
}