Skip to content

Commit

Permalink
Rename class SSD1306DisplayDevice to DisplayDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
j000bs committed Feb 4, 2024
1 parent db3c3bd commit a74041e
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/OpenBikeSensorFirmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Button button(PUSHBUTTON_PIN);

Config config;

SSD1306DisplayDevice* obsDisplay;
DisplayDevice* obsDisplay;
HCSR04SensorManager* sensorManager;
static BluetoothManager* bluetoothManager;

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/configServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions src/displays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include "fonts/fonts.h"

void SSD1306DisplayDevice::showNumConfirmed() {
void DisplayDevice::showNumConfirmed() {
String val = String(confirmedMeasurements);
if (confirmedMeasurements <= 9) {
val = "0" + val;
Expand All @@ -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;
Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -216,30 +216,30 @@ 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));
}
m_display->display();
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) {
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions src/displays.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -73,15 +73,15 @@ 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);
m_display->setTextAlignment(TEXT_ALIGN_LEFT);
m_display->display();
}

~SSD1306DisplayDevice() {
~DisplayDevice() {
delete m_display;
}

Expand Down
4 changes: 2 additions & 2 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <Arduino.h>

// Forward declare classes to build (because there is a cyclic dependency between sensor.h and displays.h)
class SSD1306DisplayDevice;
class DisplayDevice;
class HCSR04SensorManager;


Expand All @@ -52,7 +52,7 @@ extern int numButtonReleased;
extern Config config;


extern SSD1306DisplayDevice* obsDisplay;
extern DisplayDevice* obsDisplay;

extern HCSR04SensorManager* sensorManager;

Expand Down
4 changes: 2 additions & 2 deletions src/gps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand All @@ -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?";
Expand Down
6 changes: 3 additions & 3 deletions src/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "displays.h"
#include "gpsrecord.h"

class SSD1306DisplayDevice;
class DisplayDevice;

class Gps {
public:
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/utils/alpdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/utils/alpdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

};
Expand Down

0 comments on commit a74041e

Please sign in to comment.