From e399472577d9ed28d64e797040abb1637e231355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleks=20ANDR=C3=89?= Date: Sun, 5 Apr 2020 09:07:10 +0200 Subject: [PATCH 01/16] Anglicismes --- apps/probability/base.fr.i18n | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/probability/base.fr.i18n b/apps/probability/base.fr.i18n index 056fa00f6..95da17e67 100644 --- a/apps/probability/base.fr.i18n +++ b/apps/probability/base.fr.i18n @@ -10,13 +10,13 @@ UniformDistribution = "Loi uniforme" ExponentialDistribution = "Loi exponentielle" GeometricDistribution = "Loi géométrique" PoissonDistribution = "Loi de Poisson" -ChiSquaredDistribution = "Loi du chi2" +ChiSquaredDistribution = "Loi du Khi-2" StudentDistribution = "Loi de Student" FisherDistribution = "Loi de Fisher" ChooseParameters = "Choisir les paramètres" RepetitionNumber = "n : Nombre de répétitions" SuccessProbability = "p : Probabilité de succès" -IntervalDefinition = "[a,b] : Intervalle" +IntervalDefinition = "[a;b] : Intervalle" LambdaExponentialDefinition = "λ : Paramètre" MeanDefinition = "μ : Espérance ou moyenne" DeviationDefinition = "σ : Écart type" From 73f34f8f3de2815b9dcd278361a6578c9bfa3dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleks=20ANDR=C3=89?= Date: Mon, 6 Apr 2020 08:21:07 +0200 Subject: [PATCH 02/16] Relecture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit – zéro → racine. Il s’agit de la terminologie du programme de [1re spécialité](https://cache.media.education.gouv.fr/file/SP1-MEN-22-1-2019/16/8/spe632_annexe_1063168.pdf) – homogénéisation avec autres applications --- apps/graph/base.fr.i18n | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/graph/base.fr.i18n b/apps/graph/base.fr.i18n index d95a5ae63..dffa6585f 100644 --- a/apps/graph/base.fr.i18n +++ b/apps/graph/base.fr.i18n @@ -4,7 +4,7 @@ FunctionTab = "Fonctions" AddFunction = "Ajouter une fonction" DeleteFunction = "Supprimer la fonction" CurveType = "Type de courbe" -CartesianType = "Cartésien " +CartesianType = "Cartésienne " PolarType = "Polaire " ParametricType = "Paramétrique " IntervalT = "Intervalle t" @@ -16,18 +16,18 @@ NoFunction = "Aucune fonction" NoActivatedFunction = "Aucune fonction activée" PlotOptions = "Options de la courbe" Compute = "Calculer" -Zeros = "Zéros" +Zeros = "Racines" Tangent = "Tangente" Intersection = "Intersection" Preimage = "Antécédent" -SelectLowerBound = "Sélectionner la borne inférieure" -SelectUpperBound = "Sélectionner la borne supérieure" +SelectLowerBound = "Sélectionner la borne inférieure " +SelectUpperBound = "Sélectionner la borne supérieure " NoMaximumFound = "Aucun maximum trouvé" NoMinimumFound = "Aucun minimum trouvé" -NoZeroFound = "Aucun zéro trouvé" +NoZeroFound = "Aucune racine trouvée" NoIntersectionFound = "Aucune intersection trouvée" NoPreimageFound = "Aucun antécédent trouvé" DerivativeFunctionColumn = "Colonne de la fonction dérivée" HideDerivativeColumn = "Masquer la fonction dérivée" -AllowedCharactersAZaz09 = "Caractères autorisés : A-Z, a-z, 0-9, _" +AllowedCharactersAZaz09 = "Caractères autorisés : A..Z, a..z, 0..9, _" ReservedName = "Nom réservé" From 1fd216c97e04130ec6d6a4454171e64ace988b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleks=20ANDR=C3=89?= Date: Tue, 7 Apr 2020 12:09:14 +0200 Subject: [PATCH 03/16] Margins, message --- apps/graph/base.pt.i18n | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/graph/base.pt.i18n b/apps/graph/base.pt.i18n index 49ec2be81..449b4da90 100644 --- a/apps/graph/base.pt.i18n +++ b/apps/graph/base.pt.i18n @@ -20,8 +20,8 @@ Zeros = "Raízes" Tangent = "Tangente" Intersection = "Intersecção" Preimage = "Imagem inversa" -SelectLowerBound = "Selecionar limite superior" -SelectUpperBound = "Selecionar limite inferior" +SelectLowerBound = "Selecionar limite superior " +SelectUpperBound = "Selecionar limite inferior " NoMaximumFound = "Nenhum máximo encontrado" NoMinimumFound = "Nenhum mínimo encontrado" NoZeroFound = "Nenhuma raiz encontrada" @@ -29,5 +29,5 @@ NoIntersectionFound = "Nenhuma intersecção encontrada" NoPreimageFound = "Nenhuma imagem inversa encontrada" DerivativeFunctionColumn = "Coluna da função derivada" HideDerivativeColumn = "Esconder função derivada" -AllowedCharactersAZaz09 = "Caracteres permitidos : A-Z, a-z, 0-9, _" +AllowedCharactersAZaz09 = "Caracteres permitidos : A..Z, a..z, 0..9, _" ReservedName = "Nome reservado" From 53e15787cdc05aa367e9085373e5a735e9d4b952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleks=20ANDR=C3=89?= Date: Tue, 7 Apr 2020 12:08:46 +0200 Subject: [PATCH 04/16] Margins, message --- apps/graph/base.es.i18n | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/graph/base.es.i18n b/apps/graph/base.es.i18n index c2200311d..967511092 100644 --- a/apps/graph/base.es.i18n +++ b/apps/graph/base.es.i18n @@ -20,8 +20,8 @@ Zeros = "Raíces" Tangent = "Tangente" Intersection = "Intersección" Preimage = "Imagen inversa" -SelectLowerBound = "Seleccionar el límite inferior" -SelectUpperBound = "Seleccionar el límite superior" +SelectLowerBound = "Seleccionar el límite inferior " +SelectUpperBound = "Seleccionar el límite superior " NoMaximumFound = "Níngun máximo encontrado" NoMinimumFound = "Níngun mínimo encontrado" NoZeroFound = "Ninguna raíz encontrada" @@ -29,5 +29,5 @@ NoIntersectionFound = "Ninguna intersección encontrada" NoPreimageFound = "Ninguna imagen inversa encontrada" DerivativeFunctionColumn = "Columna de la derivada" HideDerivativeColumn = "Ocultar la derivada" -AllowedCharactersAZaz09 = "Caracteres permitidos : A-Z, a-z, 0-9, _" +AllowedCharactersAZaz09 = "Caracteres permitidos : A..Z, a..z, 0..9, _" ReservedName = "Nombre reservado" From b30eb20ac239296b810425c1d40f1a289b8711fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleks=20ANDR=C3=89?= Date: Tue, 7 Apr 2020 12:08:15 +0200 Subject: [PATCH 05/16] Margins, message --- apps/graph/base.en.i18n | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/graph/base.en.i18n b/apps/graph/base.en.i18n index c65a3370e..347425517 100644 --- a/apps/graph/base.en.i18n +++ b/apps/graph/base.en.i18n @@ -20,8 +20,8 @@ Zeros = "Zeros" Tangent = "Tangent" Intersection = "Intersection" Preimage = "Inverse image" -SelectLowerBound = "Select lower bound" -SelectUpperBound = "Select upper bound" +SelectLowerBound = "Select lower bound " +SelectUpperBound = "Select upper bound " NoMaximumFound = "No maximum found" NoMinimumFound = "No minimum found" NoZeroFound = "No zero found" @@ -29,5 +29,5 @@ NoIntersectionFound = "No intersection found" NoPreimageFound = "No inverse image found" DerivativeFunctionColumn = "Derivative function column" HideDerivativeColumn = "Hide the derivative function" -AllowedCharactersAZaz09 = "Allowed characters: A-Z, a-z, 0-9, _" +AllowedCharactersAZaz09 = "Allowed characters: A.Z, a..z, 0..9, _" ReservedName = "Reserved name" From ee56f02f2b6b45b5780eac7c2bb8c79d54123a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleks=20ANDR=C3=89?= Date: Tue, 7 Apr 2020 12:07:48 +0200 Subject: [PATCH 06/16] Margin, messages --- apps/graph/base.de.i18n | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/graph/base.de.i18n b/apps/graph/base.de.i18n index 3eed42db5..c816e3d06 100644 --- a/apps/graph/base.de.i18n +++ b/apps/graph/base.de.i18n @@ -20,8 +20,8 @@ Zeros = "Nullstellen" Tangent = "Tangente" Intersection = "Schnittmenge" Preimage = "Urbild" -SelectLowerBound = "Untere Integrationsgrenze" -SelectUpperBound = "Obere Integrationsgrenze" +SelectLowerBound = "Untere Integrationsgrenze " +SelectUpperBound = "Obere Integrationsgrenze " NoMaximumFound = "Kein Maximalwert gefunden" NoMinimumFound = "Kein Mindestwert gefunden" NoZeroFound = "Keine Nullstelle gefunden" @@ -29,5 +29,5 @@ NoIntersectionFound = "Kein Schnittpunkt gefunden" NoPreimageFound = "Kein Urbild gefunden" DerivativeFunctionColumn = "Spalte der Ableitungsfunktion" HideDerivativeColumn = "Ableitungsfunktion ausblenden" -AllowedCharactersAZaz09 = "Erlaubte Zeichen: A-Z, a-z, 0-9, _" +AllowedCharactersAZaz09 = "Erlaubte Zeichen: A..Z, a..z, 0..9, _" ReservedName = "Reserviertes Wort" From c36323167397e12d8dcac3a65516680e9ff261c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Tue, 7 Apr 2020 12:06:01 +0200 Subject: [PATCH 07/16] [build] --silent option in rule_for_arch_executable prevent from running 'make V=1' and getting the expected output --- build/helpers.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/helpers.mk b/build/helpers.mk index ab9934192..f44d56a26 100644 --- a/build/helpers.mk +++ b/build/helpers.mk @@ -51,7 +51,7 @@ define rule_for_arch_executable .PRECIOUS: $$(BUILD_DIR)/$(1)/%.$$(EXE) $$(BUILD_DIR)/$(1)/%.$$(EXE): force_remake $(Q) echo "MAKE ARCH=$(1)" - $(Q) $$(MAKE) ARCH=$(1) --silent $$*.$$(EXE) + $(Q) $$(MAKE) ARCH=$(1) $$*.$$(EXE) endef $(foreach ARCH,$(ARCHS),$(eval $(call rule_for_arch_executable,$(ARCH)))) From 3ae1dcd9bffb128581e9c38252bfb4143233ac1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleks=20ANDR=C3=89?= Date: Sun, 5 Apr 2020 09:00:34 +0200 Subject: [PATCH 08/16] =?UTF-8?q?retours=20=C3=A0=20la=20ligne=20aidant=20?= =?UTF-8?q?=C3=A0=20la=20lecture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/usb/base.fr.i18n | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/usb/base.fr.i18n b/apps/usb/base.fr.i18n index 5f821d5c4..aeda714e8 100644 --- a/apps/usb/base.fr.i18n +++ b/apps/usb/base.fr.i18n @@ -2,6 +2,6 @@ USBConnected = "LA CALCULATRICE EST CONNECTÉE" ConnectedMessage1 = "Pour transférer des données, connectez-" ConnectedMessage2 = "vous depuis votre ordinateur sur le site" ConnectedMessage3 = "workshop.numworks.com" -ConnectedMessage4 = "Appuyez sur la touche RETOUR de la" -ConnectedMessage5 = "calculatrice ou débranchez-la pour la" -ConnectedMessage6 = "déconnecter." +ConnectedMessage4 = "Appuyez sur la touche RETOUR" +ConnectedMessage5 = "de la calculatrice ou débranchez-la" +ConnectedMessage6 = "pour la déconnecter." From 9272d4e75ffcf46bae8ad80febd8e7106d1daf76 Mon Sep 17 00:00:00 2001 From: David <0b101@users.noreply.github.com> Date: Mon, 25 Mar 2019 17:01:03 -0500 Subject: [PATCH 09/16] Increase Brightness Levels to 12 --- apps/global_preferences.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/global_preferences.h b/apps/global_preferences.h index 50f9aa0f1..fb82cbe0c 100644 --- a/apps/global_preferences.h +++ b/apps/global_preferences.h @@ -23,7 +23,7 @@ public: void setBrightnessLevel(int brightnessLevel); const KDFont * font() const { return m_font; } void setFont(const KDFont * font) { m_font = font; } - constexpr static int NumberOfBrightnessStates = 5; + constexpr static int NumberOfBrightnessStates = 12; private: static_assert(I18n::NumberOfLanguages > 0, "I18n::NumberOfLanguages is not superior to 0"); // There should already have be an error when processing an empty EPSILON_I18N flag GlobalPreferences() : From ed7e6bec9d3ad875bb229788c99e5c68f3f9e004 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Thu, 21 Nov 2019 17:02:58 +0100 Subject: [PATCH 10/16] [build/device] Generate a RAM map --- build/device/ram_map.py | 64 ++++++++++++++++++++++++++++++++++++++++ build/targets.device.mak | 6 ++++ 2 files changed, 70 insertions(+) create mode 100644 build/device/ram_map.py diff --git a/build/device/ram_map.py b/build/device/ram_map.py new file mode 100644 index 000000000..d97ab9e04 --- /dev/null +++ b/build/device/ram_map.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import re +import subprocess +import sys +import matplotlib.pyplot as plt +from matplotlib.ticker import FormatStrFormatter + +readelf_line_regex = re.compile("[0-9]+:\s+([0-9a-f]+)\s+([0-9]+)\s+[A-Z]+") +def parse_line(line): + hex_start, dec_size = re.findall(readelf_line_regex, line)[0] + return (int(hex_start, 16), int(dec_size)) + +readelf_output = subprocess.check_output([ + "arm-none-eabi-readelf", + "-W", # Don't limit line lenght + "-s", # Sizes + sys.argv[1] +]).decode('utf-8') + +for line in readelf_output.splitlines(): + words = line.split() + if not words: + continue + symbol = words[-1] + if symbol == "_ZN3Ion17staticStorageAreaE": + storage = parse_line(line) + if symbol == "_ZZN13AppsContainer19sharedAppsContainerEvE20appsContainerStorage": + container = parse_line(line) + if symbol == "_stack_start": + stack_start, _ = parse_line(line) + if symbol == "_stack_end": + stack_end, _ = parse_line(line) + if symbol == "_heap_start": + heap_start, _ = parse_line(line) + if symbol == "_heap_end": + heap_end, _ = parse_line(line) + +stack_size = stack_start - stack_end # Stack grows downwards +stack = (stack_end, stack_size) +heap_size = heap_end - heap_start +heap = (heap_start, heap_size) + +def format_kb(i): + return ("%d KB" % (i/1024)) + +fig,ax = plt.subplots() + +def plot(value, name, c): + ax.broken_barh([value], (0, 1), color=c, label=name + " - " + format_kb(value[1])) + +plot(container, "Container", "blue") +plot(storage, "Storage", "red") +plot(heap, "Heap", "pink") +plot(stack, "Stack", "green") + +ax.set_yticks([]) +ax.set_xticks(list(range(0x20000000,0x20040001,0x10000))) +xlabels = map(lambda t: '0x%08X' % int(t), ax.get_xticks()) +ax.set_xticklabels(xlabels); +ax.legend() +fig.set_size_inches(20, 2) +fig.savefig(sys.argv[2]) + diff --git a/build/targets.device.mak b/build/targets.device.mak index 3ad973562..4965fa00f 100644 --- a/build/targets.device.mak +++ b/build/targets.device.mak @@ -3,6 +3,12 @@ include build/targets.device.$(MODEL).mak HANDY_TARGETS += flasher.light flasher.verbose bench.ram bench.flash HANDY_TARGETS_EXTENSIONS += dfu hex bin +$(eval $(call rule_for, \ + RAMSIZE, %_ram_map.png, %.elf, \ + $$(PYTHON) build/device/ram_map.py $$< $$@, \ + local \ +)) + .PHONY: %_size %_size: $(BUILD_DIR)/%.$(EXE) @echo "========= BUILD OUTPUT ========" From 35d446353fc31a897de3e6234576efd33cf9f82b Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 7 Apr 2020 14:54:28 -0400 Subject: [PATCH 11/16] [escher] Avoid long switches on Left/Up/Right/Down --- escher/src/layout_field.cpp | 87 ++++++++++++++++------- ion/include/ion/events.h | 1 + poincare/include/poincare/layout_cursor.h | 4 +- 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/escher/src/layout_field.cpp b/escher/src/layout_field.cpp index 6a7086c10..dd4268182 100644 --- a/escher/src/layout_field.cpp +++ b/escher/src/layout_field.cpp @@ -502,15 +502,46 @@ bool LayoutField::privateHandleEvent(Ion::Events::Event event) { return false; } -static inline bool IsSimpleMoveEvent(Ion::Events::Event event) { - return event == Ion::Events::Left - || event == Ion::Events::Right - || event == Ion::Events::Up - || event == Ion::Events::Down; +#define static_assert_immediately_follows(a, b) static_assert( \ + static_cast(a) + 1 == static_cast(b), \ + "Ordering error" \ +) + +#define static_assert_sequential(a, b, c, d) \ + static_assert_immediately_follows(a, b); \ + static_assert_immediately_follows(b, c); \ + static_assert_immediately_follows(c, d); + +static_assert_sequential( + LayoutCursor::Direction::Left, + LayoutCursor::Direction::Up, + LayoutCursor::Direction::Down, + LayoutCursor::Direction::Right +); + +static_assert_sequential( + Ion::Events::Left, + Ion::Events::Up, + Ion::Events::Down, + Ion::Events::Right +); + +static inline bool IsMoveEvent(Ion::Events::Event event) { + return + static_cast(event) >= static_cast(Ion::Events::Left) && + static_cast(event) <= static_cast(Ion::Events::Right); +} + +static inline LayoutCursor::Direction DirectionForMoveEvent(Ion::Events::Event event) { + assert(IsMoveEvent(event)); + return static_cast( + static_cast(LayoutCursor::Direction::Left) + + static_cast(event) - static_cast(Ion::Events::Left) + ); } bool LayoutField::privateHandleMoveEvent(Ion::Events::Event event, bool * shouldRecomputeLayout) { - if (!IsSimpleMoveEvent(event)) { + if (!IsMoveEvent(event)) { return false; } if (resetSelection()) { @@ -518,16 +549,7 @@ bool LayoutField::privateHandleMoveEvent(Ion::Events::Event event, bool * should return true; } LayoutCursor result; - if (event == Ion::Events::Left) { - result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::Direction::Left, shouldRecomputeLayout); - } else if (event == Ion::Events::Right) { - result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::Direction::Right, shouldRecomputeLayout); - } else if (event == Ion::Events::Up) { - result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::Direction::Up, shouldRecomputeLayout); - } else { - assert(event == Ion::Events::Down); - result = m_contentView.cursor()->cursorAtDirection(LayoutCursor::Direction::Down, shouldRecomputeLayout); - } + result = m_contentView.cursor()->cursorAtDirection(DirectionForMoveEvent(event), shouldRecomputeLayout); if (result.isDefined()) { m_contentView.setCursor(result); return true; @@ -535,20 +557,37 @@ bool LayoutField::privateHandleMoveEvent(Ion::Events::Event event, bool * should return false; } -bool eventIsSelection(Ion::Events::Event event) { - return event == Ion::Events::ShiftLeft || event == Ion::Events::ShiftRight || event == Ion::Events::ShiftUp || event == Ion::Events::ShiftDown; +static_assert_sequential( + Ion::Events::ShiftLeft, + Ion::Events::ShiftUp, + Ion::Events::ShiftDown, + Ion::Events::ShiftRight +); + +static inline bool IsSelectionEvent(Ion::Events::Event event) { + return + static_cast(event) >= static_cast(Ion::Events::ShiftLeft) && + static_cast(event) <= static_cast(Ion::Events::ShiftRight); +} + +static inline LayoutCursor::Direction DirectionForSelectionEvent(Ion::Events::Event event) { + assert(IsSelectionEvent(event)); + return static_cast( + static_cast(LayoutCursor::Direction::Left) + + static_cast(event) - static_cast(Ion::Events::ShiftLeft) + ); } bool LayoutField::privateHandleSelectionEvent(Ion::Events::Event event, bool * shouldRecomputeLayout) { - if (!eventIsSelection(event)) { + if (!IsSelectionEvent(event)) { return false; } Layout addedSelection; - LayoutCursor::Direction direction = event == Ion::Events::ShiftLeft ? LayoutCursor::Direction::Left : - (event == Ion::Events::ShiftRight ? LayoutCursor::Direction::Right : - (event == Ion::Events::ShiftUp ? LayoutCursor::Direction::Up : - LayoutCursor::Direction::Down)); - LayoutCursor result = m_contentView.cursor()->selectAtDirection(direction, shouldRecomputeLayout, &addedSelection); + LayoutCursor result = m_contentView.cursor()->selectAtDirection( + DirectionForSelectionEvent(event), + shouldRecomputeLayout, + &addedSelection + ); if (addedSelection.isUninitialized()) { return false; } diff --git a/ion/include/ion/events.h b/ion/include/ion/events.h index 058bdfcbc..e046aeaee 100644 --- a/ion/include/ion/events.h +++ b/ion/include/ion/events.h @@ -18,6 +18,7 @@ public: constexpr Event(int i) : m_id(i){} // TODO: Assert here that i>=0 && i<255 uint8_t id() const { return m_id; } + constexpr explicit operator uint8_t() const { return m_id; } #if DEBUG const char * name() const; #endif diff --git a/poincare/include/poincare/layout_cursor.h b/poincare/include/poincare/layout_cursor.h index 33efc29c6..8979d7b53 100644 --- a/poincare/include/poincare/layout_cursor.h +++ b/poincare/include/poincare/layout_cursor.h @@ -29,9 +29,9 @@ public: enum class Direction { Left, - Right, Up, - Down + Down, + Right }; enum class Position { From 743eb104bf74485288fc93e8f944c57406d5ffea Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 7 Apr 2020 14:59:19 -0400 Subject: [PATCH 12/16] [ion] Replace Ion::Events::Event::id() by an explicit cast operator --- escher/src/run_loop.cpp | 2 +- ion/include/ion/events.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/escher/src/run_loop.cpp b/escher/src/run_loop.cpp index 6c9ead568..4653324ff 100644 --- a/escher/src/run_loop.cpp +++ b/escher/src/run_loop.cpp @@ -53,7 +53,7 @@ bool RunLoop::step() { } #if ESCHER_LOG_EVENTS_BINARY - Ion::Console::writeChar((char)event.id()); + Ion::Console::writeChar(static_cast(event)); #endif #if ESCHER_LOG_EVENTS_NAME const char * name = event.name(); diff --git a/ion/include/ion/events.h b/ion/include/ion/events.h index e046aeaee..2b09c0795 100644 --- a/ion/include/ion/events.h +++ b/ion/include/ion/events.h @@ -17,7 +17,6 @@ public: constexpr Event() : m_id(4*PageSize){} // Return Ion::Event::None by default constexpr Event(int i) : m_id(i){} // TODO: Assert here that i>=0 && i<255 - uint8_t id() const { return m_id; } constexpr explicit operator uint8_t() const { return m_id; } #if DEBUG const char * name() const; From b59085bd7f415386485b569fa47574e37ebe5cbd Mon Sep 17 00:00:00 2001 From: FloMiau <37121807+FloMiau@users.noreply.github.com> Date: Sat, 4 Jan 2020 10:27:24 +0100 Subject: [PATCH 13/16] Update German language file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit replace "Testmodus" with "Prüfungsmodus" Real: "Reel" -> "Reell" Gradians: "Gone" -> "Gon" --- apps/settings/base.de.i18n | 10 +++++----- apps/shared.de.i18n | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/settings/base.de.i18n b/apps/settings/base.de.i18n index d726da86e..e8684369d 100644 --- a/apps/settings/base.de.i18n +++ b/apps/settings/base.de.i18n @@ -6,9 +6,9 @@ EditionMode = "Eingabe" EditionLinear = "Linear " Edition2D = "Natürlich " ComplexFormat = "Komplex" -ExamMode = "Testmodus" -ExamModeActive = "Wieder starten Testmodus" -ToDeactivateExamMode1 = "Um den Testmodus auszuschalten," +ExamMode = "Prüfungsmodus" +ExamModeActive = "Wieder starten Modus" +ToDeactivateExamMode1 = "Um den Prüfungsmodus auszuschalten," ToDeactivateExamMode2 = "schließen Sie den Rechner an einen" ToDeactivateExamMode3 = "Computer oder eine Steckdose an." # --------------------- Please do not edit these messages --------------------- @@ -22,13 +22,13 @@ AboutWarning4 = "for any resulting damage." # ----------------------------------------------------------------------------- About = "Über" Degrees = "Grad " -Gradians = "Gone " +Gradians = "Gon " Radian = "Bogenmaß " Decimal = "Dezimal " Engineering = "Technisch " Scientific = "Wissenschaftlich " SignificantFigures = "Signifikante Stellen " -Real = "Reel " +Real = "Reell " Cartesian = "Algebraische " Polar = "Polar " Brightness = "Helligkeit" diff --git a/apps/shared.de.i18n b/apps/shared.de.i18n index 0329c99cb..f6ae43bfd 100644 --- a/apps/shared.de.i18n +++ b/apps/shared.de.i18n @@ -1,9 +1,9 @@ ActivateDeactivate = "Aktivieren/Deaktivieren" ActivateDutchExamMode = "Activate Dutch exam mode" -ActivateExamMode = "Starten Testmodus" +ActivateExamMode = "Starten Prüfungsmodus" ActiveExamModeMessage1 = "Alle Ihre Daten werden " ActiveExamModeMessage2 = "gelöscht, wenn Sie den " -ActiveExamModeMessage3 = "Testmodus einschalten." +ActiveExamModeMessage3 = "Prüfungsmodus einschalten." ActiveDutchExamModeMessage1 = "All your data will be deleted when" ActiveDutchExamModeMessage2 = "you activate the exam mode. Python" ActiveDutchExamModeMessage3 = "application will be unavailable." @@ -20,8 +20,8 @@ Deviation = "Varianz" DisplayValues = "Werte anzeigen" Empty = "Leer" Eng = "tech" -ExitExamMode1 = "Möchten Sie den Testmodus " -ExitExamMode2 = "verlassen?" +ExitExamMode1 = "Möchten Sie den" +ExitExamMode2 = "Prüfungsmodus verlassen?" Exponential = "Exponentielle" FillWithFormula = "Mit einer Formel füllen" ForbiddenValue = "Verbotener Wert" From 64d0b3107f607f09ad9582840ee2f0949887e87f Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Boric Date: Sat, 30 Nov 2019 20:12:38 +0100 Subject: [PATCH 14/16] [apps] Remove statically-allocated buffers --- apps/battery_view.cpp | 9 ++++----- apps/hardware_test/arrow_view.cpp | 5 ++--- apps/lock_view.cpp | 5 ++--- apps/shared/ok_view.cpp | 5 ++--- apps/shared/round_cursor_view.cpp | 8 ++++---- apps/solver/equation_list_view.cpp | 9 ++++----- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/apps/battery_view.cpp b/apps/battery_view.cpp index 9e8b97e9c..abd03c731 100644 --- a/apps/battery_view.cpp +++ b/apps/battery_view.cpp @@ -54,9 +54,6 @@ bool BatteryView::setIsPlugged(bool isPlugged) { return false; } -KDColor s_flashWorkingBuffer[BatteryView::k_flashHeight*BatteryView::k_flashWidth]; -KDColor s_tickWorkingBuffer[BatteryView::k_tickHeight*BatteryView::k_tickWidth]; - void BatteryView::drawRect(KDContext * ctx, KDRect rect) const { assert(m_chargeState != Ion::Battery::Charge::EMPTY); /* We draw from left to right. The middle part representing the battery @@ -72,7 +69,8 @@ void BatteryView::drawRect(KDContext * ctx, KDRect rect) const { // Charging: Yellow background with flash ctx->fillRect(KDRect(batteryInsideX, 0, batteryInsideWidth, k_batteryHeight), Palette::YellowLight); KDRect frame((k_batteryWidth-k_flashWidth)/2, 0, k_flashWidth, k_flashHeight); - ctx->blendRectWithMask(frame, KDColorWhite, (const uint8_t *)flashMask, s_flashWorkingBuffer); + KDColor flashWorkingBuffer[BatteryView::k_flashHeight*BatteryView::k_flashWidth]; + ctx->blendRectWithMask(frame, KDColorWhite, (const uint8_t *)flashMask, flashWorkingBuffer); } else if (m_chargeState == Ion::Battery::Charge::LOW) { assert(!m_isPlugged); // Low: Quite empty battery @@ -91,7 +89,8 @@ void BatteryView::drawRect(KDContext * ctx, KDRect rect) const { if (m_isPlugged) { // Plugged and full: Full battery with tick KDRect frame((k_batteryWidth-k_tickWidth)/2, (k_batteryHeight-k_tickHeight)/2, k_tickWidth, k_tickHeight); - ctx->blendRectWithMask(frame, Palette::YellowDark, (const uint8_t *)tickMask, s_tickWorkingBuffer); + KDColor tickWorkingBuffer[BatteryView::k_tickHeight*BatteryView::k_tickWidth]; + ctx->blendRectWithMask(frame, Palette::YellowDark, (const uint8_t *)tickMask, tickWorkingBuffer); } } diff --git a/apps/hardware_test/arrow_view.cpp b/apps/hardware_test/arrow_view.cpp index ad5173c04..f74583986 100644 --- a/apps/hardware_test/arrow_view.cpp +++ b/apps/hardware_test/arrow_view.cpp @@ -48,16 +48,15 @@ void ArrowView::setColor(KDColor color) { } } -KDColor s_arrowWorkingBuffer[10*9]; - void ArrowView::drawRect(KDContext * ctx, KDRect rect) const { + KDColor arrowWorkingBuffer[10*9]; ctx->fillRect(bounds(), KDColorWhite); KDCoordinate startLine = m_directionIsUp ? k_arrowHeight : 0; KDCoordinate startArrow = m_directionIsUp ? 0 : bounds().height()-k_arrowHeight; ctx->fillRect(KDRect((Ion::Display::Width-k_arrowThickness)/2, startLine, k_arrowThickness, bounds().height()-k_arrowHeight), m_color); KDRect frame((Ion::Display::Width-k_arrowWidth)/2, startArrow, k_arrowWidth, k_arrowHeight); const uint8_t * mask = m_directionIsUp ? (const uint8_t *)arrowUpMask : (const uint8_t *)arrowDownMask; - ctx->blendRectWithMask(frame, m_color, mask, s_arrowWorkingBuffer); + ctx->blendRectWithMask(frame, m_color, mask, arrowWorkingBuffer); } } diff --git a/apps/lock_view.cpp b/apps/lock_view.cpp index ed41abc72..9a0113907 100644 --- a/apps/lock_view.cpp +++ b/apps/lock_view.cpp @@ -12,11 +12,10 @@ const uint8_t lockMask[LockView::k_lockHeight][LockView::k_lockWidth] = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, }; -KDColor s_lockWorkingBuffer[LockView::k_lockHeight*LockView::k_lockWidth]; - void LockView::drawRect(KDContext * ctx, KDRect rect) const { KDRect frame((bounds().width() - k_lockWidth)/2, (bounds().height()-k_lockHeight)/2, k_lockWidth, k_lockHeight); - ctx->blendRectWithMask(frame, KDColorWhite, (const uint8_t *)lockMask, s_lockWorkingBuffer); + KDColor lockWorkingBuffer[LockView::k_lockHeight*LockView::k_lockWidth]; + ctx->blendRectWithMask(frame, KDColorWhite, (const uint8_t *)lockMask, lockWorkingBuffer); } KDSize LockView::minimalSizeForOptimalDisplay() const { diff --git a/apps/shared/ok_view.cpp b/apps/shared/ok_view.cpp index bb49b69b2..d524e5725 100644 --- a/apps/shared/ok_view.cpp +++ b/apps/shared/ok_view.cpp @@ -25,13 +25,12 @@ const uint8_t okMask[OkView::k_okSize][OkView::k_okSize] = { {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE1, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, }; -KDColor s_okWorkingBuffer[OkView::k_okSize*OkView::k_okSize]; - void OkView::drawRect(KDContext * ctx, KDRect rect) const { KDCoordinate width = bounds().width(); KDCoordinate height = bounds().height(); KDRect frame((width-k_okSize)/2, (height-k_okSize)/2, k_okSize, k_okSize); - ctx->blendRectWithMask(frame, KDColorBlack, (const uint8_t *)okMask, s_okWorkingBuffer); + KDColor okWorkingBuffer[OkView::k_okSize*OkView::k_okSize]; + ctx->blendRectWithMask(frame, KDColorBlack, (const uint8_t *)okMask, okWorkingBuffer); } KDSize OkView::minimalSizeForOptimalDisplay() const { diff --git a/apps/shared/round_cursor_view.cpp b/apps/shared/round_cursor_view.cpp index 790817b7d..10b14e86b 100644 --- a/apps/shared/round_cursor_view.cpp +++ b/apps/shared/round_cursor_view.cpp @@ -2,10 +2,9 @@ namespace Shared { -static KDColor s_cursorWorkingBuffer[Dots::LargeDotDiameter*Dots::LargeDotDiameter]; - void RoundCursorView::drawRect(KDContext * ctx, KDRect rect) const { KDRect r = bounds(); + KDColor cursorWorkingBuffer[Dots::LargeDotDiameter*Dots::LargeDotDiameter]; #ifdef GRAPH_CURSOR_SPEEDUP /* Beware that only the pixels of the intersection of rect with KDContext's * clipping rect are pulled. All other pixels are left unaltered. Indeed @@ -15,7 +14,7 @@ void RoundCursorView::drawRect(KDContext * ctx, KDRect rect) const { ctx->getPixels(r, m_underneathPixelBuffer); m_underneathPixelBufferLoaded = true; #endif - ctx->blendRectWithMask(r, m_color, (const uint8_t *)Dots::LargeDotMask, s_cursorWorkingBuffer); + ctx->blendRectWithMask(r, m_color, (const uint8_t *)Dots::LargeDotMask, cursorWorkingBuffer); } KDSize RoundCursorView::minimalSizeForOptimalDisplay() const { @@ -67,10 +66,11 @@ bool RoundCursorView::eraseCursorIfPossible() { return false; } // Erase the cursor + KDColor cursorWorkingBuffer[Dots::LargeDotDiameter*Dots::LargeDotDiameter]; KDContext * ctx = KDIonContext::sharedContext(); ctx->setOrigin(currentFrame.origin()); ctx->setClippingRect(currentFrame); - ctx->fillRectWithPixels(KDRect(0,0,k_cursorSize, k_cursorSize), m_underneathPixelBuffer, s_cursorWorkingBuffer); + ctx->fillRectWithPixels(KDRect(0,0,k_cursorSize, k_cursorSize), m_underneathPixelBuffer, cursorWorkingBuffer); // TODO Restore the context to previous values? return true; } diff --git a/apps/solver/equation_list_view.cpp b/apps/solver/equation_list_view.cpp index 6edfd4092..f4a4d18f3 100644 --- a/apps/solver/equation_list_view.cpp +++ b/apps/solver/equation_list_view.cpp @@ -105,15 +105,14 @@ const uint8_t bottomBrace[braceExtremumHeight][braceExtremumWidth] = { {0xFF, 0xFF, 0xF7, 0x25, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, }; -KDColor s_braceWorkingBuffer[60]; - void EquationListView::BraceView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(bounds(), KDColorWhite); KDCoordinate height = bounds().height(); KDCoordinate margin = 3; - ctx->blendRectWithMask(KDRect(margin, 0, braceExtremumWidth, braceExtremumHeight), KDColorBlack, (const uint8_t *)topBrace, (KDColor *)(s_braceWorkingBuffer)); - ctx->blendRectWithMask(KDRect(0, height/2-braceCenterHeight/2, braceCenterWidth, braceCenterHeight), KDColorBlack, (const uint8_t *)middleBrace, (KDColor *)(s_braceWorkingBuffer)); - ctx->blendRectWithMask(KDRect(margin, height-braceExtremumHeight, braceExtremumWidth, braceExtremumHeight), KDColorBlack, (const uint8_t *)bottomBrace, (KDColor *)(s_braceWorkingBuffer)); + KDColor braceWorkingBuffer[60]; + ctx->blendRectWithMask(KDRect(margin, 0, braceExtremumWidth, braceExtremumHeight), KDColorBlack, (const uint8_t *)topBrace, (KDColor *)(braceWorkingBuffer)); + ctx->blendRectWithMask(KDRect(0, height/2-braceCenterHeight/2, braceCenterWidth, braceCenterHeight), KDColorBlack, (const uint8_t *)middleBrace, (KDColor *)(braceWorkingBuffer)); + ctx->blendRectWithMask(KDRect(margin, height-braceExtremumHeight, braceExtremumWidth, braceExtremumHeight), KDColorBlack, (const uint8_t *)bottomBrace, (KDColor *)(braceWorkingBuffer)); ctx->fillRect(KDRect(margin, braceExtremumHeight, 1, height/2-braceCenterHeight/2-braceExtremumHeight), KDColorBlack); ctx->fillRect(KDRect(margin, height/2+braceCenterHeight/2, 1, height/2-braceExtremumHeight/2-braceExtremumHeight), KDColorBlack); } From 2768ac2b48cb200f5e4c80a667a150dfc2d50a06 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Boric Date: Sat, 30 Nov 2019 20:13:02 +0100 Subject: [PATCH 15/16] [escher] Remove statically-allocated buffers --- escher/src/chevron_view.cpp | 5 ++--- escher/src/ellipsis_view.cpp | 5 ++--- escher/src/gauge_view.cpp | 5 ++--- escher/src/key_view.cpp | 5 ++--- escher/src/switch_view.cpp | 7 +++---- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/escher/src/chevron_view.cpp b/escher/src/chevron_view.cpp index b6c7b32d2..0ac38c794 100644 --- a/escher/src/chevron_view.cpp +++ b/escher/src/chevron_view.cpp @@ -14,8 +14,6 @@ const uint8_t chevronMask[ChevronView::k_chevronHeight][ChevronView::k_chevronWi {0x0C, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, }; -KDColor s_workingBuffer[ChevronView::k_chevronWidth*ChevronView::k_chevronHeight]; - void ChevronView::drawRect(KDContext * ctx, KDRect rect) const { /* Draw the chevron aligned on the right of the view and vertically centered. * The heightCenter is the coordinate of the vertical middle of the view. That @@ -24,7 +22,8 @@ void ChevronView::drawRect(KDContext * ctx, KDRect rect) const { KDCoordinate heightCenter = bounds().height()/2; KDCoordinate chevronHalfHeight = k_chevronHeight/2; KDRect frame(width - k_chevronWidth, heightCenter -chevronHalfHeight, k_chevronWidth, k_chevronHeight); - ctx->blendRectWithMask(frame, Palette::YellowDark, (const uint8_t *)chevronMask, s_workingBuffer); + KDColor workingBuffer[ChevronView::k_chevronWidth*ChevronView::k_chevronHeight]; + ctx->blendRectWithMask(frame, Palette::YellowDark, (const uint8_t *)chevronMask, workingBuffer); } KDSize ChevronView::minimalSizeForOptimalDisplay() const { diff --git a/escher/src/ellipsis_view.cpp b/escher/src/ellipsis_view.cpp index f965ea447..4a659b6a9 100644 --- a/escher/src/ellipsis_view.cpp +++ b/escher/src/ellipsis_view.cpp @@ -7,8 +7,6 @@ const uint8_t ellipsisMask[EllipsisView::k_ellipsisHeight][EllipsisView::k_ellip {0xFF, 0xD1, 0xA1, 0xC1, 0xFF, 0xFF, 0xFF, 0xD1, 0xA1, 0xC1, 0xFF, 0xFF, 0xFF, 0xD1, 0xA1, 0xC1, 0xFF}, }; -KDColor s_ellipsisWorkingBuffer[EllipsisView::k_ellipsisWidth*EllipsisView::k_ellipsisHeight]; - void EllipsisView::drawRect(KDContext * ctx, KDRect rect) const { /* Draw the ellipsis vertically and horizontally centered in the view. * The heightCenter is the coordinate of the vertical middle of the view. That @@ -18,7 +16,8 @@ void EllipsisView::drawRect(KDContext * ctx, KDRect rect) const { KDCoordinate heightCenter = bounds().height()/2; KDCoordinate ellipsisHalfHeight = k_ellipsisHeight/2; KDRect frame(widthCenter - ellipsisHalfWidth, heightCenter - ellipsisHalfHeight, k_ellipsisWidth, k_ellipsisHeight); - ctx->blendRectWithMask(frame, KDColorBlack, (const uint8_t *)ellipsisMask, s_ellipsisWorkingBuffer); + KDColor ellipsisWorkingBuffer[EllipsisView::k_ellipsisWidth*EllipsisView::k_ellipsisHeight]; + ctx->blendRectWithMask(frame, KDColorBlack, (const uint8_t *)ellipsisMask, ellipsisWorkingBuffer); } KDSize EllipsisView::minimalSizeForOptimalDisplay() const { diff --git a/escher/src/gauge_view.cpp b/escher/src/gauge_view.cpp index f22d7ecf6..71c0dc05d 100644 --- a/escher/src/gauge_view.cpp +++ b/escher/src/gauge_view.cpp @@ -40,18 +40,17 @@ void GaugeView::setBackgroundColor(KDColor color) { } } -KDColor s_gaugeIndicatorWorkingBuffer[GaugeView::k_indicatorDiameter*GaugeView::k_indicatorDiameter]; - void GaugeView::drawRect(KDContext * ctx, KDRect rect) const { ctx->fillRect(bounds(), m_backgroundColor); /* Draw the gauge centered vertically on all the width available */ KDCoordinate width = bounds().width()-k_indicatorDiameter; KDCoordinate height = bounds().height(); + KDColor gaugeIndicatorWorkingBuffer[GaugeView::k_indicatorDiameter*GaugeView::k_indicatorDiameter]; ctx->fillRect(KDRect(k_indicatorDiameter/2, (height-k_thickness)/2, width*m_level, k_thickness), Palette::YellowDark); ctx->fillRect(KDRect(k_indicatorDiameter/2+width*m_level, (height-k_thickness)/2, width*(1.0f-m_level), k_thickness), Palette::GreyDark); KDRect frame(width*m_level, (height-k_indicatorDiameter)/2, k_indicatorDiameter, k_indicatorDiameter); - ctx->blendRectWithMask(frame, Palette::YellowDark, (const uint8_t *)gaugeIndicatorMask, s_gaugeIndicatorWorkingBuffer); + ctx->blendRectWithMask(frame, Palette::YellowDark, (const uint8_t *)gaugeIndicatorMask, gaugeIndicatorWorkingBuffer); } KDSize GaugeView::minimalSizeForOptimalDisplay() const { diff --git a/escher/src/key_view.cpp b/escher/src/key_view.cpp index 1c1022f5b..d61598fec 100644 --- a/escher/src/key_view.cpp +++ b/escher/src/key_view.cpp @@ -76,14 +76,13 @@ void KeyView::setType(Type type) { markRectAsDirty(bounds()); } -KDColor s_keyWorkingBuffer[KeyView::k_keySize*KeyView::k_keySize]; - void KeyView::drawRect(KDContext * ctx, KDRect rect) const { /* Draw the key centered on the view. */ KDCoordinate width = bounds().width(); KDCoordinate height = bounds().height(); KDRect frame((width - k_keySize)/2, (height - k_keySize)/2, k_keySize, k_keySize); - ctx->blendRectWithMask(frame, KDColorBlack, mask(), s_keyWorkingBuffer); + KDColor keyWorkingBuffer[KeyView::k_keySize*KeyView::k_keySize]; + ctx->blendRectWithMask(frame, KDColorBlack, mask(), keyWorkingBuffer); } KDSize KeyView::minimalSizeForOptimalDisplay() const { diff --git a/escher/src/switch_view.cpp b/escher/src/switch_view.cpp index a88dfb7a0..b06d51620 100644 --- a/escher/src/switch_view.cpp +++ b/escher/src/switch_view.cpp @@ -46,8 +46,6 @@ void SwitchView::setState(bool state) { markRectAsDirty(bounds()); } -KDColor s_switchWorkingBuffer[SwitchView::k_switchWidth*SwitchView::k_switchHeight]; - void SwitchView::drawRect(KDContext * ctx, KDRect rect) const { /* Draw the switch aligned on the right of the view and vertically centered. * The heightCenter is the coordinate of the vertical middle of the view. That @@ -55,13 +53,14 @@ void SwitchView::drawRect(KDContext * ctx, KDRect rect) const { KDCoordinate width = bounds().width(); KDCoordinate heightCenter = bounds().height()/2; KDCoordinate switchHalfHeight = k_switchHeight/2; + KDColor switchWorkingBuffer[SwitchView::k_switchWidth*SwitchView::k_switchHeight]; KDColor mainColor = m_state ? Palette::YellowDark : Palette::GreyDark; KDRect frame(width - k_switchWidth, heightCenter -switchHalfHeight, k_switchWidth, k_switchHeight); - ctx->blendRectWithMask(frame, mainColor, (const uint8_t *)switchMask, s_switchWorkingBuffer); + ctx->blendRectWithMask(frame, mainColor, (const uint8_t *)switchMask, switchWorkingBuffer); KDCoordinate onOffX = width - (m_state ? k_onOffSize : k_switchWidth); KDRect onOffFrame(onOffX, heightCenter -switchHalfHeight, k_onOffSize, k_onOffSize); - ctx->blendRectWithMask(onOffFrame, KDColorWhite, (const uint8_t *)onOffMask, s_switchWorkingBuffer); + ctx->blendRectWithMask(onOffFrame, KDColorWhite, (const uint8_t *)onOffMask, switchWorkingBuffer); } KDSize SwitchView::minimalSizeForOptimalDisplay() const { From 2f61b823d02e0b561d6c34122fc4286b2d10bad4 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Boric Date: Sat, 30 Nov 2019 20:14:02 +0100 Subject: [PATCH 16/16] [poincare] Remove statically-allocated buffers --- poincare/include/poincare/parenthesis_layout.h | 1 - poincare/src/left_parenthesis_layout.cpp | 5 +++-- poincare/src/parenthesis_layout.cpp | 2 -- poincare/src/right_parenthesis_layout.cpp | 5 +++-- poincare/src/trigonometry_cheat_table.cpp | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/poincare/include/poincare/parenthesis_layout.h b/poincare/include/poincare/parenthesis_layout.h index 5cc757d03..f35679205 100644 --- a/poincare/include/poincare/parenthesis_layout.h +++ b/poincare/include/poincare/parenthesis_layout.h @@ -27,7 +27,6 @@ public: #endif protected: - static KDColor s_parenthesisWorkingBuffer[k_parenthesisCurveHeight*k_parenthesisCurveWidth]; KDSize computeSize() override { return KDSize(ParenthesisWidth(), HeightGivenChildHeight(childHeight())); } diff --git a/poincare/src/left_parenthesis_layout.cpp b/poincare/src/left_parenthesis_layout.cpp index 5297a2eff..c7454d81d 100644 --- a/poincare/src/left_parenthesis_layout.cpp +++ b/poincare/src/left_parenthesis_layout.cpp @@ -25,20 +25,21 @@ const uint8_t bottomLeftCurve[ParenthesisLayoutNode::k_parenthesisCurveHeight][P }; void LeftParenthesisLayoutNode::RenderWithChildHeight(KDCoordinate childHeight, KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { + KDColor parenthesisWorkingBuffer[k_parenthesisCurveHeight*k_parenthesisCurveWidth]; KDCoordinate parenthesisHeight = ParenthesisLayoutNode::HeightGivenChildHeight(childHeight); KDRect frame(p.x()+ParenthesisLayoutNode::k_externWidthMargin, p.y()+ParenthesisLayoutNode::k_externHeightMargin, ParenthesisLayoutNode::k_parenthesisCurveWidth, ParenthesisLayoutNode::k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, (KDColor *)(ParenthesisLayoutNode::s_parenthesisWorkingBuffer)); + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topLeftCurve, parenthesisWorkingBuffer); frame = KDRect(p.x()+ParenthesisLayoutNode::k_externWidthMargin, p.y() + parenthesisHeight - ParenthesisLayoutNode::k_parenthesisCurveHeight - ParenthesisLayoutNode::k_externHeightMargin, ParenthesisLayoutNode::k_parenthesisCurveWidth, ParenthesisLayoutNode::k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomLeftCurve, (KDColor *)(ParenthesisLayoutNode::s_parenthesisWorkingBuffer)); + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomLeftCurve, parenthesisWorkingBuffer); ctx->fillRect(KDRect(p.x()+ParenthesisLayoutNode::k_externWidthMargin, p.y()+ParenthesisLayoutNode::k_parenthesisCurveHeight+ParenthesisLayoutNode::k_externHeightMargin, diff --git a/poincare/src/parenthesis_layout.cpp b/poincare/src/parenthesis_layout.cpp index 40c5fc263..dece3d9d9 100644 --- a/poincare/src/parenthesis_layout.cpp +++ b/poincare/src/parenthesis_layout.cpp @@ -2,6 +2,4 @@ namespace Poincare { -KDColor ParenthesisLayoutNode::s_parenthesisWorkingBuffer[]; - } diff --git a/poincare/src/right_parenthesis_layout.cpp b/poincare/src/right_parenthesis_layout.cpp index 9f4a12eaa..09ff93132 100644 --- a/poincare/src/right_parenthesis_layout.cpp +++ b/poincare/src/right_parenthesis_layout.cpp @@ -25,20 +25,21 @@ const uint8_t bottomRightCurve[ParenthesisLayoutNode::k_parenthesisCurveHeight][ }; void RightParenthesisLayoutNode::RenderWithChildHeight(KDCoordinate childHeight, KDContext * ctx, KDPoint p, KDColor expressionColor, KDColor backgroundColor) { + KDColor parenthesisWorkingBuffer[k_parenthesisCurveHeight*k_parenthesisCurveWidth]; KDCoordinate parenthesisHeight = ParenthesisLayoutNode::HeightGivenChildHeight(childHeight); KDRect frame = KDRect(p.x() + ParenthesisLayoutNode::k_widthMargin + ParenthesisLayoutNode::k_lineThickness - ParenthesisLayoutNode::k_parenthesisCurveWidth, p.y() + ParenthesisLayoutNode::k_externHeightMargin, ParenthesisLayoutNode::k_parenthesisCurveWidth, ParenthesisLayoutNode::k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, (KDColor *)(ParenthesisLayoutNode::s_parenthesisWorkingBuffer)); + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)topRightCurve, parenthesisWorkingBuffer); frame = KDRect(p.x() + ParenthesisLayoutNode::k_widthMargin + ParenthesisLayoutNode::k_lineThickness - ParenthesisLayoutNode::k_parenthesisCurveWidth, p.y() + parenthesisHeight - ParenthesisLayoutNode::k_parenthesisCurveHeight - ParenthesisLayoutNode::k_externHeightMargin, ParenthesisLayoutNode::k_parenthesisCurveWidth, ParenthesisLayoutNode::k_parenthesisCurveHeight); - ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, (KDColor *)(ParenthesisLayoutNode::s_parenthesisWorkingBuffer)); + ctx->blendRectWithMask(frame, expressionColor, (const uint8_t *)bottomRightCurve, parenthesisWorkingBuffer); ctx->fillRect(KDRect(p.x()+ParenthesisLayoutNode::k_widthMargin, p.y()+ParenthesisLayoutNode::k_parenthesisCurveHeight+2, diff --git a/poincare/src/trigonometry_cheat_table.cpp b/poincare/src/trigonometry_cheat_table.cpp index 9cd3f9ef0..6cf2ca3e9 100644 --- a/poincare/src/trigonometry_cheat_table.cpp +++ b/poincare/src/trigonometry_cheat_table.cpp @@ -82,7 +82,7 @@ Expression TrigonometryCheatTable::simplify(const Expression e, ExpressionNode:: * For instance, when simplfy a Cosine, we always compute the value for an angle * in the top right trigonometric quadrant. */ const TrigonometryCheatTable * TrigonometryCheatTable::Table() { - static Row sTableRows[] = { + static const Row sTableRows[] = { Row(Row::Pair("-90", -90.0f), Row::Pair("π*(-2)^(-1)", -1.5707963267948966f), Row::Pair("-100", -100.0f), @@ -306,7 +306,7 @@ const TrigonometryCheatTable * TrigonometryCheatTable::Table() { Row::Pair("0",0.0f), Row::Pair("0",0.0f)) }; - static TrigonometryCheatTable sTable(sTableRows); + static const TrigonometryCheatTable sTable(sTableRows); return &sTable; }