public void Process() { DIO18Pressed = _hat.IsDIO18Pressed(); DIO22Pressed = _hat.IsDIO22Pressed(); Ain1 = _hat.ReadAnalog(FEZHAT.AnalogPin.Ain1); Ain2 = _hat.ReadAnalog(FEZHAT.AnalogPin.Ain2); Ain3 = _hat.ReadAnalog(FEZHAT.AnalogPin.Ain3); _hat.GetAcceleration(out var x, out var y, out var z); AccelerationX = x; AccelerationY = y; AccelerationZ = z; }
private void Timer_Tick(object sender, object e) { // Store light sensor value var light = _hat.GetLightLevel(); // Store motion sensor value var directHeat = _hat.ReadAnalog(FEZHAT.AnalogPin.Ain1); // if the current room is empty and lights are on if (light > 0.2 && directHeat <= 0.7) { // Generate event message var msg = new { deviceid = "119", timecreated = DateTime.UtcNow.ToString("o"), timespan = "1 min", message = "Energy waste!" }; // Send the message SendMessage(msg.ToString()); } }