1

Dependencies:   mbed-dev-f303 FastPWM3

Revision:
48:1b51771c3647
Parent:
24:58c2d7571207
diff -r 55bdc4d5096b -r 1b51771c3647 PreferenceWriter/PrefrenceWriter.cpp
--- a/PreferenceWriter/PrefrenceWriter.cpp	Sat Dec 07 08:01:06 2019 +0000
+++ b/PreferenceWriter/PrefrenceWriter.cpp	Fri Feb 07 11:31:37 2020 +0000
@@ -25,7 +25,7 @@
 void PreferenceWriter::write(float x, int index) {
     __float_reg[index] = x;
 }
-
+/*
 void PreferenceWriter::flush() {
     int offs;
     for (offs = 0; offs < 256; offs++) {
@@ -36,7 +36,18 @@
     }
     __ready = false;
 }
-
+*/
+void PreferenceWriter::flush() {
+    int offs;
+    for (offs = 0; offs < 300; offs++) {
+        writer->write(offs, __int_reg[offs]);
+    }
+    for (; offs < 364; offs++) {
+        writer->write(offs, __float_reg[offs - 300]);
+    }
+    __ready = false;
+}
+/*
 void PreferenceWriter::load() {
     int offs;
     for (offs = 0; offs < 256; offs++) {
@@ -46,6 +57,17 @@
         __float_reg[offs - 256] = flashReadFloat(__sector, offs);
     }
 }
+*/
+
+void PreferenceWriter::load() {
+    int offs;
+    for (offs = 0; offs < 300; offs++) {
+        __int_reg[offs] = flashReadInt(__sector, offs);
+    }
+    for(; offs < 364; offs++) {
+        __float_reg[offs - 300] = flashReadFloat(__sector, offs);
+    }
+}
 
 void PreferenceWriter::close() {
     __ready = false;