// private static string RoomName = "dining-room"; // private static string RoomName = "kitchen"; // private static string RoomName = "basement"; static void Main(string[] args) { var sensorReadingIntervalMilliseconds = 1000; var readings = new HomeAutomationReadings(); using (var settings = RTIMUSettings.CreateDefault()) { while (true) { var temperature = GetTemperatureReading(settings); // var humidity = GetHumidityReading(settings); // var pressure = GetPressureReading(settings); // var garageDoor = GetGarageDoorReading(); readings.TemperatureReading.Value = temperature.value; // readings.HumidityReading.Value = humidity.value; // readings.PressureReading.Value = pressure.value; // readings.GarageDoorReading.Value = garageDoor.value; Console.WriteLine(JsonSerializer.Serialize(temperature)); // Console.WriteLine(JsonSerializer.Serialize(humidity)); // Console.WriteLine(JsonSerializer.Serialize(pressure)); // Console.WriteLine(JsonSerializer.Serialize(garageDoor)); Thread.Sleep(sensorReadingIntervalMilliseconds); } } }
// private static string RoomName = "dining-room"; // private static string RoomName = "kitchen"; // private static string RoomName = "basement"; static void Main(string[] args) { var sensorReadingIntervalMilliseconds = 1000; var readings = new HomeAutomationReadings(); var joystickEvents = Joystick.Events .Subscribe(p => { if (p.Key == JoystickKey.Enter && p.State == JoystickKeyState.Release) { IsGarageDoorOpen = !IsGarageDoorOpen; if (IsGarageDoorOpen) { Console.WriteLine("Garage door is open"); } else { Console.WriteLine("Garage door is closed"); } } }); using (var settings = RTIMUSettings.CreateDefault()) { while (true) { var temperature = GetTemperatureReading(settings); var humidity = GetHumidityReading(settings); var pressure = GetPressureReading(settings); var garageDoor = GetGarageDoorReading(); readings.TemperatureReading.Value = temperature.value; readings.HumidityReading.Value = humidity.value; readings.PressureReading.Value = pressure.value; readings.GarageDoorReading.Value = garageDoor.value; Console.WriteLine(JsonSerializer.Serialize(temperature)); Console.WriteLine(JsonSerializer.Serialize(humidity)); Console.WriteLine(JsonSerializer.Serialize(pressure)); Console.WriteLine(JsonSerializer.Serialize(garageDoor)); var pixelList = new List <CellColor>(); AddPixelsForReading(pixelList, readings.TemperatureReading.Quadrant, readings.TemperatureReading.GetColor()); AddPixelsForReading(pixelList, readings.HumidityReading.Quadrant, readings.HumidityReading.GetColor()); AddPixelsForReading(pixelList, readings.PressureReading.Quadrant, readings.PressureReading.GetColor()); AddPixelsForReading(pixelList, readings.GarageDoorReading.Quadrant, readings.GarageDoorReading.GetColor()); var immutablePixels = new Sense.Led.Pixels(ImmutableList.Create(pixelList.ToArray())); Sense.Led.LedMatrix.SetPixels(immutablePixels); Sense.Led.LedMatrix.SetLowLight(true); Thread.Sleep(sensorReadingIntervalMilliseconds); } } }