From c2c9bd85999256876998ae8e3ade5a540915a24b Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Wed, 28 Jan 2015 22:04:01 +0100 Subject: [PATCH] allow sync pulse to be up to 5% of scan line length too early or too late --- app/src/main/rs/constants.rsh | 1 + app/src/main/rs/modes.rsh | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/src/main/rs/constants.rsh b/app/src/main/rs/constants.rsh index c1e7c9d..4d0c349 100644 --- a/app/src/main/rs/constants.rsh +++ b/app/src/main/rs/constants.rsh @@ -34,6 +34,7 @@ static const int mode_scottieDX = 7; static const int mode_wrasseSC2_180 = 8; static const float sync_buildup_ms = 1.1f; +static const float scanline_tolerance = 0.005f; static const float robot36_scanline_ms = 150.0f; static const float robot72_scanline_ms = 300.0f; static const float martin1_scanline_ms = 446.446f; diff --git a/app/src/main/rs/modes.rsh b/app/src/main/rs/modes.rsh index 5dbae32..0c5afaa 100644 --- a/app/src/main/rs/modes.rsh +++ b/app/src/main/rs/modes.rsh @@ -73,8 +73,8 @@ void robot36_mode() u_end = v_end = round((uv_end_ms * sample_rate) / 1000.0f); scanline_length = robot36_scanline_length; - minimum_length = scanline_length - 0.001f * sample_rate; - maximum_length = scanline_length + 0.001f * sample_rate; + minimum_length = ((1.0f - scanline_tolerance) * robot36_scanline_ms * sample_rate) / 1000.0f; + maximum_length = ((1.0f + scanline_tolerance) * robot36_scanline_ms * sample_rate) / 1000.0f; } void robot72_mode() { @@ -116,8 +116,8 @@ void robot72_mode() u_end = round((u_end_ms * sample_rate) / 1000.0f); scanline_length = robot72_scanline_length; - minimum_length = scanline_length - 0.001f * sample_rate; - maximum_length = scanline_length + 0.001f * sample_rate; + minimum_length = ((1.0f - scanline_tolerance) * robot72_scanline_ms * sample_rate) / 1000.0f; + maximum_length = ((1.0f + scanline_tolerance) * robot72_scanline_ms * sample_rate) / 1000.0f; } void martin1_mode() { @@ -149,8 +149,8 @@ void martin1_mode() b_begin = round((b_begin_ms * sample_rate) / 1000.0f); scanline_length = martin1_scanline_length; - minimum_length = scanline_length - 0.001f * sample_rate; - maximum_length = scanline_length + 0.001f * sample_rate; + minimum_length = ((1.0f - scanline_tolerance) * martin1_scanline_ms * sample_rate) / 1000.0f; + maximum_length = ((1.0f + scanline_tolerance) * martin1_scanline_ms * sample_rate) / 1000.0f; } void martin2_mode() { @@ -182,8 +182,8 @@ void martin2_mode() b_begin = round((b_begin_ms * sample_rate) / 1000.0f); scanline_length = martin2_scanline_length; - minimum_length = scanline_length - 0.001f * sample_rate; - maximum_length = scanline_length + 0.001f * sample_rate; + minimum_length = ((1.0f - scanline_tolerance) * martin2_scanline_ms * sample_rate) / 1000.0f; + maximum_length = ((1.0f + scanline_tolerance) * martin2_scanline_ms * sample_rate) / 1000.0f; } void scottie1_mode() { @@ -215,8 +215,8 @@ void scottie1_mode() b_begin = round((b_begin_ms * sample_rate) / 1000.0f); scanline_length = scottie1_scanline_length; - minimum_length = scanline_length - 0.001f * sample_rate; - maximum_length = scanline_length + 0.001f * sample_rate; + minimum_length = ((1.0f - scanline_tolerance) * scottie1_scanline_ms * sample_rate) / 1000.0f; + maximum_length = ((1.0f + scanline_tolerance) * scottie1_scanline_ms * sample_rate) / 1000.0f; } void scottie2_mode() { @@ -248,8 +248,8 @@ void scottie2_mode() b_begin = round((b_begin_ms * sample_rate) / 1000.0f); scanline_length = scottie2_scanline_length; - minimum_length = scanline_length - 0.001f * sample_rate; - maximum_length = scanline_length + 0.001f * sample_rate; + minimum_length = ((1.0f - scanline_tolerance) * scottie2_scanline_ms * sample_rate) / 1000.0f; + maximum_length = ((1.0f + scanline_tolerance) * scottie2_scanline_ms * sample_rate) / 1000.0f; } void scottieDX_mode() { @@ -281,8 +281,8 @@ void scottieDX_mode() b_begin = round((b_begin_ms * sample_rate) / 1000.0f); scanline_length = scottieDX_scanline_length; - minimum_length = scanline_length - 0.001f * sample_rate; - maximum_length = scanline_length + 0.001f * sample_rate; + minimum_length = ((1.0f - scanline_tolerance) * scottieDX_scanline_ms * sample_rate) / 1000.0f; + maximum_length = ((1.0f + scanline_tolerance) * scottieDX_scanline_ms * sample_rate) / 1000.0f; } void wrasseSC2_180_mode() { @@ -312,8 +312,8 @@ void wrasseSC2_180_mode() b_begin = round((b_begin_ms * sample_rate) / 1000.0f); scanline_length = wrasseSC2_180_scanline_length; - minimum_length = scanline_length - 0.001f * sample_rate; - maximum_length = scanline_length + 0.001f * sample_rate; + minimum_length = ((1.0f - scanline_tolerance) * wrasseSC2_180_scanline_ms * sample_rate) / 1000.0f; + maximum_length = ((1.0f + scanline_tolerance) * wrasseSC2_180_scanline_ms * sample_rate) / 1000.0f; } static void switch_mode(int new_mode)