-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marc
committed
Jul 28, 2015
1 parent
c6e6f4f
commit 578840d
Showing
8 changed files
with
178 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,10 @@ | ||
# OctoPrint-EEprom-Repetier | ||
|
||
**TODO:** Describe what your plugin does. | ||
This plugin is designed to get, change and save the values in the Eeprom of your Repetier Firmware based Machine. | ||
|
||
## Setup | ||
|
||
Install via the bundled [Plugin Manager](https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager) | ||
or manually using this URL: | ||
|
||
https://github.com/Salandora/OctoPrint-EEprom-Repetier/archive/master.zip | ||
|
||
**TODO:** Describe how to install your plugin, if more needs to be done than just installing it via pip or through | ||
the plugin manager. | ||
|
||
## Configuration | ||
|
||
**TODO:** Describe your plugin's configuration options (if any). | ||
https://github.com/Salandora/OctoPrint-EEPROM-Repetier/archive/master.zip |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/** | ||
* Created by Salandora on 27.07.2015. | ||
*/ | ||
$(function() { | ||
function EepromRepetierViewModel(parameters) { | ||
var self = this; | ||
|
||
self.control = parameters[0]; | ||
self.connection = parameters[1]; | ||
|
||
self.firmwareRegEx = /FIRMWARE_NAME:([^\s]+)/i; | ||
self.repetierRegEx = /Repetier_([^\s]*)/i; | ||
|
||
self.eepromDataRegEx = /EPR:(\d+) (\d+) ([^\s]+) ([^\n]+)/g; | ||
|
||
self.isRepetierFirmware = ko.observable(false); | ||
|
||
self.isConnected = ko.computed(function() { | ||
return self.connection.isOperational() || self.connection.isPrinting() || | ||
self.connection.isReady() || self.connection.isPaused(); | ||
}); | ||
|
||
self.eepromData = ko.observableArray([]); | ||
|
||
self.onStartup = function() { | ||
$('#settings_plugin_eeprom_repetier_link a').on('show', function(e) { | ||
if (self.isConnected() && !self.isRepetierFirmware()) | ||
self._requestFirmwareInfo(); | ||
}); | ||
} | ||
|
||
self.fromHistoryData = function(data) { | ||
_.each(data.logs, function(line) { | ||
var match = self.firmwareRegEx.exec(line); | ||
if (match != null) { | ||
if (self.repetierRegEx.exec(match[0])) | ||
self.isRepetierFirmware(true); | ||
} | ||
}); | ||
}; | ||
|
||
self.fromCurrentData = function(data) { | ||
if (!self.isRepetierFirmware()) { | ||
_.each(data.logs, function (line) { | ||
var match = self.firmwareRegEx.exec(line); | ||
if (match) { | ||
if (self.repetierRegEx.exec(match[0])) | ||
self.isRepetierFirmware(true); | ||
} | ||
}); | ||
} | ||
else | ||
{ | ||
_.each(data.logs, function (line) { | ||
var match = self.eepromDataRegEx.exec(line); | ||
if (match) { | ||
self.eepromData.push({ | ||
dataType: match[1], | ||
position: match[2], | ||
origValue: match[3], | ||
value: match[3], | ||
description: match[4] | ||
}); | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
self.onEventConnected = function() { | ||
if (self.isConnected() && !self.isRepetierFirmware()) | ||
self._requestFirmwareInfo(); | ||
} | ||
|
||
self.onEventDisconnected = function() { | ||
self.isRepetierFirmware(false); | ||
}; | ||
|
||
self.loadEeprom = function() { | ||
self.eepromData([]); | ||
self._requestEepromData(); | ||
}; | ||
|
||
self.saveEeprom = function() { | ||
var eepromData = self.eepromData(); | ||
_.each(eepromData, function(data) { | ||
if (data.origValue != data.value) { | ||
self._requestSaveDataToEeprom(data.dataType, data.position, data.value); | ||
data.origValue = data.value; | ||
} | ||
}); | ||
}; | ||
|
||
self._requestFirmwareInfo = function() { | ||
self.control.sendCustomCommand({ command: "M115" }); | ||
}; | ||
|
||
self._requestEepromData = function() { | ||
self.control.sendCustomCommand({ command: "M205" }); | ||
} | ||
self._requestSaveDataToEeprom = function(data_type, position, value) { | ||
var cmd = "M206 T" + data_type + " P" + position; | ||
if (data_type == 3) { | ||
cmd += " X" + value; | ||
self.control.sendCustomCommand({ command: cmd }); | ||
} | ||
else { | ||
cmd += " S" + value; | ||
self.control.sendCustomCommand({ command: cmd }); | ||
} | ||
} | ||
} | ||
|
||
OCTOPRINT_VIEWMODELS.push([ | ||
EepromRepetierViewModel, | ||
["controlViewModel", "connectionViewModel"], | ||
"#settings_plugin_eeprom_repetier" | ||
]); | ||
}); |
20 changes: 20 additions & 0 deletions
20
octoprint_eeprom_repetier/templates/eeprom_repetier_settings.jinja2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<h4>EEprom Repetier Plugin</h4> | ||
This plugin is designed to get, change and save the values in the Eeprom of your Repetier Firmware based Machine.<br> | ||
Your machine is <span style="color: red" data-bind="visible: isConnected() && !isRepetierFirmware()">not</span> Repetier Firmware based | ||
</> | ||
|
||
<form class="form-horizontal"> | ||
<button data-bind="enabled: isRepetierFirmware, click: loadEeprom">{{ _('Load EEprom') }}</button> | ||
<button data-bind="enabled: isRepetierFirmware, click: saveEeprom">{{ _('Save EEprom') }}</button> | ||
</form> | ||
|
||
<div data-bind="foreach: eepromData"> | ||
<form class="form-horizontal"> | ||
<div class="control-group"> | ||
<label class="control-label" style="width: 300px" data-bind="text: description, attr: { 'for': position }"></label> | ||
<div class="controls" style="margin-left: 320px; width: 30%" > | ||
<input type="text" class="input-block-level" data-bind="value: value, attr: { 'id': position }"> | ||
</div> | ||
</div> | ||
</form> | ||
</div> |