diff --git a/source/shoh/src/threads/manager/Menu.cpp b/source/shoh/src/threads/manager/Menu.cpp index 0415721..4d17cf1 100644 --- a/source/shoh/src/threads/manager/Menu.cpp +++ b/source/shoh/src/threads/manager/Menu.cpp @@ -19,6 +19,7 @@ set_point_text("CURRENT %3d DESIRED[%3d] ") this->SetState(&Menu::sInitView); ext_temp.setCurrent(0); set_point.setCurrent(0); + readSetPointFromEEPROM(); } Menu::~Menu() @@ -26,6 +27,17 @@ Menu::~Menu() LOG_DEBUG("Deleting Menu"); } +void +Menu::readSetPointFromEEPROM (void) +{ + EventRawData *data = (EventRawData *)eeprom.read_from (EEPROM_START_ADDR, + sizeof(EventRawData)); + if ((*data) > 0 && (*data) < 120) + { + ext_temp.setCurrent(*data); + } +} + void Menu::HandleEventPair (Event::EventPair *ep) { switch(ep->et/*EventType*/) @@ -135,6 +147,7 @@ void Menu::sMainView(const MenuObjEvent &e) void Menu::sSetPointMod(const MenuObjEvent &e) { static char screen_text[64]; + EventRawData sp; switch (e.type) { case MenuObjEvent::eFocus: @@ -161,6 +174,9 @@ void Menu::sSetPointMod(const MenuObjEvent &e) break; case MenuObjEvent::eClick: LOG_DEBUG("click sSetPointMod"); + sp = set_point.getCurrent(); + // Write to EEPROM + eeprom.write_to(EEPROM_START_ADDR, (void*)&sp, sizeof(EventRawData)); this->SetState(&Menu::sMainView); break; case MenuObjEvent::eRefresh: diff --git a/source/shoh/src/threads/manager/Menu.h b/source/shoh/src/threads/manager/Menu.h index 676ceb0..76b1a22 100644 --- a/source/shoh/src/threads/manager/Menu.h +++ b/source/shoh/src/threads/manager/Menu.h @@ -11,6 +11,7 @@ #include "Counter.h" #include "MenuObjEvent.h" #include "ThreadCommon.h" +#include "EEPROMio.h" #include "Event.h" class Menu; @@ -29,6 +30,7 @@ private: p_state current; Counter ext_temp; Counter set_point; + EEPROMio eeprom; const char main_text[64]; const char set_point_text[64]; /* States */ @@ -39,6 +41,7 @@ private: void SetState (p_state new_state); void HandleObj (const MenuObjEvent &event); void NotifyAndRefreshUI (const char *str); + void readSetPointFromEEPROM (void); }; #endif /* THREADS_MANAGER_MENU_H_ */