Revision e0b5db7e

View differences:

examples/restore_offsets/restore_offsets.ino
181 181
	}
182 182
	else
183 183
	{
184
		foundCalib = true;
185 184
		Serial.println("Found Calibration for this sensor in EEPROM.");
186 185
		eeAddress += sizeof(long);
187 186
		EEPROM.get(eeAddress, calibrationData);
......
192 191
		bno.setSensorOffsets(calibrationData);
193 192

  
194 193
		Serial.println("\n\nCalibration data loaded into BNO055");
194
        foundCalib = true;
195 195
	}
196 196

  
197 197
	delay(1000);
......
206 206

  
207 207
	sensors_event_t event;
208 208
	bno.getEvent(&event);
209
	Serial.println("Move sensor slightly to calibrate magnetometers");
210
	while (!bno.isFullyCalibrated())
211
	{
212
		bno.getEvent(&event);
213
		delay(BNO055_SAMPLERATE_DELAY_MS);
214
	}
209
    if(foundCalib){
210
        Serial.println("Move sensor slightly to calibrate magnetometers");
211
        while (!bno.isFullyCalibrated())
212
        {
213
            bno.getEvent(&event);
214
            delay(BNO055_SAMPLERATE_DELAY_MS);
215
        }
216
    }
217
    else
218
    {
219
        while (!bno.isFullyCalibrated())
220
        {
221
            bno.getEvent(&event);
222
            
223
            Serial.print("X: ");
224
            Serial.print(event.orientation.x, 4);
225
            Serial.print("\tY: ");
226
            Serial.print(event.orientation.y, 4);
227
            Serial.print("\tZ: ");
228
            Serial.print(event.orientation.z, 4);
229
            
230
            /* Optional: Display calibration status */
231
            displayCalStatus();
232
            
233
            /* New line for the next sample */
234
            Serial.println("");
235
            
236
            /* Wait the specified delay before requesting new data */
237
            delay(BNO055_SAMPLERATE_DELAY_MS);
238
        }
239
    }
215 240

  
216 241
	Serial.println("\nFully calibrated!");
217 242
	Serial.println("--------------------------------");
218 243
	Serial.println("Calibration Results: ");
219 244
	bno.getSensorOffsets(calibrationData);
220 245
	displaySensorOffsets(calibrationData);
221
	Serial.println("\n--------------------------------\n\n");
222

  
223
	//if (!foundCalib){
224
	Serial.println("\n\nStoring calibration data to EEPROM...");
246
    
247
    Serial.println("\n\nStoring calibration data to EEPROM...");
225 248

  
226 249
	eeAddress = 0;
227 250
	bno.getSensor(&sensor);
......
232 255
	eeAddress += sizeof(long);
233 256
	EEPROM.put(eeAddress, calibrationData);
234 257
	Serial.println("Data stored to EEPROM.\n");
235
	//}
258
    
259
	Serial.println("\n--------------------------------\n");
236 260
}
237 261

  
238 262
void loop() {
......
257 281
	/* New line for the next sample */
258 282
	Serial.println("");
259 283

  
260
	/* Wait the specified delay before requesting nex data */
284
	/* Wait the specified delay before requesting new data */
261 285
	delay(BNO055_SAMPLERATE_DELAY_MS);
262 286
}

Also available in: Unified diff