mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-06 07:12:07 +01:00
added Wrasse SC2-180 Mode
definitively need to do something about to reduce the numbers of places needed to be changed to add a new mode ..
This commit is contained in:
parent
32efb41613
commit
4e48eb185c
|
|
@ -65,6 +65,7 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
private final int mode_scottie1 = 5;
|
||||
private final int mode_scottie2 = 6;
|
||||
private final int mode_scottieDX = 7;
|
||||
private final int mode_wrasseSC2_180 = 8;
|
||||
|
||||
private final Thread thread = new Thread() {
|
||||
@Override
|
||||
|
|
@ -173,6 +174,11 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
rsDecoder.invoke_scottieDX_mode();
|
||||
}
|
||||
}
|
||||
void wrasseSC2_180_mode() {
|
||||
synchronized (thread) {
|
||||
rsDecoder.invoke_wrasseSC2_180_mode();
|
||||
}
|
||||
}
|
||||
|
||||
void updateTitle(int id) { activity.updateTitle(activity.getString(id)); }
|
||||
void switch_mode(int mode)
|
||||
|
|
@ -219,6 +225,11 @@ public class ImageView extends SurfaceView implements SurfaceHolder.Callback {
|
|||
imageHeight = 256;
|
||||
updateTitle(R.string.action_scottieDX_mode);
|
||||
break;
|
||||
case mode_wrasseSC2_180:
|
||||
imageWidth = 320;
|
||||
imageHeight = 256;
|
||||
updateTitle(R.string.action_wrasseSC2_180_mode);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ public class MainActivity extends Activity {
|
|||
case R.id.action_scottieDX_mode:
|
||||
view.scottieDX_mode();
|
||||
return true;
|
||||
case R.id.action_wrasseSC2_180_mode:
|
||||
view.wrasseSC2_180_mode();
|
||||
return true;
|
||||
case R.id.action_debug_sync:
|
||||
view.debug_sync();
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_scottieDX_mode" android:title="@string/action_scottieDX_mode"
|
||||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_wrasseSC2_180_mode" android:title="@string/action_wrasseSC2_180_mode"
|
||||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_debug_sync" android:title="@string/action_debug_sync"
|
||||
android:orderInCategory="100" android:showAsAction="never" />
|
||||
<item android:id="@+id/action_debug_image" android:title="@string/action_debug_image"
|
||||
|
|
|
|||
|
|
@ -13,5 +13,6 @@
|
|||
<string name="action_scottie1_mode">Scottie1 Mode</string>
|
||||
<string name="action_scottie2_mode">Scottie2 Mode</string>
|
||||
<string name="action_scottieDX_mode">ScottieDX Mode</string>
|
||||
<string name="action_wrasseSC2_180_mode">WrasseSC2-180 Mode</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -115,6 +115,8 @@ static int calibration_detector(float dat_value, int dat_active, int cnt_active,
|
|||
return mode_scottie2;
|
||||
case 0xcc:
|
||||
return mode_scottieDX;
|
||||
case 0xb7:
|
||||
return mode_wrasseSC2_180;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ static const int mode_martin2 = 4;
|
|||
static const int mode_scottie1 = 5;
|
||||
static const int mode_scottie2 = 6;
|
||||
static const int mode_scottieDX = 7;
|
||||
static const int mode_wrasseSC2_180 = 8;
|
||||
|
||||
static const float robot36_scanline_seconds = 0.15f;
|
||||
static const float robot72_scanline_seconds = 0.3f;
|
||||
|
|
@ -33,5 +34,6 @@ static const float martin2_scanline_seconds = 0.226798f;
|
|||
static const float scottie1_scanline_seconds = 0.42822f;
|
||||
static const float scottie2_scanline_seconds = 0.277692f;
|
||||
static const float scottieDX_scanline_seconds = 1.0503f;
|
||||
static const float wrasseSC2_180_scanline_seconds = 0.7110225f;
|
||||
|
||||
#endif
|
||||
|
|
@ -177,6 +177,7 @@ void decode(int samples) {
|
|||
case mode_scottie1:
|
||||
case mode_scottie2:
|
||||
case mode_scottieDX:
|
||||
case mode_wrasseSC2_180:
|
||||
rgb_decoder();
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ void initialize(float rate, int length, int width, int height)
|
|||
scottie1_scanline_length = scottie1_scanline_seconds * sample_rate;
|
||||
scottie2_scanline_length = scottie2_scanline_seconds * sample_rate;
|
||||
scottieDX_scanline_length = scottieDX_scanline_seconds * sample_rate;
|
||||
wrasseSC2_180_scanline_length = wrasseSC2_180_scanline_seconds * sample_rate;
|
||||
|
||||
const float pairwise_minimum_of_scanline_time_distances = 0.018226f;
|
||||
float deviation = 0.5f * pairwise_minimum_of_scanline_time_distances * sample_rate;
|
||||
|
|
|
|||
|
|
@ -218,6 +218,25 @@ void scottieDX_mode()
|
|||
scanline_length = scottieDX_scanline_length;
|
||||
maximum_length = scanline_length + sync_porch_seconds * sample_rate;
|
||||
}
|
||||
void wrasseSC2_180_mode()
|
||||
{
|
||||
save_cnt = 0;
|
||||
save_dat = 1;
|
||||
*current_mode = mode_wrasseSC2_180;
|
||||
const float tolerance = 0.5f;
|
||||
const float sync_seconds = 0.0055225f;
|
||||
const float sync_porch_seconds = 0.0005f;
|
||||
const float rgb_scan_seconds = 0.235f;
|
||||
sync_length = tolerance * sync_seconds * sample_rate;
|
||||
r_begin = 0;
|
||||
r_end = r_begin + rgb_scan_seconds * sample_rate;
|
||||
g_begin = r_end;
|
||||
g_end = g_begin + rgb_scan_seconds * sample_rate;
|
||||
b_begin = g_end;
|
||||
b_end = b_begin + rgb_scan_seconds * sample_rate;
|
||||
scanline_length = wrasseSC2_180_scanline_length;
|
||||
maximum_length = scanline_length + sync_porch_seconds * sample_rate;
|
||||
}
|
||||
|
||||
static void switch_mode(int new_mode)
|
||||
{
|
||||
|
|
@ -245,6 +264,9 @@ static void switch_mode(int new_mode)
|
|||
case mode_scottieDX:
|
||||
scottieDX_mode();
|
||||
break;
|
||||
case mode_wrasseSC2_180:
|
||||
wrasseSC2_180_mode();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,12 @@ static float scottieDX_estimator(int length)
|
|||
float deviation = length - scottieDX_scanline_length;
|
||||
return filter(&variance, deviation * deviation);
|
||||
}
|
||||
static float wrasseSC2_180_estimator(int length)
|
||||
{
|
||||
static ema_t variance = { 0.0f, ema_estimator_a };
|
||||
float deviation = length - wrasseSC2_180_scanline_length;
|
||||
return filter(&variance, deviation * deviation);
|
||||
}
|
||||
|
||||
static int scanline_estimator(int sync_level)
|
||||
{
|
||||
|
|
@ -83,11 +89,18 @@ static int scanline_estimator(int sync_level)
|
|||
float scottie1_var = scottie1_estimator(scanline_counter);
|
||||
float scottie2_var = scottie2_estimator(scanline_counter);
|
||||
float scottieDX_var = scottieDX_estimator(scanline_counter);
|
||||
float wrasseSC2_180_var = wrasseSC2_180_estimator(scanline_counter);
|
||||
scanline_counter = 0;
|
||||
|
||||
float min_var = min(min(min(robot36_var, robot72_var),
|
||||
min(martin1_var, martin2_var)),
|
||||
min(min(scottie1_var, scottie2_var), scottieDX_var));
|
||||
float min_var = min(
|
||||
min(
|
||||
min(robot36_var, robot72_var),
|
||||
min(martin1_var, martin2_var)
|
||||
), min(
|
||||
min(scottie1_var, scottie2_var),
|
||||
min(scottieDX_var, wrasseSC2_180_var)
|
||||
)
|
||||
);
|
||||
|
||||
if (min_var > maximum_variance)
|
||||
return -1;
|
||||
|
|
@ -105,6 +118,8 @@ static int scanline_estimator(int sync_level)
|
|||
return mode_scottie2;
|
||||
else if (min_var == scottieDX_var)
|
||||
return mode_scottieDX;
|
||||
else if (min_var == wrasseSC2_180_var)
|
||||
return mode_wrasseSC2_180;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,5 +40,6 @@ static int martin2_scanline_length;
|
|||
static int scottie1_scanline_length;
|
||||
static int scottie2_scanline_length;
|
||||
static int scottieDX_scanline_length;
|
||||
static int wrasseSC2_180_scanline_length;
|
||||
|
||||
#endif
|
||||
Loading…
Reference in a new issue