X-Git-Url: http://git.megacz.com/?p=eltron.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fcs%2Fobits%2Fdevice%2Fatmel%2FAtmelDevice.java;h=7e3c7fdb962af8805f6f5f530a3bde34a48e04c8;hp=515e9b0e786cb64484d1d5ff05aaf67aa1cd2623;hb=74764ab4cab924eac0a4120cb856be4c0178a9ba;hpb=660c8a0a1c0fdd92aa6e42fea6444e774493868f diff --git a/src/edu/berkeley/cs/obits/device/atmel/AtmelDevice.java b/src/edu/berkeley/cs/obits/device/atmel/AtmelDevice.java index 515e9b0..7e3c7fd 100644 --- a/src/edu/berkeley/cs/obits/device/atmel/AtmelDevice.java +++ b/src/edu/berkeley/cs/obits/device/atmel/AtmelDevice.java @@ -2,6 +2,32 @@ package edu.berkeley.cs.obits.device.atmel; import edu.berkeley.cs.obits.*; -public interface AtmelDevice extends Device { +public abstract class AtmelDevice extends Device { + + /** issue a command to the device in Mode4 format; see Gosset's documentation for further details */ public void mode4(int z, int y, int x, int d) throws DeviceException; + + public Sector sector(int col, int row) { return new Sector(col, row); } + public final class Sector { + public final int col; + public final int row; + public Sector(int col, int row) { + if (row % 4 != 0) throw new Error("Sector must be created with a multiple-of-4 row"); + if (col % 4 != 0) throw new Error("Sector must be created with a multiple-of-4 col"); + this.row = row; + this.col = col; + } + } + + public Cell cell(int col, int row) { return new Cell(col, row); } + public final class Cell { + public final int col; + public final int row; + public Sector getSector() { return sector(col - (col % 4), row - (row % 4)); } + public Cell(int col, int row) { + this.row = row; + this.col = col; + } + } + }