diff --git a/apps/math_toolbox.cpp b/apps/math_toolbox.cpp index 852459638..ae33aa01c 100644 --- a/apps/math_toolbox.cpp +++ b/apps/math_toolbox.cpp @@ -143,6 +143,8 @@ const ToolboxMessageTree unitMassGramChildren[] = { const ToolboxMessageTree unitMassImperialChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::UnitMassPoundSymbol, I18n::Message::UnitMassPound), ToolboxMessageTree::Leaf(I18n::Message::UnitMassOunceSymbol, I18n::Message::UnitMassOunce), + ToolboxMessageTree::Leaf(I18n::Message::UnitMassShortTonSymbol, I18n::Message::UnitMassShortTon), + ToolboxMessageTree::Leaf(I18n::Message::UnitMassLongTonSymbol, I18n::Message::UnitMassLongTon) }; const ToolboxMessageTree unitMassChildren[] = { diff --git a/apps/shared.universal.i18n b/apps/shared.universal.i18n index 68b7a3e3f..0ffd90a84 100644 --- a/apps/shared.universal.i18n +++ b/apps/shared.universal.i18n @@ -29,7 +29,8 @@ UnitMassGramNanoSymbol = "_ng" UnitMassTonneSymbol = "_t" UnitMassOunceSymbol = "_oz" UnitMassPoundSymbol = "_lb" -UnitMassShortTonSymbol = "_ton" +UnitMassShortTonSymbol = "_shtn" +UnitMassLongTonSymbol = "_lgtn" UnitCurrentAmpereSymbol = "_A" UnitCurrentAmpereMilliSymbol = "_mA" UnitCurrentAmpereMicroSymbol = "_μA" diff --git a/apps/toolbox.de.i18n b/apps/toolbox.de.i18n index 16359e367..bba947d96 100644 --- a/apps/toolbox.de.i18n +++ b/apps/toolbox.de.i18n @@ -36,6 +36,7 @@ UnitMassTonne = "Tonne" UnitMassOunce = "Ounce" UnitMassPound = "Pound" UnitMassShortTon = "Short Ton" +UnitMassLongTon = "Long Ton" UnitCurrentMenu = "Elektrischer Strom" UnitCurrentAmpere = "Ampere" UnitCurrentAmpereMilli = "Milliampere" diff --git a/apps/toolbox.en.i18n b/apps/toolbox.en.i18n index af73af4da..2b55b9276 100644 --- a/apps/toolbox.en.i18n +++ b/apps/toolbox.en.i18n @@ -36,6 +36,7 @@ UnitMassTonne = "Tonne" UnitMassOunce = "Ounce" UnitMassPound = "Pound" UnitMassShortTon = "Short Ton" +UnitMassLongTon = "Long Ton" UnitCurrentMenu = "Electric current" UnitCurrentAmpere = "Ampere" UnitCurrentAmpereMilli = "Milliampere" diff --git a/apps/toolbox.es.i18n b/apps/toolbox.es.i18n index 549aaef5a..8e7b57a3e 100644 --- a/apps/toolbox.es.i18n +++ b/apps/toolbox.es.i18n @@ -36,6 +36,7 @@ UnitMassTonne = "Tonne" UnitMassOunce = "Ounce" UnitMassPound = "Pound" UnitMassShortTon = "Short Ton" +UnitMassLongTon = "Long Ton" UnitCurrentMenu = "Electric current" UnitCurrentAmpere = "Ampere" UnitCurrentAmpereMilli = "Milliampere" diff --git a/apps/toolbox.fr.i18n b/apps/toolbox.fr.i18n index 425159d40..e1c891a60 100644 --- a/apps/toolbox.fr.i18n +++ b/apps/toolbox.fr.i18n @@ -36,6 +36,7 @@ UnitMassTonne = "Tonne" UnitMassOunce = "Ounce" UnitMassPound = "Pound" UnitMassShortTon = "Short Ton" +UnitMassLongTon = "Long Ton" UnitCurrentMenu = "Intensité du courant électrique" UnitCurrentAmpere = "Ampère" UnitCurrentAmpereMilli = "Milliampère" diff --git a/apps/toolbox.it.i18n b/apps/toolbox.it.i18n index eabeccbc1..1de9c5990 100644 --- a/apps/toolbox.it.i18n +++ b/apps/toolbox.it.i18n @@ -36,6 +36,7 @@ UnitMassTonne = "Tonnellata" UnitMassOunce = "Ounce" UnitMassPound = "Pound" UnitMassShortTon = "Short Ton" +UnitMassLongTon = "Long Ton" UnitCurrentMenu = "Intensità di corrente elettrica" UnitCurrentAmpere = "Ampere" UnitCurrentAmpereMilli = "Milliampere" diff --git a/apps/toolbox.nl.i18n b/apps/toolbox.nl.i18n index ce8da3c1c..a31ece722 100644 --- a/apps/toolbox.nl.i18n +++ b/apps/toolbox.nl.i18n @@ -36,6 +36,7 @@ UnitMassTonne = "Ton" UnitMassOunce = "Ounce" UnitMassPound = "Pound" UnitMassShortTon = "Short Ton" +UnitMassLongTon = "Long Ton" UnitCurrentMenu = "Elektrische stroom" UnitCurrentAmpere = "Ampère" UnitCurrentAmpereMilli = "Milliampère" diff --git a/apps/toolbox.pt.i18n b/apps/toolbox.pt.i18n index 64df135f5..f99af1d5a 100644 --- a/apps/toolbox.pt.i18n +++ b/apps/toolbox.pt.i18n @@ -36,6 +36,7 @@ UnitMassTonne = "Tonelada" UnitMassOunce = "Ounce" UnitMassPound = "Pound" UnitMassShortTon = "Short Ton" +UnitMassLongTon = "Long Ton" UnitCurrentMenu = "Intensidade da corrente elétrica" UnitCurrentAmpere = "Ampere" UnitCurrentAmpereMilli = "Miliampere" diff --git a/poincare/include/poincare/unit.h b/poincare/include/poincare/unit.h index 2360fcf2b..853e269a0 100644 --- a/poincare/include/poincare/unit.h +++ b/poincare/include/poincare/unit.h @@ -349,10 +349,14 @@ public: Representative::Prefixable::No, NoPrefix, Representative::OutputSystem::Imperial), - Representative("ton", "2000*_lb", + Representative("shtn", "2000*_lb", Representative::Prefixable::No, NoPrefix, Representative::OutputSystem::Imperial), + Representative("lgtn", "2240*_lb", + Representative::Prefixable::No, + NoPrefix, + Representative::OutputSystem::None), }, CurrentRepresentatives[] = { Representative("A", nullptr, @@ -513,9 +517,10 @@ public: static const Representative constexpr * MileRepresentative = &DistanceRepresentatives[7]; static const Representative constexpr * KilogramRepresentative = &MassRepresentatives[0]; static const Representative constexpr * GramRepresentative = &MassRepresentatives[1]; - static_assert(sizeof(MassRepresentatives)/sizeof(Representative) == 7, "The Unit::OunceRepresentative et al. might require to be fixed if the MassRepresentatives table was changed."); + static_assert(sizeof(MassRepresentatives)/sizeof(Representative) == 8, "The Unit::OunceRepresentative et al. might require to be fixed if the MassRepresentatives table was changed."); static const Representative constexpr * OunceRepresentative = &MassRepresentatives[4]; static const Representative constexpr * PoundRepresentative = &MassRepresentatives[5]; + static const Representative constexpr * ShortTonRepresentative = &MassRepresentatives[6]; static const Representative constexpr * LiterRepresentative = &VolumeRepresentatives[0]; static_assert(sizeof(VolumeRepresentatives)/sizeof(Representative) == 8, "The Unit::FluidOunceRepresentative et al. might require to be fixed if the VolumeRepresentatives table was changed."); static const Representative constexpr * FluidOunceRepresentative = &VolumeRepresentatives[3]; @@ -867,6 +872,7 @@ public: static Unit Gram() { return Builder(MassDimension, GramRepresentative, &EmptyPrefix); } static Unit Ounce() { return Builder(MassDimension, OunceRepresentative, &EmptyPrefix); } static Unit Pound() { return Builder(MassDimension, PoundRepresentative, &EmptyPrefix); } + static Unit ShortTon() { return Builder(MassDimension, ShortTonRepresentative, &EmptyPrefix); } static Unit FluidOunce() { return Builder(VolumeDimension, FluidOunceRepresentative, &EmptyPrefix); } static Unit Cup() { return Builder(VolumeDimension, CupRepresentative, &EmptyPrefix); } static Unit Gallon() { return Builder(VolumeDimension, GallonRepresentative, &EmptyPrefix); } @@ -915,6 +921,7 @@ private: static constexpr double FeetPerYard = 3.; static constexpr double YardsPerMile = 1760.; static constexpr double OuncesPerPound = 16.; + static constexpr double PoundsPerShortTon = 2000.; static constexpr double FluidOuncesPerCup = 8.; static constexpr double CupsPerGallon = 16.; UnitNode * node() const { return static_cast(Expression::node()); } diff --git a/poincare/src/unit.cpp b/poincare/src/unit.cpp index 069cde29b..12fc5b77f 100644 --- a/poincare/src/unit.cpp +++ b/poincare/src/unit.cpp @@ -589,9 +589,9 @@ Expression Unit::BuildImperialDistanceSplit(double inches, Context * context) { } Expression Unit::BuildImperialMassSplit(double ounces, Context * context) { - constexpr static int numberOfUnits = 2; - Unit units[numberOfUnits] = {Unit::Pound(), Unit::Ounce()}; - constexpr static double factors[numberOfUnits] = {OuncesPerPound, 1.}; + constexpr static int numberOfUnits = 3; + Unit units[numberOfUnits] = {Unit::ShortTon(), Unit::Pound(), Unit::Ounce()}; + constexpr static double factors[numberOfUnits] = {OuncesPerPound*PoundsPerShortTon, OuncesPerPound, 1.}; return BuildSplit(ounces, units, factors, numberOfUnits, context); }