Ejemplo n.º 1
0
        public override void Run()
        {
            temperaturestate = true;

            var tinyFont = new TinyFont();

            ISenseHatDisplay display = SenseHat.Display;

            TemperatureUnit unit = TemperatureUnit.Celcius; //we want celcius :v

            string unitText = GetUnitText(unit);

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

                if (SenseHat.Sensors.Temperature.HasValue)
                {
                    double temperatureValue = ConvertTemperatureValue(unit, SenseHat.Sensors.Temperature.Value);

                    int    temperature = (int)Math.Round(temperatureValue);
                    string text        = temperature.ToString();

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

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

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

                    Sleep(TimeSpan.FromSeconds(2));

                    temperaturestate = false;
                }
                else
                {
                    //rapid update until value is available
                    Sleep(TimeSpan.FromSeconds(0.5));
                }
                ActionRunner.Run(senseHat => HomeSelector.GetAction(senseHat, SetScreenText));
            }
        }
Ejemplo n.º 2
0
 public MainPage()
 {
     this.InitializeComponent();
     ActionRunner.Run(senseHat => HomeSelector.GetAction(senseHat, SetScreenText));
 }