altosui: Clean swing/awt bits out of altoslib
[fw/altos] / altosui / AltosEepromChunk.java
index 1e42077ff01f5168593ca3df415cedf34b12540a..77707f7bedf6acb9c55170ff72e4b01726d37082 100644 (file)
@@ -52,14 +52,27 @@ public class AltosEepromChunk {
                return data[offset] | (data[offset + 1] << 8);
        }
 
-       public AltosEepromChunk(AltosSerial serial_line, int block)
+       int data32(int offset) {
+               return data[offset] | (data[offset + 1] << 8) |
+                       (data[offset+2] << 16) | (data[offset+3] << 24);
+       }
+
+       boolean erased(int start, int len) {
+               for (int i = 0; i < len; i++)
+                       if (data[start+i] != 0xff)
+                               return false;
+               return true;
+       }
+
+       public AltosEepromChunk(AltosSerial serial_line, int block, boolean flush)
                throws TimeoutException, InterruptedException {
 
                int     offset;
 
                data = new int[chunk_size];
                address = block * chunk_size;
-               serial_line.flush_input();
+               if (flush)
+                       serial_line.flush_input();
                serial_line.printf("e %x\n", block);
 
                for (offset = 0; offset < chunk_size; offset += per_line) {