diff --git a/lib/bno080/BNO080.cpp b/lib/bno080/BNO080.cpp index 62e2787..774c4c6 100644 --- a/lib/bno080/BNO080.cpp +++ b/lib/bno080/BNO080.cpp @@ -1339,7 +1339,7 @@ void BNO080::saveCalibration() //Returns false if failed boolean BNO080::waitForI2C() { - for (uint8_t counter = 0; counter < 100; counter++) //Don't got more than 255 + for (uint8_t counter = 0; counter < 255; counter++) //Don't got more than 255 { if (_i2cPort->available() > 0) return (true); diff --git a/src/bno080sensor.cpp b/src/bno080sensor.cpp index cc950fa..fc5f701 100644 --- a/src/bno080sensor.cpp +++ b/src/bno080sensor.cpp @@ -42,6 +42,9 @@ namespace { } } +unsigned long lastData = 0; +int8_t lastReset = 0; + void BNO080Sensor::motionSetup(DeviceConfig * config) { delay(500); @@ -66,20 +69,19 @@ void BNO080Sensor::motionSetup(DeviceConfig * config) } Serial.print("Connected to "); Serial.println(IMU_NAME); - Wire.setClock(400000); - if(BNO_HASARVR_STABILIZATION) - imu.enableARVRStabilizedGameRotationVector(10); - else - imu.enableGameRotationVector(10); + #if defined(BNO_HAS_ARVR_STABILIZATION) && BNO_HAS_ARVR_STABILIZATION + imu.enableARVRStabilizedGameRotationVector(13); + #else + imu.enableGameRotationVector(13); + #endif + lastReset = imu.resetReason(); + lastData = millis(); } -unsigned long lastData = 0; -int8_t lastReset = -1; - void BNO080Sensor::motionLoop() { //Look for reports from the IMU - if (imu.dataAvailable()) + if(imu.dataAvailable()) { lastReset = -1; lastData = millis(); @@ -89,15 +91,14 @@ void BNO080Sensor::motionLoop() quaternion.w = imu.getQuatReal(); quaternion *= sensorOffset; newData = true; - } else { - if(lastData + 5000 < millis()) { - lastData = millis(); - uint8_t rr = imu.resetReason(); - if(rr != lastReset) { - lastReset = rr; - sendResetReason(rr); - digitalWrite(LOADING_LED, LOW); - } + } + if(lastData + 1000 < millis()) { + lastData = millis(); + uint8_t rr = imu.resetReason(); + if(rr != lastReset) { + lastReset = rr; + sendResetReason(rr); + digitalWrite(LOADING_LED, LOW); } } } diff --git a/src/defines.h b/src/defines.h index 6f3e737..9e48710 100644 --- a/src/defines.h +++ b/src/defines.h @@ -35,19 +35,19 @@ #define IMU_HAS_ACCELL true #define IMU_HAS_GYRO true #define IMU_HAS_MAG true - #define BNO_HASARVR_STABILIZATION true + #define BNO_HAS_ARVR_STABILIZATION true #elif IMU == IMU_BNO080 #define IMU_NAME "BNO080" #define IMU_HAS_ACCELL true #define IMU_HAS_GYRO true #define IMU_HAS_MAG true - #define BNO_HASARVR_STABILIZATION false + #define BNO_HAS_ARVR_STABILIZATION false #elif IMU == IMU_BNO055 #define IMU_NAME "BNO055" #define IMU_HAS_ACCELL true #define IMU_HAS_GYRO true #define IMU_HAS_MAG true - #define BNO_HASARVR_STABILIZATION false + #define BNO_HAS_ARVR_STABILIZATION false #elif IMU == IMU_MPU9250 #define IMU_NAME "MPU9250" #define IMU_HAS_ACCELL true diff --git a/src/main.cpp b/src/main.cpp index d3c9e0d..f79d2e6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,6 +75,7 @@ void processBlinking(); void setup() { + //wifi_set_sleep_type(NONE_SLEEP_T); // Glow diode while loading pinMode(LOADING_LED, OUTPUT); pinMode(CALIBRATING_LED, OUTPUT); @@ -85,6 +86,7 @@ void setup() Wire.flush(); Wire.begin(D2, D1); Wire.setClockStretchLimit(4000); + Wire.setClock(100000); Serial.begin(serialBaudRate); while (!Serial) ; // wait for connection diff --git a/src/udpclient.cpp b/src/udpclient.cpp index 7c69de0..3f5e19e 100644 --- a/src/udpclient.cpp +++ b/src/udpclient.cpp @@ -415,7 +415,7 @@ bool startWPSPBC() { void setUpWiFi(DeviceConfig * const config) { Serial.print("Connecting to wifi "); WiFi.mode(WIFI_STA); - + WiFi.hostname("SlimeVR"); WiFi.begin(WiFi.SSID().c_str(), WiFi.psk().c_str()); } @@ -488,7 +488,9 @@ void connectClient() port = Udp.remotePort(); lastPacketMs = now; connected = true; +#ifndef SEND_UPDATES_UNCONNECTED digitalWrite(LOADING_LED, HIGH); +#endif Serial.printf("[Handshake] Handshale sucessful, server is %s:%d\n", Udp.remoteIP().toString().c_str(), + Udp.remotePort()); return; default: @@ -518,11 +520,14 @@ void connectClient() Serial.print("Write error: "); Serial.println(Udp.getWriteError()); } - +#ifndef SEND_UPDATES_UNCONNECTED digitalWrite(LOADING_LED, LOW); +#endif } +#ifndef SEND_UPDATES_UNCONNECTED else if(lastConnectionAttemptMs + 20 < now) { digitalWrite(LOADING_LED, HIGH); } +#endif } \ No newline at end of file