mirror of
https://github.com/xdsopl/robot36.git
synced 2025-12-06 07:12:07 +01:00
preserve scope position on decoder reconstruction
This commit is contained in:
parent
8325abf6a2
commit
cdf12d2c09
|
|
@ -34,7 +34,6 @@ public class Decoder {
|
||||||
private final ArrayList<Mode> syncPulse20msModes;
|
private final ArrayList<Mode> syncPulse20msModes;
|
||||||
|
|
||||||
public Mode lastMode;
|
public Mode lastMode;
|
||||||
public int curLine;
|
|
||||||
private int curSample;
|
private int curSample;
|
||||||
private int lastSyncPulseIndex;
|
private int lastSyncPulseIndex;
|
||||||
private int lastScanLineSamples;
|
private int lastScanLineSamples;
|
||||||
|
|
@ -135,11 +134,11 @@ public class Decoder {
|
||||||
if (!okay)
|
if (!okay)
|
||||||
return;
|
return;
|
||||||
for (int row = 0; row < pixelBuffer.height; ++row) {
|
for (int row = 0; row < pixelBuffer.height; ++row) {
|
||||||
System.arraycopy(pixelBuffer.pixels, row * pixelBuffer.width, scopeBuffer.pixels, scopeBuffer.width * curLine, pixelBuffer.width);
|
System.arraycopy(pixelBuffer.pixels, row * pixelBuffer.width, scopeBuffer.pixels, scopeBuffer.width * scopeBuffer.line, pixelBuffer.width);
|
||||||
Arrays.fill(scopeBuffer.pixels, scopeBuffer.width * curLine + pixelBuffer.width, scopeBuffer.width * curLine + scopeBuffer.width, 0);
|
Arrays.fill(scopeBuffer.pixels, scopeBuffer.width * scopeBuffer.line + pixelBuffer.width, scopeBuffer.width * scopeBuffer.line + scopeBuffer.width, 0);
|
||||||
System.arraycopy(pixelBuffer.pixels, row * pixelBuffer.width, scopeBuffer.pixels, scopeBuffer.width * (curLine + scopeBuffer.height / 2), pixelBuffer.width);
|
System.arraycopy(pixelBuffer.pixels, row * pixelBuffer.width, scopeBuffer.pixels, scopeBuffer.width * (scopeBuffer.line + scopeBuffer.height / 2), pixelBuffer.width);
|
||||||
Arrays.fill(scopeBuffer.pixels, scopeBuffer.width * (curLine + scopeBuffer.height / 2) + pixelBuffer.width, scopeBuffer.width * (curLine + scopeBuffer.height / 2) + scopeBuffer.width, 0);
|
Arrays.fill(scopeBuffer.pixels, scopeBuffer.width * (scopeBuffer.line + scopeBuffer.height / 2) + pixelBuffer.width, scopeBuffer.width * (scopeBuffer.line + scopeBuffer.height / 2) + scopeBuffer.width, 0);
|
||||||
curLine = (curLine + 1) % (scopeBuffer.height / 2);
|
scopeBuffer.line = (scopeBuffer.line + 1) % (scopeBuffer.height / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
public void onPeriodicNotification(AudioRecord audioRecord) {
|
public void onPeriodicNotification(AudioRecord audioRecord) {
|
||||||
audioRecord.read(recordBuffer, 0, recordBuffer.length, AudioRecord.READ_BLOCKING);
|
audioRecord.read(recordBuffer, 0, recordBuffer.length, AudioRecord.READ_BLOCKING);
|
||||||
if (decoder.process(recordBuffer, recordChannel)) {
|
if (decoder.process(recordBuffer, recordChannel)) {
|
||||||
scopeBitmap.setPixels(scopeBuffer.pixels, scopeBuffer.width * decoder.curLine, scopeBuffer.width, 0, 0, scopeBuffer.width, scopeBuffer.height / 2);
|
scopeBitmap.setPixels(scopeBuffer.pixels, scopeBuffer.width * scopeBuffer.line, scopeBuffer.width, 0, 0, scopeBuffer.width, scopeBuffer.height / 2);
|
||||||
scopeView.invalidate();
|
scopeView.invalidate();
|
||||||
setStatus(decoder.lastMode.getName());
|
setStatus(decoder.lastMode.getName());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,12 @@ public class PixelBuffer {
|
||||||
public int[] pixels;
|
public int[] pixels;
|
||||||
public int width;
|
public int width;
|
||||||
public int height;
|
public int height;
|
||||||
|
public int line;
|
||||||
|
|
||||||
PixelBuffer(int width, int height) {
|
PixelBuffer(int width, int height) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
this.line = 0;
|
||||||
this.pixels = new int[width * height];
|
this.pixels = new int[width * height];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue