Ejemplo n.º 1
0
        private Byte[] TableEventList()
        {
            List <Byte> result  = new List <Byte>();
            UInt16      pointer = 0;
            PinPort     p       = null;

            for (byte i = 0; i < ShieldNode.ShieldBase.NumPorts; i++)
            {
                for (byte j = 0; j < ShieldNode.ShieldBase.NumPins; j++)
                {
                    result.AddRange(pointer.Uint16ToByte(ShieldNode.ShieldBase.LittleEndian));
                    p = ShieldNode.GetPinPort(i, j);
                    if (p != null)
                    {
                        pointer += SizePinEvents(p);
                    }
                }
            }

            //direccion lista de eventos de tiempo
            result.AddRange(pointer.Uint16ToByte(ShieldNode.ShieldBase.LittleEndian));

            //direccion restricciones temporales de los eventos de puertos OJO!!!
            result.Add(0x00);
            result.Add(0x00);

            //direccion region libre
            result.Add(0x00);
            result.Add(0x00);

            return(result.ToArray());
        }
Ejemplo n.º 2
0
        private Byte[] PinIOConfig(Byte port)
        {
            //Si no esta definido suponemos Entrada digital
            Byte[]  result = new Byte[5];
            PinPort p      = null;

            //Input:0 - Output:1, default=0
            result[0] = 0x00;
            for (byte i = 0; i < ShieldNode.ShieldBase.NumPins; i++)
            {
                p = ShieldNode.GetPinPort(port, i);
                if (p != null && p.Output == true)
                {
                    result[0] = (byte)(result[0] | (0x01 << i));
                }
            }

            //Analog:0 - Digital:1 default: 1
            result[1] = 0xFF;
            for (byte i = 0; i < ShieldNode.ShieldBase.NumPins; i++)
            {
                p = ShieldNode.GetPinPort(port, i);
                if (p != null && p.Digital == false)
                {
                    result[1] = (byte)(result[1] & ~(0x01 << i));
                }
            }

            //Input:0 - Output:1, default=0
            result[2] = 0x00;
            for (byte i = 0; i < ShieldNode.ShieldBase.NumPins; i++)
            {
                p = ShieldNode.GetPinPort(port, i);
                if (p != null && p.DefaultValueD == true)
                {
                    result[2] = (byte)(result[2] | (0x01 << i));
                }
            }

            //ChangetypeD None:00 Rising:10, Fall:01, Both:11
            UInt16 ctd = 0x00; //change type digital

            for (byte i = 0; i < ShieldNode.ShieldBase.NumPins; i++)
            {
                p = ShieldNode.GetPinPort(port, i);
                if (p != null)
                {
                    ctd = (byte)(ctd | ((byte)p.changeTypeD) << (i * 2));
                }
            }

            result[3] = ctd.Uint16ToByte(ShieldNode.ShieldBase.LittleEndian)[0];
            result[4] = ctd.Uint16ToByte(ShieldNode.ShieldBase.LittleEndian)[1];

            return(result);
        }
Ejemplo n.º 3
0
        private Byte[] PWMConfig()
        {
            List <Byte> result = new List <Byte>();

            foreach (String pin in ShieldNode.ShieldBase.PWMPorts)
            {
                if (ShieldNode.GetPinPort(pin[0], Byte.Parse(pin[1].ToString())) != null)
                {
                    result.Add(ShieldNode.GetPinPort(pin[0], Byte.Parse(pin[1].ToString())).DefaultValueA);
                }
                else
                {
                    result.Add(0x00);
                }
            }
            return(result.ToArray());
        }
Ejemplo n.º 4
0
        private Byte[] AnalogInputsConfig()
        {
            List <Byte> result = new List <Byte>();
            PinPort     p      = null;

            foreach (String pin in ShieldNode.ShieldBase.AnalogPorts)
            {
                p = ShieldNode.GetPinPort(pin[0], Byte.Parse(pin[1].ToString()));
                if (p != null)
                {
                    //Analog Input To Binary
                    result.Add(p.Increment);
                    result.Add(p.Threshold);
                }
                else
                {
                    result.Add(0x00); //Increment
                    result.Add(0x00); //Threshold
                }
            }

            return(result.ToArray());
        }