private Byte[] PortsEvents() { List <Byte> result = new List <Byte>(); Connector c = null; for (byte i = 0; i < ShieldNode.ShieldBase.NumPorts; i++) { for (byte j = 0; j < ShieldNode.ShieldBase.NumPins; j++) { c = ShieldNode.GetConector(i, j); if (c != null) { foreach (PinPort pin in c.Directions) { foreach (BasicEvent e in pin.PinEvents) { if (e.TimeRestrictions.Count > 0) { PortEventTimeRestrictionDictionary.Add((UInt16)result.Count, e.TimeRestrictions); } result.AddRange(ToBinaryEvent(e.Event, ShieldNode.ShieldBase.LittleEndian)); } } } } } return(result.ToArray()); }
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()); }
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); }
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()); }
// Creates the character's Urho node // <scene> is the Urho scene // <sprite> is the character's sprite // <shieldSprite> is the character's shield's sprite // <pos> is the starting position of the character public virtual void CreateNode(Scene scene, Sprite2D sprite, Sprite2D shieldSprite, Vector2 pos) { WorldNode = scene.CreateChild(); WorldNode.Position = new Vector3(pos); Position = WorldNode.Position; WorldNode.SetScale(1f / 12.14f); CharacterStaticSprite = WorldNode.CreateComponent <StaticSprite2D>(); CharacterStaticSprite.BlendMode = BlendMode.Alpha; CharacterStaticSprite.Sprite = sprite; ShieldNode = scene.CreateChild(); ShieldNode.Position = new Vector3(WorldNode.Position); StaticSprite2D staticSprite = ShieldNode.CreateComponent <StaticSprite2D>(); staticSprite.BlendMode = BlendMode.Alpha; staticSprite.Sprite = shieldSprite; WorldHitbox = new Hitbox(); WorldHitbox.Size = new Vector2(0.5f, 1f); }
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()); }