From d72ca852a67617a458766a01c8fbf42e2046a3f1 Mon Sep 17 00:00:00 2001 From: Heath123 Date: Fri, 5 May 2023 12:49:15 +0100 Subject: [PATCH] Cleanup stage 1 --- apps/graph/graph/graph_view.h | 6 ++++++ apps/home/controller.h | 11 ++++++++++- apps/settings/sub_menu/about_controller.cpp | 2 -- apps/shared/continuous_function_cache.cpp | 6 +++++- apps/shared/curve_view.h | 2 +- apps/shared/store_controller.h | 5 +++++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/apps/graph/graph/graph_view.h b/apps/graph/graph/graph_view.h index 552771dce..1b4b2b4b6 100644 --- a/apps/graph/graph/graph_view.h +++ b/apps/graph/graph/graph_view.h @@ -18,7 +18,13 @@ public: * 10.0938275501223 which are hopefully rare enough. * TODO: The drawCurve algorithm should use the derivative function to know * how fast the function moves... */ + #ifndef _PRIZM + static constexpr float k_graphStepDenominator = 10.0938275501223f; + #else + // This value rounded down has to be a factor of the horizontal resolution / 2 + // On the Casio calculator the resolution is 396 pixels, so 11 is close but works static constexpr float k_graphStepDenominator = 11.0938275501223f; + #endif GraphView(Shared::InteractiveCurveViewRange * graphRange, Shared::CurveViewCursor * cursor, Shared::BannerView * bannerView, Shared::CursorView * cursorView); diff --git a/apps/home/controller.h b/apps/home/controller.h index 39e394d26..cdb6c4de9 100644 --- a/apps/home/controller.h +++ b/apps/home/controller.h @@ -47,10 +47,19 @@ private: static constexpr KDCoordinate k_sideMargin = 4; static constexpr KDCoordinate k_bottomMargin = 14; static constexpr KDCoordinate k_indicatorMargin = 61; + + #ifndef _PRIZM + static constexpr int k_numberOfColumns = 3; + static constexpr int k_cellHeight = 104; + static constexpr int k_cellWidth = 104; + #else + // A different screen resolution so different dimensions static constexpr int k_numberOfColumns = 4; - static constexpr int k_maxNumberOfCells = 16; static constexpr int k_cellHeight = 96; static constexpr int k_cellWidth = 97; + #endif + + static constexpr int k_maxNumberOfCells = 16; ContentView m_view; AppCell m_cells[k_maxNumberOfCells]; App * m_app; diff --git a/apps/settings/sub_menu/about_controller.cpp b/apps/settings/sub_menu/about_controller.cpp index e48c63c0f..dcae3211a 100644 --- a/apps/settings/sub_menu/about_controller.cpp +++ b/apps/settings/sub_menu/about_controller.cpp @@ -89,8 +89,6 @@ bool AboutController::handleEvent(Ion::Events::Event event) { char memUseBuffer[15]; if (strchr(myCell->accessoryText(), '%') == NULL) { - // int test = Poincare::Integer((int) 1).serialize(memUseBuffer, 4); - int len = Poincare::Integer((int)((float)(Ion::Storage::k_storageSize - Ion::Storage::sharedStorage()->availableSize()) / (float)(Ion::Storage::k_storageSize) * 100.0f)).serialize(memUseBuffer, 4); memUseBuffer[len] = '%'; memUseBuffer[len+1] = '\0'; diff --git a/apps/shared/continuous_function_cache.cpp b/apps/shared/continuous_function_cache.cpp index c436572ab..a40ff304f 100644 --- a/apps/shared/continuous_function_cache.cpp +++ b/apps/shared/continuous_function_cache.cpp @@ -65,7 +65,11 @@ void ContinuousFunctionCache::ComputeNonCartesianSteps(float * tStep, float * tC const int numberOfWholeSteps = static_cast(Graph::GraphView::k_graphStepDenominator); static_assert(numberOfCacheablePoints % numberOfWholeSteps == 0, "numberOfCacheablePoints should be a multiple of numberOfWholeSteps for optimal caching"); const int multiple = numberOfCacheablePoints / numberOfWholeSteps; - // static_assert(multiple && !(multiple & (multiple - 1)), "multiple should be a power of 2 for optimal caching"); + // Ignore this on Casio calculators for now, as the screen resolution breaks this + // TODO: fix this. if it's possible + #ifndef _PRIZM + static_assert(multiple && !(multiple & (multiple - 1)), "multiple should be a power of 2 for optimal caching"); + #endif /* Define cacheStep such that every whole graph steps are equally divided * For instance, with : * graphStepDenominator = 10.1 diff --git a/apps/shared/curve_view.h b/apps/shared/curve_view.h index 0d1bc193c..91e73c5b3 100644 --- a/apps/shared/curve_view.h +++ b/apps/shared/curve_view.h @@ -142,7 +142,7 @@ private: * maxNumberOfRecursion in reached. */ void joinDots(KDContext * ctx, KDRect rect, EvaluateXYForFloatParameter xyFloatEvaluation, void * model, void * context, bool drawStraightLinesEarly, float t, float x, float y, float s, float u, float v, KDColor color, bool thick, int maxNumberOfRecursion, EvaluateXYForDoubleParameter xyDoubleEvaluation = nullptr) const; /* Join two dots with a straight line. */ - void straightJoinDots(KDContext * ctx, KDRect rect, float pxf, float pyf, float puf, float pvf, KDColor color, bool thick) const; + void straightJoinDots(KDContext * ctx, KDRect rect, float pxf, float pyf, float puf, float pvf, KDColor color, bool thick) const; /* Stamp centered around (pxf, pyf). If pxf and pyf are not round number, the * function shifts the stamp (by blending adjacent pixel colors) to draw with * anti alising. */ diff --git a/apps/shared/store_controller.h b/apps/shared/store_controller.h index b3108f81b..21c40e230 100644 --- a/apps/shared/store_controller.h +++ b/apps/shared/store_controller.h @@ -49,7 +49,12 @@ protected: static constexpr KDCoordinate k_cellWidth = Poincare::PrintFloat::glyphLengthForFloatWithPrecision(Poincare::Preferences::LargeNumberOfSignificantDigits) * 7 + 2*Metric::CellMargin + Metric::TableSeparatorThickness; // KDFont::SmallFont->glyphSize().width() = 7 constexpr static int k_maxNumberOfEditableCells = (Ion::Display::Width/k_cellWidth+2) * ((Ion::Display::Height - Metric::TitleBarHeight - Metric::TabHeight)/k_cellHeight+2); + #ifndef _PRIZM + constexpr static int k_numberOfTitleCells = 4; + #else + // This is different here due to the changed screen resolution constexpr static int k_numberOfTitleCells = 5; + #endif static constexpr int k_titleCellType = 0; static constexpr int k_editableCellType = 1;