1 /* 2 * Copyright © 2016 Greg Chabala 3 * 4 * This file is part of brick-control-lab. 5 * 6 * brick-control-lab is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as 8 * published by the Free Software Foundation, either version 3 of the 9 * License, or (at your option) any later version. 10 * 11 * brick-control-lab is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public License 17 * along with brick-control-lab. If not, see http://www.gnu.org/licenses/. 18 */ 19 package org.chabala.brick.controllab; 20 21 /** 22 * Identifiers for the direction of output ports on the control lab. 23 * <p> 24 * When an output is turned on without specifying a direction, the 25 * default direction is {@link #RIGHT}. 26 */ 27 public enum Direction { 28 /** Left direction, as indicated by the LED on the control lab. */ 29 LEFT ((byte) 0b10010100), 30 /** Right direction, as indicated by the LED on the control lab. */ 31 RIGHT ((byte) 0b10010011), 32 /** Reverse direction, relative to the existing direction of the port. */ 33 REVERSE((byte) 0b10010101); 34 35 private final byte code; 36 37 /** 38 * Enumerates possible direction values for the change direction command. 39 * @param code a byte relating to this direction 40 */ 41 Direction(byte code) { 42 this.code = code; 43 } 44 45 /** 46 * The byte expected by the control lab for the change direction command. 47 * @return a byte relating to this direction 48 */ 49 public byte getCode() { 50 return code; 51 } 52 }