X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fobits%2Fdevice%2Fatmel%2FAvrDrone.java;h=f00f79470ebe9361e8b6fc302846c2f1224e4942;hb=f4da556e7246275d49adf8bb7b4c5b0192bc7b87;hp=9e06fd1c00623bebf9c27e390f008cb7e9dcebd3;hpb=206063cc6a3b82e133b897ff688d2ae8c32b1868;p=slipway.git diff --git a/src/edu/berkeley/obits/device/atmel/AvrDrone.java b/src/edu/berkeley/obits/device/atmel/AvrDrone.java index 9e06fd1..f00f794 100644 --- a/src/edu/berkeley/obits/device/atmel/AvrDrone.java +++ b/src/edu/berkeley/obits/device/atmel/AvrDrone.java @@ -48,6 +48,12 @@ public class AvrDrone extends AtmelDevice { } catch (InterruptedException e) { throw new DeviceException(e); } } + private byte[][][] cache = new byte[24][][]; + public byte mode4(int z, int y, int x) throws DeviceException { + if (cache[x]==null) return 0; + if (cache[x][y]==null) return 0; + return cache[x][y][z]; + } public void mode4(int z, int y, int x, int d) throws DeviceException { try { Log.debug(this, "writing configuration frame [zyxd]: " + @@ -61,6 +67,9 @@ public class AvrDrone extends AtmelDevice { out.writeByte(y); out.writeByte(x); out.writeByte(d); + if (cache[x & 0xff]==null) cache[x & 0xff] = new byte[24][]; + if (cache[x & 0xff][y & 0xff]==null) cache[x & 0xff][y & 0xff] = new byte[256]; + cache[x & 0xff][y & 0xff][z & 0xff] = (byte)(d & 0xff); } catch (IOException e) { throw new DeviceException(e); } }