From 6e10eabd9f5849add5308001a996037a6ca7f2d0 Mon Sep 17 00:00:00 2001 From: Rune Harlyk Date: Wed, 16 Jul 2025 20:32:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Cleans=20up=20peripherals=20serv?= =?UTF-8?q?ice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- esp32/include/peripherals/peripherals.h | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/esp32/include/peripherals/peripherals.h b/esp32/include/peripherals/peripherals.h index debb742..36a9ca6 100644 --- a/esp32/include/peripherals/peripherals.h +++ b/esp32/include/peripherals/peripherals.h @@ -28,13 +28,6 @@ #define MAX_ESP_IMU_SIZE 500 #define EVENT_IMU "imu" -/* - * OLED Settings - */ -#define SCREEN_WIDTH 128 -#define SCREEN_HEIGHT 64 -#define SCREEN_RESET -1 - /* * Ultrasonic Sensor Settings */ @@ -77,8 +70,8 @@ class Peripherals : public StatefulService { if (!_bmp.initialize()) ESP_LOGE("IMUService", "BMP initialize failed"); #endif #if FT_ENABLED(USE_USS) - _left_sonar = new NewPing(USS_LEFT_PIN, USS_LEFT_PIN, MAX_DISTANCE); - _right_sonar = new NewPing(USS_RIGHT_PIN, USS_RIGHT_PIN, MAX_DISTANCE); + _left_sonar = std::make_unique(USS_LEFT_PIN, USS_LEFT_PIN, MAX_DISTANCE); + _right_sonar = std::make_unique(USS_RIGHT_PIN, USS_RIGHT_PIN, MAX_DISTANCE); #endif }; @@ -128,10 +121,7 @@ class Peripherals : public StatefulService { } } uint8_t nDevices = addressList.size(); - if (nDevices == 0) - ESP_LOGI("Peripherals", "No I2C devices found"); - else - ESP_LOGI("Peripherals", "Scan complete - Found %d devices", nDevices); + ESP_LOGI("Peripherals", "Scan complete - Found %d device(s)", nDevices); } /* IMU FUNCTIONS */ @@ -190,8 +180,10 @@ class Peripherals : public StatefulService { #if FT_ENABLED(USE_BMP180) _bmp.readBarometer(root); #endif +#if FT_ENABLED(USE_MPU6050 || USE_BNO055) || FT_ENABLED(USE_HMC5883) JsonVariant data = doc.as(); socket.emit(EVENT_IMU, data); +#endif } void emitSonar() { @@ -225,8 +217,8 @@ class Peripherals : public StatefulService { Barometer _bmp; #endif #if FT_ENABLED(USE_USS) - NewPing *_left_sonar; - NewPing *_right_sonar; + std::unique_ptr _left_sonar; + std::unique_ptr _right_sonar; #endif float _left_distance {MAX_DISTANCE}; float _right_distance {MAX_DISTANCE};