diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-03-02 12:18:34 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-03-02 12:18:34 -0500 |
| commit | cd73fd40ffc04a65abe0260fe82949d7c354e282 (patch) | |
| tree | 5162949c3f3e65508072eacb52f3b1c562958607 | |
| parent | 5e379b1cf70006dbe782df991a655c475630a146 (diff) | |
| download | volute-cd73fd40ffc04a65abe0260fe82949d7c354e282.zip | |
add inHG pressure unit
| -rw-r--r-- | test.c | 2 | ||||
| -rw-r--r-- | test.h | 2 | ||||
| -rw-r--r-- | test_pressure.c | 10 | ||||
| -rw-r--r-- | ui.c | 6 | ||||
| -rw-r--r-- | unit.c | 10 | ||||
| -rw-r--r-- | unit.h | 2 |
6 files changed, 29 insertions, 3 deletions
@@ -17,11 +17,13 @@ main(void) { test_kilopascal(); test_bar(); test_psi(); + test_inch_mercury(); test_as_pascal(); test_as_millibar(); test_as_kilopascal(); test_as_bar(); test_as_psi(); + test_as_inch_mercury(); test_kelvin(); test_celsius(); @@ -23,11 +23,13 @@ void test_millibar(void); void test_kilopascal(void); void test_bar(void); void test_psi(void); +void test_inch_mercury(void); void test_as_pascal(void); void test_as_millibar(void); void test_as_kilopascal(void); void test_as_bar(void); void test_as_psi(void); +void test_as_inch_mercury(void); void test_kelvin(void); void test_celsius(void); diff --git a/test_pressure.c b/test_pressure.c index f04a1bc..e805858 100644 --- a/test_pressure.c +++ b/test_pressure.c @@ -30,6 +30,11 @@ test_psi(void) { } void +test_inch_mercury(void) { + test(inch_mercury(123.456), 418070.040384); +} + +void test_as_pascal(void) { test(as_pascal(pascal(123.456)), 123.456); } @@ -53,3 +58,8 @@ void test_as_psi(void) { test(as_psi(psi(123.456)), 123.456); } + +void +test_as_inch_mercury(void) { + test(as_inch_mercury(inch_mercury(123.456)), 123.456); +} @@ -37,12 +37,12 @@ static const TemperatureReader temperature_readers[nelem(temperature_units)] = { as_celsius, as_kelvin, as_fahrenheit, as_rankine, }; -static const char *const pressure_units[] = {"mbar", "kPa", "bar", "psi"}; +static const char *const pressure_units[] = {"mbar", "kPa", "bar", "psi", "inHG"}; static const PressureMaker pressure_makers[nelem(pressure_units)] = { - millibar, kilopascal, bar, psi, + millibar, kilopascal, bar, psi, inch_mercury, }; static const PressureReader pressure_readers[nelem(pressure_units)] = { - as_millibar, as_kilopascal, as_bar, as_psi, + as_millibar, as_kilopascal, as_bar, as_psi, as_inch_mercury, }; static const char *const volume_flow_rate_units[] = {"m³/s", "CFM"}; @@ -85,6 +85,11 @@ psi(double x) { return x * KG_PER_LB * G / pow(M_PER_IN, 2); } +Pressure +inch_mercury(double x) { + return x * 3386.389; +} + double as_pascal(Pressure x) { return x; @@ -110,6 +115,11 @@ as_psi(Pressure x) { return x * pow(M_PER_IN, 2) / (KG_PER_LB * G); } +double +as_inch_mercury(Pressure x) { + return x / 3386.389; +} + Temperature kelvin(double x) { @@ -27,11 +27,13 @@ Pressure millibar(double x); Pressure kilopascal(double x); Pressure bar(double x); Pressure psi(double x); +Pressure inch_mercury(double x); double as_pascal(Pressure x); double as_millibar(Pressure x); double as_kilopascal(Pressure x); double as_bar(Pressure x); double as_psi(Pressure x); +double as_inch_mercury(Pressure x); typedef double Temperature; |