classdef DigitalOutput < handle
    properties
        channel;
        dev;
    end
    methods
        function writeOut(obj, value)
            writeDigitalPin(obj.dev, obj.channel, value);
        end
        
        function obj = DigitalOutput(dev, chan)
            channel = 0;
            switch chan
                case 1
                    channel = 21;
                case 2
                    channel = 20;
                case 3
                    channel = 16;
                case 4
                    channel = 12;
                case 5
                    channel = 25;
                case 6
                    channel = 24;
                case 7
                    channel = 23;
                case 8
                    channel = 18;
            end
            configurePin(dev, channel, 'DigitalOutput');
            obj.dev = dev;
            obj.channel = channel;
        end
    end
    methods(Static)
        function test
            pi = raspi('10.0.0.104', 'pi', 'HenryPump@1903');

            d1 = DigitalOutput(pi, 1);
            d2 = DigitalOutput(pi, 2);
            d3 = DigitalOutput(pi, 3);
            d4 = DigitalOutput(pi, 4);
            d5 = DigitalOutput(pi, 5);
            d6 = DigitalOutput(pi, 6);

            d1.writeOut(1);
            pause(0.250);
            d2.writeOut(1);
            pause(0.250);
            d3.writeOut(1);
            pause(0.250);
            d4.writeOut(1);
            pause(0.250);
            d5.writeOut(1);
            pause(0.250);
            d6.writeOut(1);
            pause(0.250);

            d1.writeOut(0);
            pause(0.250);
            d2.writeOut(0);
            pause(0.250);
            d3.writeOut(0);
            pause(0.250);
            d4.writeOut(0);
            pause(0.250);
            d5.writeOut(0);
            pause(0.250);
            d6.writeOut(0);
        end
    end
end


    