X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2FATC-Inputs.cxx;h=be59770f89fda441e7f2b9bdc8a26da1acfe0afd;hb=b0dcb657e77579ecc79798ff365737095f96f9e2;hp=f90e89129fae9bb8e0bcc9f267b8828d9ad7c01b;hpb=d9bfd5a425df1bad7e3c53a64adce871e299a6b9;p=flightgear.git diff --git a/src/Network/ATC-Inputs.cxx b/src/Network/ATC-Inputs.cxx index f90e89129..be59770f8 100644 --- a/src/Network/ATC-Inputs.cxx +++ b/src/Network/ATC-Inputs.cxx @@ -31,24 +31,27 @@ # include # include # include +# include # include # include #endif #include #include +#include #include #include #include +#include #include
#include "ATC-Inputs.hxx" -SG_USING_STD(string); - +using std::string; +using std::vector; // Constructor: The _board parameter specifies which board to @@ -419,6 +422,7 @@ bool FGATCInput::do_analog_in() { int min = 0; int max = 1023; int deadband = 0; + int hysteresis = 0; float offset = 0.0; float factor = 1.0; if ( cname == "channel" ) { @@ -458,6 +462,10 @@ bool FGATCInput::do_analog_in() { if ( prop != NULL ) { deadband = prop->getIntValue(); } + prop = child->getChild( "hysteresis" ); + if ( prop != NULL ) { + hysteresis = prop->getIntValue(); + } prop = child->getChild( "offset" ); if ( prop != NULL ) { offset = prop->getFloatValue(); @@ -482,6 +490,22 @@ bool FGATCInput::do_analog_in() { { // "Cook" the raw value float scaled_value = 0.0f; + + if ( hysteresis > 0 ) { + int last_raw_value = 0; + prop = child->getChild( "last-raw-value", 0, true ); + last_raw_value = prop->getIntValue(); + + if ( abs(raw_value - last_raw_value) < hysteresis ) + { + // not enough movement stay put + raw_value = last_raw_value; + } else { + // update last raw value + prop->setIntValue( raw_value ); + } + } + if ( center >= 0 ) { scaled_value = scale( center, deadband, min, max, raw_value ); @@ -637,9 +661,13 @@ static void update_switch_matrix( unsigned char switches = switch_data[row]; for( int column = 0; column < ATC_NUM_COLS; ++column ) { - switch_matrix[board][column][row] = switches & 1; - switches = switches >> 1; - } + if ( row < 8 ) { + switch_matrix[board][column][row] = switches & 1; + } else { + switch_matrix[board][row-8][8+column] = switches & 1; + } + switches = switches >> 1; + } } }