From e6ed1e5dbd41e95190f5015e2c5b2aeaa88e0efb Mon Sep 17 00:00:00 2001 From: ulteq Date: Fri, 15 May 2015 19:00:11 +0200 Subject: [PATCH 01/14] Added utility functions to calculate heat index and wind chill --- addons/weather/XEH_preInit.sqf | 2 ++ .../functions/fnc_calculateHeatIndex.sqf | 23 +++++++++++++++++++ .../functions/fnc_calculateWindChill.sqf | 22 ++++++++++++++++++ addons/weather/script_component.hpp | 11 +++++++++ 4 files changed, 58 insertions(+) create mode 100644 addons/weather/functions/fnc_calculateHeatIndex.sqf create mode 100644 addons/weather/functions/fnc_calculateWindChill.sqf diff --git a/addons/weather/XEH_preInit.sqf b/addons/weather/XEH_preInit.sqf index 85166ce356..453c7e57b4 100644 --- a/addons/weather/XEH_preInit.sqf +++ b/addons/weather/XEH_preInit.sqf @@ -5,8 +5,10 @@ ADDON = false; PREP(calculateAirDensity); PREP(calculateBarometricPressure); +PREP(calculateHeatIndex); PREP(calculateRoughnessLength); PREP(calculateTemperatureAtHeight); +PREP(calculateWindChill); PREP(calculateWindSpeed); PREP(displayWindInfo); PREP(getMapData); diff --git a/addons/weather/functions/fnc_calculateHeatIndex.sqf b/addons/weather/functions/fnc_calculateHeatIndex.sqf new file mode 100644 index 0000000000..4515a85a7a --- /dev/null +++ b/addons/weather/functions/fnc_calculateHeatIndex.sqf @@ -0,0 +1,23 @@ +/* + * Author: Ruthberg + * + * Calculates heat index based on temperature and humidity + * + * Arguments: + * 0: temperature - degrees celcius + * 2: relativeHumidity - value between 0.0 and 1.0 + * + * Return Value: + * 0: heat index + * + * Return value: + * None + */ +#include "script_component.hpp" + +PARAMS_2(_t, _rh); + +_rh = _rh * 100; // relative humidity in % + +// Source: https://en.wikipedia.org/wiki/Heat_index +(__C1 + __C2 * _t + __C3 * _rh + __C4 * _t * _rh + __C5 * _t^2 + __C6 * _rh^2 + __C7 * _t^2 * _rh + __C8 * _t * _rh^2 + __C9 * _t^2 * _rh^2) diff --git a/addons/weather/functions/fnc_calculateWindChill.sqf b/addons/weather/functions/fnc_calculateWindChill.sqf new file mode 100644 index 0000000000..0eb63e9701 --- /dev/null +++ b/addons/weather/functions/fnc_calculateWindChill.sqf @@ -0,0 +1,22 @@ +/* + * Author: Ruthberg + * + * Calculates wind chill based on temperature and wind speed + * + * Arguments: + * 0: temperature - degrees celcius + * 2: wind speed - m/s + * + * Return Value: + * 0: wind chill + * + * Public: No + */ +#include "script_component.hpp" + +PARAMS_2(_t, _v); + +_v = _v * 3,6; // wind speed in km/h + +// Source: https://en.wikipedia.org/wiki/Wind_chill +(13.12 + 0.06215 * _t - 11.37 * _v ^ 0.16 + 0.3965 * _t * _v^0.16) diff --git a/addons/weather/script_component.hpp b/addons/weather/script_component.hpp index edc1ac64d0..e5a7a74f39 100644 --- a/addons/weather/script_component.hpp +++ b/addons/weather/script_component.hpp @@ -18,3 +18,14 @@ #define WATER_VAPOR_MOLAR_MASS 0.018016 #define DRY_AIR_MOLAR_MASS 0.028964 #define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058 + +// Heat index coefficients +#define __C1 −8.784695 +#define __C2 1.61139411 +#define __C3 2.338549 +#define __C4 −0.14611605 +#define __C5 −1.2308094 · 10^(−2) +#define __C6 −1.6424828 · 10^(−2) +#define __C7 2.211732 · 10^(−3) +#define __C8 7.2546 · 10^(−4) +#define __C9 −3.582 · 10^(−6) From 2f7d7ece568c0cc7a8366d50bb42e6cd0a186028 Mon Sep 17 00:00:00 2001 From: ulteq Date: Fri, 15 May 2015 19:58:24 +0200 Subject: [PATCH 02/14] Added utility function to calculate the dew point --- addons/weather/XEH_preInit.sqf | 1 + .../functions/fnc_calculateDewPoint.sqf | 27 +++++++++++++++++++ .../functions/fnc_calculateHeatIndex.sqf | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 addons/weather/functions/fnc_calculateDewPoint.sqf diff --git a/addons/weather/XEH_preInit.sqf b/addons/weather/XEH_preInit.sqf index 453c7e57b4..a6fec1e77e 100644 --- a/addons/weather/XEH_preInit.sqf +++ b/addons/weather/XEH_preInit.sqf @@ -5,6 +5,7 @@ ADDON = false; PREP(calculateAirDensity); PREP(calculateBarometricPressure); +PREP(calculateDewPoint); PREP(calculateHeatIndex); PREP(calculateRoughnessLength); PREP(calculateTemperatureAtHeight); diff --git a/addons/weather/functions/fnc_calculateDewPoint.sqf b/addons/weather/functions/fnc_calculateDewPoint.sqf new file mode 100644 index 0000000000..81d4c03a7c --- /dev/null +++ b/addons/weather/functions/fnc_calculateDewPoint.sqf @@ -0,0 +1,27 @@ +/* + * Author: Ruthberg + * + * Calculates dew point based on temperature and relative humidity + * + * Arguments: + * 0: temperature - degrees celcius + * 2: relativeHumidity - value between 0.0 and 1.0 + * + * Return Value: + * 0: heat index + * + * Return value: + * None + */ +#include "script_component.hpp" + +#define __b 17.67 +#define __c 243.5 + +PARAMS_2(_t, _rh); + +// Source: https://en.wikipedia.org/wiki/Dew_point +private ["_gamma"]; +_gamma = ln(_rh) + (__b * _t) / (__c + _t); + +(__c * _gamma) / (__b - _gamma) diff --git a/addons/weather/functions/fnc_calculateHeatIndex.sqf b/addons/weather/functions/fnc_calculateHeatIndex.sqf index 4515a85a7a..8b54f4e6a0 100644 --- a/addons/weather/functions/fnc_calculateHeatIndex.sqf +++ b/addons/weather/functions/fnc_calculateHeatIndex.sqf @@ -1,7 +1,7 @@ /* * Author: Ruthberg * - * Calculates heat index based on temperature and humidity + * Calculates heat index based on temperature and relative humidity * * Arguments: * 0: temperature - degrees celcius From 7f966de28c03783d81476d4e2ddc725274dfb864 Mon Sep 17 00:00:00 2001 From: ulteq Date: Fri, 15 May 2015 21:10:46 +0200 Subject: [PATCH 03/14] Added wet bulb calculation, fixed macros --- addons/weather/XEH_preInit.sqf | 1 + .../functions/fnc_calculateAirDensity.sqf | 2 +- .../functions/fnc_calculateDewPoint.sqf | 4 ++-- .../functions/fnc_calculateHeatIndex.sqf | 2 +- .../functions/fnc_calculateWetBulb.sqf | 19 +++++++++++++++++++ .../functions/fnc_calculateWindChill.sqf | 2 +- 6 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 addons/weather/functions/fnc_calculateWetBulb.sqf diff --git a/addons/weather/XEH_preInit.sqf b/addons/weather/XEH_preInit.sqf index a6fec1e77e..2a6487f51c 100644 --- a/addons/weather/XEH_preInit.sqf +++ b/addons/weather/XEH_preInit.sqf @@ -9,6 +9,7 @@ PREP(calculateDewPoint); PREP(calculateHeatIndex); PREP(calculateRoughnessLength); PREP(calculateTemperatureAtHeight); +PREP(calculateWetBulb); PREP(calculateWindChill); PREP(calculateWindSpeed); PREP(displayWindInfo); diff --git a/addons/weather/functions/fnc_calculateAirDensity.sqf b/addons/weather/functions/fnc_calculateAirDensity.sqf index b30e0c4e01..921bff3bf3 100644 --- a/addons/weather/functions/fnc_calculateAirDensity.sqf +++ b/addons/weather/functions/fnc_calculateAirDensity.sqf @@ -16,7 +16,7 @@ */ #include "script_component.hpp" -PARAMS_3(_temperature, _pressure, _relativeHumidity); +PARAMS_3(_temperature,_pressure,_relativeHumidity); _pressure = _pressure * 100; // hPa to Pa diff --git a/addons/weather/functions/fnc_calculateDewPoint.sqf b/addons/weather/functions/fnc_calculateDewPoint.sqf index 81d4c03a7c..750b384ea0 100644 --- a/addons/weather/functions/fnc_calculateDewPoint.sqf +++ b/addons/weather/functions/fnc_calculateDewPoint.sqf @@ -8,7 +8,7 @@ * 2: relativeHumidity - value between 0.0 and 1.0 * * Return Value: - * 0: heat index + * 0: dew point * * Return value: * None @@ -18,7 +18,7 @@ #define __b 17.67 #define __c 243.5 -PARAMS_2(_t, _rh); +PARAMS_2(_t,_rh); // Source: https://en.wikipedia.org/wiki/Dew_point private ["_gamma"]; diff --git a/addons/weather/functions/fnc_calculateHeatIndex.sqf b/addons/weather/functions/fnc_calculateHeatIndex.sqf index 8b54f4e6a0..4605213e24 100644 --- a/addons/weather/functions/fnc_calculateHeatIndex.sqf +++ b/addons/weather/functions/fnc_calculateHeatIndex.sqf @@ -15,7 +15,7 @@ */ #include "script_component.hpp" -PARAMS_2(_t, _rh); +PARAMS_2(_t,_rh); _rh = _rh * 100; // relative humidity in % diff --git a/addons/weather/functions/fnc_calculateWetBulb.sqf b/addons/weather/functions/fnc_calculateWetBulb.sqf new file mode 100644 index 0000000000..c044c2ed57 --- /dev/null +++ b/addons/weather/functions/fnc_calculateWetBulb.sqf @@ -0,0 +1,19 @@ +/* + * Author: Ruthberg + * + * Calculates wet bulb based on temperature and relative humidity + * + * Arguments: + * + * + * Return Value: + * 0: wet bulb + * + * Return value: + * None + */ +#include "script_component.hpp" + +// TODO: ... + +GVAR(currentTemperature) diff --git a/addons/weather/functions/fnc_calculateWindChill.sqf b/addons/weather/functions/fnc_calculateWindChill.sqf index 0eb63e9701..04e26013d7 100644 --- a/addons/weather/functions/fnc_calculateWindChill.sqf +++ b/addons/weather/functions/fnc_calculateWindChill.sqf @@ -14,7 +14,7 @@ */ #include "script_component.hpp" -PARAMS_2(_t, _v); +PARAMS_2(_t,_v); _v = _v * 3,6; // wind speed in km/h From ef225b366bfa0c61f20ac3d6b4e9de3a44fe833d Mon Sep 17 00:00:00 2001 From: ulteq Date: Fri, 15 May 2015 21:11:03 +0200 Subject: [PATCH 04/14] Kestrel GUI expansion --- addons/kestrel4500/XEH_postInit.sqf | 2 +- .../functions/fnc_generateOutputData.sqf | 74 ++++++++++++++++--- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/addons/kestrel4500/XEH_postInit.sqf b/addons/kestrel4500/XEH_postInit.sqf index eb22aa1de2..22465bc4e0 100644 --- a/addons/kestrel4500/XEH_postInit.sqf +++ b/addons/kestrel4500/XEH_postInit.sqf @@ -2,7 +2,7 @@ #include "initKeybinds.sqf" -GVAR(Menus) = ["Direction", "Wind SPD m/s", "CROSSWIND m/s", "HEADWIND m/s", "TEMP °C", "HUMIDITY %", "BARO hPA", "ALTITUDE m", "User Screen 1", "User Screen 2"]; +GVAR(Menus) = ["Direction", "Wind SPD m/s", "CROSSWIND m/s", "HEADWIND m/s", "TEMP °C", "CHILL °C", "HUMIDITY %", "HEAT INDEX °C", "DEW POINT °C", "WET BULB °C", "BARO hPA", "ALTITUDE m", "User Screen 1", "User Screen 2"]; GVAR(TOTAL) = [0, 0, 0, 0, 0, 0, 0, 0]; GVAR(ENTRIES) = [0, 0, 0, 0, 0, 0, 0, 0]; diff --git a/addons/kestrel4500/functions/fnc_generateOutputData.sqf b/addons/kestrel4500/functions/fnc_generateOutputData.sqf index 1549bbe9cb..c0f8a83146 100644 --- a/addons/kestrel4500/functions/fnc_generateOutputData.sqf +++ b/addons/kestrel4500/functions/fnc_generateOutputData.sqf @@ -14,7 +14,7 @@ */ #include "script_component.hpp" -private ["_playerDir", "_textTop", "_textCenterBig", "_textCenterLine1Left", "_textCenterLine2Left", "_textCenterLine3Left", "_textCenterLine1Right", "_textCenterLine2Right", "_textCenterLine3Right", "_textInfoLine1", "_textInfoLine2", "_temperature", "_humidity", "_windSpeed", "_windDir"]; +private ["_playerDir", "_textTop", "_textCenterBig", "_textCenterLine1Left", "_textCenterLine2Left", "_textCenterLine3Left", "_textCenterLine1Right", "_textCenterLine2Right", "_textCenterLine3Right", "_textInfoLine1", "_textInfoLine2", "_temperature", "_chill", "_humidity", "_heatIndex", "_dewPoint", "_wetBulb", "_windSpeed", "_windDir"]; [] call FUNC(collectData); @@ -39,6 +39,10 @@ _playerAltitude = (getPosASL ACE_player) select 2; _temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); _humidity = EGVAR(weather,currentHumidity); +_chill = [_temperature, _humidity] call EFUNC(weather,calculateWindChill); +_heatIndex = [_temperature, _humidity] call EFUNC(weather,calculateHeatIndex); +_dewPoint = [_temperature, _humidity] call EFUNC(weather,calculateDewPoint); +_wetBulb = [_temperature, _humidity] call EFUNC(weather,calculateWetBulb); GVAR(Direction) = 4 * floor(_playerDir / 90); if (_playerDir % 90 > 10) then { GVAR(Direction) = GVAR(Direction) + 1}; @@ -161,9 +165,9 @@ switch (GVAR(Menu)) do { _textCenterLine3Right = Str(round((GVAR(Max) select 4) * 10) / 10); }; }; - case 5: { // HUMIDITY + case 5: { // CHILL if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(_humidity * 100 * 10) / 10); + _textCenterBig = Str(round(_chill * 10) / 10); } else { _textCenterLine1Left = "Min"; _textCenterLine2Left = "Avg"; @@ -173,9 +177,9 @@ switch (GVAR(Menu)) do { _textCenterLine3Right = Str(round((GVAR(Max) select 5) * 10) / 10); }; }; - case 6: { // BARO + case 6: { // HUMIDITY if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); + _textCenterBig = Str(round(_humidity * 100 * 10) / 10); } else { _textCenterLine1Left = "Min"; _textCenterLine2Left = "Avg"; @@ -185,19 +189,67 @@ switch (GVAR(Menu)) do { _textCenterLine3Right = Str(round((GVAR(Max) select 6) * 10) / 10); }; }; - case 7: { // ALTITUDE + case 7: { // HEAT INDEX + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_heatIndex * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 7) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 7) / (GVAR(Entries) select 7) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 7) * 10) / 10); + }; + }; + case 8: { // DEW POINT + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_dewPoint * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 8) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 8) / (GVAR(Entries) select 8) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 8) * 10) / 10); + }; + }; + case 9: { // WET BULB + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_wetBulb * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 9) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 9) / (GVAR(Entries) select 9) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 9) * 10) / 10); + }; + }; + case 10: { // BARO + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 10) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 10) / (GVAR(Entries) select 10) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 10) * 10) / 10); + }; + }; + case 11: { // ALTITUDE if (!GVAR(MinAvgMax)) then { _textCenterBig = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); } else { _textCenterLine1Left = "Min"; _textCenterLine2Left = "Avg"; _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round(GVAR(Min) select 7)); - _textCenterLine2Right = Str(round((GVAR(Total) select 7) / (GVAR(Entries) select 7))); - _textCenterLine3Right = Str(round(GVAR(Max) select 7)); + _textCenterLine1Right = Str(round(GVAR(Min) select 11)); + _textCenterLine2Right = Str(round((GVAR(Total) select 11) / (GVAR(Entries) select 11))); + _textCenterLine3Right = Str(round(GVAR(Max) select 11)); }; }; - case 8: { // User Screen 1 + case 12: { // User Screen 1 _textCenterLine1Left = Str(round(_playerDir)); _textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); _textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10); @@ -205,7 +257,7 @@ switch (GVAR(Menu)) do { _textCenterLine2Right = "m"; _textCenterLine3Right = "m/s"; }; - case 9: { // User Screen 2 + case 13: { // User Screen 2 _textCenterLine1Left = Str(round(_temperature * 10) / 10); _textCenterLine2Left = Str(round(_humidity * 100 * 10) / 10); _textCenterLine3Left = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); From 56eecfda034867ea32a1503b0f7f82b39dc67678 Mon Sep 17 00:00:00 2001 From: ulteq Date: Fri, 15 May 2015 21:41:07 +0200 Subject: [PATCH 05/14] Fixed heat index coefficients syntax --- addons/weather/script_component.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/weather/script_component.hpp b/addons/weather/script_component.hpp index e5a7a74f39..bd7270d30b 100644 --- a/addons/weather/script_component.hpp +++ b/addons/weather/script_component.hpp @@ -24,8 +24,8 @@ #define __C2 1.61139411 #define __C3 2.338549 #define __C4 −0.14611605 -#define __C5 −1.2308094 · 10^(−2) -#define __C6 −1.6424828 · 10^(−2) -#define __C7 2.211732 · 10^(−3) -#define __C8 7.2546 · 10^(−4) -#define __C9 −3.582 · 10^(−6) +#define __C5 −0.012308094 +#define __C6 −0.016424828 +#define __C7 0.002211732 +#define __C8 0.00072546 +#define __C9 -0.000003582 From 8b878552cbebff19c721298d4f6dfb4aedebd387 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 00:51:53 +0200 Subject: [PATCH 06/14] Fixed several typos in the heat index coefficients --- addons/weather/script_component.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/weather/script_component.hpp b/addons/weather/script_component.hpp index bd7270d30b..bf16255590 100644 --- a/addons/weather/script_component.hpp +++ b/addons/weather/script_component.hpp @@ -20,12 +20,12 @@ #define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058 // Heat index coefficients -#define __C1 −8.784695 +#define __C1 -8.784695 #define __C2 1.61139411 #define __C3 2.338549 -#define __C4 −0.14611605 -#define __C5 −0.012308094 -#define __C6 −0.016424828 +#define __C4 -0.14611605 +#define __C5 -0.012308094 +#define __C6 -0.016424828 #define __C7 0.002211732 #define __C8 0.00072546 #define __C9 -0.000003582 From 0377526a7c9941b6be54d9315258dc669e38256c Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 11:12:29 +0200 Subject: [PATCH 07/14] Finished heat index and wet bulb functions --- .../functions/fnc_calculateHeatIndex.sqf | 10 +++++++ .../functions/fnc_calculateWetBulb.sqf | 28 +++++++++++++++++-- addons/weather/script_component.hpp | 11 -------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/addons/weather/functions/fnc_calculateHeatIndex.sqf b/addons/weather/functions/fnc_calculateHeatIndex.sqf index 4605213e24..95060bd0a2 100644 --- a/addons/weather/functions/fnc_calculateHeatIndex.sqf +++ b/addons/weather/functions/fnc_calculateHeatIndex.sqf @@ -15,6 +15,16 @@ */ #include "script_component.hpp" +#define __C1 -8.784695 +#define __C2 1.61139411 +#define __C3 2.338549 +#define __C4 -0.14611605 +#define __C5 -0.012308094 +#define __C6 -0.016424828 +#define __C7 0.002211732 +#define __C8 0.00072546 +#define __C9 -0.000003582 + PARAMS_2(_t,_rh); _rh = _rh * 100; // relative humidity in % diff --git a/addons/weather/functions/fnc_calculateWetBulb.sqf b/addons/weather/functions/fnc_calculateWetBulb.sqf index c044c2ed57..c180cf8384 100644 --- a/addons/weather/functions/fnc_calculateWetBulb.sqf +++ b/addons/weather/functions/fnc_calculateWetBulb.sqf @@ -4,7 +4,9 @@ * Calculates wet bulb based on temperature and relative humidity * * Arguments: - * + * 0: temperature - degrees celcius + * 1: pressure - hPa + * 2: relativeHumidity - value between 0.0 and 1.0 * * Return Value: * 0: wet bulb @@ -14,6 +16,26 @@ */ #include "script_component.hpp" -// TODO: ... +private ["_es", "_e", "_eDiff", "_eGuessPrev", "_cTempDelta", "_twGuess", "_eguess"]; -GVAR(currentTemperature) +PARAMS_3(_temperature,_pressure,_relativeHumidity); + +// Source: http://cosmoquest.org/forum/showthread.php?155366-Calculating-Wet-Bulb-Temperature-from-RH-amp-Dry-Bulb +_es = 6.112 * exp((17.67 * _temperature) / (_temperature + 243.5)); +_e = _es * _relativeHumidity; +_eDiff = _es - _e; +_eGuessPrev = _es; +_cTempDelta = 3.3145; +_twGuess = _temperature; + +for "_j" from 1 to 50 do { + _twGuess = _twGuess - _cTempDelta; + _eguess = 6.112 * exp((17.67 * _twGuess) / (_twGuess + 243.5)); + _eguess = _eguess - (_pressure * (_temperature - _twGuess) * 0.00066 * (1 + (0.00115 * _twGuess))); + _eDiff = _eguess - _e; + if (abs(_eDiff) <= 0.001) exitWith {}; + _cTempDelta = _eDiff / ((_eguessprev - _eguess) / _cTempDelta); + _eguessprev = _eguess; +}; + +_twGuess diff --git a/addons/weather/script_component.hpp b/addons/weather/script_component.hpp index bf16255590..edc1ac64d0 100644 --- a/addons/weather/script_component.hpp +++ b/addons/weather/script_component.hpp @@ -18,14 +18,3 @@ #define WATER_VAPOR_MOLAR_MASS 0.018016 #define DRY_AIR_MOLAR_MASS 0.028964 #define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058 - -// Heat index coefficients -#define __C1 -8.784695 -#define __C2 1.61139411 -#define __C3 2.338549 -#define __C4 -0.14611605 -#define __C5 -0.012308094 -#define __C6 -0.016424828 -#define __C7 0.002211732 -#define __C8 0.00072546 -#define __C9 -0.000003582 From b65ac1f305a8041e442e3b062632194c81d36423 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 11:13:50 +0200 Subject: [PATCH 08/14] Fixed some bugs in the Kestrel 4500 output generation --- .../functions/fnc_generateOutputData.sqf | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/kestrel4500/functions/fnc_generateOutputData.sqf b/addons/kestrel4500/functions/fnc_generateOutputData.sqf index c0f8a83146..95e9ec5712 100644 --- a/addons/kestrel4500/functions/fnc_generateOutputData.sqf +++ b/addons/kestrel4500/functions/fnc_generateOutputData.sqf @@ -14,7 +14,7 @@ */ #include "script_component.hpp" -private ["_playerDir", "_textTop", "_textCenterBig", "_textCenterLine1Left", "_textCenterLine2Left", "_textCenterLine3Left", "_textCenterLine1Right", "_textCenterLine2Right", "_textCenterLine3Right", "_textInfoLine1", "_textInfoLine2", "_temperature", "_chill", "_humidity", "_heatIndex", "_dewPoint", "_wetBulb", "_windSpeed", "_windDir"]; +private ["_playerDir", "_playerAltitude", "_temperature", "_humidity", "_barometricPressure", "_chill", "_heatIndex", "_dewPoint", "_wetBulb", "_windSpeed", "_windDir", "_textTop", "_textCenterBig", "_textCenterLine1Left", "_textCenterLine2Left", "_textCenterLine3Left", "_textCenterLine1Right", "_textCenterLine2Right", "_textCenterLine3Right", "_textInfoLine1", "_textInfoLine2"]; [] call FUNC(collectData); @@ -39,10 +39,11 @@ _playerAltitude = (getPosASL ACE_player) select 2; _temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); _humidity = EGVAR(weather,currentHumidity); +_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); _chill = [_temperature, _humidity] call EFUNC(weather,calculateWindChill); _heatIndex = [_temperature, _humidity] call EFUNC(weather,calculateHeatIndex); _dewPoint = [_temperature, _humidity] call EFUNC(weather,calculateDewPoint); -_wetBulb = [_temperature, _humidity] call EFUNC(weather,calculateWetBulb); +_wetBulb = [_temperature, _barometricPressure, _humidity] call EFUNC(weather,calculateWetBulb); GVAR(Direction) = 4 * floor(_playerDir / 90); if (_playerDir % 90 > 10) then { GVAR(Direction) = GVAR(Direction) + 1}; @@ -184,9 +185,9 @@ switch (GVAR(Menu)) do { _textCenterLine1Left = "Min"; _textCenterLine2Left = "Avg"; _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round((GVAR(Min) select 6) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 6) / (GVAR(Entries) select 6) * 10) / 10); - _textCenterLine3Right = Str(round((GVAR(Max) select 6) * 10) / 10); + _textCenterLine1Right = Str(round((GVAR(Min) select 6) * 100 * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 6) / (GVAR(Entries) select 6) * 100 * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 6) * 100 * 10) / 10); }; }; case 7: { // HEAT INDEX @@ -227,7 +228,7 @@ switch (GVAR(Menu)) do { }; case 10: { // BARO if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); + _textCenterBig = Str(round(_barometricPressure * 10) / 10); } else { _textCenterLine1Left = "Min"; _textCenterLine2Left = "Avg"; From ea68e91ef96ae2c17b22d4cadfb05bf86b84b5fc Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 11:13:54 +0200 Subject: [PATCH 09/14] Refactored and expanded the kestrel data collection --- addons/kestrel4500/XEH_postInit.sqf | 4 +- .../kestrel4500/functions/fnc_collectData.sqf | 77 ++++++++----------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/addons/kestrel4500/XEH_postInit.sqf b/addons/kestrel4500/XEH_postInit.sqf index 22465bc4e0..674e8c5026 100644 --- a/addons/kestrel4500/XEH_postInit.sqf +++ b/addons/kestrel4500/XEH_postInit.sqf @@ -4,8 +4,8 @@ GVAR(Menus) = ["Direction", "Wind SPD m/s", "CROSSWIND m/s", "HEADWIND m/s", "TEMP °C", "CHILL °C", "HUMIDITY %", "HEAT INDEX °C", "DEW POINT °C", "WET BULB °C", "BARO hPA", "ALTITUDE m", "User Screen 1", "User Screen 2"]; -GVAR(TOTAL) = [0, 0, 0, 0, 0, 0, 0, 0]; -GVAR(ENTRIES) = [0, 0, 0, 0, 0, 0, 0, 0]; +GVAR(TOTAL) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; +GVAR(ENTRIES) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; GVAR(MinAvgMax) = false; GVAR(MinAvgMaxMode) = 0; diff --git a/addons/kestrel4500/functions/fnc_collectData.sqf b/addons/kestrel4500/functions/fnc_collectData.sqf index 60bab4b9ec..8e19b93f22 100644 --- a/addons/kestrel4500/functions/fnc_collectData.sqf +++ b/addons/kestrel4500/functions/fnc_collectData.sqf @@ -14,27 +14,35 @@ */ #include "script_component.hpp" -private ["_playerAltitude", "_playerDir", "_windSpeed", "_crosswind", "_headwind", "_humidity", "_temperature", "_humidity", "_barometricPressure", "_altitude"]; +private ["_playerDir", "_playerAltitude", "_temperature", "_humidity", "_barometricPressure", "_altitude", "_chill", "_heatIndex", "_dewPoint", "_wetBulb", "_fnc_updateMemory", "_windSpeed", "_crosswind", "_headwind"]; +_playerDir = getDir ACE_player; _playerAltitude = (getPosASL ACE_player) select 2; +_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); +_humidity = EGVAR(weather,currentHumidity); +_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); +_altitude = EGVAR(weather,Altitude) + _playerAltitude; +_chill = [_temperature, _humidity] call EFUNC(weather,calculateWindChill); +_heatIndex = [_temperature, _humidity] call EFUNC(weather,calculateHeatIndex); +_dewPoint = [_temperature, _humidity] call EFUNC(weather,calculateDewPoint); +_wetBulb = [_temperature, _barometricPressure, _humidity] call EFUNC(weather,calculateWetBulb); if (isNil QGVAR(MIN) || isNil QGVAR(MAX)) then { - _temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); - _humidity = EGVAR(weather,currentHumidity); - _barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); - _altitude = EGVAR(weather,Altitude) + _playerAltitude; - GVAR(MIN) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude]; - GVAR(MAX) = [0, 0, 0, 0, _temperature, _humidity, _barometricPressure, _altitude]; + GVAR(MIN) = [_playerDir, 0, 0, 0, _temperature, _chill, _humidity, _heatIndex, _dewPoint, _wetBulb, _barometricPressure, _altitude]; + GVAR(MAX) = [_playerDir, 0, 0, 0, _temperature, _chill, _humidity, _heatIndex, _dewPoint, _wetBulb, _barometricPressure, _altitude]; }; { GVAR(ENTRIES) set [_x, (GVAR(ENTRIES) select _x) + 1]; -} forEach [0, 4, 5, 6 ,7]; +} forEach [0, 4, 5, 6, 7, 8, 9, 10, 11]; -// Direction -_playerDir = getDir ACE_player; -GVAR(MIN) set [0, (GVAR(MIN) select 0) min _playerDir]; -GVAR(MAX) set [0, _playerDir max (GVAR(MAX) select 0)]; -GVAR(TOTAL) set [0, (GVAR(TOTAL) select 0) + _playerDir]; +_fnc_updateMemory = { + PARAMS_2(_slot,_value); + GVAR(MIN) set [_slot, (GVAR(MIN) select _slot) min _value]; + GVAR(MAX) set [_slot, _value max (GVAR(MAX) select _slot)]; + GVAR(TOTAL) set [_slot, (GVAR(TOTAL) select _slot) + _value]; +}; + +[0, _playerDir] call _fnc_updateMemory; if (GVAR(MinAvgMaxMode) == 1) then { { @@ -43,9 +51,7 @@ if (GVAR(MinAvgMaxMode) == 1) then { // Wind SPD _windSpeed = call FUNC(measureWindSpeed); - GVAR(MIN) set [1, (GVAR(MIN) select 1) min _windSpeed]; - GVAR(MAX) set [1, _windSpeed max (GVAR(MAX) select 1)]; - GVAR(TOTAL) set [1, (GVAR(TOTAL) select 1) + _windSpeed]; + [1, _windSpeed] call _fnc_updateMemory; // CROSSWIND _crosswind = 0; @@ -54,9 +60,7 @@ if (GVAR(MinAvgMaxMode) == 1) then { } else { _crosswind = abs(sin(GVAR(RefHeading)) * _windSpeed); }; - GVAR(MIN) set [2, (GVAR(MIN) select 2) min _crosswind]; - GVAR(MAX) set [2, _crosswind max (GVAR(MAX) select 2)]; - GVAR(TOTAL) set [2, (GVAR(TOTAL) select 2) + _crosswind]; + [2, _crosswind] call _fnc_updateMemory; // HEADWIND _headwind = 0; @@ -65,31 +69,14 @@ if (GVAR(MinAvgMaxMode) == 1) then { } else { _headwind = abs(cos(GVAR(RefHeading)) * _windSpeed); }; - GVAR(MIN) set [3, (GVAR(MIN) select 3) min _headwind]; - GVAR(MAX) set [3, _headwind max (GVAR(MAX) select 3)]; - GVAR(TOTAL) set [3, (GVAR(TOTAL) select 3) + _headwind]; + [3, _headwind] call _fnc_updateMemory; }; -// TEMP -_temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); -GVAR(MIN) set [4, (GVAR(MIN) select 4) min _temperature]; -GVAR(MAX) set [4, _temperature max (GVAR(MAX) select 4)]; -GVAR(TOTAL) set [4, (GVAR(TOTAL) select 4) + _temperature]; - -// HUMIDITY -_humidity = EGVAR(weather,currentHumidity); -GVAR(MIN) set [5, (GVAR(MIN) select 5) min _humidity]; -GVAR(MAX) set [5, _humidity max (GVAR(MAX) select 5)]; -GVAR(TOTAL) set [5, (GVAR(TOTAL) select 5) + _humidity]; - -// BARO -_barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); -GVAR(MIN) set [6, (GVAR(MIN) select 6) min _barometricPressure]; -GVAR(MAX) set [6, _barometricPressure max (GVAR(MAX) select 6)]; -GVAR(TOTAL) set [6, (GVAR(TOTAL) select 6) + _barometricPressure]; - -// ALTITUDE -_altitude = EGVAR(weather,Altitude) + _playerAltitude; -GVAR(MIN) set [7, (GVAR(MIN) select 7) min _altitude]; -GVAR(MAX) set [7, _altitude max (GVAR(MAX) select 7)]; -GVAR(TOTAL) set [7, (GVAR(TOTAL) select 7) + _altitude]; \ No newline at end of file +[4, _temperature] call _fnc_updateMemory; +[5, _chill] call _fnc_updateMemory; +[6, _humidity] call _fnc_updateMemory; +[7, _heatIndex] call _fnc_updateMemory; +[8, _dewPoint] call _fnc_updateMemory; +[9, _wetBulb] call _fnc_updateMemory; +[10, _barometricPressure] call _fnc_updateMemory; +[11, _altitude] call _fnc_updateMemory; From 03b478aeee95317b37f2daa446c08e88f46bfdc4 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 12:39:52 +0200 Subject: [PATCH 10/14] Reworked dew point, heat index and wind chill calculations --- .../functions/fnc_calculateDewPoint.sqf | 1 + .../functions/fnc_calculateHeatIndex.sqf | 23 ++++++++++--------- .../functions/fnc_calculateWindChill.sqf | 9 +++++--- addons/weather/script_component.hpp | 2 ++ 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/addons/weather/functions/fnc_calculateDewPoint.sqf b/addons/weather/functions/fnc_calculateDewPoint.sqf index 750b384ea0..c5de883090 100644 --- a/addons/weather/functions/fnc_calculateDewPoint.sqf +++ b/addons/weather/functions/fnc_calculateDewPoint.sqf @@ -21,6 +21,7 @@ PARAMS_2(_t,_rh); // Source: https://en.wikipedia.org/wiki/Dew_point + private ["_gamma"]; _gamma = ln(_rh) + (__b * _t) / (__c + _t); diff --git a/addons/weather/functions/fnc_calculateHeatIndex.sqf b/addons/weather/functions/fnc_calculateHeatIndex.sqf index 95060bd0a2..085edcd1a9 100644 --- a/addons/weather/functions/fnc_calculateHeatIndex.sqf +++ b/addons/weather/functions/fnc_calculateHeatIndex.sqf @@ -15,19 +15,20 @@ */ #include "script_component.hpp" -#define __C1 -8.784695 -#define __C2 1.61139411 -#define __C3 2.338549 -#define __C4 -0.14611605 -#define __C5 -0.012308094 -#define __C6 -0.016424828 -#define __C7 0.002211732 -#define __C8 0.00072546 -#define __C9 -0.000003582 +#define __C1 0.363445176 +#define __C2 0.988622465 +#define __C3 4.777114035 +#define __C4 -0.114037667 +#define __C5 -0.000850208 +#define __C6 -0.020716198 +#define __C7 0.000687678 +#define __C8 0.000274954 PARAMS_2(_t,_rh); +// Source: https://en.wikipedia.org/wiki/Heat_index + +_t = FAHRENHEIT(_t); _rh = _rh * 100; // relative humidity in % -// Source: https://en.wikipedia.org/wiki/Heat_index -(__C1 + __C2 * _t + __C3 * _rh + __C4 * _t * _rh + __C5 * _t^2 + __C6 * _rh^2 + __C7 * _t^2 * _rh + __C8 * _t * _rh^2 + __C9 * _t^2 * _rh^2) +CELSIUS(__C1 + __C2 * _t + __C3 * _rh + __C4 * _t * _rh + __C5 * _t^2 + __C6 * _rh^2 + __C7 * _t^2 * _rh + __C8 * _t * _rh^2) diff --git a/addons/weather/functions/fnc_calculateWindChill.sqf b/addons/weather/functions/fnc_calculateWindChill.sqf index 04e26013d7..021d2f8b99 100644 --- a/addons/weather/functions/fnc_calculateWindChill.sqf +++ b/addons/weather/functions/fnc_calculateWindChill.sqf @@ -16,7 +16,10 @@ PARAMS_2(_t,_v); -_v = _v * 3,6; // wind speed in km/h - // Source: https://en.wikipedia.org/wiki/Wind_chill -(13.12 + 0.06215 * _t - 11.37 * _v ^ 0.16 + 0.3965 * _t * _v^0.16) + +if (_t > 10) exitWith { _t }; +if (_v < 1.39) exitWith { _t }; + +_v = _v * 3,6; // wind speed in km/h +(13.12 + 0.6215 * _t - 11.37 * _v ^ 0.16 + 0.3965 * _t * _v ^ 0.16) diff --git a/addons/weather/script_component.hpp b/addons/weather/script_component.hpp index edc1ac64d0..dedfc59236 100644 --- a/addons/weather/script_component.hpp +++ b/addons/weather/script_component.hpp @@ -18,3 +18,5 @@ #define WATER_VAPOR_MOLAR_MASS 0.018016 #define DRY_AIR_MOLAR_MASS 0.028964 #define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058 +#define CELSIUS(t) ((t - 32) / 1.8) +#define FAHRENHEIT(t) (t * 1.8 + 32) From 9116fed415a3d666a40dcdd43e3bb077e84aa356 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 20:26:52 +0200 Subject: [PATCH 11/14] New main menu: 'date' | New sub menu: 'magnetic heading' --- addons/kestrel4500/RscTitles.hpp | 194 ++++---- addons/kestrel4500/XEH_postInit.sqf | 13 +- .../functions/fnc_buttonPressed.sqf | 77 ++- .../kestrel4500/functions/fnc_collectData.sqf | 30 +- .../functions/fnc_displayKestrel.sqf | 47 +- .../functions/fnc_generateOutputData.sqf | 467 ++++++++++-------- .../functions/fnc_updateDisplay.sqf | 43 +- 7 files changed, 546 insertions(+), 325 deletions(-) diff --git a/addons/kestrel4500/RscTitles.hpp b/addons/kestrel4500/RscTitles.hpp index b091a07561..fe0adf2c4b 100644 --- a/addons/kestrel4500/RscTitles.hpp +++ b/addons/kestrel4500/RscTitles.hpp @@ -2,8 +2,7 @@ #define ST_RIGHT 1 #define ST_CENTER 2 -class Kestrel4500_RscText -{ +class Kestrel4500_RscText { idc=-1; type=0; style=ST_CENTER; @@ -19,8 +18,7 @@ class Kestrel4500_RscText sizeEx=0.04; shadow=0; }; -class Kestrel4500_RscButton -{ +class Kestrel4500_RscButton { text=""; colorText[]={0,0,0,1}; colorDisabled[]={0,0,0,0}; @@ -49,8 +47,7 @@ class Kestrel4500_RscButton borderSize=0; shadow=0; }; -class Kestrel4500_Display -{ +class Kestrel4500_Display { name="Kestrel4500_Display"; idd=-1; onLoad="uiNamespace setVariable ['Kestrel4500_Display', (_this select 0)]"; @@ -58,10 +55,8 @@ class Kestrel4500_Display movingEnable=1; controlsBackground[]={}; objects[]={}; - class controls - { - class BACKGROUND - { + class controls { + class BACKGROUND { moving=1; type=0; font="TahomaB"; @@ -76,18 +71,16 @@ class Kestrel4500_Display colorText[]={1,1,1,1}; text=PATHTOF(UI\Kestrel4500.paa); }; - class POWER: Kestrel4500_RscButton - { + class POWER: Kestrel4500_RscButton { idc=-1; x=safezoneX+0.385; y=safezoneY+1.125; w=0.042; h=0.042*4/3; - action="closeDialog 0"; + action=QUOTE(7 call FUNC(buttonPressed)); onMouseButtonDown = "playSound 'kestrel4500_exit_button_click'"; }; - class ENTER: POWER - { + class ENTER: POWER { idc=-1; x=safezoneX+0.46; y=safezoneY+1.0; @@ -95,8 +88,7 @@ class Kestrel4500_Display action=QUOTE(0 call FUNC(buttonPressed)); onMouseButtonDown = "playSound 'kestrel4500_center_button_click'"; }; - class TOP: Kestrel4500_RscButton - { + class TOP: Kestrel4500_RscButton { idc=-1; x=safezoneX+0.46; y=safezoneY+0.93; @@ -105,15 +97,13 @@ class Kestrel4500_Display action=QUOTE(1 call FUNC(buttonPressed)); onMouseButtonDown = "playSound 'kestrel4500_top_button_click'"; }; - class BOTTOM: TOP - { + class BOTTOM: TOP { idc=-1; y=safezoneY+1.1; action=QUOTE(2 call FUNC(buttonPressed)); onMouseButtonDown = "playSound 'kestrel4500_bottom_button_click'"; }; - class LEFT: Kestrel4500_RscButton - { + class LEFT: Kestrel4500_RscButton { idc=-1; x=safezoneX+0.4; y=safezoneY+0.97; @@ -122,15 +112,13 @@ class Kestrel4500_Display action=QUOTE(3 call FUNC(buttonPressed)); onMouseButtonDown = "playSound 'kestrel4500_left_button_click'"; }; - class RIGHT: LEFT - { + class RIGHT: LEFT { idc=-1; x=safezoneX+0.58; action=QUOTE(4 call FUNC(buttonPressed)); onMouseButtonDown = "playSound 'kestrel4500_right_button_click'"; }; - class MEMORY: Kestrel4500_RscButton - { + class MEMORY: Kestrel4500_RscButton { idc=-1; x=safezoneX+0.395; y=safezoneY+0.87; @@ -138,15 +126,13 @@ class Kestrel4500_Display h=0.045*4/3; action=QUOTE(5 call FUNC(buttonPressed)); }; - class BACKLIGHT: MEMORY - { + class BACKLIGHT: MEMORY { idc=-1; x=safezoneX+0.585; action=QUOTE(6 call FUNC(buttonPressed)); }; - class TEXT_TOP: Kestrel4500_RscText - { + class TEXT_TOP: Kestrel4500_RscText { idc=74100; x=safezoneX+0.40; y=safezoneY+0.58; @@ -154,68 +140,86 @@ class Kestrel4500_Display h=0.04; text=""; }; - class TEXT_CENTER_BIG: TEXT_TOP - { + class TEXT_CENTER_BIG: TEXT_TOP { idc=74200; y=safezoneY+0.61; h=0.10; SizeEx=0.06; - text=""; }; - class TEXT_CENTER_LINE_1_LEFT: TEXT_TOP - { + class TEXT_CENTER: TEXT_TOP { + idc=74201; + y=safezoneY+0.64; + }; + class TEXT_CENTER_LINE_1_LEFT: TEXT_TOP { idc=74300; y=safezoneY+0.60; style=ST_LEFT; h=0.10; SizeEx=0.05; - text=""; }; - class TEXT_CENTER_LINE2_LEFT: TEXT_CENTER_LINE_1_LEFT - { + class TEXT_CENTER_LINE2_LEFT: TEXT_CENTER_LINE_1_LEFT { idc=74301; y=safezoneY+0.64; - text=""; }; - class TEXT_CENTER_LINE_3_LEFT: TEXT_CENTER_LINE2_LEFT - { + class TEXT_CENTER_LINE_3_LEFT: TEXT_CENTER_LINE2_LEFT { idc=74302; y=safezoneY+0.68; - text=""; }; - class TEXT_CENTER_LINE_1_RIGHT: TEXT_CENTER_LINE_1_LEFT - { + class TEXT_CENTER_LINE_1_RIGHT: TEXT_CENTER_LINE_1_LEFT { idc=74303; style=ST_RIGHT; }; - class TEXT_CENTER_LINE2_RIGHT: TEXT_CENTER_LINE2_LEFT - { + class TEXT_CENTER_LINE2_RIGHT: TEXT_CENTER_LINE2_LEFT { idc=74304; style=ST_RIGHT; }; - class TEXT_CENTER_LINE_3_RIGHT: TEXT_CENTER_LINE_3_LEFT - { + class TEXT_CENTER_LINE_3_RIGHT: TEXT_CENTER_LINE_3_LEFT { idc=74305; style=ST_RIGHT; }; - class TEXT_INFO_LINE_1: TEXT_TOP - { + class TEXT_INFO_LINE_1: TEXT_TOP { idc=74400; - y=safezoneY+0.69; - text=""; + y=safezoneY+0.68; }; - class TEXT_INFO_LINE_2: TEXT_TOP - { + class TEXT_INFO_LINE_2: TEXT_TOP { idc=74401; y=safezoneY+0.72; - text=""; + }; + class TEXT_BOTTOM_BIG: TEXT_TOP { + idc=74500; + y=safezoneY+0.67; + h=0.10; + SizeEx=0.06; + }; + class TEXT_CENTER_LINE_1: TEXT_TOP { + idc=74600; + y=safezoneY+0.58; + SizeEx=0.03; + }; + class TEXT_CENTER_LINE_2: TEXT_CENTER_LINE_1 { + idc=74601; + y=safezoneY+0.61; + }; + class TEXT_CENTER_LINE_3: TEXT_CENTER_LINE_1 { + idc=74602; + y=safezoneY+0.64; + }; + class TEXT_CENTER_LINE_4: TEXT_CENTER_LINE_1 { + idc=74603; + y=safezoneY+0.67; + }; + class TEXT_CENTER_LINE_5: TEXT_CENTER_LINE_1 { + idc=74604; + y=safezoneY+0.70; + }; + class TEXT_CENTER_LINE_6: TEXT_CENTER_LINE_1 { + idc=74605; + y=safezoneY+0.73; }; }; }; -class RscTitles -{ - class RscKestrel4500 - { +class RscTitles { + class RscKestrel4500 { idd=-1; onLoad="with uiNameSpace do { RscKestrel4500 = _this select 0 };"; onUnload=(_this call FUNC(onCloseDisplay)); @@ -223,10 +227,8 @@ class RscTitles duration=60; fadeIn="false"; fadeOut="false"; - class controls - { - class RscKestrel4500 - { + class controls { + class RscKestrel4500 { idc=75000; moving=0; type=0; @@ -241,8 +243,7 @@ class RscTitles colorText[]={1,1,1,1}; text=PATHTOF(UI\Kestrel4500_0.paa); }; - class RscTextTop: Kestrel4500_RscText - { + class RscTextTop: Kestrel4500_RscText { idc=75100; x=safezoneX-0.05+0.40*0.75; y=safezoneY+0.7+0.58*0.75; @@ -251,16 +252,18 @@ class RscTitles SizeEx=0.04*0.75; text=""; }; - class RscTextCenterBig: RscTextTop - { + class RscTextCenterBig: RscTextTop { idc=75200; y=safezoneY+0.7+0.61*0.75; h=0.10*0.75; SizeEx=0.06*0.75; text=""; }; - class RscTextCenterLine1Left: RscTextTop - { + class RscTextCenter: RscTextTop { + idc=75201; + y=safezoneY+0.7+0.64*0.75; + }; + class RscTextCenterLine1Left: RscTextTop { idc=75300; y=safezoneY+0.7+0.60*0.75; style=ST_LEFT; @@ -268,45 +271,70 @@ class RscTitles SizeEx=0.05*0.75; text=""; }; - class RscTextCenterLine2Left: RscTextCenterLine1Left - { + class RscTextCenterLine2Left: RscTextCenterLine1Left { idc=75301; y=safezoneY+0.7+0.64*0.75; text=""; }; - class RscTextCenterLine3Left: RscTextCenterLine2Left - { + class RscTextCenterLine3Left: RscTextCenterLine2Left { idc=75302; y=safezoneY+0.7+0.68*0.75; text=""; }; - class RscTextCenterLine1Right: RscTextCenterLine1Left - { + class RscTextCenterLine1Right: RscTextCenterLine1Left { idc=75303; style=ST_RIGHT; }; - class RscTextCenterLine2Right: RscTextCenterLine2Left - { + class RscTextCenterLine2Right: RscTextCenterLine2Left { idc=75304; style=ST_RIGHT; }; - class RscTextCenterLine3Right: RscTextCenterLine3Left - { + class RscTextCenterLine3Right: RscTextCenterLine3Left { idc=75305; style=ST_RIGHT; }; - class RscTextInfoLine1: RscTextTop - { + class RscTextInfoLine1: RscTextTop { idc=75400; - y=safezoneY+0.7+0.69*0.75; + y=safezoneY+0.7+0.68*0.75; text=""; }; - class RscTextInfoLine2: RscTextTop - { + class RscTextInfoLine2: RscTextTop { idc=75401; y=safezoneY+0.7+0.72*0.75; text=""; }; + class RscTextBottomBig: RscTextTop { + idc=75500; + y=safezoneY+0.7+0.67*0.75; + h=0.10*0.75; + SizeEx=0.06*0.75; + text=""; + }; + class RscTextCenterLine1: RscTextTop { + idc=75600; + y=safezoneY+0.7+0.58*0.75; + SizeEx=0.03*0.75; + }; + class RscTextCenterLine2: RscTextCenterLine1 { + idc=75601; + y=safezoneY+0.7+0.61*0.75; + }; + class RscTextCenterLine3: RscTextCenterLine1 { + idc=75602; + y=safezoneY+0.7+0.64*0.75; + }; + class RscTextCenterLine4: RscTextCenterLine1 { + idc=75603; + y=safezoneY+0.7+0.67*0.75; + }; + class RscTextCenterLine5: RscTextCenterLine1 { + idc=75604; + y=safezoneY+0.7+0.70*0.75; + }; + class RscTextCenterLine6: RscTextCenterLine1 { + idc=75605; + y=safezoneY+0.7+0.73*0.75; + }; }; }; diff --git a/addons/kestrel4500/XEH_postInit.sqf b/addons/kestrel4500/XEH_postInit.sqf index 674e8c5026..7790386cf7 100644 --- a/addons/kestrel4500/XEH_postInit.sqf +++ b/addons/kestrel4500/XEH_postInit.sqf @@ -2,22 +2,27 @@ #include "initKeybinds.sqf" -GVAR(Menus) = ["Direction", "Wind SPD m/s", "CROSSWIND m/s", "HEADWIND m/s", "TEMP °C", "CHILL °C", "HUMIDITY %", "HEAT INDEX °C", "DEW POINT °C", "WET BULB °C", "BARO hPA", "ALTITUDE m", "User Screen 1", "User Screen 2"]; +GVAR(Menus) = ["Date", "Direction", "Wind SPD m/s", "CROSSWIND m/s", "HEADWIND m/s", "TEMP °C", "CHILL °C", "HUMIDITY %", "HEAT INDEX °C", "DEW POINT °C", "WET BULB °C", "BARO hPA", "ALTITUDE m", "User Screen 1", "User Screen 2"]; -GVAR(TOTAL) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; -GVAR(ENTRIES) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; +GVAR(TOTAL) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; +GVAR(ENTRIES) = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; GVAR(MinAvgMax) = false; GVAR(MinAvgMaxMode) = 0; +GVAR(referenceHeadingMenu) = 0; +GVAR(referenceHeadingAutoSet) = true; +GVAR(manualSetCooldown) = diag_tickTime; +GVAR(headingSetDisplayTimer) = 0; GVAR(Menu) = 1; GVAR(Directions) = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"]; GVAR(Direction) = 0; GVAR(RefHeading) = 0; +GVAR(TmpHeading) = 0; GVAR(updateTimer) = 0; -GVAR(outputData) = ["", "", "", "", "", "", "", "", "", ""]; +GVAR(outputData) = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]; GVAR(MeasuredWindSpeed) = 0; GVAR(ImpellerState) = 0; diff --git a/addons/kestrel4500/functions/fnc_buttonPressed.sqf b/addons/kestrel4500/functions/fnc_buttonPressed.sqf index 1d73f9ac79..5c6553e402 100644 --- a/addons/kestrel4500/functions/fnc_buttonPressed.sqf +++ b/addons/kestrel4500/functions/fnc_buttonPressed.sqf @@ -18,7 +18,29 @@ switch (_this) do { case 0: { // Enter if (!GVAR(MinAvgMax) && (GVAR(Menu) == 2 || GVAR(Menu) == 3)) then { - GVAR(RefHeading) = getDir ACE_player; + switch (GVAR(referenceHeadingMenu)) do { + case 0: { // Head- and Crosswind main page + GVAR(TmpHeading) = GVAR(RefHeading); + GVAR(referenceHeadingMenu) = 1; + }; + case 1: { // Mode selection + if (GVAR(referenceHeadingAutoSet)) then { + GVAR(referenceHeadingMenu) = 2; + } else { + GVAR(referenceHeadingMenu) = 3; + }; + }; + case 2: { // Auto set + GVAR(RefHeading) = getDir ACE_player; + GVAR(referenceHeadingMenu) = 0; + GVAR(headingSetDisplayTimer) = diag_tickTime; + }; + case 3: { // Manual set + GVAR(RefHeading) = GVAR(TmpHeading); + GVAR(referenceHeadingMenu) = 0; + GVAR(headingSetDisplayTimer) = diag_tickTime; + }; + }; }; if (GVAR(MinAvgMax) && GVAR(Menu) > 0 && GVAR(Menu) < 4) then { if (GVAR(MinAvgMaxMode) != 1) then { @@ -33,21 +55,66 @@ switch (_this) do { }; }; case 1: { // Top - GVAR(Menu) = (GVAR(Menu) - 1 + (count GVAR(Menus))) % (count GVAR(Menus)); + if (GVAR(referenceHeadingMenu) == 1) then { + GVAR(referenceHeadingAutoSet) = !GVAR(referenceHeadingAutoSet); + } else { + GVAR(Menu) = (GVAR(Menu) - 1 + (count GVAR(Menus))) % (count GVAR(Menus)); + }; }; case 2: { // Bottom - GVAR(Menu) = (GVAR(Menu) + 1 + (count GVAR(Menus))) % (count GVAR(Menus)); + if (GVAR(referenceHeadingMenu) == 1) then { + GVAR(referenceHeadingAutoSet) = !GVAR(referenceHeadingAutoSet); + } else { + GVAR(Menu) = (GVAR(Menu) + 1 + (count GVAR(Menus))) % (count GVAR(Menus)); + }; }; case 3: { // Left - GVAR(MinAvgMax) = !GVAR(MinAvgMax); + if (GVAR(referenceHeadingMenu) == 0) then { + GVAR(MinAvgMax) = !GVAR(MinAvgMax); + } else { + if (GVAR(referenceHeadingMenu) == 3) then { + if (diag_tickTime - GVAR(manualSetCooldown) < 0.2) then { + GVAR(TmpHeading) = GVAR(TmpHeading) - 10; + } else { + GVAR(TmpHeading) = GVAR(TmpHeading) - 1; + }; + GVAR(manualSetCooldown) = diag_tickTime; + }; + }; }; case 4: { // Right - GVAR(MinAvgMax) = !GVAR(MinAvgMax); + if (GVAR(referenceHeadingMenu) == 0) then { + GVAR(MinAvgMax) = !GVAR(MinAvgMax); + } else { + if (GVAR(referenceHeadingMenu) == 3) then { + if (diag_tickTime - GVAR(manualSetCooldown) < 0.2) then { + GVAR(TmpHeading) = GVAR(TmpHeading) + 10; + } else { + GVAR(TmpHeading) = GVAR(TmpHeading) + 1; + }; + GVAR(manualSetCooldown) = diag_tickTime; + }; + }; }; case 5: { // Memory }; case 6: { // Backlight }; + case 7: { // Exit + private ["_exit"]; + _exit = true; + if (GVAR(referenceHeadingMenu) == 1) then { + GVAR(referenceHeadingMenu) = 0; + _exit = false; + }; + if (GVAR(referenceHeadingMenu) > 1) then { + GVAR(referenceHeadingMenu) = 1; + _exit = false; + }; + if (_exit) then { + closeDialog 0; + }; + }; }; [] call FUNC(updateDisplay); diff --git a/addons/kestrel4500/functions/fnc_collectData.sqf b/addons/kestrel4500/functions/fnc_collectData.sqf index 8e19b93f22..a20c944d1e 100644 --- a/addons/kestrel4500/functions/fnc_collectData.sqf +++ b/addons/kestrel4500/functions/fnc_collectData.sqf @@ -27,13 +27,13 @@ _dewPoint = [_temperature, _humidity] call EFUNC(weather,calculateDewPoint); _wetBulb = [_temperature, _barometricPressure, _humidity] call EFUNC(weather,calculateWetBulb); if (isNil QGVAR(MIN) || isNil QGVAR(MAX)) then { - GVAR(MIN) = [_playerDir, 0, 0, 0, _temperature, _chill, _humidity, _heatIndex, _dewPoint, _wetBulb, _barometricPressure, _altitude]; - GVAR(MAX) = [_playerDir, 0, 0, 0, _temperature, _chill, _humidity, _heatIndex, _dewPoint, _wetBulb, _barometricPressure, _altitude]; + GVAR(MIN) = [0, _playerDir, 0, 0, 0, _temperature, _chill, _humidity, _heatIndex, _dewPoint, _wetBulb, _barometricPressure, _altitude]; + GVAR(MAX) = [0, _playerDir, 0, 0, 0, _temperature, _chill, _humidity, _heatIndex, _dewPoint, _wetBulb, _barometricPressure, _altitude]; }; { GVAR(ENTRIES) set [_x, (GVAR(ENTRIES) select _x) + 1]; -} forEach [0, 4, 5, 6, 7, 8, 9, 10, 11]; +} forEach [1, 5, 6, 7, 8, 9, 10, 11, 12]; _fnc_updateMemory = { PARAMS_2(_slot,_value); @@ -47,11 +47,11 @@ _fnc_updateMemory = { if (GVAR(MinAvgMaxMode) == 1) then { { GVAR(ENTRIES) set [_x, (GVAR(ENTRIES) select _x) + 1]; - } forEach [1, 2, 3]; + } forEach [2, 3, 4]; // Wind SPD _windSpeed = call FUNC(measureWindSpeed); - [1, _windSpeed] call _fnc_updateMemory; + [2, _windSpeed] call _fnc_updateMemory; // CROSSWIND _crosswind = 0; @@ -60,7 +60,7 @@ if (GVAR(MinAvgMaxMode) == 1) then { } else { _crosswind = abs(sin(GVAR(RefHeading)) * _windSpeed); }; - [2, _crosswind] call _fnc_updateMemory; + [3, _crosswind] call _fnc_updateMemory; // HEADWIND _headwind = 0; @@ -69,14 +69,14 @@ if (GVAR(MinAvgMaxMode) == 1) then { } else { _headwind = abs(cos(GVAR(RefHeading)) * _windSpeed); }; - [3, _headwind] call _fnc_updateMemory; + [4, _headwind] call _fnc_updateMemory; }; -[4, _temperature] call _fnc_updateMemory; -[5, _chill] call _fnc_updateMemory; -[6, _humidity] call _fnc_updateMemory; -[7, _heatIndex] call _fnc_updateMemory; -[8, _dewPoint] call _fnc_updateMemory; -[9, _wetBulb] call _fnc_updateMemory; -[10, _barometricPressure] call _fnc_updateMemory; -[11, _altitude] call _fnc_updateMemory; +[5, _temperature] call _fnc_updateMemory; +[6, _chill] call _fnc_updateMemory; +[7, _humidity] call _fnc_updateMemory; +[8, _heatIndex] call _fnc_updateMemory; +[9, _dewPoint] call _fnc_updateMemory; +[10, _wetBulb] call _fnc_updateMemory; +[11, _barometricPressure] call _fnc_updateMemory; +[12, _altitude] call _fnc_updateMemory; diff --git a/addons/kestrel4500/functions/fnc_displayKestrel.sqf b/addons/kestrel4500/functions/fnc_displayKestrel.sqf index 8eb2cea0ad..fc0a1f278a 100644 --- a/addons/kestrel4500/functions/fnc_displayKestrel.sqf +++ b/addons/kestrel4500/functions/fnc_displayKestrel.sqf @@ -18,6 +18,7 @@ #define __ctrlKestrel4500 (__dsp displayCtrl 75000) #define __ctrlTop (__dsp displayCtrl 75100) #define __ctrlCenterBig (__dsp displayCtrl 75200) +#define __ctrlCenter (__dsp displayCtrl 75201) #define __ctrlCenterLine1Left (__dsp displayCtrl 75300) #define __ctrlCenterLine2Left (__dsp displayCtrl 75301) #define __ctrlCenterLine3Left (__dsp displayCtrl 75302) @@ -26,6 +27,13 @@ #define __ctrlCenterLine3Right (__dsp displayCtrl 75305) #define __ctrlInfoLine1 (__dsp displayCtrl 75400) #define __ctrlInfoLine2 (__dsp displayCtrl 75401) +#define __ctrlBottomBig (__dsp displayCtrl 75500) +#define __ctrlCenterLine1 (__dsp displayCtrl 75600) +#define __ctrlCenterLine2 (__dsp displayCtrl 75601) +#define __ctrlCenterLine3 (__dsp displayCtrl 75602) +#define __ctrlCenterLine4 (__dsp displayCtrl 75603) +#define __ctrlCenterLine5 (__dsp displayCtrl 75604) +#define __ctrlCenterLine6 (__dsp displayCtrl 75605) if (GVAR(Overlay)) exitWith { GVAR(Overlay) = false; @@ -63,17 +71,40 @@ GVAR(Overlay) = true; __ctrlTop ctrlSetText (_outputData select 0); __ctrlCenterBig ctrlSetText (_outputData select 1); + __ctrlCenter ctrlSetText (_outputData select 2); - __ctrlCenterLine1Left ctrlSetText (_outputData select 2); - __ctrlCenterLine2Left ctrlSetText (_outputData select 3); - __ctrlCenterLine3Left ctrlSetText (_outputData select 4); + __ctrlCenterLine1Left ctrlSetText (_outputData select 3); + __ctrlCenterLine2Left ctrlSetText (_outputData select 4); + __ctrlCenterLine3Left ctrlSetText (_outputData select 5); - __ctrlCenterLine1Right ctrlSetText (_outputData select 5); - __ctrlCenterLine2Right ctrlSetText (_outputData select 6); - __ctrlCenterLine3Right ctrlSetText (_outputData select 7); + __ctrlCenterLine1Right ctrlSetText (_outputData select 6); + __ctrlCenterLine2Right ctrlSetText (_outputData select 7); + __ctrlCenterLine3Right ctrlSetText (_outputData select 8); - __ctrlInfoLine1 ctrlSetText (_outputData select 8); - __ctrlInfoLine2 ctrlSetText (_outputData select 9); + __ctrlInfoLine1 ctrlSetText (_outputData select 9); + __ctrlInfoLine2 ctrlSetText (_outputData select 10); + + __ctrlBottomBig ctrlSetText (_outputData select 11); + + __ctrlCenterLine1 ctrlSetText (_outputData select 12); + __ctrlCenterLine2 ctrlSetText (_outputData select 13); + __ctrlCenterLine3 ctrlSetText (_outputData select 14); + __ctrlCenterLine4 ctrlSetText (_outputData select 15); + __ctrlCenterLine5 ctrlSetText (_outputData select 16); + __ctrlCenterLine6 ctrlSetText (_outputData select 17); + + if (GVAR(referenceHeadingMenu) == 1) then { + if (GVAR(referenceHeadingAutoSet)) then { + __ctrlCenterLine3 ctrlSetTextColor [0, 0, 0, 0.6]; + __ctrlCenterLine4 ctrlSetTextColor [0, 0, 0, 1.0]; + } else { + __ctrlCenterLine3 ctrlSetTextColor [0, 0, 0, 1.0]; + __ctrlCenterLine4 ctrlSetTextColor [0, 0, 0, 0.6]; + }; + } else { + __ctrlCenterLine3 ctrlSetTextColor [0, 0, 0, 1.0]; + __ctrlCenterLine4 ctrlSetTextColor [0, 0, 0, 1.0]; + }; }; call FUNC(updateImpellerState); diff --git a/addons/kestrel4500/functions/fnc_generateOutputData.sqf b/addons/kestrel4500/functions/fnc_generateOutputData.sqf index 95e9ec5712..106c1f3d32 100644 --- a/addons/kestrel4500/functions/fnc_generateOutputData.sqf +++ b/addons/kestrel4500/functions/fnc_generateOutputData.sqf @@ -14,12 +14,15 @@ */ #include "script_component.hpp" -private ["_playerDir", "_playerAltitude", "_temperature", "_humidity", "_barometricPressure", "_chill", "_heatIndex", "_dewPoint", "_wetBulb", "_windSpeed", "_windDir", "_textTop", "_textCenterBig", "_textCenterLine1Left", "_textCenterLine2Left", "_textCenterLine3Left", "_textCenterLine1Right", "_textCenterLine2Right", "_textCenterLine3Right", "_textInfoLine1", "_textInfoLine2"]; +if (diag_tickTime - GVAR(headingSetDisplayTimer) < 0.8) exitWith {["", "", " Heading Set", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]}; + +private ["_playerDir", "_playerAltitude", "_temperature", "_humidity", "_barometricPressure", "_chill", "_heatIndex", "_dewPoint", "_wetBulb", "_fnc_dayOfWeek", "_dayString", "_monthString", "_windSpeed", "_windDir", "_textTop", "_textCenterBig", "_textCenter", "_textCenterLine1Left", "_textCenterLine2Left", "_textCenterLine3Left", "_textCenterLine1Right", "_textCenterLine2Right", "_textCenterLine3Right", "_textInfoLine1", "_textInfoLine2", "_textBottomBig", "_textCenterLine1", "_textCenterLine2", "_textCenterLine3", "_textCenterLine4", "_textCenterLine5", "_textCenterLine6"]; [] call FUNC(collectData); _textTop = GVAR(Menus) select GVAR(Menu); _textCenterBig = ""; +_textCenter = ""; _textCenterLine1Left = ""; _textCenterLine2Left = ""; @@ -31,6 +34,15 @@ _textCenterLine3Right = ""; _textInfoLine1 = ""; _textInfoLine2 = ""; +_textBottomBig = ""; + +_textCenterLine1 = ""; +_textCenterLine2 = ""; +_textCenterLine3 = ""; +_textCenterLine4 = ""; +_textCenterLine5 = ""; +_textCenterLine6 = ""; + _windSpeed = call FUNC(measureWindSpeed); _windDir = (ACE_wind select 0) atan2 (ACE_wind select 1); @@ -45,6 +57,19 @@ _heatIndex = [_temperature, _humidity] call EFUNC(weather,calculateHeatIndex); _dewPoint = [_temperature, _humidity] call EFUNC(weather,calculateDewPoint); _wetBulb = [_temperature, _barometricPressure, _humidity] call EFUNC(weather,calculateWetBulb); +_fnc_dayOfWeek = { + private ["_year", "_month", "_day", "_table"]; + _year = _this select 0; + _month = _this select 1; + _day = _this select 2; + + _table = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4]; + if (_month < 3) then { + _year = _year - 1; + }; + (_year + floor(_year/4) - floor(_year/100) + floor(_year/400) + (_table select (_month - 1)) + _day) % 7 +}; + GVAR(Direction) = 4 * floor(_playerDir / 90); if (_playerDir % 90 > 10) then { GVAR(Direction) = GVAR(Direction) + 1}; if (_playerDir % 90 > 35) then { GVAR(Direction) = GVAR(Direction) + 1}; @@ -52,220 +77,258 @@ if (_playerDir % 90 > 55) then { GVAR(Direction) = GVAR(Direction) + 1}; if (_playerDir % 90 > 80) then { GVAR(Direction) = GVAR(Direction) + 1}; GVAR(Direction) = GVAR(Direction) % 16; -switch (GVAR(Menu)) do { - case 0: { // Direction - if (!GVAR(MinAvgMax)) then { - _textCenterBig = format["%1", format["%1 %2", GVAR(Directions) select GVAR(Direction), round(_playerDir)]]; - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = "N/A"; - _textCenterLine2Right = "N/A"; - _textCenterLine3Right = "N/A"; +if (GVAR(referenceHeadingMenu) == 0) then { + switch (GVAR(Menu)) do { + case 0: { // Date + EXPLODE_3_PVT(date,_year,_month,_day); + _dayString = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] select (date call _fnc_dayOfWeek); + _monthString = localize (["str_january","str_february","str_march","str_april","str_may","str_june","str_july","str_august","str_september","str_october","str_november","str_december"] select (_month - 1)); + _textTop = _dayString; + _textCenter = format["%1 %2 %3", _day, _monthString, _year]; + _textBottomBig = [daytime, "HH:MM:SS"] call bis_fnc_timeToString; }; - }; - case 1: { // Wind SPD - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(abs(_windSpeed) * 10) / 10); - } else { - _textCenterLine1Left = "Max"; - _textCenterLine2Left = "Avg"; - switch (GVAR(MinAvgMaxMode)) do { - case 0: { - _textCenterLine1Right = "--. -"; - _textCenterLine2Right = "--. -"; - _textInfoLine2 = "- average"; - }; - case 1: { - _textCenterLine1Right = Str(round((GVAR(Max) select 1) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 1) / (GVAR(Entries) select 1) * 10) / 10); - _textInfoLine2 = "- stop"; - }; - case 2: { - _textCenterLine1Right = Str(round((GVAR(Max) select 1) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 1) / (GVAR(Entries) select 1) * 10) / 10); - _textInfoLine2 = "- clear"; - }; - }; - }; - }; - case 2: { // CROSSWIND - if (!GVAR(MinAvgMax)) then { - if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { - _textCenterBig = Str(round(abs(sin(GVAR(RefHeading) - _playerDir) * _windSpeed) * 10) / 10); - _textInfoLine1 = format["%1 m/s @ %2", round((abs(cos(_playerDir - _windDir)) * _windSpeed) * 10) / 10, round(_playerDir)]; + case 1: { // Direction + if (!GVAR(MinAvgMax)) then { + _textCenterBig = format["%1", format["%1 %2", GVAR(Directions) select GVAR(Direction), round(_playerDir)]]; } else { - _textCenterBig = Str(round(abs(sin(GVAR(RefHeading)) * _windSpeed) * 10) / 10); - _textInfoLine1 = format["%1 m/s @ %2", round(_windSpeed * 10) / 10, round(_windDir)]; - }; - _textInfoLine2 = "- set heading"; - } else { - _textCenterLine1Left = "Max"; - _textCenterLine2Left = "Avg"; - switch (GVAR(MinAvgMax)Mode) do { - case 0: { - _textCenterLine1Right = "--. -"; - _textCenterLine2Right = "--. -"; - _textInfoLine2 = "- average"; - }; - case 1: { - _textCenterLine1Right = Str(round((GVAR(Max) select 2) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 2) / (GVAR(Entries) select 2) * 10) / 10); - _textInfoLine2 = "- stop"; - }; - case 2: { - _textCenterLine1Right = Str(round((GVAR(Max) select 2) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 2) / (GVAR(Entries) select 2) * 10) / 10); - _textInfoLine2 = "- clear"; - }; + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = "N/A"; + _textCenterLine2Right = "N/A"; + _textCenterLine3Right = "N/A"; }; }; - }; - case 3: { // HEADWIND - if (!GVAR(MinAvgMax)) then { - if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { - _textCenterBig = Str(round(abs(cos(GVAR(RefHeading) - _playerDir) * _windSpeed) * 10) / 10); - _textInfoLine1 = format["%1 m/s @ %2", round((abs(cos(_playerDir - _windDir)) * _windSpeed) * 10) / 10, round(_playerDir)]; + case 2: { // Wind SPD + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(abs(_windSpeed) * 10) / 10); } else { - _textCenterBig = Str(round(abs(cos(GVAR(RefHeading)) * _windSpeed) * 10) / 10); - _textInfoLine1 = format["%1 m/s @ %2", round(_windSpeed * 10) / 10, round(_windDir)]; - }; - _textInfoLine2 = "- set heading"; - } else { - _textCenterLine1Left = "Max"; - _textCenterLine2Left = "Avg"; - switch (GVAR(MinAvgMax)Mode) do { - case 0: { - _textCenterLine1Right = "--. -"; - _textCenterLine2Right = "--. -"; - _textInfoLine2 = "- average"; - }; - case 1: { - _textCenterLine1Right = Str(round((GVAR(Max) select 3) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 3) / (GVAR(Entries) select 3) * 10) / 10); - _textInfoLine2 = "- stop"; - }; - case 2: { - _textCenterLine1Right = Str(round((GVAR(Max) select 3) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 3) / (GVAR(Entries) select 3) * 10) / 10); - _textInfoLine2 = "- clear"; + _textCenterLine1Left = "Max"; + _textCenterLine2Left = "Avg"; + switch (GVAR(MinAvgMaxMode)) do { + case 0: { + _textCenterLine1Right = "--. -"; + _textCenterLine2Right = "--. -"; + _textInfoLine2 = "- average"; + }; + case 1: { + _textCenterLine1Right = Str(round((GVAR(Max) select 2) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 2) / (GVAR(Entries) select 2) * 10) / 10); + _textInfoLine2 = "- stop"; + }; + case 2: { + _textCenterLine1Right = Str(round((GVAR(Max) select 2) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 2) / (GVAR(Entries) select 2) * 10) / 10); + _textInfoLine2 = "- clear"; + }; }; }; }; - }; - case 4: { // TEMP - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(_temperature * 10) / 10); - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round((GVAR(Min) select 4) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 4) / (GVAR(Entries) select 4) * 10) / 10); - _textCenterLine3Right = Str(round((GVAR(Max) select 4) * 10) / 10); + case 3: { // CROSSWIND + if (!GVAR(MinAvgMax)) then { + if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { + _textCenterBig = Str(round(abs(sin(GVAR(RefHeading) - _playerDir) * _windSpeed) * 10) / 10); + _textInfoLine1 = format["%1 m/s @ %2", round((abs(cos(_playerDir - _windDir)) * _windSpeed) * 10) / 10, round(_playerDir)]; + } else { + _textCenterBig = Str(round(abs(sin(GVAR(RefHeading)) * _windSpeed) * 10) / 10); + _textInfoLine1 = format["%1 m/s @ %2", round(_windSpeed * 10) / 10, round(_windDir)]; + }; + _textInfoLine2 = "- set heading"; + } else { + _textCenterLine1Left = "Max"; + _textCenterLine2Left = "Avg"; + switch (GVAR(MinAvgMax)Mode) do { + case 0: { + _textCenterLine1Right = "--. -"; + _textCenterLine2Right = "--. -"; + _textInfoLine2 = "- average"; + }; + case 1: { + _textCenterLine1Right = Str(round((GVAR(Max) select 3) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 3) / (GVAR(Entries) select 3) * 10) / 10); + _textInfoLine2 = "- stop"; + }; + case 2: { + _textCenterLine1Right = Str(round((GVAR(Max) select 3) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 3) / (GVAR(Entries) select 3) * 10) / 10); + _textInfoLine2 = "- clear"; + }; + }; + }; + }; + case 4: { // HEADWIND + if (!GVAR(MinAvgMax)) then { + if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { + _textCenterBig = Str(round(abs(cos(GVAR(RefHeading) - _playerDir) * _windSpeed) * 10) / 10); + _textInfoLine1 = format["%1 m/s @ %2", round((abs(cos(_playerDir - _windDir)) * _windSpeed) * 10) / 10, round(_playerDir)]; + } else { + _textCenterBig = Str(round(abs(cos(GVAR(RefHeading)) * _windSpeed) * 10) / 10); + _textInfoLine1 = format["%1 m/s @ %2", round(_windSpeed * 10) / 10, round(_windDir)]; + }; + _textInfoLine2 = "- set heading"; + } else { + _textCenterLine1Left = "Max"; + _textCenterLine2Left = "Avg"; + switch (GVAR(MinAvgMax)Mode) do { + case 0: { + _textCenterLine1Right = "--. -"; + _textCenterLine2Right = "--. -"; + _textInfoLine2 = "- average"; + }; + case 1: { + _textCenterLine1Right = Str(round((GVAR(Max) select 4) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 4) / (GVAR(Entries) select 4) * 10) / 10); + _textInfoLine2 = "- stop"; + }; + case 2: { + _textCenterLine1Right = Str(round((GVAR(Max) select 4) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 4) / (GVAR(Entries) select 4) * 10) / 10); + _textInfoLine2 = "- clear"; + }; + }; + }; + }; + case 5: { // TEMP + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_temperature * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 5) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 5) / (GVAR(Entries) select 5) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 5) * 10) / 10); + }; + }; + case 6: { // CHILL + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_chill * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 6) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 6) / (GVAR(Entries) select 6) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 6) * 10) / 10); + }; + }; + case 7: { // HUMIDITY + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_humidity * 100 * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 7) * 100 * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 7) / (GVAR(Entries) select 7) * 100 * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 7) * 100 * 10) / 10); + }; + }; + case 8: { // HEAT INDEX + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_heatIndex * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 8) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 8) / (GVAR(Entries) select 8) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 8) * 10) / 10); + }; + }; + case 9: { // DEW POINT + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_dewPoint * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 9) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 9) / (GVAR(Entries) select 9) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 9) * 10) / 10); + }; + }; + case 10: { // WET BULB + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_wetBulb * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 10) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 10) / (GVAR(Entries) select 10) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 10) * 10) / 10); + }; + }; + case 11: { // BARO + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(_barometricPressure * 10) / 10); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round((GVAR(Min) select 11) * 10) / 10); + _textCenterLine2Right = Str(round((GVAR(Total) select 11) / (GVAR(Entries) select 11) * 10) / 10); + _textCenterLine3Right = Str(round((GVAR(Max) select 11) * 10) / 10); + }; + }; + case 12: { // ALTITUDE + if (!GVAR(MinAvgMax)) then { + _textCenterBig = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); + } else { + _textCenterLine1Left = "Min"; + _textCenterLine2Left = "Avg"; + _textCenterLine3Left = "Max"; + _textCenterLine1Right = Str(round(GVAR(Min) select 12)); + _textCenterLine2Right = Str(round((GVAR(Total) select 12) / (GVAR(Entries) select 12))); + _textCenterLine3Right = Str(round(GVAR(Max) select 12)); + }; + }; + case 13: { // User Screen 1 + _textCenterLine1Left = Str(round(_playerDir)); + _textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); + _textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10); + _textCenterLine1Right = GVAR(Directions) select GVAR(Direction); + _textCenterLine2Right = "m"; + _textCenterLine3Right = "m/s"; + }; + case 14: { // User Screen 2 + _textCenterLine1Left = Str(round(_temperature * 10) / 10); + _textCenterLine2Left = Str(round(_humidity * 100 * 10) / 10); + _textCenterLine3Left = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); + _textCenterLine1Right = "C"; + _textCenterLine2Right = "%"; + _textCenterLine3Right = "hPA"; }; }; - case 5: { // CHILL - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(_chill * 10) / 10); - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round((GVAR(Min) select 5) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 5) / (GVAR(Entries) select 5) * 10) / 10); - _textCenterLine3Right = Str(round((GVAR(Max) select 5) * 10) / 10); +} else { + _textTop = ""; + switch (GVAR(referenceHeadingMenu)) do { + case 1: { + _textCenterLine1 = "MAGNETIC HEADING"; + _textCenterLine2 = Str(round(GVAR(RefHeading))); + _textCenterLine3 = "Auto Set "; + _textCenterLine4 = "Manual Set "; + _textCenterLine5 = "================"; + _textCenterLine6 = "- select (|) exit"; }; - }; - case 6: { // HUMIDITY - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(_humidity * 100 * 10) / 10); - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round((GVAR(Min) select 6) * 100 * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 6) / (GVAR(Entries) select 6) * 100 * 10) / 10); - _textCenterLine3Right = Str(round((GVAR(Max) select 6) * 100 * 10) / 10); + case 2: { + _textCenterLine1 = "MAGNETIC HEADING"; + _textCenterLine2 = Str(round(_playerDir)); + _textCenterLine3 = "Point Down the"; + _textCenterLine4 = "Runway or Range"; + _textCenterLine5 = "================"; + _textCenterLine6 = "- set heading"; }; - }; - case 7: { // HEAT INDEX - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(_heatIndex * 10) / 10); - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round((GVAR(Min) select 7) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 7) / (GVAR(Entries) select 7) * 10) / 10); - _textCenterLine3Right = Str(round((GVAR(Max) select 7) * 10) / 10); + case 3: { + _textCenterLine1 = "MAGNETIC HEADING"; + _textCenterLine2 = Str(round(GVAR(TmpHeading))); + _textCenterLine3 = "Press < and >"; + _textCenterLine4 = "to Adjust"; + _textCenterLine5 = "================"; + _textCenterLine6 = "- set heading"; }; }; - case 8: { // DEW POINT - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(_dewPoint * 10) / 10); - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round((GVAR(Min) select 8) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 8) / (GVAR(Entries) select 8) * 10) / 10); - _textCenterLine3Right = Str(round((GVAR(Max) select 8) * 10) / 10); - }; - }; - case 9: { // WET BULB - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(_wetBulb * 10) / 10); - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round((GVAR(Min) select 9) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 9) / (GVAR(Entries) select 9) * 10) / 10); - _textCenterLine3Right = Str(round((GVAR(Max) select 9) * 10) / 10); - }; - }; - case 10: { // BARO - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(_barometricPressure * 10) / 10); - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round((GVAR(Min) select 10) * 10) / 10); - _textCenterLine2Right = Str(round((GVAR(Total) select 10) / (GVAR(Entries) select 10) * 10) / 10); - _textCenterLine3Right = Str(round((GVAR(Max) select 10) * 10) / 10); - }; - }; - case 11: { // ALTITUDE - if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); - } else { - _textCenterLine1Left = "Min"; - _textCenterLine2Left = "Avg"; - _textCenterLine3Left = "Max"; - _textCenterLine1Right = Str(round(GVAR(Min) select 11)); - _textCenterLine2Right = Str(round((GVAR(Total) select 11) / (GVAR(Entries) select 11))); - _textCenterLine3Right = Str(round(GVAR(Max) select 11)); - }; - }; - case 12: { // User Screen 1 - _textCenterLine1Left = Str(round(_playerDir)); - _textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); - _textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10); - _textCenterLine1Right = GVAR(Directions) select GVAR(Direction); - _textCenterLine2Right = "m"; - _textCenterLine3Right = "m/s"; - }; - case 13: { // User Screen 2 - _textCenterLine1Left = Str(round(_temperature * 10) / 10); - _textCenterLine2Left = Str(round(_humidity * 100 * 10) / 10); - _textCenterLine3Left = Str(round((_playerAltitude call EFUNC(weather,calculateBarometricPressure)) * 10) / 10); - _textCenterLine1Right = "C"; - _textCenterLine2Right = "%"; - _textCenterLine3Right = "hPA"; - }; }; -[_textTop, _textCenterBig, _textCenterLine1Left, _textCenterLine2Left, _textCenterLine3Left, _textCenterLine1Right, _textCenterLine2Right, _textCenterLine3Right, _textInfoLine1, _textInfoLine2] +[_textTop, _textCenterBig, _textCenter, _textCenterLine1Left, _textCenterLine2Left, _textCenterLine3Left, _textCenterLine1Right, _textCenterLine2Right, _textCenterLine3Right, _textInfoLine1, _textInfoLine2, _textBottomBig, _textCenterLine1, _textCenterLine2, _textCenterLine3, _textCenterLine4, _textCenterLine5, _textCenterLine6] diff --git a/addons/kestrel4500/functions/fnc_updateDisplay.sqf b/addons/kestrel4500/functions/fnc_updateDisplay.sqf index 0f8be4f873..90f77f5f6a 100644 --- a/addons/kestrel4500/functions/fnc_updateDisplay.sqf +++ b/addons/kestrel4500/functions/fnc_updateDisplay.sqf @@ -14,20 +14,47 @@ */ #include "script_component.hpp" +#define __dsp (uiNamespace getVariable "Kestrel4500_Display") +#define __ctrlCenterLine3 (__dsp displayCtrl 74602) +#define __ctrlCenterLine4 (__dsp displayCtrl 74603) + private ["_outputData"]; _outputData = [] call FUNC(generateOutputData); ctrlSetText [74100, _outputData select 0]; ctrlSetText [74200, _outputData select 1]; +ctrlSetText [74201, _outputData select 2]; -ctrlSetText [74300, _outputData select 2]; -ctrlSetText [74301, _outputData select 3]; -ctrlSetText [74302, _outputData select 4]; +ctrlSetText [74300, _outputData select 3]; +ctrlSetText [74301, _outputData select 4]; +ctrlSetText [74302, _outputData select 5]; -ctrlSetText [74303, _outputData select 5]; -ctrlSetText [74304, _outputData select 6]; -ctrlSetText [74305, _outputData select 7]; +ctrlSetText [74303, _outputData select 6]; +ctrlSetText [74304, _outputData select 7]; +ctrlSetText [74305, _outputData select 8]; -ctrlSetText [74400, _outputData select 8]; -ctrlSetText [74401, _outputData select 9]; \ No newline at end of file +ctrlSetText [74400, _outputData select 9]; +ctrlSetText [74401, _outputData select 10]; + +ctrlSetText [74500, _outputData select 11]; + +ctrlSetText [74600, _outputData select 12]; +ctrlSetText [74601, _outputData select 13]; +ctrlSetText [74602, _outputData select 14]; +ctrlSetText [74603, _outputData select 15]; +ctrlSetText [74604, _outputData select 16]; +ctrlSetText [74605, _outputData select 17]; + +if (GVAR(referenceHeadingMenu) == 1) then { + if (GVAR(referenceHeadingAutoSet)) then { + __ctrlCenterLine3 ctrlSetTextColor [0, 0, 0, 0.6]; + __ctrlCenterLine4 ctrlSetTextColor [0, 0, 0, 1.0]; + } else { + __ctrlCenterLine3 ctrlSetTextColor [0, 0, 0, 1.0]; + __ctrlCenterLine4 ctrlSetTextColor [0, 0, 0, 0.6]; + }; +} else { + __ctrlCenterLine3 ctrlSetTextColor [0, 0, 0, 1.0]; + __ctrlCenterLine4 ctrlSetTextColor [0, 0, 0, 1.0]; +}; From f9b7e3c6f7045be5e901fcf6ac4265564d7a22c4 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 21:10:34 +0200 Subject: [PATCH 12/14] Fixed clashing MACRO names --- addons/weather/functions/fnc_calculateDewPoint.sqf | 2 ++ addons/weather/functions/fnc_calculateHeatIndex.sqf | 4 ++-- addons/weather/script_component.hpp | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/weather/functions/fnc_calculateDewPoint.sqf b/addons/weather/functions/fnc_calculateDewPoint.sqf index c5de883090..76656b1f55 100644 --- a/addons/weather/functions/fnc_calculateDewPoint.sqf +++ b/addons/weather/functions/fnc_calculateDewPoint.sqf @@ -20,6 +20,8 @@ PARAMS_2(_t,_rh); +if (_rh == 0) exitWith { CELSIUS(0) }; + // Source: https://en.wikipedia.org/wiki/Dew_point private ["_gamma"]; diff --git a/addons/weather/functions/fnc_calculateHeatIndex.sqf b/addons/weather/functions/fnc_calculateHeatIndex.sqf index 085edcd1a9..473360c867 100644 --- a/addons/weather/functions/fnc_calculateHeatIndex.sqf +++ b/addons/weather/functions/fnc_calculateHeatIndex.sqf @@ -28,7 +28,7 @@ PARAMS_2(_t,_rh); // Source: https://en.wikipedia.org/wiki/Heat_index -_t = FAHRENHEIT(_t); +_t = TO_FAHRENHEIT(_t); _rh = _rh * 100; // relative humidity in % -CELSIUS(__C1 + __C2 * _t + __C3 * _rh + __C4 * _t * _rh + __C5 * _t^2 + __C6 * _rh^2 + __C7 * _t^2 * _rh + __C8 * _t * _rh^2) +TO_CELSIUS(__C1 + __C2 * _t + __C3 * _rh + __C4 * _t * _rh + __C5 * _t^2 + __C6 * _rh^2 + __C7 * _t^2 * _rh + __C8 * _t * _rh^2) diff --git a/addons/weather/script_component.hpp b/addons/weather/script_component.hpp index dedfc59236..2a6aeb0393 100644 --- a/addons/weather/script_component.hpp +++ b/addons/weather/script_component.hpp @@ -18,5 +18,5 @@ #define WATER_VAPOR_MOLAR_MASS 0.018016 #define DRY_AIR_MOLAR_MASS 0.028964 #define SPECIFIC_GAS_CONSTANT_DRY_AIR 287.058 -#define CELSIUS(t) ((t - 32) / 1.8) -#define FAHRENHEIT(t) (t * 1.8 + 32) +#define TO_CELSIUS(t) ((t - 32) / 1.8) +#define TO_FAHRENHEIT(t) (t * 1.8 + 32) From cdd07a33c9ae3c39f5c94bb8168a9d6e761ec7e6 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 23:30:16 +0200 Subject: [PATCH 13/14] Fixed some typos --- addons/kestrel4500/functions/fnc_buttonPressed.sqf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/kestrel4500/functions/fnc_buttonPressed.sqf b/addons/kestrel4500/functions/fnc_buttonPressed.sqf index 5c6553e402..66c4c647de 100644 --- a/addons/kestrel4500/functions/fnc_buttonPressed.sqf +++ b/addons/kestrel4500/functions/fnc_buttonPressed.sqf @@ -17,7 +17,7 @@ switch (_this) do { case 0: { // Enter - if (!GVAR(MinAvgMax) && (GVAR(Menu) == 2 || GVAR(Menu) == 3)) then { + if (!GVAR(MinAvgMax) && (GVAR(Menu) == 3 || GVAR(Menu) == 4)) then { switch (GVAR(referenceHeadingMenu)) do { case 0: { // Head- and Crosswind main page GVAR(TmpHeading) = GVAR(RefHeading); @@ -42,14 +42,14 @@ switch (_this) do { }; }; }; - if (GVAR(MinAvgMax) && GVAR(Menu) > 0 && GVAR(Menu) < 4) then { + if (GVAR(MinAvgMax) && GVAR(Menu) > 1 && GVAR(Menu) < 5) then { if (GVAR(MinAvgMaxMode) != 1) then { { GVAR(MIN) set [_x, 0]; GVAR(MAX) set [_x, 0]; GVAR(TOTAL) set [_x, 0]; GVAR(ENTRIES) set [_x, 0]; - } forEach [1, 2, 3]; + } forEach [2, 3, 4]; }; GVAR(MinAvgMaxMode) = (GVAR(MinAvgMaxMode) + 1) % 3; }; From a008c45875ce7697996f13a761fb2e26e96f0812 Mon Sep 17 00:00:00 2001 From: ulteq Date: Sat, 16 May 2015 23:34:50 +0200 Subject: [PATCH 14/14] Fixed heading can be negative --- addons/kestrel4500/functions/fnc_buttonPressed.sqf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/kestrel4500/functions/fnc_buttonPressed.sqf b/addons/kestrel4500/functions/fnc_buttonPressed.sqf index 66c4c647de..c88d9df72f 100644 --- a/addons/kestrel4500/functions/fnc_buttonPressed.sqf +++ b/addons/kestrel4500/functions/fnc_buttonPressed.sqf @@ -31,7 +31,7 @@ switch (_this) do { }; }; case 2: { // Auto set - GVAR(RefHeading) = getDir ACE_player; + GVAR(RefHeading) = (getDir ACE_player) % 360; GVAR(referenceHeadingMenu) = 0; GVAR(headingSetDisplayTimer) = diag_tickTime; }; @@ -78,6 +78,7 @@ switch (_this) do { } else { GVAR(TmpHeading) = GVAR(TmpHeading) - 1; }; + GVAR(TmpHeading) = (GVAR(TmpHeading) + 360) % 360; GVAR(manualSetCooldown) = diag_tickTime; }; }; @@ -92,6 +93,7 @@ switch (_this) do { } else { GVAR(TmpHeading) = GVAR(TmpHeading) + 1; }; + GVAR(TmpHeading) = (GVAR(TmpHeading) + 360) % 360; GVAR(manualSetCooldown) = diag_tickTime; }; };