From a74041efa9bceffd81f97eefa1cca0e2ea573ed0 Mon Sep 17 00:00:00 2001 From: j000bs Date: Sun, 17 Dec 2023 08:23:55 +0100 Subject: [PATCH] Rename class `SSD1306DisplayDevice` to `DisplayDevice` --- src/OpenBikeSensorFirmware.cpp | 4 ++-- src/configServer.cpp | 2 +- src/displays.cpp | 28 ++++++++++++++-------------- src/displays.h | 6 +++--- src/globals.h | 4 ++-- src/gps.cpp | 4 ++-- src/gps.h | 6 +++--- src/utils/alpdata.cpp | 4 ++-- src/utils/alpdata.h | 4 ++-- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/OpenBikeSensorFirmware.cpp b/src/OpenBikeSensorFirmware.cpp index 64a8b0e9..315b25d7 100644 --- a/src/OpenBikeSensorFirmware.cpp +++ b/src/OpenBikeSensorFirmware.cpp @@ -57,7 +57,7 @@ Button button(PUSHBUTTON_PIN); Config config; -SSD1306DisplayDevice* obsDisplay; +DisplayDevice* obsDisplay; HCSR04SensorManager* sensorManager; static BluetoothManager* bluetoothManager; @@ -209,7 +209,7 @@ void setup() { if (displayError != 0) { Serial.println("Display not found"); } - obsDisplay = new SSD1306DisplayDevice; + obsDisplay = new DisplayDevice; obsDisplay->showLogo(true); obsDisplay->showTextOnGrid(2, obsDisplay->startLine(), OBSVersion); diff --git a/src/configServer.cpp b/src/configServer.cpp index 5a4c118c..b1a154c0 100644 --- a/src/configServer.cpp +++ b/src/configServer.cpp @@ -492,7 +492,7 @@ String getIp() { } } -void updateDisplay(SSD1306DisplayDevice * const display, String action = "") { +void updateDisplay(DisplayDevice * const display, String action = "") { if (action.isEmpty()) { display->showTextOnGrid(0, 0, "Ver.:"); display->showTextOnGrid(1, 0, OBSVersion); diff --git a/src/displays.cpp b/src/displays.cpp index a04877fd..207c7ad7 100644 --- a/src/displays.cpp +++ b/src/displays.cpp @@ -25,7 +25,7 @@ #include "fonts/fonts.h" -void SSD1306DisplayDevice::showNumConfirmed() { +void DisplayDevice::showNumConfirmed() { String val = String(confirmedMeasurements); if (confirmedMeasurements <= 9) { val = "0" + val; @@ -34,7 +34,7 @@ void SSD1306DisplayDevice::showNumConfirmed() { this->prepareTextOnGrid(3, 5, "conf"); } -void SSD1306DisplayDevice::showNumButtonPressed() { +void DisplayDevice::showNumButtonPressed() { String val = String(numButtonReleased); if (numButtonReleased <= 9) { val = "0" + val; @@ -43,7 +43,7 @@ void SSD1306DisplayDevice::showNumButtonPressed() { this->prepareTextOnGrid(1, 5, "press"); } -void SSD1306DisplayDevice::displaySimple(uint16_t value) { +void DisplayDevice::displaySimple(uint16_t value) { if (value == MAX_SENSOR_VALUE) { this->prepareTextOnGrid(0, 0, "", HUGE_FONT, -7, -7); @@ -54,7 +54,7 @@ void SSD1306DisplayDevice::displaySimple(uint16_t value) { this->prepareTextOnGrid(3, 2, "cm", MEDIUM_FONT, -7, -5); } -void SSD1306DisplayDevice::showValues( +void DisplayDevice::showValues( HCSR04SensorInfo sensor1, HCSR04SensorInfo sensor2, uint16_t minDistanceToConfirm, int16_t batteryPercentage, int16_t TemperaturValue, int lastMeasurements, boolean insidePrivacyArea, double speed, uint8_t satellites) { @@ -141,7 +141,7 @@ void SSD1306DisplayDevice::showValues( } -void SSD1306DisplayDevice::showGPS(uint8_t sats) { +void DisplayDevice::showGPS(uint8_t sats) { String val = String(sats); if (sats <= 9) { val = "0" + val; @@ -150,7 +150,7 @@ void SSD1306DisplayDevice::showGPS(uint8_t sats) { this->prepareTextOnGrid(3, 5, "sats"); } -void SSD1306DisplayDevice::showBatterieValue(int16_t input_val){ +void DisplayDevice::showBatterieValue(int16_t input_val){ uint8_t x_offset_batterie_logo = 65; uint8_t y_offset_batterie_logo = 2; @@ -195,7 +195,7 @@ void SSD1306DisplayDevice::showBatterieValue(int16_t input_val){ //m_display->display(); } -void SSD1306DisplayDevice::showTemperatureValue(int16_t input_val){ +void DisplayDevice::showTemperatureValue(int16_t input_val){ uint8_t x_offset_temp_logo = 30; uint8_t y_offset_temp_logo = 2; cleanTemperatur(x_offset_temp_logo,y_offset_temp_logo); @@ -204,7 +204,7 @@ void SSD1306DisplayDevice::showTemperatureValue(int16_t input_val){ this->showTextOnGrid(1, 0, val + "°C", TINY_FONT); } -void SSD1306DisplayDevice::showSpeed(double velocity) { +void DisplayDevice::showSpeed(double velocity) { const int bufSize = 4; char buffer[bufSize]; if (velocity >= 0) { @@ -216,18 +216,18 @@ void SSD1306DisplayDevice::showSpeed(double velocity) { this->prepareTextOnGrid(1, 5, "km/h"); } -uint8_t SSD1306DisplayDevice::currentLine() const { +uint8_t DisplayDevice::currentLine() const { return mCurrentLine; } -uint8_t SSD1306DisplayDevice::newLine() { +uint8_t DisplayDevice::newLine() { if (mCurrentLine >= 5) { scrollUp(); } return ++mCurrentLine; } -uint8_t SSD1306DisplayDevice::scrollUp() { +uint8_t DisplayDevice::scrollUp() { for (uint8_t i = 0; i < 5; i++) { prepareTextOnGrid(2, i, obsDisplay->get_gridTextofCell(2, i + 1)); } @@ -235,11 +235,11 @@ uint8_t SSD1306DisplayDevice::scrollUp() { return mCurrentLine--; } -uint8_t SSD1306DisplayDevice::startLine() { +uint8_t DisplayDevice::startLine() { return mCurrentLine = 0; } -void SSD1306DisplayDevice::highlight(uint32_t highlightTimeMillis) { +void DisplayDevice::highlight(uint32_t highlightTimeMillis) { mHighlightTill = millis() + highlightTimeMillis; if (!mHighlighted) { if (mInverted) { @@ -251,7 +251,7 @@ void SSD1306DisplayDevice::highlight(uint32_t highlightTimeMillis) { } } -void SSD1306DisplayDevice::handleHighlight() { +void DisplayDevice::handleHighlight() { if (mHighlighted && mHighlightTill < millis()) { if (mInverted) { m_display->invertDisplay(); diff --git a/src/displays.h b/src/displays.h index 290aae6f..7c7cd4f3 100644 --- a/src/displays.h +++ b/src/displays.h @@ -60,7 +60,7 @@ const int DIO = 25; //Set the DIO pin connection to the display extern bool BMP280_active; -class SSD1306DisplayDevice { +class DisplayDevice { private: void handleHighlight(); void displaySimple(uint16_t value); @@ -73,7 +73,7 @@ class SSD1306DisplayDevice { bool mHighlighted = false; public: - SSD1306DisplayDevice() { + DisplayDevice() { m_display = new SSD1306(0x3c, 21, 22); // ADDRESS, SDA, SCL m_display->init(); m_display->setBrightness(255); @@ -81,7 +81,7 @@ class SSD1306DisplayDevice { m_display->display(); } - ~SSD1306DisplayDevice() { + ~DisplayDevice() { delete m_display; } diff --git a/src/globals.h b/src/globals.h index d430ed62..ba2b758e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -27,7 +27,7 @@ #include // Forward declare classes to build (because there is a cyclic dependency between sensor.h and displays.h) -class SSD1306DisplayDevice; +class DisplayDevice; class HCSR04SensorManager; @@ -52,7 +52,7 @@ extern int numButtonReleased; extern Config config; -extern SSD1306DisplayDevice* obsDisplay; +extern DisplayDevice* obsDisplay; extern HCSR04SensorManager* sensorManager; diff --git a/src/gps.cpp b/src/gps.cpp index c1aff2f7..271dfc64 100644 --- a/src/gps.cpp +++ b/src/gps.cpp @@ -545,7 +545,7 @@ PrivacyArea Gps::newPrivacyArea(double latitude, double longitude, int radius) { return newPrivacyArea; } -bool Gps::hasFix(SSD1306DisplayDevice *display) const { +bool Gps::hasFix(DisplayDevice *display) const { bool result = false; if (mCurrentGpsRecord.hasValidFix() && mLastTimeTimeSet) { log_d("Got location..."); @@ -563,7 +563,7 @@ int32_t Gps::getMessagesWithFailedCrcCount() const { return mMessagesWithFailedCrcReceived; } -void Gps::showWaitStatus(SSD1306DisplayDevice const * display) const { +void Gps::showWaitStatus(DisplayDevice const * display) const { String satellitesString[2]; if (mValidMessagesReceived == 0) { // could not get any valid char from GPS module satellitesString[0] = "OFF?"; diff --git a/src/gps.h b/src/gps.h index d940a081..34403f44 100644 --- a/src/gps.h +++ b/src/gps.h @@ -31,7 +31,7 @@ #include "displays.h" #include "gpsrecord.h" -class SSD1306DisplayDevice; +class DisplayDevice; class Gps { public: @@ -47,7 +47,7 @@ class Gps { /* read and process data from serial, true if there was valid data. */ bool handle(); - bool hasFix(SSD1306DisplayDevice *display) const; + bool hasFix(DisplayDevice *display) const; /* Returns true if valid communication with the gps module was possible. */ bool moduleIsAlive() const; @@ -56,7 +56,7 @@ class Gps { uint8_t getValidSatellites() const; - void showWaitStatus(const SSD1306DisplayDevice *display) const; + void showWaitStatus(const DisplayDevice *display) const; /* Returns current speed, negative value means unknown speed. */ double getSpeed() const; diff --git a/src/utils/alpdata.cpp b/src/utils/alpdata.cpp index b889a1b9..9e3c51ff 100644 --- a/src/utils/alpdata.cpp +++ b/src/utils/alpdata.cpp @@ -30,7 +30,7 @@ /* Download http://alp.u-blox.com/current_14d.alp (ssl?) if there is a new one * Takes 5 seconds to update the data. */ -void AlpData::update(SSD1306DisplayDevice *display) { +void AlpData::update(DisplayDevice *display) { String lastModified = loadLastModified(); File f = SD.open(ALP_DATA_FILE_NAME, FILE_READ); @@ -95,7 +95,7 @@ void AlpData::update(SSD1306DisplayDevice *display) { httpClient.end(); } -void AlpData::displayHttpClientError(SSD1306DisplayDevice *display, int httpError) { +void AlpData::displayHttpClientError(DisplayDevice *display, int httpError) { display->showTextOnGrid(0, 4, String("ALP data failed ") + String(httpError).c_str()); String errorString = HTTPClient::errorToString(httpError); display->showTextOnGrid(0, 5, errorString.c_str()); diff --git a/src/utils/alpdata.h b/src/utils/alpdata.h index 5c4040f4..32cbecf9 100644 --- a/src/utils/alpdata.h +++ b/src/utils/alpdata.h @@ -39,7 +39,7 @@ static const char *const ALP_DOWNLOAD_URL = "https://alp.u-blox.com/current_14d. class AlpData { public: - static void update(SSD1306DisplayDevice *display); + static void update(DisplayDevice *display); static bool available(); static void saveMessage(const uint8_t *data, size_t size); static size_t loadMessage(uint8_t *data, size_t size); @@ -50,7 +50,7 @@ class AlpData { private: static void saveLastModified(const String &header); static String loadLastModified(); - static void displayHttpClientError(SSD1306DisplayDevice *display, int httpError); + static void displayHttpClientError(DisplayDevice *display, int httpError); File mAlpDataFile; };