From c834940c2785accc3e612c38f8fe7caeb7427086 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Mon, 24 Jul 2017 12:16:04 +0200
Subject: [PATCH] Saved the calibration once it is done for the next time.

---
 src/bno055.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/bno055.c b/src/bno055.c
index a7647fa..5e7520f 100644
--- a/src/bno055.c
+++ b/src/bno055.c
@@ -115,7 +115,7 @@ void bno055_erase_calibration(void)
 {
   uint8_t i;
 
-  for(i=0;i<24;i++)
+  for(i=0;i<2;i++)
     eeprom_write_byte(&bno055_cal_data[i],0xFF); 
 }
 
@@ -237,7 +237,10 @@ void bno055_loop(void)
                           else
                             ram_data[IMU_CONTROL]&=0xEF;
                           if((ram_data[IMU_CONTROL]&0x70)==0x70)
+                          {
                             bno055_state=idle;
+                            bno055_save_calibration();
+                          }
                           else
                             bno055_state=get_calibrated;
                         }
-- 
GitLab