Slow down grpc loader, fix width setting for SLAM and invert colours.
This commit is contained in:
@@ -62,7 +62,7 @@ public class PiLoader implements Runnable {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Use the same update rate as a typical screen refresh rate.
|
// Use the same update rate as a typical screen refresh rate.
|
||||||
TimeUnit.MILLISECONDS.sleep(15);
|
TimeUnit.MILLISECONDS.sleep(200);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO: Handle when interrupted and sleeping.
|
// TODO: Handle when interrupted and sleeping.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public class SlamView extends SurfaceView implements SlamUpdater.MapChangedListe
|
|||||||
private SlamUpdater slam;
|
private SlamUpdater slam;
|
||||||
private Thread mapThread;
|
private Thread mapThread;
|
||||||
private Context context;
|
private Context context;
|
||||||
private int width;
|
|
||||||
private SurfaceHolder surfaceHolder;
|
private SurfaceHolder surfaceHolder;
|
||||||
private Paint paint;
|
private Paint paint;
|
||||||
private SlamControlGrpc.SlamControlStub stub;
|
private SlamControlGrpc.SlamControlStub stub;
|
||||||
@@ -118,11 +117,12 @@ public class SlamView extends SurfaceView implements SlamUpdater.MapChangedListe
|
|||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.drawColor(Color.WHITE);
|
canvas.drawColor(Color.WHITE);
|
||||||
// Using width as we want square.
|
// Using width as we want square.
|
||||||
Bitmap bitmap = Bitmap.createBitmap(width, width, Bitmap.Config.ALPHA_8);
|
Bitmap bitmap = Bitmap.createBitmap(mapSizePixels, mapSizePixels, Bitmap.Config.ALPHA_8);
|
||||||
for (int i = 0; i < width; i++) {
|
for (int i = 0; i < mapSizePixels; i++) {
|
||||||
for (int j = 0; j < width; j++) {
|
for (int j = 0; j < mapSizePixels; j++) {
|
||||||
// 0-255 is appropriate for the config used.
|
// 0-255 is appropriate for the config used.
|
||||||
bitmap.setPixel(i, j, map.byteAt(i * width + j));
|
// Take away from 255 to invert the colours, so walls are the correct colour.
|
||||||
|
bitmap.setPixel(i, j, 255 - map.byteAt(i * mapSizePixels + j));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
canvas.drawBitmap(bitmap, 0, 0, paint);
|
canvas.drawBitmap(bitmap, 0, 0, paint);
|
||||||
@@ -130,10 +130,4 @@ public class SlamView extends SurfaceView implements SlamUpdater.MapChangedListe
|
|||||||
surfaceHolder.unlockCanvasAndPost(canvas);
|
surfaceHolder.unlockCanvasAndPost(canvas);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onSizeChanged(int w, int b, int oldW, int oldB) {
|
|
||||||
super.onSizeChanged(w, b, oldW, oldB);
|
|
||||||
width = w;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user