Debugging... debugging...

This commit is contained in:
Eiren Rain
2021-05-11 05:24:36 +03:00
parent aab07e3ee4
commit d4d99f83bb
5 changed files with 32 additions and 24 deletions

View File

@@ -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);

View File

@@ -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);
}
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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
}