예제 #1
0
파일: Pin.cs 프로젝트: Deerap/sharpduino
 public Pin(CapabilityMessage message)
     : this()
 {
     foreach (var mes in message.Modes)
         Capabilities[mes.Key] = mes.Value;
     PinNo = message.PinNo;
     if(HasDigitalCapability())
         Port = (byte) PinNo/8;
 }
예제 #2
0
        public void HasInputCapabilityTest()
        {
            var capability = new CapabilityMessage();
            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);
            Assert.IsTrue(pin.HasInputCapability());
        }
예제 #3
0
        public void CreationTest()
        {
            var capability = new CapabilityMessage();
            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);

            Assert.NotNull(pin);
            Assert.IsTrue(pin.Port == 0);
        }
예제 #4
0
        public void HasAnalogCapabilityTest()
        {
            var capability = new CapabilityMessage();
            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);
            Assert.IsFalse(pin.HasAnalogCapability());

            pin.Capabilities[PinModes.Analog] = 1;
            Assert.IsTrue(pin.HasAnalogCapability());
        }
예제 #5
0
 private Pin Pin(CapabilityMessage message)
 {
     return new Pin(message);
 }
예제 #6
0
        public void ResolutionOfCapabilityTest()
        {
            var capability = new CapabilityMessage();
            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);
            Assert.IsTrue(pin.ResolutionOfCapability(PinModes.Input)== 1);
            Assert.IsTrue(pin.ResolutionOfCapability(PinModes.Output) == -1);
        }
예제 #7
0
        public void IsShiftModeTest()
        {
            var capability = new CapabilityMessage();
            capability.PinNo = 1;
            capability.Modes[PinModes.Analog] = 1;

            var pin = Pin(capability);
            Assert.IsFalse(pin.IsShiftMode());

            pin.CurrentMode = PinModes.Shift;
            Assert.IsTrue(pin.IsShiftMode());
        }
예제 #8
0
        public void IsInputModeTest()
        {
            var capability = new CapabilityMessage();
            capability.PinNo = 1;
            capability.Modes[PinModes.Input] = 1;

            var pin = Pin(capability);
            //CurrentMode is set to PinModes.Input by default
            //http://stackoverflow.com/questions/1165402/initial-value-of-an-enum
            Assert.IsTrue(pin.IsInputMode());

            pin.CurrentMode = PinModes.I2C;
            Assert.IsFalse(pin.IsInputMode());
        }