@@ -57,7 +57,7 @@ Button button(PUSHBUTTON_PIN);
5757
5858Config config;
5959
60- SSD1306DisplayDevice* displayTest ;
60+ SSD1306DisplayDevice* obsDisplay ;
6161HCSR04SensorManager* sensorManager;
6262static BluetoothManager* bluetoothManager;
6363
@@ -135,7 +135,7 @@ void setupSensors() {
135135
136136static void setupBluetooth (const ObsConfig &cfg, const String &trackUniqueIdentifier) {
137137 if (cfg.getProperty <bool >(ObsConfig::PROPERTY_BLUETOOTH)) {
138- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " Bluetooth .." );
138+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " Bluetooth .." );
139139 bluetoothManager = new BluetoothManager;
140140 bluetoothManager->init (
141141 cfg.getProperty <String>(ObsConfig::PROPERTY_OBS_NAME),
@@ -144,7 +144,7 @@ static void setupBluetooth(const ObsConfig &cfg, const String &trackUniqueIdenti
144144 batteryPercentage,
145145 trackUniqueIdentifier);
146146 bluetoothManager->activateBluetooth ();
147- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), " Bluetooth up" );
147+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), " Bluetooth up" );
148148 } else {
149149 bluetoothManager = nullptr ;
150150 ESP_ERROR_CHECK_WITHOUT_ABORT (
@@ -215,22 +215,22 @@ void setup() {
215215 if (displayError != 0 ) {
216216 Serial.println (" Display not found" );
217217 }
218- displayTest = new SSD1306DisplayDevice;
218+ obsDisplay = new SSD1306DisplayDevice;
219219
220220 switch_wire_speed_to_SSD1306 ();
221221
222- displayTest ->showLogo (true );
223- displayTest ->showTextOnGrid (2 , displayTest ->startLine (), OBSVersion);
222+ obsDisplay ->showLogo (true );
223+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->startLine (), OBSVersion);
224224
225225 voltageMeter = new VoltageMeter; // takes a moment, so do it here
226226 if (voltageMeter->hasReadings ()) {
227- displayTest ->showTextOnGrid (2 , displayTest ->newLine (),
227+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (),
228228 " Battery: " + String (voltageMeter->read (), 1 ) + " V" );
229229 delay (333 ); // Added for user experience
230230 }
231231 if (voltageMeter->isWarningLevel ()) {
232- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " LOW BAT" );
233- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " WARNING!" );
232+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " LOW BAT" );
233+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " WARNING!" );
234234 delay (5000 );
235235 }
236236
@@ -244,19 +244,19 @@ void setup() {
244244 // Handle SD
245245 // ##############################################################
246246 int8_t sdCount = 0 ;
247- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " SD..." );
247+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " SD..." );
248248 while (!SD.begin ()) {
249249 sdCount++;
250- displayTest ->showTextOnGrid (2 ,
251- displayTest ->currentLine (), " SD... error " + String (sdCount));
250+ obsDisplay ->showTextOnGrid (2 ,
251+ obsDisplay ->currentLine (), " SD... error " + String (sdCount));
252252 if (config.simRaMode || button.read () == HIGH || sdCount > 10 ) {
253253 break ;
254254 }
255255 delay (200 );
256256 }
257257
258258 if (SD.begin ()) {
259- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), " SD... OK" );
259+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), " SD... OK" );
260260 }
261261 delay (333 ); // Added for user experience
262262
@@ -281,7 +281,7 @@ void setup() {
281281 }
282282
283283 if (button.read () == HIGH || (!config.simRaMode && displayError != 0 ) || triggerServerMode) {
284- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " Start Server" );
284+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " Start Server" );
285285 ESP_ERROR_CHECK_WITHOUT_ABORT (
286286 esp_bt_mem_release (ESP_BT_MODE_BTDM)); // no bluetooth at all here.
287287
@@ -302,17 +302,17 @@ void setup() {
302302 // Prepare CSV file
303303 // ##############################################################
304304
305- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " CSV file..." );
305+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " CSV file..." );
306306 const String trackUniqueIdentifier = ObsUtils::createTrackUuid ();
307307
308308
309309 if (SD.begin ()) {
310310 writer = new CSVFileWriter;
311311 writer->setFileName ();
312312 writer->writeHeader (trackUniqueIdentifier);
313- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), " CSV file... OK" );
313+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), " CSV file... OK" );
314314 } else {
315- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), " CSV. skipped" );
315+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), " CSV. skipped" );
316316 }
317317
318318 gps.handle ();
@@ -328,22 +328,22 @@ void setup() {
328328
329329 setupBluetooth (cfg, trackUniqueIdentifier);
330330
331- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " Wait for GPS" );
332- displayTest ->newLine ();
331+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " Wait for GPS" );
332+ obsDisplay ->newLine ();
333333 gps.handle ();
334334 gps.setStatisticsIntervalInSeconds (1 ); // get regular updates.
335335
336- while (!gps.hasFix (displayTest )) {
336+ while (!gps.hasFix (obsDisplay )) {
337337 currentTimeMillis = millis ();
338338 gps.handle ();
339339 sensorManager->pollDistancesAlternating ();
340340 reportBluetooth ();
341- gps.showWaitStatus (displayTest );
341+ gps.showWaitStatus (obsDisplay );
342342 if (button.read () == HIGH
343343 || (config.simRaMode && !gps.moduleIsAlive ()) // no module && simRaMode
344344 ) {
345345 log_d (" Skipped get GPS..." );
346- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), " ...skipped" );
346+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), " ...skipped" );
347347 break ;
348348 }
349349 }
@@ -354,7 +354,7 @@ void setup() {
354354 gps.enableSbas ();
355355 gps.handle (1100 ); // Added for user experience
356356 gps.pollStatistics ();
357- displayTest ->clear ();
357+ obsDisplay ->clear ();
358358}
359359
360360void serverLoop () {
@@ -368,12 +368,12 @@ void handleButtonInServerMode() {
368368 button.handle ();
369369 if (!configServerWasConnectedViaHttp ()) {
370370 if (button.gotPressed ()) {
371- displayTest ->showTextOnGrid (0 , 3 , " Press the button for" );
372- displayTest ->showTextOnGrid (0 , 4 , " automatic track upload." );
373- displayTest ->clearProgressBar (5 );
371+ obsDisplay ->showTextOnGrid (0 , 3 , " Press the button for" );
372+ obsDisplay ->showTextOnGrid (0 , 4 , " automatic track upload." );
373+ obsDisplay ->clearProgressBar (5 );
374374 } else if (button.getPreviousStateMillis () > 0 && button.getState () == HIGH) {
375375 const uint32_t buttonPressedMs = button.getCurrentStateMillis ();
376- displayTest ->drawProgressBar (5 , buttonPressedMs, LONG_BUTTON_PRESS_TIME_MS);
376+ obsDisplay ->drawProgressBar (5 , buttonPressedMs, LONG_BUTTON_PRESS_TIME_MS);
377377 if (buttonPressedMs > LONG_BUTTON_PRESS_TIME_MS) {
378378 uploadTracks ();
379379 }
@@ -456,7 +456,7 @@ void loop() {
456456
457457 if (lastDisplayInterval != (currentTimeMillis / DISPLAY_INTERVAL_MILLIS)) {
458458 lastDisplayInterval = currentTimeMillis / DISPLAY_INTERVAL_MILLIS;
459- displayTest ->showValues (
459+ obsDisplay ->showValues (
460460 sensorManager->m_sensors [LEFT_SENSOR_ID],
461461 sensorManager->m_sensors [RIGHT_SENSOR_ID],
462462 minDistanceToConfirm,
@@ -472,7 +472,7 @@ void loop() {
472472 reportBluetooth ();
473473 if (button.gotPressed ()) { // after button was released, detect long press here
474474 // immediate user feedback - we start the action
475- displayTest ->highlight ();
475+ obsDisplay ->highlight ();
476476
477477 transmitConfirmedData = true ;
478478 numButtonReleased++;
@@ -558,27 +558,27 @@ uint8_t batteryPercentage() {
558558
559559bool loadConfig (ObsConfig &cfg) {
560560 bool isNew = false ;
561- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " Config... " );
561+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " Config... " );
562562
563563 if (!SPIFFS.begin (true )) {
564564 log_e (" An Error has occurred while mounting SPIFFS" );
565- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), " Config... error " );
566- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " Please reboot!" );
565+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), " Config... error " );
566+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " Please reboot!" );
567567 while (true ) {
568568 delay (1000 );
569569 }
570570 }
571571
572572 if (SD.begin () && SD.exists (" /obs.json" )) {
573- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), " Init from SD." );
573+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), " Init from SD." );
574574 log_i (" Configuration init from SD." );
575575 delay (1000 );
576576 File f = SD.open (" /obs.json" );
577577 if (cfg.loadConfig (f)) {
578578 cfg.saveConfig ();
579- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " done." );
579+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " done." );
580580 } else {
581- displayTest ->showTextOnGrid (2 , displayTest ->newLine (), " format error." );
581+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->newLine (), " format error." );
582582 }
583583 f.close ();
584584 SD.remove (" /obs.json" );
@@ -590,7 +590,7 @@ bool loadConfig(ObsConfig &cfg) {
590590
591591 log_i (" Load cfg" );
592592 if (!cfg.loadConfig ()) {
593- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), " Config...RESET" );
593+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), " Config...RESET" );
594594 isNew = true ;
595595 cfg.saveConfig (); // save the new config - next boot will allow obs mode
596596 }
@@ -603,19 +603,19 @@ bool loadConfig(ObsConfig &cfg) {
603603
604604 // Setup display, this is not the right place ;)
605605 if (config.displayConfig & DisplayInvert) {
606- displayTest ->invert ();
606+ obsDisplay ->invert ();
607607 } else {
608- displayTest ->normalDisplay ();
608+ obsDisplay ->normalDisplay ();
609609 }
610610 if (config.displayConfig & DisplayFlip) {
611- displayTest ->flipScreen ();
611+ obsDisplay ->flipScreen ();
612612 }
613613
614614 delay (333 ); // Added for user experience
615615 char buffer[32 ];
616616 snprintf (buffer, sizeof (buffer), " <%02d| - |%02d>" ,
617617 config.sensorOffsets [LEFT_SENSOR_ID],
618618 config.sensorOffsets [RIGHT_SENSOR_ID]);
619- displayTest ->showTextOnGrid (2 , displayTest ->currentLine (), buffer);
619+ obsDisplay ->showTextOnGrid (2 , obsDisplay ->currentLine (), buffer);
620620 return isNew;
621621}
0 commit comments