From b9356c9ae863871f277998ab1eb1bb55e008ff37 Mon Sep 17 00:00:00 2001
From: Thomas Hooge <thomas@hoogi.de>
Date: Tue, 21 Jan 2025 09:28:53 +0100
Subject: [PATCH] Fix warning and FRAM code on system page

---
 lib/obp60task/OBP60Extensions.h | 1 +
 lib/obp60task/PageSystem.cpp    | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/obp60task/OBP60Extensions.h b/lib/obp60task/OBP60Extensions.h
index 972d148..fa80cc9 100644
--- a/lib/obp60task/OBP60Extensions.h
+++ b/lib/obp60task/OBP60Extensions.h
@@ -10,6 +10,7 @@
 // FRAM address reservations 32kB: 0x0000 - 0x7FFF
 // 0x0000 - 0x03ff: single variables
 #define FRAM_PAGE_NO 0x0002
+#define FRAM_SYSTEM_MODE 0x009
 // Voltage page
 #define FRAM_VOLTAGE_AVG 0x000A
 #define FRAM_VOLTAGE_TREND 0x000B
diff --git a/lib/obp60task/PageSystem.cpp b/lib/obp60task/PageSystem.cpp
index b69cd25..7beb13d 100644
--- a/lib/obp60task/PageSystem.cpp
+++ b/lib/obp60task/PageSystem.cpp
@@ -3,7 +3,7 @@
 #include "Pagedata.h"
 #include "OBP60Extensions.h"
 #include "images/logo64.xbm"
-#include <esp_clk.h>
+#include <esp32/clk.h>
 
 #define STRINGIZE_IMPL(x) #x
 #define STRINGIZE(x) STRINGIZE_IMPL(x)
@@ -31,6 +31,9 @@ public:
     PageSystem(CommonData &common){
         commonData = &common;
         common.logger->logDebug(GwLog::LOG,"Instantiate PageSystem");
+        if (hasFRAM) {
+            mode = fram.read(FRAM_SYSTEM_MODE);
+        }
         chipid = ESP.getEfuseMac();
         simulation = common.config->getBool(common.config->useSimuData);
         buzzer_mode = common.config->getString(common.config->buzzerMode);
@@ -60,7 +63,7 @@ public:
             } else {
                 mode = 'N';
             }
-            if (hasFRAM) fram.write(FRAM_VOLTAGE_MODE, mode);
+            if (hasFRAM) fram.write(FRAM_SYSTEM_MODE, mode);
             return 0;
         }
         // grab cursor keys to disable page navigation