Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 9, 2019
1 parent 79574dc commit 3889509
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 75 deletions.
56 changes: 18 additions & 38 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -11209,7 +11209,7 @@
"width": 78,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_M_center"
"inheritFrom": "default"
},
"displayOption": 0
},
Expand Down Expand Up @@ -11396,8 +11396,7 @@
"width": 78,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_S_left",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
},
Expand Down Expand Up @@ -11427,8 +11426,7 @@
"width": 78,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_S_left",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
}
Expand Down Expand Up @@ -11470,8 +11468,7 @@
"width": 78,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_S_left",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
},
Expand Down Expand Up @@ -11501,8 +11498,7 @@
"width": 78,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_S_left",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
}
Expand Down Expand Up @@ -12324,8 +12320,7 @@
"width": 74,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_M_center",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
},
Expand Down Expand Up @@ -12480,8 +12475,7 @@
"width": 74,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_S_left",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
}
Expand Down Expand Up @@ -13003,8 +12997,7 @@
"width": 95,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_M_center",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
},
Expand Down Expand Up @@ -13089,8 +13082,7 @@
"width": 95,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_M_center",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
},
Expand Down Expand Up @@ -13120,8 +13112,7 @@
"width": 78,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_S_left",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
}
Expand Down Expand Up @@ -13560,8 +13551,7 @@
"width": 96,
"height": 32,
"focusStyle": {
"inheritFrom": "edit_value_active_M_center",
"padding": 0
"inheritFrom": "default"
},
"displayOption": 0
},
Expand Down Expand Up @@ -14773,8 +14763,7 @@
{
"type": "DisplayData",
"style": {
"inheritFrom": "edit_value_active_S_center",
"padding": 0
"inheritFrom": "edit_value_active_S_center"
},
"data": "channel_list_dwell",
"action": "channel_lists_edit",
Expand Down Expand Up @@ -14819,8 +14808,7 @@
{
"type": "DisplayData",
"style": {
"inheritFrom": "edit_value_active_S_center",
"padding": 0
"inheritFrom": "edit_value_active_S_center"
},
"data": "channel_list_voltage",
"action": "channel_lists_edit",
Expand Down Expand Up @@ -14866,8 +14854,7 @@
{
"type": "DisplayData",
"style": {
"inheritFrom": "edit_value_active_S_center",
"padding": 0
"inheritFrom": "edit_value_active_S_center"
},
"data": "channel_list_current",
"action": "channel_lists_edit",
Expand Down Expand Up @@ -25155,7 +25142,7 @@
"top": 0,
"width": 41,
"height": 32,
"text": "E",
"text": "H",
"focusStyle": {}
},
{
Expand Down Expand Up @@ -28602,9 +28589,7 @@
{
"type": "DisplayData",
"style": {
"inheritFrom": "encoder_cursor_14_enabled",
"font": "Oswald14",
"alignHorizontal": "center"
"inheritFrom": "encoder_cursor_14_enabled"
},
"data": "channel_u_edit",
"action": "edit",
Expand Down Expand Up @@ -29003,9 +28988,7 @@
{
"type": "DisplayData",
"style": {
"inheritFrom": "encoder_cursor_14_enabled",
"font": "Oswald14",
"alignHorizontal": "center"
"inheritFrom": "encoder_cursor_14_enabled"
},
"data": "channel_u_edit",
"action": "edit",
Expand Down Expand Up @@ -29251,9 +29234,7 @@
{
"type": "DisplayData",
"style": {
"inheritFrom": "encoder_cursor_14_enabled",
"font": "Oswald14",
"alignHorizontal": "center"
"inheritFrom": "encoder_cursor_14_enabled"
},
"data": "channel_u_edit",
"action": "edit",
Expand Down Expand Up @@ -38226,7 +38207,6 @@
"type": "DisplayData",
"style": {
"inheritFrom": "encoder_cursor_14_enabled",
"font": "Oswald14",
"backgroundColor": "text_enable_background"
},
"data": "channel_protection_opp_level",
Expand Down
10 changes: 3 additions & 7 deletions src/eez/gui/app_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ Page *AppContext::getActivePage() {
return m_activePage.page;
}

int AppContext::getPreviousPageId() {
return m_previousPageId;
}

Page *AppContext::getPreviousPage() {
if (m_pageNavigationStackPointer > 0) {
return m_pageNavigationStack[m_pageNavigationStackPointer - 1].page;
Expand All @@ -180,7 +176,7 @@ Page *AppContext::getPreviousPage() {
}
}

void AppContext::onPageChanged() {
void AppContext::onPageChanged(int previousPageId, int activePageId) {
eez::mcu::display::turnOn();
psu::idle::noteGuiActivity();
}
Expand All @@ -191,7 +187,7 @@ void AppContext::doShowPage(int index, Page *page) {
m_activePage.page->pageFree();
}

m_previousPageId = m_activePage.pageId;
int previousPageId = m_activePage.pageId;

m_activePage.page = page ? page : getPageFromId(index);
m_activePage.pageId = index;
Expand All @@ -206,7 +202,7 @@ void AppContext::doShowPage(int index, Page *page) {
if (getActivePageId() != PAGE_ID_TEXT_MESSAGE && m_textMessage[0]) {
m_textMessage[0] = 0;
}
onPageChanged();
onPageChanged(previousPageId, m_activePage.pageId);

refreshScreen();
}
Expand Down
4 changes: 1 addition & 3 deletions src/eez/gui/app_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class AppContext {
return (InternalPage *)getActivePage();
}

int getPreviousPageId();
Page *getPreviousPage();

void pushSelectFromEnumPage(const data::EnumItem *enumDefinition, uint16_t currentValue,
Expand Down Expand Up @@ -117,14 +116,13 @@ class AppContext {

protected:
virtual int getMainPageId() = 0;
virtual void onPageChanged();
virtual void onPageChanged(int previousPageId, int activePageId);

//
PageOnStack m_activePage;
bool m_isTopPage;
PageOnStack m_activePageSaved;

int m_previousPageId = INTERNAL_PAGE_ID_NONE;
PageOnStack m_pageNavigationStack[CONF_GUI_PAGE_NAVIGATION_STACK_SIZE];
int m_pageNavigationStackPointer = 0;

Expand Down
4 changes: 0 additions & 4 deletions src/eez/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ Page *getActivePage() {
return g_appContext->getActivePage();
}

int getPreviousPageId() {
return g_appContext->getPreviousPageId();
}

Page *getPreviousPage() {
return g_appContext->getPreviousPage();
}
Expand Down
1 change: 0 additions & 1 deletion src/eez/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void popPage();
void replacePage(int pageId, Page *page = nullptr);
int getActivePageId();
Page *getActivePage();
int getPreviousPageId();
Page *getPreviousPage();
Page *getPage(int pageId);
bool isPageActiveOrOnStack(int pageId);
Expand Down
40 changes: 19 additions & 21 deletions src/eez/modules/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,22 +280,20 @@ bool isChSettingsSubPage(int pageId) {
}


void PsuAppContext::onPageChanged() {
AppContext::onPageChanged();
void PsuAppContext::onPageChanged(int previousPageId, int activePageId) {
AppContext::onPageChanged(previousPageId, activePageId);

if (m_previousPageId == PAGE_ID_WELCOME) {
if (previousPageId == PAGE_ID_WELCOME) {
animateFadeOutFadeIn();
}

g_focusEditValue = data::Value();

int activePageId = getActivePageId();

if (m_previousPageId == PAGE_ID_EVENT_QUEUE) {
if (previousPageId == PAGE_ID_EVENT_QUEUE) {
if (getActivePageId() == PAGE_ID_MAIN) {
animateSlideUp();
}
} else if (m_previousPageId == PAGE_ID_MAIN) {
} else if (previousPageId == PAGE_ID_MAIN) {
if (activePageId == PAGE_ID_SYS_SETTINGS) {
animateShowSysSettings();
} else if (isSysSettingsSubPage(activePageId)) {
Expand All @@ -315,69 +313,69 @@ void PsuAppContext::onPageChanged() {
} else if (activePageId == PAGE_ID_RECORDINGS_VIEW) {
animateSlideDown();
}
} else if (m_previousPageId == PAGE_ID_USER_PROFILES) {
} else if (previousPageId == PAGE_ID_USER_PROFILES) {
if (activePageId == PAGE_ID_USER_PROFILE_0_SETTINGS) {
animateSlideDown();
} else if (activePageId == PAGE_ID_USER_PROFILE_SETTINGS) {
animateSlideDown();
} else if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
}
} else if (m_previousPageId == PAGE_ID_USER_PROFILE_0_SETTINGS) {
} else if (previousPageId == PAGE_ID_USER_PROFILE_0_SETTINGS) {
if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
} else if (activePageId == PAGE_ID_USER_PROFILES) {
animateSlideUp();
}
} else if (m_previousPageId == PAGE_ID_USER_PROFILE_SETTINGS) {
} else if (previousPageId == PAGE_ID_USER_PROFILE_SETTINGS) {
if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
} else if (activePageId == PAGE_ID_USER_PROFILES) {
animateSlideUp();
}
} else if (m_previousPageId == PAGE_ID_SYS_INFO) {
} else if (previousPageId == PAGE_ID_SYS_INFO) {
if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
}
} else if (m_previousPageId == PAGE_ID_SYS_SETTINGS_TRACKING) {
} else if (previousPageId == PAGE_ID_SYS_SETTINGS_TRACKING) {
if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
} else if (activePageId == PAGE_ID_SYS_SETTINGS_COUPLING) {
animateSlideLeft();
}
} else if (activePageId == PAGE_ID_SYS_SETTINGS_COUPLING) {
} else if (previousPageId == PAGE_ID_SYS_SETTINGS_COUPLING) {
if (activePageId == PAGE_ID_SYS_SETTINGS_TRACKING) {
animateSlideRight();
} else if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
}
} else if (m_previousPageId == PAGE_ID_SYS_SETTINGS) {
} else if (previousPageId == PAGE_ID_SYS_SETTINGS) {
if (activePageId == PAGE_ID_MAIN) {
animateHideSysSettings();
} else if (isSysSettingsSubPage(activePageId)) {
animateSettingsSlideLeft();
}
} else if (m_previousPageId == PAGE_ID_SYS_SETTINGS_TRIGGER) {
} else if (previousPageId == PAGE_ID_SYS_SETTINGS_TRIGGER) {
if (activePageId == PAGE_ID_MAIN) {
animateHideSysSettings();
} else if (activePageId == PAGE_ID_CH_SETTINGS_TRIGGER) {
animateSlideUp();
} else if (activePageId == PAGE_ID_SYS_SETTINGS) {
animateSettingsSlideRight();
}
} else if (isSysSettingsSubPage(m_previousPageId)) {
} else if (isSysSettingsSubPage(previousPageId)) {
if (activePageId == PAGE_ID_MAIN) {
animateHideSysSettings();
} else if (activePageId == PAGE_ID_SYS_SETTINGS) {
animateSettingsSlideRight();
}
} else if (m_previousPageId == PAGE_ID_CH_SETTINGS) {
} else if (previousPageId == PAGE_ID_CH_SETTINGS) {
if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
} else if (isChSettingsSubPage(activePageId)) {
animateSlideLeft();
}
} else if (m_previousPageId == PAGE_ID_CH_SETTINGS_TRIGGER) {
} else if (previousPageId == PAGE_ID_CH_SETTINGS_TRIGGER) {
if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
} else if (activePageId == PAGE_ID_SYS_SETTINGS_TRIGGER) {
Expand All @@ -387,17 +385,17 @@ void PsuAppContext::onPageChanged() {
} else if (activePageId == PAGE_ID_CH_SETTINGS) {
animateSlideRight();
}
} else if (m_previousPageId == PAGE_ID_CH_SETTINGS_LISTS) {
} else if (previousPageId == PAGE_ID_CH_SETTINGS_LISTS) {
if (activePageId == PAGE_ID_CH_SETTINGS_TRIGGER) {
animateSlideUp();
}
} else if (isChSettingsSubPage(m_previousPageId)) {
} else if (isChSettingsSubPage(previousPageId)) {
if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
} else if (activePageId == PAGE_ID_CH_SETTINGS) {
animateSlideRight();
}
} else if (m_previousPageId == PAGE_ID_RECORDINGS_VIEW) {
} else if (previousPageId == PAGE_ID_RECORDINGS_VIEW) {
if (activePageId == PAGE_ID_MAIN) {
animateSlideUp();
}
Expand Down
Loading

0 comments on commit 3889509

Please sign in to comment.