Beispiel #1
0
        public override void Run()
        {
            //get the humidity data
            SenseHat.Sensors.HumiditySensor.Update();
            humidity = (SenseHat.Sensors.Humidity.Value);

            //get the temperature data
            temperature = (SenseHat.Sensors.Temperature.Value);

            if ((humidity > 60) & (temperature < 28))
            {
                drawrain();
            }
            else if ((humidity < 40) & (temperature > 35))
            {
                drawsun();
            }

            /*else
             * {
             *  drawcloud();
             * }*/

            Sleep(TimeSpan.FromSeconds(2));
            ActionRunner.Run(senseHat => HomeSelector.GetAction(senseHat, SetScreenText));
        }
Beispiel #2
0
        public override void Run()
        {
            pressurestate = true;

            var tinyFont = new TinyFont();

            ISenseHatDisplay display = SenseHat.Display;

            while (pressurestate == true)
            {
                SenseHat.Sensors.PressureSensor.Update();

                if (SenseHat.Sensors.Pressure.HasValue)
                {
                    double pressurevalue = SenseHat.Sensors.Pressure.Value;

                    int    pressure = (int)Math.Round(pressurevalue / 1000);
                    string text     = pressure.ToString();

                    if (text.Length > 2)
                    {
                        // too long to display :'v
                        text = "**";
                    }

                    display.Clear();
                    tinyFont.Write(display, text, Colors.IndianRed);
                    display.Update();

                    SetScreenText?.Invoke($"{pressure:0:1}");

                    Sleep(TimeSpan.FromSeconds(2));

                    pressurestate = false;
                }
                else
                {
                    Sleep(TimeSpan.FromSeconds(0.5));
                }
                ActionRunner.Run(senseHat => HomeSelector.GetAction(senseHat, SetScreenText));
            }
        }
Beispiel #3
0
        public override void Run()
        {
            humiditystate = true;

            var tinyFont = new TinyFont();

            ISenseHatDisplay display = SenseHat.Display;

            while (humiditystate == true)
            {
                SenseHat.Sensors.HumiditySensor.Update();

                if (SenseHat.Sensors.Humidity.HasValue)
                {
                    double humidityValue = SenseHat.Sensors.Humidity.Value;
                    int    humidity      = (int)Math.Round(humidityValue);
                    string text          = humidity.ToString();

                    if (text.Length > 2)
                    {
                        text = "**";
                    }

                    display.Clear();
                    tinyFont.Write(display, text, Colors.Blue);
                    display.Update();

                    SetScreenText?.Invoke($"{humidityValue:0:1}");

                    Sleep(TimeSpan.FromSeconds(2));

                    humiditystate = false;
                }
                else
                {
                    Sleep(TimeSpan.FromSeconds(0.5));
                }
                ActionRunner.Run(senseHat => HomeSelector.GetAction(senseHat, SetScreenText));
            }
        }
Beispiel #4
0
        public override void Run()
        {
            // notify with blue screen
            SenseHat.Display.Clear();
            SenseHat.Display.Fill(Colors.DeepSkyBlue);
            SenseHat.Display.Update();
            //update the sensor
            SenseHat.Sensors.HumiditySensor.Update();
            SenseHat.Sensors.PressureSensor.Update();
            // get the data to send
            SenseHatDatas data = new SenseHatDatas();

            data.TemperatureData = SenseHat.Sensors.Temperature;
            data.HumidityData    = SenseHat.Sensors.Humidity;
            data.PressureData    = SenseHat.Sensors.Pressure;
            // send to cloud
            AzureIoTHub.SendDeviceToCloudMessageAsync(data);



            ActionRunner.Run(senseHat => HomeSelector.GetAction(senseHat, SetScreenText));
        }
Beispiel #5
0
        public override void Run()
        {
            // Blink red for 3 times.
            for (int i = 1; i <= 3; i++)
            {
                SenseHat.Display.Clear();
                SenseHat.Display.Fill(Colors.Red);
                SenseHat.Display.Update();
                Sleep(TimeSpan.FromMilliseconds(100));
                SenseHat.Display.Fill(Colors.Black);
                SenseHat.Display.Update();
                Sleep(TimeSpan.FromMilliseconds(500));
            }



            // Get a copy of the rainbow colors.
            SenseHat.Display.Reset();
            SenseHat.Display.CopyScreenToColors(_rainbowColors);

            // Recreate the font from the serialized bytes.
            SingleColorFont font = SingleColorFont.Deserialize(FontBytes);

            // Get the characters to scroll.
            IEnumerable <SingleColorCharacter> characters = font.GetChars(_scrollText);

            // Create the character renderer.
            SingleColorCharacterRenderer characterRenderer = new SingleColorCharacterRenderer(GetCharacterColor);

            // Create the text scroller.
            var textScroller = new TextScroller <SingleColorCharacter>(
                SenseHat.Display,
                characterRenderer,
                characters);

            displaystate = true;


            while (displaystate == true)
            {
                // Step the scroller.
                if (!textScroller.Step())
                {
                    // Stop the scroller when reaching the end.
                    displaystate = false;
                    ActionRunner.Run(senseHat => HomeSelector.GetAction(senseHat, SetScreenText));
                    SenseHat.Display.Fill(Colors.Black);
                    SenseHat.Display.Update();
                }

                // Draw the background.
                FillDisplay(textScroller.ScrollPixelOffset);

                // Draw the scroll text.
                textScroller.Render();

                // Update the physical display.
                SenseHat.Display.Update();

                // Should the drawing mode change?
                if (SenseHat.Joystick.Update() && (SenseHat.Joystick.EnterKey == KeyState.Pressing))
                {
                    // The middle button is just pressed.
                    SwitchToNextScrollMode();
                }

                // Pause for a short while.
                Sleep(TimeSpan.FromMilliseconds(50));
            }
        }