Skip to content

Commit

Permalink
Follow SI notation (#114)
Browse files Browse the repository at this point in the history
* Follow SI notation

Added space between number and unit to follow the rules of the International System of Units notation.

* remove space between quantity and unit for percent and degree units

SI specifies no spaces between units for degree symbol. (see SI Brochure <https://www.bipm.org/en/publications/si-brochure>, 9th ed., 5.4.3)

All major weather websites and apps prefer not to use a space
when the percent unit is present. The Chicago Manual of Style has a FAQ on this which explains the convention and notes this common deviation from SI. <https://www.chicagomanualofstyle.org/qanda/data/faq/topics/Abbreviations/faq0097.html>

---------

Co-authored-by: Luke Marzen <[email protected]>
  • Loading branch information
miohna and lmarzen authored Aug 25, 2024
1 parent 9d9cdf3 commit f91f8bb
Show file tree
Hide file tree
Showing 11 changed files with 69 additions and 29 deletions.
6 changes: 5 additions & 1 deletion platformio/include/_locale.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ extern const char *TXT_UNITS_PRES_MILLIBARS;
extern const char *TXT_UNITS_PRES_ATMOSPHERES;
extern const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER;
extern const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH;
// UNITS - VISIBILITY DISTANCE
// UNIT SYMBOLS - VISIBILITY DISTANCE
extern const char *TXT_UNITS_DIST_KILOMETERS;
extern const char *TXT_UNITS_DIST_MILES;
// UNIT SYMBOLS - PRECIPITATION
extern const char *TXT_UNITS_PRECIP_MILLIMETERS;
extern const char *TXT_UNITS_PRECIP_CENTIMETERS;
extern const char *TXT_UNITS_PRECIP_INCHES;

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_de_DE.inc
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\262";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\262";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_en_GB.inc
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\xB2";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\xB2";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_en_US.inc
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\262";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\262";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_et_EE.inc
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\262";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\262";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_fi_FI.inc
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\262";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\262";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_fr_FR.inc
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\262";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\262";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_it_IT.inc
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\262";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\262";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_nl_BE.inc
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\262";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\262";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
6 changes: 5 additions & 1 deletion platformio/src/locales/locale_pt_BR.inc
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ const char *TXT_UNITS_PRES_MILLIBARS = "mbar";
const char *TXT_UNITS_PRES_ATMOSPHERES = "atm";
const char *TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER = "g/cm\xB2";
const char *TXT_UNITS_PRES_POUNDSPERSQUAREINCH = "lb/in\xB2";
// UNITS - VISIBILITY DISTANCE
// UNITS SYMBOLS - VISIBILITY DISTANCE
const char *TXT_UNITS_DIST_KILOMETERS = "km";
const char *TXT_UNITS_DIST_MILES = "mi";
// UNITS SYMBOLS - PRECIPITATION
const char *TXT_UNITS_PRECIP_MILLIMETERS = "mm";
const char *TXT_UNITS_PRECIP_CENTIMETERS = "cm";
const char *TXT_UNITS_PRECIP_INCHES = "in";

// MISCELLANEOUS MESSAGES
// Title Case
Expand Down
38 changes: 19 additions & 19 deletions platformio/src/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,31 +393,31 @@ void drawCurrentConditions(const owm_current_t &current,
#endif
#ifdef UNITS_SPEED_METERSPERSECOND
dataStr = String(static_cast<int>(std::round(current.wind_speed)));
unitStr = TXT_UNITS_SPEED_METERSPERSECOND;
unitStr = String(" ") + TXT_UNITS_SPEED_METERSPERSECOND;
#endif
#ifdef UNITS_SPEED_FEETPERSECOND
dataStr = String(static_cast<int>(std::round(
meterspersecond_to_feetpersecond(current.wind_speed) )));
unitStr = TXT_UNITS_SPEED_FEETPERSECOND;
unitStr = String(" ") + TXT_UNITS_SPEED_FEETPERSECOND;
#endif
#ifdef UNITS_SPEED_KILOMETERSPERHOUR
dataStr = String(static_cast<int>(std::round(
meterspersecond_to_kilometersperhour(current.wind_speed) )));
unitStr = TXT_UNITS_SPEED_KILOMETERSPERHOUR;
unitStr = String(" ") + TXT_UNITS_SPEED_KILOMETERSPERHOUR;
#endif
#ifdef UNITS_SPEED_MILESPERHOUR
dataStr = String(static_cast<int>(std::round(
meterspersecond_to_milesperhour(current.wind_speed) )));
unitStr = TXT_UNITS_SPEED_MILESPERHOUR;
unitStr = String(" ") + TXT_UNITS_SPEED_MILESPERHOUR;
#endif
#ifdef UNITS_SPEED_KNOTS
dataStr = String(static_cast<int>(std::round(
meterspersecond_to_knots(current.wind_speed) )));
unitStr = TXT_UNITS_SPEED_KNOTS;
unitStr = String(" ") + TXT_UNITS_SPEED_KNOTS;
#endif
#ifdef UNITS_SPEED_BEAUFORT
dataStr = String(meterspersecond_to_beaufort(current.wind_speed));
unitStr = TXT_UNITS_SPEED_BEAUFORT;
unitStr = String(" ") + TXT_UNITS_SPEED_BEAUFORT;
#endif

#ifdef WIND_INDICATOR_ARROW
Expand Down Expand Up @@ -563,46 +563,46 @@ void drawCurrentConditions(const owm_current_t &current,
// pressure
#ifdef UNITS_PRES_HECTOPASCALS
dataStr = String(current.pressure);
unitStr = TXT_UNITS_PRES_HECTOPASCALS;
unitStr = String(" ") + TXT_UNITS_PRES_HECTOPASCALS;
#endif
#ifdef UNITS_PRES_PASCALS
dataStr = String(static_cast<int>(std::round(
hectopascals_to_pascals(current.pressure) )));
unitStr = TXT_UNITS_PRES_PASCALS;
unitStr = String(" ") + TXT_UNITS_PRES_PASCALS;
#endif
#ifdef UNITS_PRES_MILLIMETERSOFMERCURY
dataStr = String(static_cast<int>(std::round(
hectopascals_to_millimetersofmercury(current.pressure) )));
unitStr = TXT_UNITS_PRES_MILLIMETERSOFMERCURY;
unitStr = String(" ") + TXT_UNITS_PRES_MILLIMETERSOFMERCURY;
#endif
#ifdef UNITS_PRES_INCHESOFMERCURY
dataStr = String(std::round(1e1f *
hectopascals_to_inchesofmercury(current.pressure)
) / 1e1f, 1);
unitStr = TXT_UNITS_PRES_INCHESOFMERCURY;
unitStr = String(" ") + TXT_UNITS_PRES_INCHESOFMERCURY;
#endif
#ifdef UNITS_PRES_MILLIBARS
dataStr = String(static_cast<int>(std::round(
hectopascals_to_millibars(current.pressure) )));
unitStr = TXT_UNITS_PRES_MILLIBARS;
unitStr = String(" ") + TXT_UNITS_PRES_MILLIBARS;
#endif
#ifdef UNITS_PRES_ATMOSPHERES
dataStr = String(std::round(1e3f *
hectopascals_to_atmospheres(current.pressure) )
/ 1e3f, 3);
unitStr = TXT_UNITS_PRES_ATMOSPHERES;
unitStr = String(" ") + TXT_UNITS_PRES_ATMOSPHERES;
#endif
#ifdef UNITS_PRES_GRAMSPERSQUARECENTIMETER
dataStr = String(static_cast<int>(std::round(
hectopascals_to_gramspersquarecentimeter(current.pressure)
)));
unitStr = TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER;
unitStr = String(" ") + TXT_UNITS_PRES_GRAMSPERSQUARECENTIMETER;
#endif
#ifdef UNITS_PRES_POUNDSPERSQUAREINCH
dataStr = String(std::round(1e2f *
hectopascals_to_poundspersquareinch(current.pressure)
) / 1e2f, 2);
unitStr = TXT_UNITS_PRES_POUNDSPERSQUAREINCH;
unitStr = String(" ") + TXT_UNITS_PRES_POUNDSPERSQUAREINCH;
#endif
display.setFont(&FONT_12pt8b);
drawString(170 + 48, 204 + 17 / 2 + (48 + 8) * 2 + 48 / 2, dataStr, LEFT);
Expand All @@ -615,11 +615,11 @@ void drawCurrentConditions(const owm_current_t &current,
display.setFont(&FONT_12pt8b);
#ifdef UNITS_DIST_KILOMETERS
float vis = meters_to_kilometers(current.visibility);
unitStr = TXT_UNITS_DIST_KILOMETERS;
unitStr = String(" ") + TXT_UNITS_DIST_KILOMETERS;
#endif
#ifdef UNITS_DIST_MILES
float vis = meters_to_miles(current.visibility);
unitStr = TXT_UNITS_DIST_MILES;
unitStr = String(" ") + TXT_UNITS_DIST_MILES;
#endif
// if visibility is less than 1.95, round to 1 decimal place
// else round to int
Expand Down Expand Up @@ -728,19 +728,19 @@ void drawForecast(owm_daily_t *const daily, tm timeInfo)
// Round up to nearest mm
dailyPrecip = std::round(dailyPrecip);
dataStr = String(static_cast<int>(dailyPrecip));
unitStr = "mm";
unitStr = String(" ") + TXT_UNITS_PRECIP_MILLIMETERS;
#elif defined(UNITS_DAILY_PRECIP_CENTIMETERS)
// Round up to nearest 0.1 cm
dailyPrecip = millimeters_to_centimeters(dailyPrecip);
dailyPrecip = std::round(dailyPrecip * 10) / 10.0f;
dataStr = String(dailyPrecip, 1);
unitStr = "cm";
unitStr = String(" ") + TXT_UNITS_PRECIP_CENTIMETERS;
#elif defined(UNITS_DAILY_PRECIP_INCHES)
// Round up to nearest 0.1 inch
dailyPrecip = millimeters_to_inches(dailyPrecip);
dailyPrecip = std::round(dailyPrecip * 10) / 10.0f;
dataStr = String(dailyPrecip, 1);
unitStr = "in";
unitStr = String(" ") + TXT_UNITS_PRECIP_INCHES;
#endif
#endif
#if (DISPLAY_DAILY_PRECIP == 2) // smart
Expand Down

0 comments on commit f91f8bb

Please sign in to comment.