Made wizard firmware install functional
This commit is contained in:
1 parent
d3af800217
commit
224dcfdef5
9 files changed
+3220
-22
No files matched your search
@@ -1,14 +1,14 @@
|
||||
from __future__ import absolute_import
|
||||
import __init__
|
||||
|
||||
import wx, os, platform, types
|
||||
import wx, os, platform, types, webbrowser
|
||||
import wx.wizard
|
||||
|
||||
from fabmetheus_utilities import settings
|
||||
from newui import machineCom
|
||||
|
||||
class InfoPage(wx.wizard.WizardPageSimple):
|
||||
def __init__(self, parent, title):
|
||||
"""Constructor"""
|
||||
wx.wizard.WizardPageSimple.__init__(self, parent)
|
||||
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
@@ -21,7 +21,9 @@ class InfoPage(wx.wizard.WizardPageSimple):
|
||||
sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 5)
|
||||
|
||||
def AddText(self,info):
|
||||
self.GetSizer().Add(wx.StaticText(self, -1, info), 0, wx.LEFT|wx.RIGHT, 5)
|
||||
text = wx.StaticText(self, -1, info)
|
||||
self.GetSizer().Add(text, 0, wx.LEFT|wx.RIGHT, 5)
|
||||
return text
|
||||
|
||||
def AddSeperator(self):
|
||||
self.GetSizer().Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 5)
|
||||
@@ -34,6 +36,16 @@ class InfoPage(wx.wizard.WizardPageSimple):
|
||||
self.GetSizer().Add(radio, 0, wx.EXPAND|wx.ALL, 5)
|
||||
return radio
|
||||
|
||||
def AddDualButton(self, label1, label2):
|
||||
p = wx.Panel(self)
|
||||
p.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
|
||||
button1 = wx.Button(p, -1, label1)
|
||||
p.GetSizer().Add(button1, 0)
|
||||
button2 = wx.Button(p, -1, label2)
|
||||
p.GetSizer().Add(button2, 0)
|
||||
self.GetSizer().Add(p, 0)
|
||||
return button1, button2
|
||||
|
||||
def AllowNext(self):
|
||||
return True
|
||||
|
||||
@@ -51,6 +63,13 @@ class FirstInfoPage(InfoPage):
|
||||
self.AddText('* Calibrate your machine')
|
||||
#self.AddText('* Do your first print')
|
||||
|
||||
class RepRapInfoPage(InfoPage):
|
||||
def __init__(self, parent):
|
||||
super(RepRapInfoPage, self).__init__(parent, "RepRap information")
|
||||
self.AddText('Sorry, but this wizard will not help you with\nconfiguring and calibrating your RepRap.')
|
||||
self.AddSeperator()
|
||||
self.AddText('You will have to manually install Marlin firmware\nand configure SkeinPyPy.')
|
||||
|
||||
class MachineSelectPage(InfoPage):
|
||||
def __init__(self, parent):
|
||||
super(MachineSelectPage, self).__init__(parent, "Select your machine")
|
||||
@@ -65,7 +84,7 @@ class MachineSelectPage(InfoPage):
|
||||
wx.wizard.WizardPageSimple.Chain(self, self.GetParent().ultimakerFirmwareUpgradePage)
|
||||
|
||||
def OnOtherSelect(self, e):
|
||||
wx.wizard.WizardPageSimple.Chain(self, self.GetParent().configureMachineDimensions)
|
||||
wx.wizard.WizardPageSimple.Chain(self, self.GetParent().repRapInfoPage)
|
||||
|
||||
def StoreData(self):
|
||||
if self.UltimakerRadio.GetValue():
|
||||
@@ -74,7 +93,14 @@ class MachineSelectPage(InfoPage):
|
||||
settings.putPreference('machine_height', '200')
|
||||
settings.putProfileSetting('nozzle_size', '0.4')
|
||||
settings.putProfileSetting('machine_center_x', '100')
|
||||
settings.putProfileSetting('machine_center_x', '100')
|
||||
settings.putProfileSetting('machine_center_y', '100')
|
||||
else:
|
||||
settings.putPreference('machine_width', '80')
|
||||
settings.putPreference('machine_depth', '80')
|
||||
settings.putPreference('machine_height', '60')
|
||||
settings.putProfileSetting('nozzle_size', '0.4')
|
||||
settings.putProfileSetting('machine_center_x', '40')
|
||||
settings.putProfileSetting('machine_center_y', '40')
|
||||
|
||||
class FirmwareUpgradePage(InfoPage):
|
||||
def __init__(self, parent):
|
||||
@@ -84,18 +110,60 @@ class FirmwareUpgradePage(InfoPage):
|
||||
self.AddText('The firmware shipping with new Ultimakers works, but upgrades\nhave been made to make better prints, and make calibration easier.')
|
||||
self.AddHiddenSeperator()
|
||||
self.AddText('SkeinPyPy requires these new features and thus\nyour firmware will most likely need to be upgraded.\nYou will get the chance to do so now.')
|
||||
self.AddHiddenSeperator()
|
||||
button = wx.Button(self, -1, 'Upgrade firmware')
|
||||
self.Bind(wx.EVT_BUTTON, self.OnUpgradeClick)
|
||||
self.GetSizer().Add(button, 0)
|
||||
b1, b2 = self.AddDualButton('Upgrade firmware', 'Skip upgrade')
|
||||
b1.Bind(wx.EVT_BUTTON, self.OnUpgradeClick)
|
||||
b2.Bind(wx.EVT_BUTTON, self.OnSkipClick)
|
||||
self.AddHiddenSeperator()
|
||||
self.AddText('Do not upgrade to this firmware if:')
|
||||
self.AddText('* You have an older machine based on ATMega1280')
|
||||
self.AddText('* Using an LCD panel')
|
||||
self.AddText('* Have other changes in the firmware')
|
||||
button = wx.Button(self, -1, 'Goto this page for a custom firmware')
|
||||
button.Bind(wx.EVT_BUTTON, self.OnUrlClick)
|
||||
self.GetSizer().Add(button, 0)
|
||||
|
||||
def AllowNext(self):
|
||||
return False
|
||||
|
||||
def OnUpgradeClick(self, e):
|
||||
pass
|
||||
if machineCom.installFirmware("firmware/default.hex"):
|
||||
self.GetParent().FindWindowById(wx.ID_FORWARD).Enable()
|
||||
|
||||
def OnSkipClick(self, e):
|
||||
self.GetParent().FindWindowById(wx.ID_FORWARD).Enable()
|
||||
|
||||
def OnUrlClick(self, e):
|
||||
webbrowser.open('http://daid.mine.nu/~daid/marlin_build/')
|
||||
|
||||
class UltimakerCheckupPage(InfoPage):
|
||||
def __init__(self, parent):
|
||||
super(UltimakerCheckupPage, self).__init__(parent, "Ultimaker Checkup")
|
||||
self.AddText('It is a good idea to do a few sanity checks\nnow on your Ultimaker. But you can skip these\nif you know your machine is functional.')
|
||||
b1, b2 = self.AddDualButton('Run checks', 'Skip checks')
|
||||
b1.Bind(wx.EVT_BUTTON, self.OnCheckClick)
|
||||
b2.Bind(wx.EVT_BUTTON, self.OnSkipClick)
|
||||
self.AddSeperator();
|
||||
self.checkPanel = None
|
||||
|
||||
def AllowNext(self):
|
||||
return False
|
||||
|
||||
def OnSkipClick(self, e):
|
||||
self.GetParent().FindWindowById(wx.ID_FORWARD).Enable()
|
||||
|
||||
def OnCheckClick(self, e):
|
||||
if self.checkPanel != None:
|
||||
self.checkPanel.Destroy()
|
||||
self.checkPanel = wx.Panel(self)
|
||||
self.checkPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
|
||||
self.GetSizer().Add(self.checkPanel, 0, wx.LEFT|wx.RIGHT, 5)
|
||||
self.AddProgressText("Starting machine check...")
|
||||
self.Layout()
|
||||
|
||||
def AddProgressText(self, info):
|
||||
text = wx.StaticText(self.checkPanel, -1, info)
|
||||
self.checkPanel.GetSizer().Add(text, 0)
|
||||
self.checkPanel.Layout()
|
||||
|
||||
class configWizard(wx.wizard.Wizard):
|
||||
def __init__(self):
|
||||
@@ -107,10 +175,12 @@ class configWizard(wx.wizard.Wizard):
|
||||
self.firstInfoPage = FirstInfoPage(self)
|
||||
self.machineSelectPage = MachineSelectPage(self)
|
||||
self.ultimakerFirmwareUpgradePage = FirmwareUpgradePage(self)
|
||||
self.configureMachineDimensions = InfoPage(self, 'BLA2')
|
||||
self.ultimakerCheckupPage = UltimakerCheckupPage(self)
|
||||
self.repRapInfoPage = RepRapInfoPage(self)
|
||||
|
||||
wx.wizard.WizardPageSimple.Chain(self.firstInfoPage, self.machineSelectPage)
|
||||
wx.wizard.WizardPageSimple.Chain(self.machineSelectPage, self.ultimakerFirmwareUpgradePage)
|
||||
wx.wizard.WizardPageSimple.Chain(self.ultimakerFirmwareUpgradePage, self.ultimakerCheckupPage)
|
||||
|
||||
self.FitToPage(self.firstInfoPage)
|
||||
self.GetPageAreaSizer().Add(self.firstInfoPage)
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
from __future__ import absolute_import
|
||||
import __init__
|
||||
|
||||
import os, glob, wx
|
||||
|
||||
from serial import Serial
|
||||
|
||||
from avr_isp import stk500v2
|
||||
from avr_isp import ispBase
|
||||
from avr_isp import intelHex
|
||||
|
||||
try:
|
||||
import _winreg
|
||||
except:
|
||||
pass
|
||||
|
||||
def serialList():
|
||||
baselist=[]
|
||||
if os.name=="nt":
|
||||
try:
|
||||
key=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"HARDWARE\\DEVICEMAP\\SERIALCOMM")
|
||||
i=0
|
||||
while(1):
|
||||
baselist+=[_winreg.EnumValue(key,i)[1]]
|
||||
i+=1
|
||||
except:
|
||||
pass
|
||||
return baselist+glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyACM*') +glob.glob("/dev/tty.*")+glob.glob("/dev/cu.*")+glob.glob("/dev/rfcomm*")
|
||||
|
||||
def installFirmware(filename, port = 'AUTO'):
|
||||
hexFile = intelHex.readHex(filename)
|
||||
programmer = stk500v2.Stk500v2()
|
||||
if port == 'AUTO':
|
||||
for port in serialList():
|
||||
try:
|
||||
programmer.connect(port)
|
||||
except ispBase.IspError:
|
||||
pass
|
||||
else:
|
||||
programmer.connect(port)
|
||||
if programmer.isConnected():
|
||||
programmer.programChip(hexFile)
|
||||
programmer.close()
|
||||
return True
|
||||
wx.MessageBox('Failed to find machine for firmware upgrade\nIs your machine connected to the PC?', 'Firmware update', wx.OK | wx.ICON_ERROR)
|
||||
return False
|
||||
|
||||
def serialOpen(port = 'AUTO', baudrate = 115200):
|
||||
if port == 'AUTO':
|
||||
programmer = stk500v2.Stk500v2()
|
||||
for port in serialList():
|
||||
try:
|
||||
programmer.connect(port)
|
||||
programmer.close()
|
||||
return Serial(port, baudrate, timeout=5)
|
||||
except ispBase.IspError:
|
||||
pass
|
||||
programmer.close()
|
||||
else:
|
||||
return Serial(port, baudrate, timeout=5)
|
||||
return False
|
||||
|
||||
@@ -5,6 +5,8 @@ import wx, os, platform, types
|
||||
import ConfigParser
|
||||
|
||||
from newui import configBase
|
||||
from newui import validators
|
||||
from newui import machineCom
|
||||
|
||||
class preferencesDialog(configBase.configWindowBase):
|
||||
def __init__(self, parent):
|
||||
@@ -24,8 +26,8 @@ class preferencesDialog(configBase.configWindowBase):
|
||||
validators.validFloat(c, 10.0)
|
||||
|
||||
configBase.TitleRow(left, 'Communication settings')
|
||||
c = configBase.SettingRow(left, 'Serial port', 'serial_port', 'AUTO', 'Serial port to use for communication with the printer', type = 'preference')
|
||||
c = configBase.SettingRow(left, 'Baudrate', 'serial_baud', '250000', 'Speed of the serial port communication\nNeeds to match your firmware settings', type = 'preference')
|
||||
c = configBase.SettingRow(left, 'Serial port', 'serial_port', ['AUTO'] + machineCom.serialList(), 'Serial port to use for communication with the printer', type = 'preference')
|
||||
c = configBase.SettingRow(left, 'Baudrate', 'serial_baud', '250000', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference')
|
||||
|
||||
self.MakeModal(True)
|
||||
main.Fit()
|
||||
|
||||
Reference in new issue
Block a user