Skip to content

Commit

Permalink
Merge pull request #181 from donovan6000/devel
Browse files Browse the repository at this point in the history
Rearranged firmware checking incase other third-party firmwares get r…
  • Loading branch information
donovan6000 authored Aug 18, 2016
2 parents aa94a44 + 3a83773 commit ef1bfff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions octoprint_m33fio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3434,23 +3434,23 @@ def updateFirmware(self, connection, encryptedRom, romVersion) :
# Check if old and new firmware types are known
if oldFirmwareType is not None and newFirmwareType is not None :

# Check if going from M3D or M3D Mod firmware to iMe firmware
if (oldFirmwareType == "M3D" or oldFirmwareType == "M3D Mod") and newFirmwareType == "iMe" :
# Check if going from M3D or M3D Mod firmware to a different firmware
if (oldFirmwareType == "M3D" or oldFirmwareType == "M3D Mod") and newFirmwareType != "M3D" and newFirmwareType != "M3D Mod" :

# Check if Z state was saved
if self.eepromGetInt("savedZState") != 0 :

# Get current Z value from EEPROM
currentValueZ = self.eepromGetInt("lastRecordedZValue")

# Convert current Z to single-precision floating-point format used by iMe firmware
# Convert current Z to single-precision floating-point format used by other firmwares
currentValueZ /= 5170.635833481

# Set error to if setting current Z in EEPROM failed
error = self.eepromSetFloat(connection, "lastRecordedZValue", currentValueZ)

# Otherwise check if going from iMe firmware to M3D or M3D Mod firmware
elif oldFirmwareType == "iMe" and (newFirmwareType == "M3D" or newFirmwareType == "M3D Mod") :
# Otherwise check if going from a different firmware to M3D or M3D Mod firmware
elif oldFirmwareType != "M3D" and oldFirmwareType != "M3D Mod" and (newFirmwareType == "M3D" or newFirmwareType == "M3D Mod") :

# Check if Z state was saved
if self.eepromGetInt("savedZState") != 0 :
Expand Down
28 changes: 14 additions & 14 deletions octoprint_m33fio/static/js/m33fio.js
Original file line number Diff line number Diff line change
Expand Up @@ -8977,7 +8977,7 @@ $(function() {
// Set commands
var commands = [
"G90",
"G0 Z" + (currentFirmwareType === "iMe" ? 0 : (parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOrientation()) + parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOffset()))) + " F90"
"G0 Z" + (currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOrientation()) + parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOffset())) : 0) + " F90"
];

// Send request
Expand Down Expand Up @@ -9010,7 +9010,7 @@ $(function() {
// Set commands
var commands = [
"G90",
"G0 Z" + (currentFirmwareType === "iMe" ? 0 : (parseFloat(self.settings.settings.plugins.m33fio.FrontRightOrientation()) + parseFloat(self.settings.settings.plugins.m33fio.FrontRightOffset()))) + " F90"
"G0 Z" + (currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (parseFloat(self.settings.settings.plugins.m33fio.FrontRightOrientation()) + parseFloat(self.settings.settings.plugins.m33fio.FrontRightOffset())) : 0) + " F90"
];

// Send request
Expand Down Expand Up @@ -9043,7 +9043,7 @@ $(function() {
// Set commands
var commands = [
"G90",
"G0 Z" + (currentFirmwareType === "iMe" ? 0 : (parseFloat(self.settings.settings.plugins.m33fio.BackRightOrientation()) + parseFloat(self.settings.settings.plugins.m33fio.BackRightOffset()))) + " F90"
"G0 Z" + (currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (parseFloat(self.settings.settings.plugins.m33fio.BackRightOrientation()) + parseFloat(self.settings.settings.plugins.m33fio.BackRightOffset())) : 0) + " F90"
];

// Send request
Expand Down Expand Up @@ -9076,7 +9076,7 @@ $(function() {
// Set commands
var commands = [
"G90",
"G0 Z" + (currentFirmwareType === "iMe" ? 0 : (parseFloat(self.settings.settings.plugins.m33fio.BackLeftOrientation()) + parseFloat(self.settings.settings.plugins.m33fio.BackLeftOffset()))) + " F90"
"G0 Z" + (currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (parseFloat(self.settings.settings.plugins.m33fio.BackLeftOrientation()) + parseFloat(self.settings.settings.plugins.m33fio.BackLeftOffset())) : 0) + " F90"
];

// Send request
Expand Down Expand Up @@ -9119,7 +9119,7 @@ $(function() {

// Set commands
commands = [
"M618 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "iMe" ? (currentZ + parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOffset())) : (currentZ - parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOrientation()))),
"M618 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (currentZ - parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOrientation())) : (currentZ + parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOffset()))),
"M619 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"],
"M65536;wait"
];
Expand Down Expand Up @@ -9201,7 +9201,7 @@ $(function() {

// Set commands
commands = [
"M618 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "iMe" ? (currentZ + parseFloat(self.settings.settings.plugins.m33fio.FrontRightOffset())) : (currentZ - parseFloat(self.settings.settings.plugins.m33fio.FrontRightOrientation()))),
"M618 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (currentZ - parseFloat(self.settings.settings.plugins.m33fio.FrontRightOrientation())) : (currentZ + parseFloat(self.settings.settings.plugins.m33fio.FrontRightOffset()))),
"M619 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"],
"M65536;wait"
];
Expand Down Expand Up @@ -9283,7 +9283,7 @@ $(function() {

// Set commands
commands = [
"M618 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "iMe" ? (currentZ + parseFloat(self.settings.settings.plugins.m33fio.BackRightOffset())) : (currentZ - parseFloat(self.settings.settings.plugins.m33fio.BackRightOrientation()))),
"M618 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (currentZ - parseFloat(self.settings.settings.plugins.m33fio.BackRightOrientation())) : (currentZ + parseFloat(self.settings.settings.plugins.m33fio.BackRightOffset()))),
"M619 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"],
"M65536;wait"
];
Expand Down Expand Up @@ -9365,7 +9365,7 @@ $(function() {

// Set commands
commands = [
"M618 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "iMe" ? (currentZ + parseFloat(self.settings.settings.plugins.m33fio.BackLeftOffset())) : (currentZ - parseFloat(self.settings.settings.plugins.m33fio.BackLeftOrientation()))),
"M618 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (currentZ - parseFloat(self.settings.settings.plugins.m33fio.BackLeftOrientation())) : (currentZ + parseFloat(self.settings.settings.plugins.m33fio.BackLeftOffset()))),
"M619 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"],
"M65536;wait"
];
Expand Down Expand Up @@ -9448,10 +9448,10 @@ $(function() {
waitingCallback = function() {

// Set commands
commands = currentFirmwareType === "iMe" ? [] : [
commands = currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? [
"G91",
"G0 Z0.1 F90"
];
] : [];

commands.push("G33");
commands.push("M65536;wait");
Expand Down Expand Up @@ -9940,7 +9940,7 @@ $(function() {

// Set commands
commands = [
"M618 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "iMe" ? (currentZ + parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOffset())) : (currentZ - parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOrientation()))),
"M618 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (currentZ - parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOrientation())) : (currentZ + parseFloat(self.settings.settings.plugins.m33fio.FrontLeftOffset()))),
"M619 S" + eepromOffsets["bedOffsetFrontLeft"]["offset"] + " T" + eepromOffsets["bedOffsetFrontLeft"]["bytes"],
"M65536;wait"
];
Expand Down Expand Up @@ -9982,7 +9982,7 @@ $(function() {

// Set commands
commands = [
"M618 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "iMe" ? (currentZ + parseFloat(self.settings.settings.plugins.m33fio.FrontRightOffset())) : (currentZ - parseFloat(self.settings.settings.plugins.m33fio.FrontRightOrientation()))),
"M618 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (currentZ - parseFloat(self.settings.settings.plugins.m33fio.FrontRightOrientation())) : (currentZ + parseFloat(self.settings.settings.plugins.m33fio.FrontRightOffset()))),
"M619 S" + eepromOffsets["bedOffsetFrontRight"]["offset"] + " T" + eepromOffsets["bedOffsetFrontRight"]["bytes"],
"M65536;wait"
];
Expand Down Expand Up @@ -10024,7 +10024,7 @@ $(function() {

// Set commands
commands = [
"M618 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "iMe" ? (currentZ + parseFloat(self.settings.settings.plugins.m33fio.BackRightOffset())) : (currentZ - parseFloat(self.settings.settings.plugins.m33fio.BackRightOrientation()))),
"M618 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (currentZ - parseFloat(self.settings.settings.plugins.m33fio.BackRightOrientation())) : (currentZ + parseFloat(self.settings.settings.plugins.m33fio.BackRightOffset()))),
"M619 S" + eepromOffsets["bedOffsetBackRight"]["offset"] + " T" + eepromOffsets["bedOffsetBackRight"]["bytes"],
"M65536;wait"
];
Expand Down Expand Up @@ -10066,7 +10066,7 @@ $(function() {

// Set commands
commands = [
"M618 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "iMe" ? (currentZ + parseFloat(self.settings.settings.plugins.m33fio.BackLeftOffset())) : (currentZ - parseFloat(self.settings.settings.plugins.m33fio.BackLeftOrientation()))),
"M618 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"] + " P" + floatToBinary(currentFirmwareType === "M3D" || currentFirmwareType === "M3D Mod" ? (currentZ - parseFloat(self.settings.settings.plugins.m33fio.BackLeftOrientation())) : (currentZ + parseFloat(self.settings.settings.plugins.m33fio.BackLeftOffset()))),
"M619 S" + eepromOffsets["bedOffsetBackLeft"]["offset"] + " T" + eepromOffsets["bedOffsetBackLeft"]["bytes"],
"M65536;wait"
];
Expand Down

0 comments on commit ef1bfff

Please sign in to comment.