7e3c7fdb962af8805f6f5f530a3bde34a48e04c8
[eltron.git] / src / edu / berkeley / cs / obits / device / atmel / AtmelDevice.java
1 package edu.berkeley.cs.obits.device.atmel;
2
3 import edu.berkeley.cs.obits.*;
4
5 public abstract class AtmelDevice extends Device {
6
7     /** issue a command to the device in Mode4 format; see Gosset's documentation for further details */
8     public void mode4(int z, int y, int x, int d) throws DeviceException;
9
10     public Sector sector(int col, int row) { return new Sector(col, row); }
11     public final class Sector {
12         public final int col;
13         public final int row;
14         public Sector(int col, int row) {
15             if (row % 4 != 0) throw new Error("Sector must be created with a multiple-of-4 row");
16             if (col % 4 != 0) throw new Error("Sector must be created with a multiple-of-4 col");
17             this.row = row;
18             this.col = col;
19         }
20     }
21     
22     public Cell cell(int col, int row) { return new Cell(col, row); }
23     public final class Cell {
24         public final int col;
25         public final int row;
26         public Sector getSector() { return sector(col - (col % 4), row - (row % 4)); }
27         public Cell(int col, int row) {
28             this.row = row;
29             this.col = col;
30         }
31     }
32
33 }