Exemplo n.º 1
0
        public static void TestFezHat()
        {
            hat = GIS.FEZHAT.Create();

            hat.S1.SetLimits(500, 2400, 0, 180);
            hat.S2.SetLimits(500, 2400, 0, 180);
            timer = new Timer(TimerCallback, null, 0, 100);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of the FEZ HAT.
        /// </summary>
        /// <returns>The new instance.</returns>
        public static FEZHAT Create()
        {
            //var gpioController = GpioController.GetDefault();
            //var i2cController = (await DeviceInformation.FindAllAsync(I2cDevice.GetDeviceSelector(FEZHAT.I2cDeviceName)))[0];
            var hat = new FEZHAT();

            if (i2cBus == null)
            {
                i2cBus = new Mono.Linux.I2C.I2CBus(0x01);
            }
            //I2CDevice i2c_accelerometer = Pi.I2C.AddDevice(MMA8453.GetAddress(false));
            var i2c_accelerometer = new Mono.Linux.I2C.I2CDevice(i2cBus, MMA8453.GetAddress(false));

            hat.accelerometer = new MMA8453(i2c_accelerometer);

            //I2CDevice i2c_analog = Pi.I2C.AddDevice(ADS7830.GetAddress(false, false));
            var i2c_analog = new Mono.Linux.I2C.I2CDevice(i2cBus, ADS7830.GetAddress(false, false));

            hat.analog = new ADS7830(i2c_analog);

            //I2CDevice i2c_pwm = Pi.I2C.AddDevice(PCA9685.GetAddress(true, true, true, true, true, true));
            var i2c_pwm = new Mono.Linux.I2C.I2CDevice(i2cBus, PCA9685.GetAddress(true, true, true, true, true, true));

            hat.pwm = new PCA9685(i2c_pwm, Pi.Gpio.Pin23);//Pi.Gpio.Pin13);x
            hat.pwm.OutputEnabled = true;
            hat.pwm.Frequency     = 1500;

            //mapping wiring pi vs gpio win iot
            hat.dio16 = Pi.Gpio.Pin27; //Pi.Gpio.Pin16;x
            hat.dio26 = Pi.Gpio.Pin25; //Pi.Gpio.Pin26;x
            hat.dio24 = Pi.Gpio.Pin05; //Pi.Gpio.Pin24;x
            hat.dio18 = Pi.Gpio.Pin01; //Pi.Gpio.Pin18;x
            hat.dio22 = Pi.Gpio.Pin03; //Pi.Gpio.Pin22;x

            hat.dio16.PinMode = GpioPinDriveMode.Input;
            hat.dio26.PinMode = GpioPinDriveMode.Input;
            hat.dio24.PinMode = GpioPinDriveMode.Output;
            hat.dio18.PinMode = GpioPinDriveMode.Input;
            hat.dio22.PinMode = GpioPinDriveMode.Input;

            hat.motorEnable         = Pi.Gpio.Pin26;//Pi.Gpio.Pin12;x
            hat.motorEnable.PinMode = GpioPinDriveMode.Output;
            hat.motorEnable.Write(GpioPinValue.High);

            hat.MotorA = new Motor(hat.pwm, 14, Pi.Gpio.Pin02, Pi.Gpio.Pin04); //Pi.Gpio.Pin27, Pi.Gpio.Pin23);x
            hat.MotorB = new Motor(hat.pwm, 13, Pi.Gpio.Pin22, Pi.Gpio.Pin21); //Pi.Gpio.Pin06, Pi.Gpio.Pin05);x

            hat.D2 = new RgbLed(hat.pwm, 1, 0, 2);
            hat.D3 = new RgbLed(hat.pwm, 4, 3, 15);

            hat.S1 = new Servo(hat.pwm, 9);
            hat.S2 = new Servo(hat.pwm, 10);

            return(hat);
        }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     hat = GIS.FEZHAT.Create();
     hat.S1.SetLimits(500, 2400, 0, 180);
     hat.S2.SetLimits(500, 2400, 0, 180);
     Console.WriteLine("Simulated device\n");
     deviceClient             = DeviceClient.CreateFromConnectionString(ConnStr, TransportType.Amqp);
     deviceClient.ProductInfo = "HappyPath_Simulated-CSharp";
     SendDeviceToCloudMessagesAsync();
     Console.ReadLine();
 }