@@ -0,0 +1,2733 @@
+package com.easternedgerobotics.rov.io.arduino;%0A%0Aimport rx.Observable;%0Aimport rx.subjects.PublishSubject;%0A%0Afinal class ArduinoWriter %7B%0A    /**%0A     * Indicates the start of a serial message.%0A     */%0A    private static final byte MESSAGE_START = (byte) 0xAA;%0A%0A    /**%0A     * Indicates the start of a write digital value message.%0A     */%0A    private static final byte WRITE_DIGITAL_VAL = 0x01;%0A%0A    /**%0A     * Indicates the start of a write digital mode message.%0A     */%0A    private static final byte WRITE_DIGITAL_MODE = 0x02;%0A%0A    /**%0A     * Select input mode option when setting digital pin mode.%0A     */%0A    private static final byte INPUT_MODE = 0x01;%0A%0A    /**%0A     * Select output mode option when setting digital pin mode.%0A     */%0A    private static final byte OUTPUT_MODE = 0x02;%0A%0A    /**%0A     * Select input pullup mode option when setting digital pin mode.%0A     */%0A    private static final byte INPUT_PULLUP_MODE = 0x03;%0A%0A    /**%0A     * Indicates the start of a heartbeat request message.%0A     */%0A    private static final byte HEARTBEAT_REQUEST = 0x03;%0A%0A    /**%0A     * The output stream connected to the mega.%0A     */%0A    private final PublishSubject%3Cbyte%5B%5D%3E out = PublishSubject.create();%0A%0A    Observable%3Cbyte%5B%5D%3E getOutput() %7B%0A        return out;%0A    %7D%0A%0A    /**%0A     * Tell the arduino to respond with a heartbeat to prove that the connection still exists.%0A     */%0A    void requestHeartbeat() %7B%0A        out.onNext(new byte%5B%5D%7BMESSAGE_START, HEARTBEAT_REQUEST%7D);%0A    %7D%0A%0A    /**%0A     * Set the value of a digital pin.%0A     *%0A     * @param address the physical location of the pin.%0A     * @param value the desiered state of the pin.%0A     */%0A    void setPinValue(final byte address, final boolean value) %7B%0A        if (value) %7B%0A            out.onNext(new byte%5B%5D%7BMESSAGE_START, WRITE_DIGITAL_VAL, address, 1%7D);%0A        %7D else %7B%0A            out.onNext(new byte%5B%5D%7BMESSAGE_START, WRITE_DIGITAL_VAL, address, 0%7D);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Set the mode of a pin to output.%0A     *%0A     * @param address the physical location of the pin.%0A     */%0A    void setPinOutputMode(final byte address) %7B%0A        out.onNext(new byte%5B%5D%7BMESSAGE_START, WRITE_DIGITAL_MODE, address, OUTPUT_MODE%7D);%0A    %7D%0A%0A    /**%0A     * Set the mode of a pin to input.%0A     *%0A     * @param address the physical location of the pin.%0A     */%0A    void setPinInputMode(final byte address) %7B%0A        out.onNext(new byte%5B%5D%7BMESSAGE_START, WRITE_DIGITAL_MODE, address, INPUT_MODE%7D);%0A    %7D%0A%0A    /**%0A     * Set the mode of a pin to input pullup.%0A     *%0A     * @param address the physical location of the pin.%0A     */%0A    void setPinInputPullupMode(final byte address) %7B%0A        out.onNext(new byte%5B%5D%7BMESSAGE_START, WRITE_DIGITAL_MODE, address, INPUT_PULLUP_MODE%7D);%0A    %7D%0A%7D%0A

Translate arduino commands into byte array observable