Skip to content

Commit

Permalink
Fix for CPU temp color in #40 and added cpu frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
sco01 committed Oct 12, 2019
1 parent 45f61c0 commit d779b8c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion octoprint_dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DashboardPlugin(octoprint.plugin.SettingsPlugin,
extruder_mode = ""
cpu_percent = 0
cpu_temp = 0
cpu_freq = 0
virtual_memory_percent = 0
disk_usage = 0
layer_times = []
Expand All @@ -35,6 +36,7 @@ def psUtilGetStats(self):
temp_sum = temp_sum+thermal["coretemp"][temp][1]
self.cpu_temp = temp_sum / len(thermal["coretemp"])
self.cpu_percent = str(psutil.cpu_percent(interval=None, percpu=False))
self.cpu_freq = str(psutil.cpu_freq(percpu=False).current)
self.virtual_memory_percent = str(psutil.virtual_memory().percent)
self.disk_usage = str(psutil.disk_usage("/").percent)

Expand All @@ -50,6 +52,7 @@ def send_notifications(self):
virtualMemPercent=str(self.virtual_memory_percent),
diskUsagePercent=str(self.disk_usage),
cpuTemp=str(self.cpu_temp),
cpuFreq=str(self.cpu_freq),
extrudedFilament=str( round( (sum(self.extruded_filament_arr) + self.extruded_filament) / 1000, 2) ),
layerTimes=str(self.layer_times),
layerLabels=str(self.layer_labels),
Expand Down Expand Up @@ -110,7 +113,7 @@ def get_settings_defaults(self):
showSensorInfo=False,
showJobControlButtons=False,
cpuTempWarningThreshold="70",
cpuTempCriticalThreshold="80"
cpuTempCriticalThreshold="85"
)

def on_settings_save(self, data):
Expand Down
2 changes: 2 additions & 0 deletions octoprint_dashboard/static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ $(function () {
self.layerProgressBarString = ko.observable("0%");
self.printerMessage = ko.observable("");
self.cpuPercent = ko.observable(0);
self.cpuFreq = ko.observable(0);
self.virtualMemPercent = ko.observable(0);
self.diskUsagePercent = ko.observable(0);
self.cpuTemp = ko.observable(0);
Expand Down Expand Up @@ -248,6 +249,7 @@ $(function () {
if (data.lastLayerDuration) { self.lastLayerDuration(data.lastLayerDuration); }
if (data.averageLayerDuration) { self.averageLayerDuration(data.averageLayerDuration); }
if (data.cpuPercent) { self.cpuPercent(data.cpuPercent); }
if (data.cpuFreq) { self.cpuFreq(data.cpuFreq); }
if (data.virtualMemPercent) { self.virtualMemPercent(data.virtualMemPercent); }
if (data.diskUsagePercent) { self.diskUsagePercent(data.diskUsagePercent); }
if (data.cpuTemp) { self.cpuTemp(data.cpuTemp); }
Expand Down
3 changes: 2 additions & 1 deletion octoprint_dashboard/templates/dashboard_tab.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
<img class="dashboardIcon" title="CPU Usage" src="plugin/dashboard/static/img/cpu-icon.png">
<div class="inline">
<span id="cpuInfo" data-bind="attr: { title: 'CPU Usage' }, html: cpuPercent() + '%'"></span>
<span class="dashboardSmall" id="cpuTemp" data-bind="attr: { title: 'CPU Temperature' }, html: cpuTemp() + '°C', style: { color: cpuTempColor()}"></span>
<span class="dashboardSmall" id="cpuTemp" data-bind="attr: { title: 'CPU Temperature' }, html: cpuTemp() + '°C', style: { color: cpuTempColor()}"></span><br/>
<span class="dashboardSmall" id="cpuFreq" data-bind="attr: { title: 'CPU Frequency' }, html: cpuFreq() + 'MHz'"></span>
</div>
</div>
<div class="dashboardGridItem" data-bind="visible: settingsViewModel.settings.plugins.dashboard.showSystemInfo()">
Expand Down

0 comments on commit d779b8c

Please sign in to comment.