using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Digi.Drivers;

namespace I2C_Expansor_iMX51
{
    public partial class Form1 : Form
    {
        GPIO_IOEXPANSORiMX51 pin0 = new GPIO_IOEXPANSORiMX51(0, GPIO.DirectionValue.Output, GPIO.IoValue.Low);
        GPIO_IOEXPANSORiMX51 pin1 = new GPIO_IOEXPANSORiMX51(1, GPIO.DirectionValue.Output, GPIO.IoValue.Low);
        GPIO_IOEXPANSORiMX51 pin2 = new GPIO_IOEXPANSORiMX51(2, GPIO.DirectionValue.Output, GPIO.IoValue.Low);
        GPIO_IOEXPANSORiMX51 pin3 = new GPIO_IOEXPANSORiMX51(3, GPIO.DirectionValue.Output, GPIO.IoValue.Low);
        GPIO_IOEXPANSORiMX51 pin4 = new GPIO_IOEXPANSORiMX51(4, GPIO.DirectionValue.Output, GPIO.IoValue.Low);
        GPIO_IOEXPANSORiMX51 pin5 = new GPIO_IOEXPANSORiMX51(5, GPIO.DirectionValue.Output, GPIO.IoValue.Low);
        GPIO_IOEXPANSORiMX51 pin6 = new GPIO_IOEXPANSORiMX51(6, GPIO.DirectionValue.Output, GPIO.IoValue.Low);
        GPIO_IOEXPANSORiMX51 pin7 = new GPIO_IOEXPANSORiMX51(7, GPIO.DirectionValue.Output, GPIO.IoValue.Low);
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (pin0.Value == GPIO.IoValue.Low)
            {
                pin0.Value = GPIO.IoValue.High;
                pin1.Value = GPIO.IoValue.High;
                pin2.Value = GPIO.IoValue.High;
                pin3.Value = GPIO.IoValue.High;
                pin4.Value = GPIO.IoValue.High;
                pin5.Value = GPIO.IoValue.High;
                pin6.Value = GPIO.IoValue.High;
                pin7.Value = GPIO.IoValue.High;
            }
            else
            {
                pin0.Value = GPIO.IoValue.Low;
                pin1.Value = GPIO.IoValue.Low;
                pin2.Value = GPIO.IoValue.Low;
                pin3.Value = GPIO.IoValue.Low;
                pin4.Value = GPIO.IoValue.Low;
                pin5.Value = GPIO.IoValue.Low;
                pin6.Value = GPIO.IoValue.Low;
                pin7.Value = GPIO.IoValue.Low;
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Pin0= " + pin0.Value.ToString() + "\n\rPin1= " + pin1.Value.ToString() + "\n\rPin2= " + pin2.Value.ToString() + "\n\rPin3= " + pin3.Value.ToString() + "\n\rPin4= " + pin4.Value.ToString() + "\n\rPin5= " + pin5.Value.ToString() + "\n\rPin6= " + pin6.Value.ToString() + "\n\rPin7= " + pin7.Value.ToString() + " ");
        }
    }
}