Exemplo n.º 1
0
        public MeadowApp()
        {
            this.InitializeCharacterDisplay();
            this.InitializeBme280();

            OnboardLed led = new OnboardLed(Device);

            led.SetColor(RgbColor.Green);
        }
Exemplo n.º 2
0
 private static void Worker()
 {
     while (true)
     {
         while (_run)
         {
             OnboardLed.Blink(2);
             Thread.Sleep(1500);
         }
     }
 }
Exemplo n.º 3
0
        public void CycleLeds()
        {
            const int wait = 200;

            using OnboardLed led = new OnboardLed(Device);

            RgbColor currentColor = RgbColor.None;

            while (true)
            {
                currentColor = currentColor.GetNext();
                Console.WriteLine($"Setting color to {currentColor}.");
                led.SetColor(currentColor);
                Thread.Sleep(wait);
            }
        }
Exemplo n.º 4
0
        public MeadowApp()
        {
            Console.WriteLine("Initializing...");

            this.analogTemperature = new AnalogTemperature(
                device: Device,
                analogPin: Device.Pins.A00,
                sensorType: AnalogTemperature.KnownSensorType.LM35
                );
            this.analogTemperature.Updated += this.AnalogTemperatureUpdated;

            SpiClockConfiguration config = new SpiClockConfiguration(
                speedKHz: 6000,
                SpiClockConfiguration.Mode.Mode3);

            ISpiBus spiBus = Device.CreateSpiBus(
                Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config);

            this.st7789 = new St7789(
                device: Device,
                spiBus: spiBus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00,
                width: 240, height: 240
                );

            this.displayWidth  = Convert.ToInt32(this.st7789.Width);
            this.displayHeight = Convert.ToInt32(this.st7789.Height);

            this.graphics = new GraphicsLibrary(this.st7789)
            {
                Rotation = GraphicsLibrary.RotationType._270Degrees
            };

            this.LoadScreen();
            this.analogTemperature.StartUpdating();

            OnboardLed led = new OnboardLed(Device);

            led.SetColor(RgbColor.Green);
        }
Exemplo n.º 5
0
        public MeadowApp()
        {
            this.spdtSwitch          = new SpdtSwitch(Device.CreateDigitalInputPort(Device.Pins.D04, InterruptMode.EdgeBoth));
            this.displayInCelcius    = this.spdtSwitch.IsOn;
            this.spdtSwitch.Changed += this.SpdtSwitch_Changed;

            this.st7789            = InitializeLcdScreen(out this.displayWidth, out this.displayHeight, out this.graphics);
            this.analogTemperature = InitializeAnalogTemperatureSensor(this.AnalogTemperatureUpdated);

            this.mcp9808 = InitializeMcp9808TemperatureSensor();
            this.Display9808Temperature(this.mcp9808.GetTemperature());
            this.mcp9808.Subscribe(new FilterableChangeObserver <AtmosphericConditionChangeResult, AtmosphericConditions>(
                                       this.Mcp9808TemperatureUpdated,
                                       e => Math.Abs(e.Delta.Temperature.Value) > 0.1
                                       ));
            this.mcp9808.StartUpdating();

            OnboardLed led = new OnboardLed(Device);

            led.SetColor(RgbColor.Green);
        }