clock: Display CPU percentage correctly

psutil.cpu_percent() actually delivers a percentage from 0 to 100. We need to
normalize that value to 0..1 to display properly.
This commit is contained in:
June Tate-Gans 2021-05-23 11:31:12 -05:00
parent 9fb8dbab4d
commit 802b342a1c

View File

@ -48,8 +48,8 @@ class ClockApplet(Applet):
DISPLAY_WIDTH // 2 - 5, 12) DISPLAY_WIDTH // 2 - 5, 12)
self.screen.addChild(self._loadGraph) self.screen.addChild(self._loadGraph)
self._ramGraph = Graph(DISPLAY_WIDTH // 2 + 5, 18, self._ramGraph = Graph(DISPLAY_WIDTH // 2 + 2, 18,
DISPLAY_WIDTH // 2 - 7, 12) DISPLAY_WIDTH // 2 - 5, 12)
self.screen.addChild(self._ramGraph) self.screen.addChild(self._ramGraph)
self._update() self._update()
@ -73,7 +73,7 @@ class ClockApplet(Applet):
x = (DISPLAY_WIDTH // 2) - (w // 2) x = (DISPLAY_WIDTH // 2) - (w // 2)
self._timeLabel.position = (x, 0) self._timeLabel.position = (x, 0)
self._loadGraph.addValue(psutil.cpu_percent()) self._loadGraph.addValue(psutil.cpu_percent() / 100)
self._ramGraph.addValue(psutil.virtual_memory().percent / 100) self._ramGraph.addValue(psutil.virtual_memory().percent / 100)
def _pushTime(self): def _pushTime(self):