From 61cbf9f87a990e8082612cc4fe0cca33456ba6d8 Mon Sep 17 00:00:00 2001 From: Dipesh Acharya Date: Fri, 25 Jan 2013 10:52:56 +0545 Subject: [PATCH] 0 degree temp ignored; added support for showing max temp instead of average temp --- extension.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/extension.js b/extension.js index 2c29896..75f1aaa 100644 --- a/extension.js +++ b/extension.js @@ -92,13 +92,19 @@ CpuTemperature.prototype = { if(sensors_output[0]) tempInfo = this._findTemperatureFromSensorsOutput(sensors_output[1].toString());//get temperature from sensors if (tempInfo){ var s=0, n=0;//sum and count + var smax = 0;//max temp for (let sensor in tempInfo){ - s+=tempInfo[sensor]['temp']; - n++; - items.push(tempInfo[sensor]['label']+': '+this._formatTemp(tempInfo[sensor]['temp'])); + if (tempInfo[sensor]['temp']>0){ + s+=tempInfo[sensor]['temp']; + n++; + if (tempInfo[sensor]['temp'] > smax) + smax=tempInfo[sensor]['temp']; + items.push(tempInfo[sensor]['label']+': '+this._formatTemp(tempInfo[sensor]['temp'])); + } } if (n!=0){//if temperature is detected this.title=this._formatTemp(s/n);//set title as average + //this.title=this._formatTemp(smax);//or the maximum temp } } }