diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-03-01 12:40:27 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-03-01 12:40:27 -0500 |
| commit | e9e5c21068ab8d92b69d522a752f4362a112242b (patch) | |
| tree | f6ea257ccc6c70e3e5539fc622f604edd50a9a53 /ui.c | |
| parent | ad29f3a56e4db0c56e216cd0b4a0f1bdbcc47ff8 (diff) | |
| download | volute-e9e5c21068ab8d92b69d522a752f4362a112242b.zip | |
reformat MAP when unit changes
Diffstat (limited to 'ui.c')
| -rw-r--r-- | ui.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -24,6 +24,9 @@ static const char *const pressure_units[] = {"mbar", "kPa", "bar", "psi"}; static const PressureMaker pressure_makers[nelem(pressure_units)] = { millibar, kilopascal, bar, psi, }; +static const PressureReader pressure_readers[nelem(pressure_units)] = { + as_millibar, as_kilopascal, as_bar, as_psi, +}; static const char *const volume_flow_rate_units[] = {"m³/s", "CFM"}; static VolumeFlowRateReader volume_flow_rate_readers[nelem(volume_flow_rate_units)] = { @@ -95,6 +98,21 @@ set_map(UI *ui, int idx) { } void +set_map_unit(UI *ui) { + PressureMaker maker; + PressureReader reader; + int i; + Pressure map; + + maker = pressure_makers[ui->map_unit.oldidx]; + reader = pressure_readers[ui->map_unit.idx]; + for (i = 0; i < ui->npoints; i++) { + map = maker(ui->map[i].value); + w_set_field(&ui->map[i], reader(map)); + } +} + +void set_ve(UI *ui, int idx) { ui->points[idx].ve = percent(ui->ve[idx].value); } |