From 30a6d256ba77e87eb67954fedda6d9768ee09444 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Sun, 7 Dec 2014 22:26:03 +0100 Subject: [PATCH] made decoder.rs independent of new modes --- app/src/main/java/xdsopl/robot36/ImageView.java | 4 ++-- app/src/main/rs/constants.rsh | 7 ++++++- app/src/main/rs/decoder.rs | 15 +++++---------- app/src/main/rs/modes.rsh | 17 ++++++++++++++--- app/src/main/rs/state.rsh | 1 + 5 files changed, 28 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/xdsopl/robot36/ImageView.java b/app/src/main/java/xdsopl/robot36/ImageView.java index 75d3f65..0b086e1 100644 --- a/app/src/main/java/xdsopl/robot36/ImageView.java +++ b/app/src/main/java/xdsopl/robot36/ImageView.java @@ -57,7 +57,7 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback { private final Allocation rsDecoderCurrentMode; private final ScriptC_decoder rsDecoder; - private final int mode_raw = 0; + private final int mode_debug = 0; private final int mode_robot36 = 1; private final int mode_robot72 = 2; private final int mode_martin1 = 3; @@ -185,7 +185,7 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback { { synchronized (thread) { switch (mode) { - case mode_raw: + case mode_debug: imageWidth = 320; imageHeight = bitmap.getHeight(); updateTitle(R.string.action_debug_mode); diff --git a/app/src/main/rs/constants.rsh b/app/src/main/rs/constants.rsh index 26c6d8f..55419b1 100644 --- a/app/src/main/rs/constants.rsh +++ b/app/src/main/rs/constants.rsh @@ -17,7 +17,12 @@ limitations under the License. #ifndef CONSTANTS_RSH #define CONSTANTS_RSH -static const int mode_raw = 0; +static const int decoder_raw = 0; +static const int decoder_robot36 = 1; +static const int decoder_yuv = 2; +static const int decoder_rgb = 3; + +static const int mode_debug = 0; static const int mode_robot36 = 1; static const int mode_robot72 = 2; static const int mode_martin1 = 3; diff --git a/app/src/main/rs/decoder.rs b/app/src/main/rs/decoder.rs index 62047d7..f25dbdd 100644 --- a/app/src/main/rs/decoder.rs +++ b/app/src/main/rs/decoder.rs @@ -143,7 +143,7 @@ void decode(int samples) { int sync_pulse = !sync_level && sync_counter >= sync_length; sync_counter = sync_level ? sync_counter + 1 : 0; - if (*current_mode != mode_raw) { + if (*current_mode != mode_debug) { int detected_mode = calibration_detector(dat_value, dat_active, cnt_active, cnt_quantized); if (detected_mode >= 0) reset(); @@ -165,19 +165,14 @@ void decode(int samples) { seperator_counter = 0; continue; } - switch (*current_mode) { - case mode_robot36: + switch (current_decoder) { + case decoder_robot36: robot36_decoder(); break; - case mode_robot72: + case decoder_yuv: yuv_decoder(); break; - case mode_martin1: - case mode_martin2: - case mode_scottie1: - case mode_scottie2: - case mode_scottieDX: - case mode_wrasseSC2_180: + case decoder_rgb: rgb_decoder(); break; default: diff --git a/app/src/main/rs/modes.rsh b/app/src/main/rs/modes.rsh index 6c286c3..99f1be9 100644 --- a/app/src/main/rs/modes.rsh +++ b/app/src/main/rs/modes.rsh @@ -25,7 +25,8 @@ void debug_sync() { save_cnt = 1; save_dat = 0; - *current_mode = mode_raw; + *current_mode = mode_debug; + current_decoder = decoder_raw; sync_length = minimum_sync_length; maximum_length = buffer_length; scanline_length = maximum_length; @@ -34,7 +35,8 @@ void debug_image() { save_dat = 1; save_cnt = 0; - *current_mode = mode_raw; + *current_mode = mode_debug; + current_decoder = decoder_raw; sync_length = minimum_sync_length; maximum_length = buffer_length; scanline_length = maximum_length; @@ -43,7 +45,8 @@ void debug_both() { save_cnt = 1; save_dat = 1; - *current_mode = mode_raw; + *current_mode = mode_debug; + current_decoder = decoder_raw; sync_length = minimum_sync_length; maximum_length = buffer_length; scanline_length = maximum_length; @@ -53,6 +56,7 @@ void robot36_mode() save_dat = 1; save_cnt = 0; *current_mode = mode_robot36; + current_decoder = decoder_robot36; const float tolerance = 0.8f; const float settling_time = 0.0011f; const float sync_seconds = 0.009f; @@ -77,6 +81,7 @@ void robot72_mode() save_dat = 1; save_cnt = 0; *current_mode = mode_robot72; + current_decoder = decoder_yuv; const float tolerance = 0.8f; const float settling_time = 0.0011f; const float sync_seconds = 0.009f; @@ -105,6 +110,7 @@ void martin1_mode() save_cnt = 0; save_dat = 1; *current_mode = mode_martin1; + current_decoder = decoder_rgb; const float tolerance = 0.5f; const float sync_seconds = 0.004862f; const float sync_porch_seconds = 0.000572f; @@ -128,6 +134,7 @@ void martin2_mode() save_cnt = 0; save_dat = 1; *current_mode = mode_martin2; + current_decoder = decoder_rgb; const float tolerance = 0.5f; const float sync_seconds = 0.004862f; const float sync_porch_seconds = 0.000572f; @@ -151,6 +158,7 @@ void scottie1_mode() save_cnt = 0; save_dat = 1; *current_mode = mode_scottie1; + current_decoder = decoder_rgb; const float tolerance = 0.8f; const float settling_time = 0.0011f; const float sync_seconds = 0.009f; @@ -175,6 +183,7 @@ void scottie2_mode() save_cnt = 0; save_dat = 1; *current_mode = mode_scottie2; + current_decoder = decoder_rgb; const float tolerance = 0.8f; const float settling_time = 0.0011f; const float sync_seconds = 0.009f; @@ -199,6 +208,7 @@ void scottieDX_mode() save_cnt = 0; save_dat = 1; *current_mode = mode_scottieDX; + current_decoder = decoder_rgb; const float tolerance = 0.8f; const float settling_time = 0.0011f; const float sync_seconds = 0.009f; @@ -223,6 +233,7 @@ void wrasseSC2_180_mode() save_cnt = 0; save_dat = 1; *current_mode = mode_wrasseSC2_180; + current_decoder = decoder_rgb; const float tolerance = 0.5f; const float sync_seconds = 0.0055225f; const float sync_porch_seconds = 0.0005f; diff --git a/app/src/main/rs/state.rsh b/app/src/main/rs/state.rsh index a695c44..cafb56c 100644 --- a/app/src/main/rs/state.rsh +++ b/app/src/main/rs/state.rsh @@ -20,6 +20,7 @@ limitations under the License. static ema_t avg_power, leader_lowpass; static ddc_t cnt_ddc, dat_ddc; static fmd_t cnt_fmd, dat_fmd; +static int current_decoder; static int sample_rate, even_hpos; static int maximum_variance, minimum_sync_length; static int scanline_length, minimum_length, maximum_length;