Commit Graph

11730 Commits

Author SHA1 Message Date
Gabriel Ozouf
52dcd8e749 [poincare/unit] Restructure Unit
1. Information about a unit's dimension now uses inheritance.
   _m is an instance of DistanceAlias, which is derived from Alias.
   A UnitNode now keeps a pointer to an Alias and one to a Prefix.
   All aliases are still defined as constexpr.
   This cleans up a lot of the code used namely for computing the
   additional outputs in Calculation.

2. Instead of being defined with a string, each unit is described by its
   ratio with the base SI unit (ex: _L is 0.001 instead of "0.001_m^3").
   This greatly speeds up the calculations using units, as the algorithm
   to find the best unit used to parse the definition.

Change-Id: I4d6ed6ad4cb967026a3f01a335aec270066e2b9f
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
e48e826536 [poincare/test] Updated tests on units
Change-Id: I7c146174bcedcccc3ed31a298c9720aa2a5ba3a9
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
1f3c4b66a0 [poincare/unit] Changed imperial units definitions
Imperial units are now defined directly from the base unit, instead of
building on one another.

Change-Id: Ieb020643983ef49092d2d3033a7cc2135c646015
2020-11-04 15:11:45 +01:00
Gabriel Ozouf
87dd1b6310 [apps/i18n] Translate imperial units
Change-Id: I8f586b752c0c2114dfb656e34c9b9d928c5b6c59
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
f288573db0 [apps/unit] Add short and long tons
Change-Id: Ib48c6a7c773e9e1d18c9f55e6dda5330fe0a28f9
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
284c501532 [apps/unit] Add restriction to some input prefixes
The symbol for pint (_pt) conflicts with the symbol for pico-tonne. To
solve that, prefixes for tonnes are now restricted to the positive
prefixes : k, M, G, T.

Change-Id: Ie968374bbb5e0ebd2c0f08e4b1bdc1708eb6a041
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
b2f81db4a9 [apps/home] Apps placement defined by country
Instead of relying on the order in which the apps are passed at compile
time, the look of the Home app is defined in a config file, and depends
on the country chosen.

Change-Id: If7f56a284e0001d6d75ece1e7efdf5fd1d0a9978
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
fad375c11c [poincare] Add unitFormat to ReductionContext
Change-Id: I1d3fcd2f47c973c041e1be84e9a902dd58de3562
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
6c676782aa [apps/calculation] New additional results on units
The additional results on units now include conversions into both unit
systems (metric and imperial).

Change-Id: Ie0f12eb3735e775560b66c2cbd78bc9a659145bb
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
3ff25fb5c1 [poincare/unit] Standard unit methods
Added methods to return the standard format for each dimension,
depending on the chosen unit system.

Change-Id: I3591a806beca315674cc09093b57e8753db5db6a
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
9f40e45b20 [poincare/unit] Split for several dimensions
A split (such as _h+_min+_s) can now be generated for distances, volumes
and masses using imperial units.

Change-Id: Ib3ad63614979eddd02fbe0e99f16cf09dcf7c1fc
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
4d9f3aae97 [poincare/unit] Generalized BuildTimeSplit method
BuildTimesplit (used to create expressions of the form h+min+s) is now
based on the more general BuildSplit.

Change-Id: I3e55359cc6b9735269140942b29bd1d364fc35e7
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
5a31a6c1e2 [poincare/unit] Output units based on region
When the country is USA, the units will be simplified to common imperial
units rather than metric.

Change-Id: Ia533527a429ac26526380e324b9543b359f3b400
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
62f598110e [apps/shared] Created LocalizationController
Classes LanguageController and CountryController have been fused into
one class LocalizationController, as they were very similar. This allows
the Settings and OnBoarding apps to only keep one controller for both
functions.

Change-Id: Ic23f300c37122249d34caaf18a633b5815240a78
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
5749d871b0 [apps/i18n] Moved country preferences
Instead of being hardcoded in the python script, preferences specific to
each country are defined in the country_preferences.h and .csv files.

Change-Id: I71e276341e1586935b4d5814be5b1be80fa170a0
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
8121400cf2 [apps/i18n.py] Method for printing lists
New methods print_block_from_list factors code used to generate enum
classes and arrays.

Change-Id: I4ce7d22c3ffca4f12b9439f88ce288fcf9b85090
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
2b59509fdd [apps/i18n] Derive preferences from country
Each country comes with an set of preferences, built at compile time by
apps/i18n.py, used to define :
  - the exam mode
  - the method for computing quartiles
  - the unit system in which to output the results with units
Functions to access those preferences are available in
via sharedGlobalPreferences.

Change-Id: I220ebaa9b9e8954dfe33cd51936f47505b98978d
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
e2a6edd78f [poincare/preferences] Added UnitFormat preference
The UnitFormat can either be Imperial (for the US) or Metric (for the
rest of the world.

Change-Id: Ic698e6732f1fa225d88a14e61751b775fe70f1ab
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
4d6682e211 [poincare/unit] Added imperial units
The new units are :
  distance    mile, yard, foot, inch
  mass        pound, ounce
  volume      gallon, quart, pint, cup, fluid ounce
              table spoon, tea spoon

Change-Id: I6864067a1822a077764ed3b61fc46004732e9447
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
ea127cdfa9 [apps/statistics] Added tests for all countries
As some definitions now depend on the selected country, tests for the
statistics app now check that the right method is used for each country,
and that each method yields the correct results.

Change-Id: Ia5ad091136746f3284f7524376301fac0c582364
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
86f7a87d45 [apps/statistics] International quartiles
Implemented a new method for computing quartiles, used for all countries
except France and Italy. Quartiles are now computed as the medians of
the lower half and upper half of the dataset.

Change-Id: Idfb89a617799eca1d23326ebbcfbbea58e6236b8
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
8d362ef4de [apps/settings] Added message to country menu
Change-Id: Iec064d0ac86f54a10cf63236b6f958d53cecb2e2
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
b35cdca9bb [apps/exam_mode] Country-locked Dutch exam mode
The Dutch exam mode is now only accessible when the selected country is
Netherlands on an official firmware.

Change-Id: I6d70f79b6e728482d8c7d86ef6a2e5c53ee18a39
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
509a7e4628 [apps/on_boarding] Added country to onboarding
Change-Id: I55c50330baf226826e44467756bcd9e5c89d4262
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
a96b5d1bc4 [escher] Typo in StackViewController
Change-Id: I13bdd05759fd2f0bc6911adafe8950e46c2bfe85
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
fe25118d04 [apps/shared] Sorted countries in menu
Country names now appear in alphabetical order in the menu, depending on
the chosen language.

Change-Id: I57b8ce0a7120a3c8a433ce1b05628842c4d0aeb5
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
51747d3d36 [apps/settings] Added country to settings
Refactored Settings::MainController::handleEvent

Change-Id: Id8ad604183a64520dd785356514e87fddc50354c
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
1642276678 [apps/shared] CountryController
Created a CountryController class to chose the country in the settings
and at onboarding.

Change-Id: I6787e8b45744a8a98e83f59e5d2c4760364635cb
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
3f9b8f03af [apps/global_preferences] Added country preference
Change-Id: Ifbe09e2a24b4e1b9386f323bd5ebd9bed7fc8440
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
d156c8c99e [apps/i18n] Added country support
Added a list of supported countries to I18n, and created messages for
each country's names in each language.

Change-Id: I1b887d75da980d99e21f89cc151249e42c78de88
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
87591369b8 [apps/regression] Model stays selected in menu
When opening the window for choosing the regression model, the row
corresponding to the currently selected model will be highlighted.

Change-Id: I65772186fc302c3706a5571f98ecff620e4a8ca9
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
0a7833ec3d [poincare/test] Added 0*inf*π = undef test
Change-Id: Ie18e75c3cfd2a39f8436405f1061ba8fc5317b7f
2020-11-04 15:11:44 +01:00
Gabriel Ozouf
206013f2db [poincare/multiplication] Return Undef early
Multiplication::privateShallowReduce can create an Undef node by
multiplying 0 and inf. In this case, we set the whole multiplication to
undef, to avoid things such as undef*π.
This fixes the following bug :
  - In Graph, enter i*inf*π as one of the bounds. An assertion fails in
    Multiplication::removeUnit.

Change-Id: Ie9d0d561d6e310f52220b98541f22a4b5e56762c
2020-11-04 15:11:44 +01:00
Hugo Saint-Vignes
aa14a6a82e [apps/apps_conainer] Add Home and PowerOn/Off to interrupt computations
Change-Id: I3951cda606760843fb0703864b9da078bf7fd887
2020-11-04 15:11:44 +01:00
Arthur Camouseigt
58b69c2779 [AbsoluteValue] Adding formal derivate to absolute value
This will prevent diff(|x|, x, 0) to be evaluated to 0 instead of undef
This fixes issue #1393
Change-Id: I73f40aa29f04c373cd3e9edbbd4fbe7be6d7a988
2020-11-04 15:11:44 +01:00
Hugo Saint-Vignes
f562886a7e [poincare] Fixed crash due to infinite loop with horizontal layout
Change-Id: I00106525b29ce441e10a6d88766efdecd80d8291
2020-11-04 15:11:44 +01:00
Hugo Saint-Vignes
74a2211a6a [poincare] Use default methods for GCD and LCM instead of n_ary ones
Change-Id: Id353e4367bcb6700bae2f9c121af93b9379a8051
2020-11-04 15:11:44 +01:00
Émilie Feral
ec0e766c94 [apps/graph] text_field_function_title_cell: fix read of uninitialized buffer
This fixes the following crash: when reloading the cell before
initializing the m_textFieldBuffer, TextField::ContentView::text() will
use the content of the uninitialized m_textFieldBuffer to compute the
minimalSizeForOptimalDisplay.
2020-11-04 15:11:44 +01:00
Hugo Saint-Vignes
5b82b94c20 [poincare] Prevent forbidden ChildAtIndex call in fraction_layout
Change-Id: I00d282a6dd3618f669aaeb0202d6495ae8035f12
2020-11-04 15:11:44 +01:00
Arthur Camouseigt
edcc1f6e80 [Poincare/integral_layout.cpp] Fixed crash due to infinite loop
Changed previousNestedIntegral method to prevent integrals located in
integral bounds to be considered as nested.

Change-Id: Id8cc4369f53c278ac59039fde1c2818af2ccacab
2020-11-04 15:11:44 +01:00
Hugo Saint-Vignes
685b2a8d6d [poincare] Reduce Abs layout verticalMargin
Change-Id: I3edacc192b0274d73fd787bb81b0c895e29ddda3
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
2512425868 [poincare] Factorize bracket pair rendering
Change-Id: I80f2d04c8833352f4097bcfdcf90b5ec147dc19f
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
3aa5e8bcd6 [poincare] Add Vector Norm Layout
Change-Id: Iae5bbeabaa0ca627ae6651f187d1a42b970df37d
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
8d2af7e77f [poincare/test] Add VectorOperation tests, tidy rref tests
Change-Id: I4072bee6b2d3bf1ad17045149bff8dcdb6a2f238
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
6db02ea122 [poincare/vectors] Implement Vectors operations
Change-Id: Ib5aa2f5951f4eabe3b04078eab8b7d3a4d3769e7
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
ca91b7c43d [apps/toolbox] Add Vector operation toolbox menus
Change-Id: Iab8faa45a3f30be979f7d705ac169e8f2b801da9
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
8688fd5b95 [apps/shared] Add template for privateEvaluateXYAtParameter
Change-Id: I97b4165307f57e52924e321cb85154cb32ba1008
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
56a9e8d74b [poincare] Fix LCM GCD bug on device compilation
Change-Id: I5ac11b7e72ede335db503b1d0f9c0be00710cd0b
2020-11-04 15:11:43 +01:00
Hugo Saint-Vignes
53e204db3a [liba] Add abs function for int
Change-Id: Ic133ff2f34c7ff24ecbec69d5f31e447a72ae4fe
2020-11-04 15:11:43 +01:00
Arthur Camouseigt
0a92499dd7 [Poincare/unit] Changing the value of AU
The value of astronomical unit was wrong. This fixes issue #1637

Change-Id: I175c8fae9044beb1e863ddbf3a260224a9c60bd6
2020-11-04 15:11:43 +01:00