Esempio n. 1
0
        private void Arduino_AnalogPinUpdated(string pin, ushort value)
        {
            AModule module = _moduleNum[pin];
            APin    p      = _pinNum[pin];

            if (onPinUpdateEvent != null)
            {
                onPinUpdateEvent(module, p, value);
            }
        }
Esempio n. 2
0
        private void Arduino_DigitalPinUpdated(byte pin, PinState state)
        {
            string  pinNumber = ((short)pin).ToString();
            AModule module    = _moduleNum[pinNumber];
            APin    p         = _pinNum[pinNumber];

            if (onPinUpdateEvent != null)
            {
                onPinUpdateEvent(module, p, (ushort)state);
            }
        }
Esempio n. 3
0
        private void BindPins(AModule mod)
        {
            foreach (APin pin in mod.pins)
            {
                //Analogic or Digital pin

                if (char.IsLetter(pin.pinNumber[0]))
                {
                    arduino.pinMode(pin.pinNumber, pin.pinMode);
                }
                else
                {
                    arduino.pinMode((byte)short.Parse(pin.pinNumber), pin.pinMode);
                }
            }
        }
Esempio n. 4
0
 public void AddModule(AModule mod)
 {
     lock (_moduleNum)
     {
         foreach (APin apm in mod.pins)
         {
             if (_pinNum.ContainsKey(apm.pinNumber))
             {
                 throw new ModuleConflictException("Pin " + apm.pinNumber + " already used in '" + _moduleNum[apm.pinNumber].name + "' module.");
             }
         }
         if (deviceReady)
         {
             BindPins(mod);
         }
         foreach (APin apm in mod.pins)
         {
             _pinNum.Add(apm.pinNumber, apm);
             _moduleNum.Add(apm.pinNumber, mod);
         }
     }
 }