06-02-2018 21:05
06-02-2018 21:05
I have been using this same code in my watch-face for about a month now and its been working properly. I was making some modifications to the permissions and other elements in my watch face and now the barometer does not appear to be outputting any data. Did something change with the barometer settings?
import document from "document"; import { Barometer } from "barometer"; // Altimeter // Fetch UI elements we will need to change var altitudeLabel = document.getElementById("altitude"); var pressureLabel = document.getElementById("pressure"); // Initialize the UI with some values altitudeLabel.text = "--"; pressureLabel.text = "--"; // Create a new instance of the Barometer var bar = new Barometer(); // Update the lavel with each reading from the sensor bar.onreading = () => { altitudeLabel.text = altitudeFromPressure(bar.pressure / 100) + " ft"; pressureLabel.text = Math.round(bar.pressure / 100) + " hPa"; } // Begin monitoring the sensor bar.start(); // Converts pressure in millibars to altitude in feet // https://en.wikipedia.org/wiki/Pressure_altitude function altitudeFromPressure(pressure) { return (1 - (pressure/1013.25)**0.190284)*145366.45; } //End altimeter
Answered! Go to the Best Answer.
06-02-2018 21:06
06-02-2018 21:06
Solved by rebooting watch.
06-02-2018 21:06
06-02-2018 21:06
Solved by rebooting watch.