Ejemplo n.º 1
0
        public static void Main()
        {
            var config = new SPI.Configuration(SPI_mod: SPI_Devices.SPI1,
                                               ChipSelect_Port: Pins.GPIO_PIN_D8,
                                               ChipSelect_ActiveState: false,
                                               ChipSelect_SetupTime: 0,
                                               ChipSelect_HoldTime: 0,
                                               Clock_IdleState: true,
                                               Clock_Edge: true,
                                               Clock_RateKHz: 10);

            var shiftRegister = new x74595(8, config);

            DigitalOutputPort relayPort = shiftRegister.CreateOutputPort(0, false);

            var relay = new Relay(relayPort);

            while (true)
            {
                // toggle the relay
                relay.Toggle();

                Debug.Print("Relay on: " + relay.IsOn.ToString());

                // wait for 5 seconds
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 2
0
        public MeadowApp()
        {
            var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue);

            led.SetColor(RgbLed.Colors.Red);

            shiftRegister = new x74595(Device, Device.CreateSpiBus(), Device.Pins.D00, 8);
            shiftRegister.Clear();

            IDigitalOutputPort[] ports =
            {
                Device.CreateDigitalOutputPort(Device.Pins.D14),
                Device.CreateDigitalOutputPort(Device.Pins.D15),
                shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP0,false,  OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP1,false,  OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP2,false,  OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP3,false,  OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4,false,  OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP5,false,  OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP6,false,  OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP7,false,  OutputType.PushPull),
            };

            ledBarGraph            = new LedBarGraph(ports);
            ledBarGraph.Percentage = 1;

            rotaryEncoder = new RotaryEncoder(Device, Device.Pins.D02, Device.Pins.D03);
            //Device.CreateDigitalInputPort(Device.Pins.D02, InterruptMode.EdgeRising, ResistorMode.InternalPullUp, 0, 5),
            //Device.CreateDigitalInputPort(Device.Pins.D03, InterruptMode.EdgeRising, ResistorMode.InternalPullUp, 0, 5));
            rotaryEncoder.Rotated += RotaryEncoderRotated;

            led.SetColor(RgbLed.Colors.Green);
        }
Ejemplo n.º 3
0
        public MeadowApp()
        {
            this.shiftRegister = new x74595(
                device: Device,
                spiBus: Device.CreateSpiBus(),
                pinChipSelect: Device.Pins.D03,
                pins: 8);

            this.TestX74595();
        }
Ejemplo n.º 4
0
        protected void InitializePeripherals()
        {
            var config = new SPI.Configuration(SPI_mod: SPI_Devices.SPI1,
                                               ChipSelect_Port: Pins.GPIO_PIN_D8,
                                               ChipSelect_ActiveState: false,
                                               ChipSelect_SetupTime: 0,
                                               ChipSelect_HoldTime: 0,
                                               Clock_IdleState: true,
                                               Clock_Edge: true,
                                               Clock_RateKHz: 10);

            shiftRegister = new x74595(8, config);
        }
Ejemplo n.º 5
0
        public MeadowApp()
        {
            var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue);

            led.SetColor(RgbLed.Colors.Red);

            shiftRegister = new x74595(
                device: Device,
                spiBus: Device.CreateSpiBus(),
                pinChipSelect: Device.Pins.D03,
                pins: 8);

            shiftRegister.Clear(true);

            TestX74595();

            led.SetColor(RgbLed.Colors.Green);
        }
        void Initialize()
        {
            var onboardLed = new RgbPwmLed(
                device: Device,
                redPwmPin: Device.Pins.OnboardLedRed,
                greenPwmPin: Device.Pins.OnboardLedGreen,
                bluePwmPin: Device.Pins.OnboardLedBlue);

            onboardLed.SetColor(Color.Red);

            shiftRegister = new x74595(
                device: Device,
                spiBus: Device.CreateSpiBus(),
                pinChipSelect: Device.Pins.D03,
                pins: 8);

            onboardLed.SetColor(Color.Green);
        }
Ejemplo n.º 7
0
        public MeadowApp()
        {
            this.onboardLed = new RgbPwmLed(Device,
                                            Device.Pins.OnboardLedRed,
                                            Device.Pins.OnboardLedGreen,
                                            Device.Pins.OnboardLedBlue,
                                            3.3f, 3.3f, 3.3f,
                                            Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode);
            this.onboardLed.SetColor(Color.Red);

            this.shiftRegister = new x74595(Device, Device.CreateSpiBus(), Device.Pins.D00, 8);
            this.shiftRegister.Clear();

            IDigitalOutputPort[] ports =
            {
                Device.CreateDigitalOutputPort(Device.Pins.D14),
                Device.CreateDigitalOutputPort(Device.Pins.D15),
                shiftRegister.CreateDigitalOutputPort(
                    shiftRegister.Pins.GP0,                             false, OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(
                    shiftRegister.Pins.GP1,                             false, OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(
                    shiftRegister.Pins.GP2,                             false, OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(
                    shiftRegister.Pins.GP3,                             false, OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(
                    shiftRegister.Pins.GP4,                             false, OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(
                    shiftRegister.Pins.GP5,                             false, OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(
                    shiftRegister.Pins.GP6,                             false, OutputType.PushPull),
                shiftRegister.CreateDigitalOutputPort(
                    shiftRegister.Pins.GP7,                             false, OutputType.PushPull),
            };

            this.ledBarGraph = new LedBarGraph(ports);

            this.rotaryEncoder = new RotaryEncoder(
                Device, Device.Pins.D02, Device.Pins.D03);
            this.rotaryEncoder.Rotated += this.RotaryEncoderRotated;

            this.onboardLed.SetColor(Color.Green);
        }
Ejemplo n.º 8
0
        public static void Main()
        {
            var config = new SPI.Configuration(SPI_mod: SPI_Devices.SPI1,
                                               ChipSelect_Port: Pins.GPIO_PIN_D8,
                                               ChipSelect_ActiveState: false,
                                               ChipSelect_SetupTime: 0,
                                               ChipSelect_HoldTime: 0,
                                               Clock_IdleState: true,
                                               Clock_Edge: true,
                                               Clock_RateKHz: 10);

            var shiftRegister = new x74595(8, config);

            while (true)
            {
                shiftRegister.Clear(true);
                for (byte index = 0; index <= 7; index++)
                {
                    shiftRegister[index] = true;
                    Thread.Sleep(500);
                    shiftRegister[index] = false;
                }
            }
        }
Ejemplo n.º 9
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            shiftRegister = new x74595(Device, Device.CreateSpiBus(), Device.Pins.D00, 8);
        }