var min = mSensorIter.getMin(); // float in System.println(min)
var max = mSensorIter.getMax(); // float in System.println(max)
var previous = mSensorIter.next().data; // number in System.println(previous)
// Prints (current elevation: 1364 max: 1371.599976 min: 914.400146)
How can I get the last temperature sample? thx for help
//Check if SensorHistory supports the Device
var lastTemp = 0;
if ( Toybox.SensorHistory has :getTemperatureHistory )
{
//get the iterator... dont use the ":period" for options because I experienced memory leak using that one but still you can try
var sample = Toybox.SensorHistory.getTemperatureHistory( {:order=>Toybox.SensorHistory.ORDER_NEWEST_FIRST} );
//Check if No Data is available
if (sample != null)
{
var nextInfo = sample.next();
//Check for Invalid Value
if ( nextInfo != null )
{
lastTemp = nextInfo.data;
}
}
}
if (sample != null)
{
var min=sample.getMin();
var max=sample.getMax();
var nextInfo = sample.next();
//Check for Invalid Value
if ( nextInfo != null )
{
lastTemp = nextInfo.data;
}
}