Merge branch 'nativeserial' into mrbeam

This commit is contained in:
make-ing 2016-04-18 17:16:28 +02:00
commit e7fcb5b228
9 changed files with 167 additions and 19 deletions

View file

@ -1160,6 +1160,7 @@ ul.dropdown-menu li a {
#control_zaxis {
display:inline-block;
width: 80px;
margin: 1em auto 0;
}
#control_zaxis_focus {
display:inline-block;
@ -1541,7 +1542,7 @@ td.settings_printerProfiles_profiles_action a.disabled {
.nav-pills>li>a,
select,
textarea,
input,
input, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"],
input.search-query,
.uneditable-input,
.input-append .add-on:last-child,

View file

@ -102,3 +102,28 @@ svg text {
.overrideSlider span {
padding-left: .6em;
}
.repeatGcode .btn-group {
width: 145px;
}
.repeatGcode input, .repeatGcode button {
width: 33%;
}
.repeatGcode input {
margin-bottom:0;
padding-left: 0;
padding-right: 0;
text-align: center;
}
.repeatGcode>span {
padding-left: .6em;
}
.manual_position_input {
padding-top: 12px;
}
#manual_position.warning {
color: #DD0000;
}

View file

@ -450,10 +450,16 @@ $(function(){
};
self.getUsefulDimensions = function(wpx, hpx){
var maxWidthMM = wpx * 0.25; // TODO parametrize
var aspectRatio = wpx / hpx;
var destWidthMM = Math.min(self.workingAreaWidthMM() - 2, maxWidthMM);
var destHeightMM = destWidthMM / aspectRatio;
var maxWidthMM = wpx * 0.25; // TODO parametrize
var maxHeightMM = hpx * 0.25; // TODO parametrize
var aspectRatio = wpx / hpx;
var destWidthMM = Math.min(self.workingAreaWidthMM() - 2, maxWidthMM);
var destHeightMM = Math.min(self.workingAreaHeightMM() - 2, maxHeightMM);
if ((destWidthMM / aspectRatio) > destHeightMM) {
destWidthMM = destHeightMM * aspectRatio;
} else {
destHeightMM = destWidthMM / aspectRatio;
}
var destWidthPT = self.mm2svgUnits(destWidthMM);
var destHeightPT = self.mm2svgUnits(destHeightMM);
return [destWidthPT, destHeightPT];

View file

@ -433,6 +433,22 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
payload["origin"] = FileDestinations.SDCARD
eventManager().fire(Events.PRINT_FAILED, payload)
def increase_passes(self):
"""
increase the number of passes by one.
"""
if self._comm is None:
return
self._comm.increasePasses()
def degrease_passes(self):
"""
degrease the number of passes by one.
"""
if self._comm is None:
return
self._comm.degreasePasses()
def get_state_string(self):
"""
Returns a human readable string corresponding to the current communication state.

View file

@ -23,7 +23,9 @@ def controlJob():
"start": [],
"restart": [],
"pause": [],
"cancel": []
"cancel": [],
"incpasses": [],
"degpasses": []
}
command, data, response = get_json_command_from_request(request, valid_commands)
@ -48,6 +50,15 @@ def controlJob():
if not activePrintjob:
return make_response("Printer is neither printing nor paused, 'cancel' command cannot be performed", 409)
printer.cancel_print()
elif command == "incpasses":
if not activePrintjob:
return make_response("Printer is neither printing nor paused, 'incpasses' command cannot be performed", 409)
printer.increase_passes()
elif command == "degpasses":
if not activePrintjob:
return make_response("Printer is neither printing nor paused, 'degpasses' command cannot be performed", 409)
printer.degrease_passes()
return NO_CONTENT

View file

@ -404,6 +404,11 @@ $(function() {
self.onStartup = function () {
self.requestData();
self._configureJogDistanceSlider();
$('#manual_position').keyup(function(e) {
if (e.which === 13){ // 13 == enter
self.manualPosition();
}
});
};
self.updateRotatorWidth = function() {
@ -606,6 +611,24 @@ $(function() {
self.setCoordinateOrigin = function () {
self.sendCustomCommand({type: 'command', command: "G92 X0 Y0"});
};
self.manualPosition = function(){
$('#manual_position').removeClass('warning');
var s = $('#manual_position').val();
var tmp = s.split(/[^0-9.,-\\+]+/);
if (tmp.length === 2) {
var x = parseFloat(tmp[0]);
var y = parseFloat(tmp[1]);
if(!isNaN(x) && !isNaN(y)) {
self.sendCustomCommand({type: 'command', command: "G0X"+x+"Y"+y});
$('#manual_position').val('');
} else {
$('#manual_position').addClass('warning');
}
} else {
$('#manual_position').addClass('warning');
}
};
self.jogDistanceInMM = ko.observable(undefined);

View file

@ -38,6 +38,7 @@ $(function() {
self.feedrateOverride = ko.observable(100);
self.intensityOverride.extend({ rateLimit: 500 });
self.feedrateOverride.extend({ rateLimit: 500 });
self.numberOfPasses = ko.observable(1);
self.TITLE_PRINT_BUTTON_PAUSED = gettext("Restarts the print job from the beginning");
self.TITLE_PRINT_BUTTON_UNPAUSED = gettext("Starts the print job");
@ -216,6 +217,8 @@ $(function() {
$("#confirmation_dialog .confirmation_dialog_acknowledge").click(
function (e) {
if (typeof callback === 'function') {
self.resetOverrideSlider();
self.numberOfPasses(1);
callback(e);
$("#confirmation_dialog").modal("hide");
$("#confirmation_dialog .confirmation_dialog_message").html('');
@ -285,14 +288,14 @@ $(function() {
self.onEventRealTimeState = function(payload){
self.currentPos({x: payload.wx, y: payload.wy});
};
self.intensityOverride.subscribe(function(factor){
self._overrideCommand("/intensity "+factor);
});
self.feedrateOverride.subscribe(function(factor){
self._overrideCommand("/feedrate "+factor);
});
self._overrideCommand = function(command, callback) {
$.ajax({
url: API_BASEURL + "printer/command",
@ -307,7 +310,7 @@ $(function() {
}
});
};
self._configureOverrideSliders = function() {
self.intensityOverrideSlider = $("#intensity_override_slider").slider({
step: 1,
@ -318,7 +321,7 @@ $(function() {
}).on("slideStop", function(ev){
self.intensityOverride(ev.value);
});
self.feedrateOverrideSlider = $("#feedrate_override_slider").slider({
step: 1,
min: 10,
@ -330,17 +333,31 @@ $(function() {
});
};
self.increasePasses = function(){
self.numberOfPasses(self.numberOfPasses()+1);
self._jobCommand("incpasses");
}
self.decreasePasses = function(){
var passes = Math.max(self.numberOfPasses()-1, 1);
self.numberOfPasses(passes);
self._jobCommand("degpasses");
}
self.onEventPrintDone = function(){
self.feedrateOverrideSlider.slider('setValue', 100);
self.resetOverrideSlider();
};
self.onStartup = function() {
self._configureOverrideSliders();
};
self.resetOverrideSlider = function() {
self.feedrateOverrideSlider.slider('setValue', 100);
self.intensityOverrideSlider.slider('setValue', 100);
self.intensityOverride(100);
self.feedrateOverride(100);
};
self.onStartup = function() {
self._configureOverrideSliders();
};
}
OCTOPRINT_VIEWMODELS.push([

View file

@ -123,6 +123,10 @@
<div class="distance">
<input type="text" id="jogDistance" />
</div>
<div class="input-append manual_position_input">
<input id="manual_position" placeholder="x.xx y.yy" onsubmit="manualPosition"/>
<button class="" data-bind="click: manualPosition">Go</button>
</div>
</div>
</div>
</div>
@ -168,6 +172,19 @@
<input id="feedrate_override_slider" type="text" data-bind="sliderValue: feedrateOverride">
<span data-bind="text:feedrateOverride()">100</span>% Feedrate
</div>
<div class="repeatGcode">
<div class="btn-group">
<button type="button" class="btn btn-default btn-number" data-bind="enable: numberOfPasses() > 1, click:decreasePasses">
<span class="icon-minus"></span>
</button>
<input type="text" class="input-mini text-right" value="1" min="1" max="10" data-bind="value:numberOfPasses()">
<button type="button" class="btn btn-default btn-number" data-bind="click:increasePasses">
<span class="icon-plus"></span>
</button>
</div>
<span>Passes</span>
</div>
</div>
<!-- {{ _('Print Time') }}: <strong data-bind="text: printTimeString"></strong><br>

View file

@ -84,6 +84,8 @@ class MachineCom(object):
self._actual_intensity = None
self._feedrate_dict = {}
self._intensity_dict = {}
self._passes = 1
self._finished_passes = 0
# regular expressions
self._regex_command = re.compile("^\s*\$?([GM]\d+|[TH])")
@ -164,8 +166,15 @@ class MachineCom(object):
if cmd is not None:
self.sendCommand(cmd)
self._callback.on_comm_progress()
elif len(self._acc_line_buffer) == 0:
self._set_print_finished()
else:
if self._finished_passes >= self._passes:
if len(self._acc_line_buffer) == 0:
self._set_print_finished()
self._currentFile.resetToBeginning()
cmd = self._getNext()
if cmd is not None:
self.sendCommand(cmd)
self._callback.on_comm_progress()
self._sendCommand()
self._send_event.wait(1)
@ -311,7 +320,9 @@ class MachineCom(object):
if self._finished_currentFile is False:
line = self._currentFile.getNext()
if line is None:
self._finished_currentFile = True
self._finished_passes += 1
if self._finished_passes >= self._passes:
self._finished_currentFile = True
return line
else:
return None
@ -824,6 +835,12 @@ class MachineCom(object):
if self._currentFile is None:
raise ValueError("No file selected for printing")
# reset feedrate and intesity factor in case they where changed in a previous run
self._feedrate_factor = 1
self._intensity_factor = 1
self._passes = 1
self._finished_passes = 0
try:
# ensure fan is on whatever gcode follows.
self.sendCommand("M08")
@ -893,6 +910,14 @@ class MachineCom(object):
self._send_event.set()
eventManager().fire(Events.PRINT_PAUSED, payload)
def increasePasses(self):
self._passes += 1
self._log("increased Passes to %d" % self._passes)
def degreasePasses(self):
self._passes -= 1
self._log("degrease Passes to %d" % self._passes)
def getStateString(self):
if self._state == self.STATE_NONE:
return "Offline"
@ -1155,6 +1180,12 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
pass
self._handle = None
def resetToBeginning(self):
"""
resets the file handle so you can read from the beginning again.
"""
self._handle = open(self._filename, "r")
def getNext(self):
"""
Retrieves the next line for printing.
@ -1244,6 +1275,7 @@ def serialList():
baselist = baselist \
+ glob.glob("/dev/ttyUSB*") \
+ glob.glob("/dev/ttyACM*") \
+ glob.glob("/dev/ttyAMA*") \
+ glob.glob("/dev/tty.usb*") \
+ glob.glob("/dev/cu.*") \
+ glob.glob("/dev/cuaU*") \