From 11863804f70c8dea423c73e1fdca141ff3df98b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 10 Jul 2019 15:38:07 +0200 Subject: [PATCH] [scripts] Remove EPSILON_BOOT_PROMPT flag --- Makefile | 9 +- apps/Makefile | 9 +- apps/apps_container.cpp | 60 ++---------- apps/apps_container.h | 10 +- apps/apps_container_prompt_beta.cpp | 23 +++++ apps/apps_container_prompt_none.cpp | 8 ++ apps/apps_container_prompt_update.cpp | 19 ++++ apps/global_preferences.h | 6 -- apps/on_boarding/language_controller.cpp | 10 +- apps/on_boarding/pop_up_controller.cpp | 4 - apps/on_boarding/pop_up_controller.h | 4 - apps/settings/Makefile | 4 + apps/settings/main_controller.cpp | 98 +++++-------------- apps/settings/main_controller.h | 11 +-- apps/settings/main_controller_prompt_beta.cpp | 35 +++++++ apps/settings/main_controller_prompt_none.cpp | 36 +++++++ .../main_controller_prompt_update.cpp | 40 ++++++++ scripts/platform.device.mak | 1 - scripts/targets.device.mak | 9 +- 19 files changed, 219 insertions(+), 177 deletions(-) create mode 100644 apps/apps_container_prompt_beta.cpp create mode 100644 apps/apps_container_prompt_none.cpp create mode 100644 apps/apps_container_prompt_update.cpp create mode 100644 apps/settings/main_controller_prompt_beta.cpp create mode 100644 apps/settings/main_controller_prompt_none.cpp create mode 100644 apps/settings/main_controller_prompt_update.cpp diff --git a/Makefile b/Makefile index cd809461f..a64f1decd 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,6 @@ endef .PHONY: info info: @echo "EPSILON_VERSION = $(EPSILON_VERSION)" - @echo "EPSILON_BOOT_PROMPT = $(EPSILON_BOOT_PROMPT)" @echo "EPSILON_APPS = $(EPSILON_APPS)" @echo "EPSILON_I18N = $(EPSILON_I18N)" @@ -81,13 +80,15 @@ all_objs = $(call object_for,$(all_src)) # but allows correct yet optimal incremental builds. -include $(all_objs:.o=.d) -executables = epsilon epsilon.on-boarding test +executables = epsilon epsilon.on-boarding epsilon.on-boarding.update epsilon.on-boarding.beta test #define platform generic targets -$(BUILD_DIR)/epsilon.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_default_src)) +$(BUILD_DIR)/epsilon.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_default_src) $(apps_prompt_none_src)) -$(BUILD_DIR)/epsilon.on-boarding.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_on_boarding_src)) +$(BUILD_DIR)/epsilon.on-boarding.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_on_boarding_src) $(apps_prompt_none_src)) +$(BUILD_DIR)/epsilon.on-boarding.update.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_on_boarding_src) $(apps_prompt_update_src)) +$(BUILD_DIR)/epsilon.on-boarding.beta.$(EXE): $(call object_for,$(src) $(epsilon_src) $(ion_device_dfu_relocated_src) $(apps_launch_on_boarding_src) $(apps_prompt_beta_src)) $(BUILD_DIR)/test.$(EXE): $(BUILD_DIR)/quiz/src/tests_symbols.o $(call object_for,$(src) $(ion_device_dfu_relocated_src) $(tests) $(runner_src)) diff --git a/apps/Makefile b/apps/Makefile index 1ca0ffa6c..5e83fe2d2 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -30,8 +30,11 @@ app_src += $(addprefix apps/,\ variable_box_empty_controller.cpp \ ) -apps_launch_on_boarding_src = apps/apps_container_launch_on_boarding.cpp -apps_launch_default_src = apps/apps_container_launch_default.cpp +apps_launch_on_boarding_src += apps/apps_container_launch_on_boarding.cpp +apps_launch_default_src += apps/apps_container_launch_default.cpp +apps_prompt_none_src += apps/apps_container_prompt_none.cpp +apps_prompt_beta_src += apps/apps_container_prompt_beta.cpp +apps_prompt_update_src += apps/apps_container_prompt_update.cpp snapshots_declaration = $(foreach i,$(apps),$(i)::Snapshot m_snapshot$(subst :,,$(i))Snapshot;) apps_declaration = $(foreach i,$(apps),$(i) m_$(subst :,,$(i));) @@ -92,7 +95,7 @@ epsilon_src += $(addprefix apps/, \ i18n.py \ ) -all_app_src = $(app_src) $(epsilon_src) $(apps_launch_on_boarding_src) $(apps_launch_default_src) +all_app_src = $(app_src) $(epsilon_src) $(apps_launch_on_boarding_src) $(apps_launch_default_src) $(apps_prompt_none_src) $(apps_container_prompt_update) $(apps_prompt_beta_src) $(call object_for,$(all_app_src)): $(BUILD_DIR)/apps/i18n.h $(call object_for,$(all_app_src)): $(BUILD_DIR)/python/port/genhdr/qstrdefs.generated.h diff --git a/apps/apps_container.cpp b/apps/apps_container.cpp index 86c0d06b7..adb666104 100644 --- a/apps/apps_container.cpp +++ b/apps/apps_container.cpp @@ -11,48 +11,6 @@ extern "C" { using namespace Shared; -#if EPSILON_BOOT_PROMPT == EPSILON_BETA_PROMPT - -static I18n::Message sPromptMessages[] = { - I18n::Message::BetaVersion, - I18n::Message::BetaVersionMessage1, - I18n::Message::BetaVersionMessage2, - I18n::Message::BetaVersionMessage3, - I18n::Message::BlankMessage, - I18n::Message::BetaVersionMessage4, - I18n::Message::BetaVersionMessage5, - I18n::Message::BetaVersionMessage6}; - -static KDColor sPromptColors[] = { - KDColorBlack, - KDColorBlack, - KDColorBlack, - KDColorBlack, - KDColorWhite, - KDColorBlack, - KDColorBlack, - Palette::YellowDark}; - -#elif EPSILON_BOOT_PROMPT == EPSILON_UPDATE_PROMPT - -static I18n::Message sPromptMessages[] = { - I18n::Message::UpdateAvailable, - I18n::Message::UpdateMessage1, - I18n::Message::UpdateMessage2, - I18n::Message::BlankMessage, - I18n::Message::UpdateMessage3, - I18n::Message::UpdateMessage4}; - -static KDColor sPromptColors[] = { - KDColorBlack, - KDColorBlack, - KDColorBlack, - KDColorWhite, - KDColorBlack, - Palette::YellowDark}; - -#endif - AppsContainer * AppsContainer::sharedAppsContainer() { static AppsContainerStorage appsContainerStorage; return &appsContainerStorage; @@ -65,11 +23,7 @@ AppsContainer::AppsContainer() : m_globalContext(), m_variableBoxController(), m_examPopUpController(this), -#if EPSILON_BOOT_PROMPT == EPSILON_BETA_PROMPT - m_promptController(sPromptMessages, sPromptColors, 8), -#elif EPSILON_BOOT_PROMPT == EPSILON_UPDATE_PROMPT - m_promptController(sPromptMessages, sPromptColors, 6), -#endif + m_promptController(k_promptMessages, k_promptColors, k_promptNumberOfMessages), m_batteryTimer(), m_suspendTimer(), m_backlightDimmingTimer(), @@ -137,11 +91,10 @@ VariableBoxController * AppsContainer::variableBoxController() { void AppsContainer::suspend(bool checkIfOnOffKeyReleased) { resetShiftAlphaStatus(); GlobalPreferences * globalPreferences = GlobalPreferences::sharedGlobalPreferences(); -#ifdef EPSILON_BOOT_PROMPT - if (s_activeApp->snapshot()!= onBoardingAppSnapshot() && s_activeApp->snapshot() != hardwareTestAppSnapshot() && globalPreferences->showPopUp()) { - s_activeApp->displayModalViewController(&m_promptController, 0.f, 0.f); + // Display the prompt if it has a message to display + if (promptController() != nullptr && s_activeApp->snapshot()!= onBoardingAppSnapshot() && s_activeApp->snapshot() != hardwareTestAppSnapshot() && globalPreferences->showPopUp()) { + s_activeApp->displayModalViewController(promptController(), 0.f, 0.f); } -#endif Ion::Power::suspend(checkIfOnOffKeyReleased); /* Ion::Power::suspend() completely shuts down the LCD controller. Therefore * the frame memory is lost. That's why we need to force a window redraw @@ -352,11 +305,12 @@ bool AppsContainer::updateAlphaLock() { return m_window.updateAlphaLock(); } -#ifdef EPSILON_BOOT_PROMPT OnBoarding::PopUpController * AppsContainer::promptController() { + if (k_promptNumberOfMessages == 0) { + return nullptr; + } return &m_promptController; } -#endif void AppsContainer::redrawWindow() { m_window.redraw(); diff --git a/apps/apps_container.h b/apps/apps_container.h index 78afb96ce..bd0c8fb2c 100644 --- a/apps/apps_container.h +++ b/apps/apps_container.h @@ -15,10 +15,7 @@ #include "suspend_timer.h" #include "backlight_dimming_timer.h" #include "shared/global_context.h" - -#ifdef EPSILON_BOOT_PROMPT #include "on_boarding/pop_up_controller.h" -#endif #include @@ -47,9 +44,7 @@ public: void displayExamModePopUp(bool activate); void shutdownDueToLowBattery(); void setShiftAlphaStatus(Ion::Events::ShiftAlphaStatus newStatus); -#ifdef EPSILON_BOOT_PROMPT OnBoarding::PopUpController * promptController(); -#endif void redrawWindow(); // Exam pop-up controller delegate void examDeactivatingPopUpIsDismissed() override; @@ -66,15 +61,16 @@ private: void resetShiftAlphaStatus(); bool updateAlphaLock(); + static I18n::Message k_promptMessages[]; + static KDColor k_promptColors[]; + static int k_promptNumberOfMessages; AppsWindow m_window; EmptyBatteryWindow m_emptyBatteryWindow; Shared::GlobalContext m_globalContext; MathToolbox m_mathToolbox; VariableBoxController m_variableBoxController; ExamPopUpController m_examPopUpController; -#ifdef EPSILON_BOOT_PROMPT OnBoarding::PopUpController m_promptController; -#endif BatteryTimer m_batteryTimer; SuspendTimer m_suspendTimer; BacklightDimmingTimer m_backlightDimmingTimer; diff --git a/apps/apps_container_prompt_beta.cpp b/apps/apps_container_prompt_beta.cpp new file mode 100644 index 000000000..85be074d1 --- /dev/null +++ b/apps/apps_container_prompt_beta.cpp @@ -0,0 +1,23 @@ +#include "apps_container.h" + +I18n::Message AppsContainer::k_promptMessages[] = { + I18n::Message::BetaVersion, + I18n::Message::BetaVersionMessage1, + I18n::Message::BetaVersionMessage2, + I18n::Message::BetaVersionMessage3, + I18n::Message::BlankMessage, + I18n::Message::BetaVersionMessage4, + I18n::Message::BetaVersionMessage5, + I18n::Message::BetaVersionMessage6}; + +KDColor AppsContainer::k_promptColors[] = { + KDColorBlack, + KDColorBlack, + KDColorBlack, + KDColorBlack, + KDColorWhite, + KDColorBlack, + KDColorBlack, + Palette::YellowDark}; + +int AppsContainer::k_promptNumberOfMessages = 8; diff --git a/apps/apps_container_prompt_none.cpp b/apps/apps_container_prompt_none.cpp new file mode 100644 index 000000000..65556d670 --- /dev/null +++ b/apps/apps_container_prompt_none.cpp @@ -0,0 +1,8 @@ +#include "apps_container.h" + +I18n::Message AppsContainer::k_promptMessages[] = {}; + +KDColor AppsContainer::k_promptColors[] = {}; + +int AppsContainer::k_promptNumberOfMessages = 0; + diff --git a/apps/apps_container_prompt_update.cpp b/apps/apps_container_prompt_update.cpp new file mode 100644 index 000000000..25fe11b64 --- /dev/null +++ b/apps/apps_container_prompt_update.cpp @@ -0,0 +1,19 @@ +#include "apps_container.h" + +I18n::Message AppsContainer::k_promptMessages[] = { + I18n::Message::UpdateAvailable, + I18n::Message::UpdateMessage1, + I18n::Message::UpdateMessage2, + I18n::Message::BlankMessage, + I18n::Message::UpdateMessage3, + I18n::Message::UpdateMessage4}; + +KDColor AppsContainer::k_promptColors[] = { + KDColorBlack, + KDColorBlack, + KDColorBlack, + KDColorWhite, + KDColorBlack, + Palette::YellowDark}; + +int AppsContainer::k_promptNumberOfMessages = 6; diff --git a/apps/global_preferences.h b/apps/global_preferences.h index 24ff19581..88a57109f 100644 --- a/apps/global_preferences.h +++ b/apps/global_preferences.h @@ -14,10 +14,8 @@ public: void setLanguage(I18n::Language language) { m_language = language; } ExamMode examMode() const { return m_examMode; } void setExamMode(ExamMode examMode) { m_examMode = examMode; } -#ifdef EPSILON_BOOT_PROMPT bool showPopUp() const { return m_showPopUp; } void setShowPopUp(bool showPopUp) { m_showPopUp = showPopUp; } -#endif int brightnessLevel() const { return m_brightnessLevel; } void setBrightnessLevel(int brightnessLevel); constexpr static int NumberOfBrightnessStates = 5; @@ -25,15 +23,11 @@ private: GlobalPreferences() : m_language(I18n::Language::EN), m_examMode(ExamMode::Deactivate), -#ifdef EPSILON_BOOT_PROMPT m_showPopUp(true), -#endif m_brightnessLevel(Ion::Backlight::MaxBrightness) {} I18n::Language m_language; ExamMode m_examMode; -#ifdef EPSILON_BOOT_PROMPT bool m_showPopUp; -#endif int m_brightnessLevel; }; diff --git a/apps/on_boarding/language_controller.cpp b/apps/on_boarding/language_controller.cpp index 6d2753b9e..3319b507c 100644 --- a/apps/on_boarding/language_controller.cpp +++ b/apps/on_boarding/language_controller.cpp @@ -12,11 +12,11 @@ LanguageController::LanguageController(Responder * parentResponder) : bool LanguageController::handleEvent(Ion::Events::Event event) { if (Shared::LanguageController::handleEvent(event)) { AppsContainer * appsContainer = AppsContainer::sharedAppsContainer(); -#ifdef EPSILON_BOOT_PROMPT - Container::activeApp()->displayModalViewController(appsContainer->promptController(), 0.5f, 0.5f); -#else - appsContainer->switchTo(appsContainer->appSnapshotAtIndex(0)); -#endif + if (appsContainer->promptController()) { + Container::activeApp()->displayModalViewController(appsContainer->promptController(), 0.5f, 0.5f); + } else { + appsContainer->switchTo(appsContainer->appSnapshotAtIndex(0)); + } return true; } if (event == Ion::Events::Back) { diff --git a/apps/on_boarding/pop_up_controller.cpp b/apps/on_boarding/pop_up_controller.cpp index 61cf77906..4a057a2b4 100644 --- a/apps/on_boarding/pop_up_controller.cpp +++ b/apps/on_boarding/pop_up_controller.cpp @@ -4,8 +4,6 @@ namespace OnBoarding { -#ifdef EPSILON_BOOT_PROMPT - PopUpController::MessageViewWithSkip::MessageViewWithSkip(I18n::Message * messages, KDColor * colors, uint8_t numberOfMessages) : MessageView(messages, colors, numberOfMessages), m_skipView(KDFont::SmallFont, I18n::Message::Skip, 1.0f, 0.5f), @@ -64,6 +62,4 @@ bool PopUpController::handleEvent(Ion::Events::Event event) { return false; } -#endif - } diff --git a/apps/on_boarding/pop_up_controller.h b/apps/on_boarding/pop_up_controller.h index 38eac9a73..9f1b3d78b 100644 --- a/apps/on_boarding/pop_up_controller.h +++ b/apps/on_boarding/pop_up_controller.h @@ -8,8 +8,6 @@ namespace OnBoarding { -#ifdef EPSILON_BOOT_PROMPT - class PopUpController : public ViewController { public: PopUpController(I18n::Message * messages, KDColor * colors, uint8_t numberOfMessages); @@ -33,8 +31,6 @@ private: MessageViewWithSkip m_messageViewWithSkip; }; -#endif - } #endif diff --git a/apps/settings/Makefile b/apps/settings/Makefile index 7061f6951..9d1ab8a62 100644 --- a/apps/settings/Makefile +++ b/apps/settings/Makefile @@ -14,6 +14,10 @@ app_src += $(addprefix apps/settings/,\ sub_menu/preferences_controller.cpp \ ) +apps_prompt_none_src += apps/settings/main_controller_prompt_none.cpp +apps_prompt_beta_src += apps/settings/main_controller_prompt_beta.cpp +apps_prompt_update_src += apps/settings/main_controller_prompt_update.cpp + i18n_files += $(addprefix apps/settings/,\ base.de.i18n\ base.en.i18n\ diff --git a/apps/settings/main_controller.cpp b/apps/settings/main_controller.cpp index fd664d74d..42c68fbfd 100644 --- a/apps/settings/main_controller.cpp +++ b/apps/settings/main_controller.cpp @@ -7,45 +7,11 @@ using namespace Poincare; namespace Settings { -const SettingsMessageTree angleChildren[2] = {SettingsMessageTree(I18n::Message::Degres), SettingsMessageTree(I18n::Message::Radian)}; -const SettingsMessageTree editionModeChildren[2] = {SettingsMessageTree(I18n::Message::Edition2D), SettingsMessageTree(I18n::Message::EditionLinear)}; -const SettingsMessageTree floatDisplayModeChildren[3] = {SettingsMessageTree(I18n::Message::Decimal), SettingsMessageTree(I18n::Message::Scientific), SettingsMessageTree(I18n::Message::SignificantFigures)}; -const SettingsMessageTree complexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)}; -const SettingsMessageTree examChildren[1] = {SettingsMessageTree(I18n::Message::ActivateExamMode)}; -const SettingsMessageTree aboutChildren[3] = {SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId)}; - -#ifdef EPSILON_BOOT_PROMPT -const SettingsMessageTree menu[9] = -#else -const SettingsMessageTree menu[8] = -#endif - {SettingsMessageTree(I18n::Message::AngleUnit, angleChildren, 2), - SettingsMessageTree(I18n::Message::DisplayMode, floatDisplayModeChildren, 3), - SettingsMessageTree(I18n::Message::EditionMode, editionModeChildren, 2), - SettingsMessageTree(I18n::Message::ComplexFormat, complexFormatChildren, 3), - SettingsMessageTree(I18n::Message::Brightness), - SettingsMessageTree(I18n::Message::Language), - SettingsMessageTree(I18n::Message::ExamMode, examChildren, 1), -#if EPSILON_BOOT_PROMPT == EPSILON_BETA_PROMPT - SettingsMessageTree(I18n::Message::BetaPopUp), -#elif EPSILON_BOOT_PROMPT == EPSILON_UPDATE_PROMPT - SettingsMessageTree(I18n::Message::UpdatePopUp), -#endif - SettingsMessageTree(I18n::Message::About, aboutChildren, 3)}; -#ifdef EPSILON_BOOT_PROMPT -const SettingsMessageTree model = SettingsMessageTree(I18n::Message::SettingsApp, menu, 9); -#else -const SettingsMessageTree model = SettingsMessageTree(I18n::Message::SettingsApp, menu, 8); -#endif - MainController::MainController(Responder * parentResponder, InputEventHandlerDelegate * inputEventHandlerDelegate) : ViewController(parentResponder), -#ifdef EPSILON_BOOT_PROMPT - m_popUpCell(I18n::Message::Default, KDFont::LargeFont), -#endif m_brightnessCell(I18n::Message::Default, KDFont::LargeFont), + m_popUpCell(I18n::Message::Default, KDFont::LargeFont), m_selectableTableView(this), - m_messageTreeModel((MessageTree *)&model), m_preferencesController(this), m_displayModeController(this, inputEventHandlerDelegate), m_languageController(this, 13), @@ -70,13 +36,8 @@ void MainController::didBecomeFirstResponder() { bool MainController::handleEvent(Ion::Events::Event event) { GlobalPreferences * globalPreferences = GlobalPreferences::sharedGlobalPreferences(); - if (m_messageTreeModel->children(selectedRow())->numberOfChildren() == 0) { -#if EPSILON_BOOT_PROMPT == EPSILON_BETA_PROMPT - if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::BetaPopUp) { -#elif EPSILON_BOOT_PROMPT == EPSILON_UPDATE_PROMPT - if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::UpdatePopUp) { -#endif -#ifdef EPSILON_BOOT_PROMPT + if (model()->children(selectedRow())->numberOfChildren() == 0) { + if (model()->children(selectedRow())->label() == promptMessage()) { if (event == Ion::Events::OK || event == Ion::Events::EXE) { globalPreferences->setShowPopUp(!globalPreferences->showPopUp()); m_selectableTableView.reloadCellAtLocation(m_selectableTableView.selectedColumn(), m_selectableTableView.selectedRow()); @@ -84,8 +45,7 @@ bool MainController::handleEvent(Ion::Events::Event event) { } return false; } -#endif - if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::Brightness) { + if (model()->children(selectedRow())->label() == I18n::Message::Brightness) { if (event == Ion::Events::Right || event == Ion::Events::Left || event == Ion::Events::Plus || event == Ion::Events::Minus) { int delta = Ion::Backlight::MaxBrightness/GlobalPreferences::NumberOfBrightnessStates; int direction = (event == Ion::Events::Right || event == Ion::Events::Plus) ? delta : -delta; @@ -95,7 +55,7 @@ bool MainController::handleEvent(Ion::Events::Event event) { } return false; } - if (m_messageTreeModel->children(selectedRow())->label() == I18n::Message::Language) { + if (model()->children(selectedRow())->label() == I18n::Message::Language) { if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) { stackController()->push(&m_languageController); return true; @@ -105,27 +65,19 @@ bool MainController::handleEvent(Ion::Events::Event event) { } if (event == Ion::Events::OK || event == Ion::Events::EXE || event == Ion::Events::Right) { GenericSubController * subController = nullptr; - switch (selectedRow()) { - case 1: - subController = &m_displayModeController; - break; - case 4: - case 5: - assert(false); - case 6: - subController = &m_examModeController; - break; -#ifdef EPSILON_BOOT_PROMPT - case 8: -#else - case 7: -#endif - subController = &m_aboutController; - break; - default: - subController = &m_preferencesController; + int rowIndex = selectedRow(); + if (rowIndex == 1) { + subController = &m_displayModeController; + } else if (rowIndex == 4 || rowIndex == 5) { + assert(false); + } else if (rowIndex == 6) { + subController = &m_examModeController; + } else if (rowIndex == 7 + hasPrompt()) { + subController = &m_aboutController; + } else { + subController = &m_preferencesController; } - subController->setMessageTreeModel(m_messageTreeModel->children(selectedRow())); + subController->setMessageTreeModel(model()->children(selectedRow())); StackViewController * stack = stackController(); stack->push(subController); return true; @@ -134,7 +86,7 @@ bool MainController::handleEvent(Ion::Events::Event event) { } int MainController::numberOfRows() { - return m_messageTreeModel->numberOfChildren(); + return model()->numberOfChildren(); }; KDCoordinate MainController::rowHeight(int j) { @@ -156,11 +108,9 @@ HighlightCell * MainController::reusableCell(int index, int type) { return &m_cells[index]; } assert(index == 0); -#ifdef EPSILON_BOOT_PROMPT if (type == 2) { return &m_popUpCell; } -#endif assert(type == 1); return &m_brightnessCell; } @@ -176,11 +126,9 @@ int MainController::typeAtLocation(int i, int j) { if (j == 4) { return 1; } -#ifdef EPSILON_BOOT_PROMPT - if (j == 7) { + if (hasPrompt() && j == 7) { return 2; } -#endif return 0; } @@ -188,7 +136,7 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { GlobalPreferences * globalPreferences = GlobalPreferences::sharedGlobalPreferences(); Preferences * preferences = Preferences::sharedPreferences(); MessageTableCell * myCell = (MessageTableCell *)cell; - myCell->setMessage(m_messageTreeModel->children(index)->label()); + myCell->setMessage(model()->children(index)->label()); if (index == 4) { MessageTableCellWithGauge * myGaugeCell = (MessageTableCellWithGauge *)cell; GaugeView * myGauge = (GaugeView *)myGaugeCell->accessoryView(); @@ -200,14 +148,12 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { static_cast(cell)->setSubtitle(I18n::LanguageNames[index]); return; } -#ifdef EPSILON_BOOT_PROMPT - if (index == 7) { + if (hasPrompt() && index == 7) { MessageTableCellWithSwitch * mySwitchCell = (MessageTableCellWithSwitch *)cell; SwitchView * mySwitch = (SwitchView *)mySwitchCell->accessoryView(); mySwitch->setState(globalPreferences->showPopUp()); return; } -#endif MessageTableCellWithChevronAndMessage * myTextCell = (MessageTableCellWithChevronAndMessage *)cell; int childIndex = -1; switch (index) { @@ -224,7 +170,7 @@ void MainController::willDisplayCellForIndex(HighlightCell * cell, int index) { childIndex = (int)preferences->complexFormat(); break; } - I18n::Message message = childIndex >= 0 ? m_messageTreeModel->children(index)->children(childIndex)->label() : I18n::Message::Default; + I18n::Message message = childIndex >= 0 ? model()->children(index)->children(childIndex)->label() : I18n::Message::Default; myTextCell->setSubtitle(message); } diff --git a/apps/settings/main_controller.h b/apps/settings/main_controller.h index 6098c5848..7d9d68d71 100644 --- a/apps/settings/main_controller.h +++ b/apps/settings/main_controller.h @@ -27,18 +27,15 @@ public: void willDisplayCellForIndex(HighlightCell * cell, int index) override; void viewWillAppear() override; private: + static const SettingsMessageTree * model(); StackViewController * stackController() const; -#ifdef EPSILON_BOOT_PROMPT - constexpr static int k_totalNumberOfCell = 9; - MessageTableCellWithSwitch m_popUpCell; -#else - constexpr static int k_totalNumberOfCell = 8; -#endif + I18n::Message promptMessage() const; + bool hasPrompt() const { return promptMessage() != I18n::Message::Default; } constexpr static int k_numberOfSimpleChevronCells = 7; MessageTableCellWithChevronAndMessage m_cells[k_numberOfSimpleChevronCells]; MessageTableCellWithGauge m_brightnessCell; + MessageTableCellWithSwitch m_popUpCell; SelectableTableView m_selectableTableView; - MessageTree * m_messageTreeModel; PreferencesController m_preferencesController; DisplayModeController m_displayModeController; LanguageController m_languageController; diff --git a/apps/settings/main_controller_prompt_beta.cpp b/apps/settings/main_controller_prompt_beta.cpp new file mode 100644 index 000000000..7cfed84e9 --- /dev/null +++ b/apps/settings/main_controller_prompt_beta.cpp @@ -0,0 +1,35 @@ +#include "main_controller.h" +#include + +namespace Settings { + +constexpr SettingsMessageTree s_modelAngleChildren[2] = {SettingsMessageTree(I18n::Message::Degres), SettingsMessageTree(I18n::Message::Radian)}; +constexpr SettingsMessageTree s_modelEditionModeChildren[2] = {SettingsMessageTree(I18n::Message::Edition2D), SettingsMessageTree(I18n::Message::EditionLinear)}; +constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[3] = {SettingsMessageTree(I18n::Message::Decimal), SettingsMessageTree(I18n::Message::Scientific), SettingsMessageTree(I18n::Message::SignificantFigures)}; +constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)}; +constexpr SettingsMessageTree s_modelExamChildren[1] = {SettingsMessageTree(I18n::Message::ActivateExamMode)}; +constexpr SettingsMessageTree s_modelAboutChildren[3] = {SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId)}; + +constexpr SettingsMessageTree s_modelMenu[] = + {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 2), + SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren, 3), + SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren, 2), + SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren, 3), + SettingsMessageTree(I18n::Message::Brightness), + SettingsMessageTree(I18n::Message::Language), + SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 1), + SettingsMessageTree(I18n::Message::BetaPopUp), + SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 3)}; + +constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 9); + + +I18n::Message MainController::promptMessage() const { + return I18n::Message::BetaPopUp; +} + +const SettingsMessageTree * MainController::model() { + return &s_model; +} + +} diff --git a/apps/settings/main_controller_prompt_none.cpp b/apps/settings/main_controller_prompt_none.cpp new file mode 100644 index 000000000..21a6d8c7d --- /dev/null +++ b/apps/settings/main_controller_prompt_none.cpp @@ -0,0 +1,36 @@ +#include "main_controller.h" +#include + +namespace Settings { + +// TODO: factorize most parts of the final models with main_controller_prompt_beta and main_controller_prompt_update +constexpr SettingsMessageTree s_modelAngleChildren[2] = {SettingsMessageTree(I18n::Message::Degres), SettingsMessageTree(I18n::Message::Radian)}; +constexpr SettingsMessageTree s_modelEditionModeChildren[2] = {SettingsMessageTree(I18n::Message::Edition2D), SettingsMessageTree(I18n::Message::EditionLinear)}; +constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[3] = {SettingsMessageTree(I18n::Message::Decimal), SettingsMessageTree(I18n::Message::Scientific), SettingsMessageTree(I18n::Message::SignificantFigures)}; +constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)}; +constexpr SettingsMessageTree s_modelExamChildren[1] = {SettingsMessageTree(I18n::Message::ActivateExamMode)}; +constexpr SettingsMessageTree s_modelAboutChildren[3] = {SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId)}; + +constexpr SettingsMessageTree s_modelMenu[] = + {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 2), + SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren, 3), + SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren, 2), + SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren, 3), + SettingsMessageTree(I18n::Message::Brightness), + SettingsMessageTree(I18n::Message::Language), + SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 1), + SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 3)}; + +constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 8); + + +I18n::Message MainController::promptMessage() const { + return I18n::Message::Default; +} + +const SettingsMessageTree * MainController::model() { + return &s_model; +} + +} + diff --git a/apps/settings/main_controller_prompt_update.cpp b/apps/settings/main_controller_prompt_update.cpp new file mode 100644 index 000000000..a8f25a680 --- /dev/null +++ b/apps/settings/main_controller_prompt_update.cpp @@ -0,0 +1,40 @@ +#include "main_controller.h" +#include + +namespace Settings { +#include "main_controller.h" +#include + +namespace Settings { + +constexpr SettingsMessageTree s_modelAngleChildren[2] = {SettingsMessageTree(I18n::Message::Degres), SettingsMessageTree(I18n::Message::Radian)}; +constexpr SettingsMessageTree s_modelEditionModeChildren[2] = {SettingsMessageTree(I18n::Message::Edition2D), SettingsMessageTree(I18n::Message::EditionLinear)}; +constexpr SettingsMessageTree s_modelFloatDisplayModeChildren[3] = {SettingsMessageTree(I18n::Message::Decimal), SettingsMessageTree(I18n::Message::Scientific), SettingsMessageTree(I18n::Message::SignificantFigures)}; +constexpr SettingsMessageTree s_modelComplexFormatChildren[3] = {SettingsMessageTree(I18n::Message::Real), SettingsMessageTree(I18n::Message::Cartesian), SettingsMessageTree(I18n::Message::Polar)}; +constexpr SettingsMessageTree s_modelExamChildren[1] = {SettingsMessageTree(I18n::Message::ActivateExamMode)}; +constexpr SettingsMessageTree s_modelAboutChildren[3] = {SettingsMessageTree(I18n::Message::SoftwareVersion), SettingsMessageTree(I18n::Message::SerialNumber), SettingsMessageTree(I18n::Message::FccId)}; + +constexpr SettingsMessageTree s_modelMenu[] = + {SettingsMessageTree(I18n::Message::AngleUnit, s_modelAngleChildren, 2), + SettingsMessageTree(I18n::Message::DisplayMode, s_modelFloatDisplayModeChildren, 3), + SettingsMessageTree(I18n::Message::EditionMode, s_modelEditionModeChildren, 2), + SettingsMessageTree(I18n::Message::ComplexFormat, s_modelComplexFormatChildren, 3), + SettingsMessageTree(I18n::Message::Brightness), + SettingsMessageTree(I18n::Message::Language), + SettingsMessageTree(I18n::Message::ExamMode, s_modelExamChildren, 1), + SettingsMessageTree(I18n::Message::UpdatePopUp), + SettingsMessageTree(I18n::Message::About, s_modelAboutChildren, 3)}; + +constexpr SettingsMessageTree s_model = SettingsMessageTree(I18n::Message::SettingsApp, s_modelMenu, 9); + + +I18n::Message MainController::promptMessage() const { + return I18n::Message::UpdatePopUp; + +} + +const SettingsMessageTree * MainController::model() { + return &s_model; +} + +} diff --git a/scripts/platform.device.mak b/scripts/platform.device.mak index f49212340..69e892df5 100644 --- a/scripts/platform.device.mak +++ b/scripts/platform.device.mak @@ -1,7 +1,6 @@ MODEL ?= n0110 USE_LIBA = 1 EXE = elf -EPSILON_BOOT_PROMPT = update BUILD_DIR = build/$(PLATFORM)/$(MODEL) diff --git a/scripts/targets.device.mak b/scripts/targets.device.mak index 8d1e85cd1..06ce84b9f 100644 --- a/scripts/targets.device.mak +++ b/scripts/targets.device.mak @@ -71,7 +71,6 @@ $(BUILD_DIR)/bench.ram.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/shared/ram.ld $(BUILD_DIR)/bench.flash.$(EXE): LDSCRIPT = ion/src/$(PLATFORM)/$(MODEL)/internal_flash.ld $(BUILD_DIR)/bench.%.$(EXE): $(call object_for,$(src) $(bench_src) $(ion_device_dfu_xip_src)) -ifeq ($(EPSILON_BOOT_PROMPT),update) .PHONY: %.two_binaries %.two_binaries: %.elf @echo "Building an internal and an external binary for $<" @@ -80,10 +79,6 @@ ifeq ($(EPSILON_BOOT_PROMPT),update) @echo "Padding $(basename $<).external.bin and $(basename $<).internal.bin" $(Q) printf "\xFF\xFF\xFF\xFF" >> $(basename $<).external.bin $(Q) printf "\xFF\xFF\xFF\xFF" >> $(basename $<).internal.bin -else -%_two_binaries: - @echo "Error: two_binaries requires EPSILON_BOOT_PROMPT=update" -endif .PHONY: binpack binpack: @@ -97,8 +92,8 @@ binpack: make -j8 $(BUILD_DIR)/bench.ram.bin cp $(BUILD_DIR)/bench.ram.bin $(BUILD_DIR)/bench.flash.bin build/binpack make clean - make -j8 EPSILON_BOOT_PROMPT=update $(BUILD_DIR)/epsilon.on-boarding.two_binaries - cp $(BUILD_DIR)/epsilon.on-boarding.internal.bin $(BUILD_DIR)/epsilon.on-boarding.external.bin build/binpack + make -j8 $(BUILD_DIR)/epsilon.on-boarding.update.two_binaries + cp $(BUILD_DIR)/epsilon.on-boarding.update.internal.bin $(BUILD_DIR)/epsilon.on-boarding.update.external.bin build/binpack make clean cd build && for binary in flasher.light.bin bench.flash.bin bench.ram.bin epsilon.on-boarding.internal.bin epsilon.on-boarding.external.bin; do shasum -a 256 -b binpack/$${binary} > binpack/$${binary}.sha256;done cd build && tar cvfz binpack-`git rev-parse HEAD | head -c 7`.tgz binpack