11const St = imports . gi . St ;
22const PanelMenu = imports . ui . panelMenu ;
3- const PopupMenu = imports . ui . popupMenu ;
43const Main = imports . ui . main ;
54const Lang = imports . lang ;
65const GLib = imports . gi . GLib ;
@@ -10,7 +9,6 @@ const Shell = imports.gi.Shell;
109const Clutter = imports . gi . Clutter
1110
1211const POWER_NOW = "/sys/class/power_supply/BAT0/power_now" ;
13- const WINDOW_SIZE = 100 ;
1412
1513let meta ;
1614let tp_wattmeter ;
@@ -26,7 +24,7 @@ var TPWattMeter = class TPWattMeter extends PanelMenu.Button {
2624 super . _init ( St . Align . START ) ;
2725 this . mainBox = null ;
2826 this . buttonText = new St . Label ( {
29- text : _ ( "?W" ) ,
27+ text : _ ( "?W" ) ,
3028 y_align : Clutter . ActorAlign . CENTER ,
3129 style_class : 'tp_wattmeter_lbl' ,
3230 } ) ;
@@ -41,11 +39,7 @@ var TPWattMeter = class TPWattMeter extends PanelMenu.Button {
4139 this . powerWindows = [ ] ;
4240 return true ;
4341 }
44-
4542 this . powerWindows . push ( power ) ;
46- if ( this . powerWindows . length >= WINDOW_SIZE ) {
47- this . powerWindows . shift ( ) ;
48- }
4943 return true ;
5044 }
5145 _refresh ( ) {
@@ -56,7 +50,10 @@ var TPWattMeter = class TPWattMeter extends PanelMenu.Button {
5650 power_text = this . lastStatus != null ? this . lastStatus : 'N/A' ;
5751 } else {
5852 let avg = this . powerWindows . reduce ( ( acc , elem ) => acc + elem , 0.0 ) / this . powerWindows . length ;
59- power_text = avg . toFixed ( 2 ) + 'W'
53+ while ( this . powerWindows . length ) { this . powerWindows . pop ( ) ; } ;
54+ this . powerWindows . push ( avg ) ;
55+
56+ power_text = avg . toFixed ( 2 ) + 'W' ;
6057 }
6158
6259 temp . set_text ( power_text ) ;
0 commit comments