Skip to content

Commit 0218067

Browse files
committed
Increase font size for display simple
1 parent 898e64a commit 0218067

4 files changed

Lines changed: 66 additions & 71 deletions

File tree

src/displays.cpp

Lines changed: 54 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -43,112 +43,95 @@ void SSD1306DisplayDevice::showNumButtonPressed() {
4343
this->prepareTextOnGrid(1, 5, "press");
4444
}
4545

46+
void SSD1306DisplayDevice::displaySimple(uint16_t value) {
47+
if (value == MAX_SENSOR_VALUE) {
48+
this->prepareTextOnGrid(0, 0,
49+
"", HUGE_FONT, -7, -7);
50+
} else {
51+
this->prepareTextOnGrid(0, 0,
52+
ObsUtils::to3DigitString(value), HUGE_FONT, -7, -7);
53+
}
54+
this->prepareTextOnGrid(3, 2, "cm", MEDIUM_FONT, -7, -5);
55+
}
56+
4657
void SSD1306DisplayDevice::showValues(
4758
HCSR04SensorInfo sensor1, HCSR04SensorInfo sensor2, uint16_t minDistanceToConfirm, int16_t batteryPercentage,
4859
int16_t TemperaturValue, int lastMeasurements, boolean insidePrivacyArea,
4960
double speed, uint8_t satellites) {
5061

5162
handleHighlight();
52-
// Show sensor1, when DisplaySimple or DisplayLeft is configured
53-
if (config.displayConfig & DisplaySimple || config.displayConfig & DisplayLeft) {
54-
uint16_t value1 = sensor1.minDistance;
55-
if (minDistanceToConfirm != MAX_SENSOR_VALUE) {
56-
value1 = minDistanceToConfirm;
57-
}
58-
59-
String loc1 = sensor1.sensorLocation;
60-
if (insidePrivacyArea) {
61-
loc1 = "(" + loc1 + ")";
62-
}
6363

64-
// Do not show location, when DisplaySimple is configured
65-
if (!(config.displayConfig & DisplaySimple)) {
64+
uint16_t value1 = sensor1.minDistance;
65+
if (minDistanceToConfirm != MAX_SENSOR_VALUE) {
66+
value1 = minDistanceToConfirm;
67+
}
68+
if (config.displayConfig & DisplaySimple) {
69+
displaySimple(value1);
70+
} else {
71+
if (config.displayConfig & DisplayLeft) {
72+
String loc1 = sensor1.sensorLocation;
73+
if (insidePrivacyArea) {
74+
loc1 = "(" + loc1 + ")";
75+
}
6676
this->prepareTextOnGrid(0, 0, loc1);
67-
}
68-
69-
if (value1 == MAX_SENSOR_VALUE) {
70-
this->prepareTextOnGrid(0, 1, "---", LARGE_FONT);
71-
} else {
72-
String val = String(value1);
73-
if (value1 <= 9) {
74-
val = "00" + val;
75-
} else if (value1 >= 10 && value1 <= 99) {
76-
val = "0" + val;
77+
if (value1 == MAX_SENSOR_VALUE) {
78+
this->prepareTextOnGrid(0, 1, "---", LARGE_FONT);
79+
} else {
80+
this->prepareTextOnGrid(0, 1,
81+
ObsUtils::to3DigitString(value1), LARGE_FONT);
7782
}
78-
79-
this->prepareTextOnGrid(0, 1, val, LARGE_FONT);
8083
}
81-
82-
if (config.displayConfig & DisplaySimple) {
83-
this->prepareTextOnGrid(2, 2, "cm", MEDIUM_FONT,5,0);
84-
}
85-
}
86-
87-
if (!(config.displayConfig & DisplaySimple)) {
88-
8984
// Show sensor2, when DisplayRight is configured
9085
if (config.displayConfig & DisplayRight) {
9186
uint16_t value2 = sensor2.distance;
9287
String loc2 = sensor2.sensorLocation;
93-
9488
this->prepareTextOnGrid(3, 0, loc2);
9589
if (value2 == MAX_SENSOR_VALUE || value2 == 0) {
96-
this->prepareTextOnGrid(2, 1, "---", LARGE_FONT,5,0);
90+
this->prepareTextOnGrid(2, 1, "---", LARGE_FONT, 5, 0);
9791
} else {
98-
String val = String(value2);
99-
if (value2 <= 9) {
100-
val = "00" + val;
101-
} else if (value2 <= 99) {
102-
val = "0" + val;
103-
}
104-
this->prepareTextOnGrid(2, 1, val, LARGE_FONT,5,0);
92+
this->prepareTextOnGrid(2, 1,
93+
ObsUtils::to3DigitString(value2), LARGE_FONT, 5, 0);
10594
}
10695
}
107-
if (config.displayConfig & DisplayDistanceDetail) {
108-
const int bufSize = 64;
109-
char buffer[bufSize];
96+
} // NOT SIMPLE
97+
if (config.displayConfig & DisplayDistanceDetail) {
98+
const int bufSize = 64;
99+
char buffer[bufSize];
110100
// #ifdef NERD_SENSOR_DISTANCE
111101
snprintf(buffer, bufSize - 1, "%03d|%02d|%03d", sensor1.rawDistance,
112102
lastMeasurements, sensor2.rawDistance);
113103
// #endif
114104
#ifdef NERD_HEAP
115-
snprintf(buffer, bufSize - 1, "%03d|%02d|%uk", sensor1.rawDistance,
116-
lastMeasurements, ESP.getFreeHeap() / 1024);
105+
snprintf(buffer, bufSize - 1, "%03d|%02d|%uk", sensor1.rawDistance,
106+
lastMeasurements, ESP.getFreeHeap() / 1024);
117107
#endif
118108
#ifdef NERD_VOLT
119-
snprintf(buffer, bufSize - 1, "%03d|%02d|%3.2fV", sensor1.rawDistance,
120-
lastMeasurements, voltageMeter->read());
109+
snprintf(buffer, bufSize - 1, "%03d|%02d|%3.2fV", sensor1.rawDistance,
110+
lastMeasurements, voltageMeter->read());
121111
#endif
122112
#ifdef NERD_GPS
123-
snprintf(buffer, bufSize - 1, "%02ds|%s|%03u",
124-
satellites,
125-
gps.getHdopAsString().c_str(), gps.getLastNoiseLevel() );
113+
snprintf(buffer, bufSize - 1, "%02ds|%s|%03u",
114+
satellites,
115+
gps.getHdopAsString().c_str(), gps.getLastNoiseLevel() );
126116
#endif
127-
this->prepareTextOnGrid(0, 4, buffer, MEDIUM_FONT);
128-
} else if (config.displayConfig & DisplayNumConfirmed) {
129-
showNumButtonPressed();
130-
showNumConfirmed();
131-
} else {
132-
// Show GPS info, when DisplaySatellites is configured
133-
if (config.displayConfig & DisplaySatellites) {
134-
showGPS(satellites);
135-
}
136-
137-
// Show velocity, when DisplayVelocity is configured
138-
if (config.displayConfig & DisplayVelocity) {
139-
showSpeed(speed);
140-
}
141-
117+
this->prepareTextOnGrid(0, 4, buffer, MEDIUM_FONT);
118+
} else if (config.displayConfig & DisplayNumConfirmed) {
119+
showNumButtonPressed();
120+
showNumConfirmed();
121+
} else {
122+
// Show GPS info, when DisplaySatellites is configured
123+
if (config.displayConfig & DisplaySatellites) {
124+
showGPS(satellites);
125+
}
142126

127+
// Show velocity, when DisplayVelocity is configured
128+
if (config.displayConfig & DisplayVelocity) {
129+
showSpeed(speed);
143130
}
144131
}
145-
// Show Batterie voltage
146-
#warning not checked if colliding with other stuff
147-
148132
if (batteryPercentage >= -1) {
149133
showBatterieValue(batteryPercentage);
150134
}
151-
152135
if (!(config.displayConfig & DisplaySimple)){
153136
if(BMP280_active == true)
154137
showTemperatureValue(TemperaturValue);

src/displays.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class DisplayDevice {
7474
class SSD1306DisplayDevice : public DisplayDevice {
7575
private:
7676
void handleHighlight();
77+
void displaySimple(uint16_t value);
7778
SSD1306* m_display;
7879
String gridText[ 4 ][ 6 ];
7980
uint8_t mLastProgress = 255;

src/utils/obsutils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,13 @@ String ObsUtils::sha256ToString(byte *sha256) {
110110
}
111111
return String(hash_print);
112112
}
113+
114+
String ObsUtils::to3DigitString(uint32_t value) {
115+
String val = String(value);
116+
if (value <= 9) {
117+
val = "00" + val;
118+
} else if (value >= 10 && value <= 99) {
119+
val = "0" + val;
120+
} // no overflow
121+
return val;
122+
}

src/utils/obsutils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ObsUtils {
4141
static String encodeForUrl(const String &url);
4242
static String toScaledByteString(uint64_t size);
4343
static void logHexDump(const uint8_t *buffer, uint16_t length);
44+
static String to3DigitString(uint32_t value);
4445

4546
};
4647

0 commit comments

Comments
 (0)