Skip to content

Commit

Permalink
Repetier EEPROM load and saveable
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc committed Jul 28, 2015
1 parent c6e6f4f commit 578840d
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 95 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ insert_final_newline = true
trim_trailing_whitespace = true

[**.py]
indent_style = tab
indent_style = space
indent_size = 4

[**.js]
indent_style = space
Expand Down
9 changes: 0 additions & 9 deletions .gitignore

This file was deleted.

11 changes: 2 additions & 9 deletions README.md
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
8 changes: 0 additions & 8 deletions extras/README.txt

This file was deleted.

55 changes: 0 additions & 55 deletions extras/eeprom_repetier.md

This file was deleted.

49 changes: 36 additions & 13 deletions octoprint_eeprom_repetier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,45 @@
# Take a look at the documentation on what other plugin mixins are available.

import octoprint.plugin
import octoprint.server

class Eeprom_repetierPlugin(octoprint.plugin.TemplatePlugin):
# TODO Implement me!
pass
class Eeprom_repetierPlugin(octoprint.plugin.AssetPlugin,
octoprint.plugin.TemplatePlugin):
def get_assets(self):
return dict(
js=["js/eeprom_repetier.js"]
)

# If you want your plugin to be registered within OctoPrint under a different name than what you defined in setup.py
# ("OctoPrint-PluginSkeleton"), you may define that here. Same goes for the other metadata derived from setup.py that
# can be overwritten via __plugin_xyz__ control properties. See the documentation for that.
__plugin_name__ = "Eeprom_repetier Plugin"
def get_template_configs(self):
return [
dict(type="settings", template="eeprom_repetier_settings.jinja2", custom_bindings=True)
]

def get_update_information(self):
return dict(
systemcommandeditor=dict(
displayName="EEPROM Repetier Editor Plugin",
displayVersion=self._plugin_version,

# version check: github repository
type="github_release",
user="Salandora",
repo="OctoPrint-EEPROM-Repetier",
current=self._plugin_version,

# update method: pip
pip="https://github.com/Salandora/OctoPrint-EEPROM-Repetier/archive/{target_version}.zip"
)
)

__plugin_name__ = "EEPROM Repetier Editor Plugin"

def __plugin_load__():
global __plugin_implementation__
__plugin_implementation__ = Eeprom_repetierPlugin()
global __plugin_implementation__
__plugin_implementation__ = Eeprom_repetierPlugin()

# global __plugin_hooks__
# __plugin_hooks__ = {
# "some.octoprint.hook": __plugin_implementation__.some_hook_handler
# }
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
}

118 changes: 118 additions & 0 deletions octoprint_eeprom_repetier/static/js/eeprom_repetier.js
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"
]);
});
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>

0 comments on commit 578840d

Please sign in to comment.