Made wizard firmware install functional

master
daid 2012-03-06 17:48:56 +01:00
parent d3af800217
commit 224dcfdef5
9 changed files with 3220 additions and 22 deletions

View File

@ -0,0 +1,13 @@
"""
This page is in the table of contents.
This is required to workaround the python import bug where relative imports don't work if the module is imported as a main module.
"""
import os
import sys
numberOfLevelsDeepInPackageHierarchy = 1
packageFilePath = os.path.abspath(__file__)
for level in range( numberOfLevelsDeepInPackageHierarchy + 1 ):
packageFilePath = os.path.dirname( packageFilePath )
if packageFilePath not in sys.path:
sys.path.insert( 0, packageFilePath )

View File

@ -12,3 +12,4 @@ def getChipFromDB(sig):
if chip['signature'] == sig:
return chip
return False

View File

@ -9,16 +9,13 @@ class IspBase():
self.curExtAddr = -1
self.chip = chipDB.getChipFromDB(self.getSignature())
if self.chip == False:
print "Chip with signature: " + str(self.getSignature()) + "not found"
return False
raise IspError("Chip with signature: " + str(self.getSignature()) + "not found")
self.chipErase()
print "Flashing %i bytes" % len(flashData)
self.writeFlash(flashData)
print "Verifying %i bytes" % len(flashData)
self.verifyFlash(flashData)
return True
#low level ISP commands
def getSignature(self):

View File

@ -12,7 +12,7 @@ class Stk500v2(ispBase.IspBase):
def connect(self, port = 'COM3', speed = 115200):
if self.serial != None:
self.serial.close()
self.close()
self.serial = Serial(port, speed, timeout=5)
self.seq = 1
@ -23,15 +23,28 @@ class Stk500v2(ispBase.IspBase):
self.sendMessage([1])
if self.sendMessage([0x10, 0xc8, 0x64, 0x19, 0x20, 0x00, 0x53, 0x03, 0xac, 0x53, 0x00, 0x00]) != [0x10, 0x00]:
self.close()
raise ispBase.IspError("Failed to enter programming mode")
def close(self):
if self.serial != None:
self.serial.close()
self.serial = None
def isConnected(self):
return self.serial != None
def sendISP(self, data):
recv = self.sendMessage([0x1D, 4, 4, 0, data[0], data[1], data[2], data[3]])
return recv[2:6]
def writeFlash(self, flashData):
#Set load addr to 0 (with more then 64k load)
self.sendMessage([0x06, 0x80, 0x00, 0x00, 0x00])
#Set load addr to 0, in case we have more then 64k flash we need to enable the address extension
flashSize = self.chip['pageSize'] * 2 * self.chip['pageCount']
if flashSize > 0xFFFF:
self.sendMessage([0x06, 0x80, 0x00, 0x00, 0x00])
else:
self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00])
loadCount = (len(flashData) + 0xFF) / 0x100
for i in xrange(0, loadCount):
@ -39,8 +52,12 @@ class Stk500v2(ispBase.IspBase):
print "#%i#%i#" % (i + 1, loadCount)
def verifyFlash(self, flashData):
#Set load addr to 0 (with more then 64k load)
self.sendMessage([0x06, 0x80, 0x00, 0x00, 0x00])
#Set load addr to 0, in case we have more then 64k flash we need to enable the address extension
flashSize = self.chip['pageSize'] * 2 * self.chip['pageCount']
if flashSize > 0xFFFF:
self.sendMessage([0x06, 0x80, 0x00, 0x00, 0x00])
else:
self.sendMessage([0x06, 0x00, 0x00, 0x00, 0x00])
loadCount = (len(flashData) + 0xFF) / 0x100
for i in xrange(0, loadCount):

View File

@ -0,0 +1,100 @@
#ifndef __CONFIGURATION_H
#define __CONFIGURATION_H
#define STRING_VERSION_CONFIG_H "Marlin-Mon, 5 Mar 2012 09:56:50 -0800 - f3095493b06d52a33ae77a0b8c1f92a22633261a"
#define STRING_CONFIG_H_AUTHOR "Build-Me-Marlin"
#define BAUDRATE 250000
#define __ARDUINO_NR__ 4
#define EXTRUDERS 1
#define MINIMUM_PLANNER_SPEED 2.0
#define MOTHERBOARD 7
#define HEATER_0_USES_AD595
#define HEATER_0_MINTEMP 5
#define HEATER_0_MAXTEMP 275
#define BED_CHECK_INTERVAL 5000
#define TEMP_RESIDENCY_TIME 30
#define TEMP_HYSTERESIS 3
#define TEMP_SENSOR_AD595_OFFSET 0.000000
#define TEMP_SENSOR_AD595_GAIN 1.000000
#define CooldownNoWait true
#define HEATING_EARLY_FINISH_DEG_OFFSET 1
#define PIDTEMP
#define PID_MAX 255
#define PID_INTEGRAL_DRIVE_MAX 255
#define K1 0.95
#define PID_dT 0.128
#define PID_PID
#define DEFAULT_Kp 22.2
#define DEFAULT_Ki (1.25*PID_dT)
#define DEFAULT_Kd (99/PID_dT)
#define PID_ADD_EXTRUSION_RATE
#define DEFAULT_Kc (1)
#define ENDSTOPPULLUPS
const bool X_ENDSTOPS_INVERTING = true;
const bool Y_ENDSTOPS_INVERTING = true;
const bool Z_ENDSTOPS_INVERTING = true;
#define X_ENABLE_ON 0
#define Y_ENABLE_ON 0
#define Z_ENABLE_ON 0
#define E_ENABLE_ON 0
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z false
#define DISABLE_E false
#define INVERT_X_DIR true
#define INVERT_Y_DIR false
#define INVERT_Z_DIR true
#define INVERT_E0_DIR false
#define INVERT_E1_DIR false
#define INVERT_E2_DIR false
#define X_HOME_DIR -1
#define Y_HOME_DIR -1
#define Z_HOME_DIR -1
#define min_software_endstops false
#define max_software_endstops false
#define X_MAX_LENGTH 205
#define Y_MAX_LENGTH 205
#define Z_MAX_LENGTH 200
#define X_HOME_POS 0
#define Y_HOME_POS 0
#define Z_HOME_POS 0
#define NUM_AXIS 4
#define HOMING_FEEDRATE {50*60, 50*60, 4*60, 0}
#define X_HOME_RETRACT_MM 5
#define Y_HOME_RETRACT_MM 5
#define Z_HOME_RETRACT_MM 1
#define QUICK_HOME
#define AXIS_RELATIVE_MODES {false, false, false, false}
#define MAX_STEP_FREQUENCY 40000
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,533.333333333,865.888}
#define DEFAULT_MAX_FEEDRATE {250, 250, 5, 45}
#define DEFAULT_MAX_ACCELERATION {9000,9000,100,10000}
#define DEFAULT_ACCELERATION 3000
#define DEFAULT_RETRACT_ACCELERATION 3000
#define DEFAULT_MINIMUMFEEDRATE 0.0
#define DEFAULT_MINTRAVELFEEDRATE 0.0
#define DEFAULT_MINSEGMENTTIME 20000
#define DEFAULT_XYJERK 20.0
#define DEFAULT_ZJERK 0.4
#define DEFAULT_EJERK 5.0
#define SLOWDOWN
#define DEFAULT_STEPPER_DEACTIVE_TIME 60
#define DEFAULT_STEPPER_DEACTIVE_COMMAND "M84 X Y E"
#define EEPROM_SETTINGS
#define EEPROM_CHITCHAT
#define PLA_PREHEAT_HOTEND_TEMP 180
#define PLA_PREHEAT_HPB_TEMP 70
#define PLA_PREHEAT_FAN_SPEED 255
#define ABS_PREHEAT_HOTEND_TEMP 240
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 255
#define MM_PER_ARC_SEGMENT 1
#define N_ARC_CORRECTION 25
#define PREVENT_DANGEROUS_EXTRUDE
#define EXTRUDE_MINTEMP 170
#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH)
const int dropsegments=5;
#define BLOCK_BUFFER_SIZE 16
#define MAX_CMD_SIZE 96
#define BUFSIZE 4
#include "thermistortables.h"
#endif //__CONFIGURATION_H

File diff suppressed because it is too large Load Diff

View File

@ -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)

View File

@ -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

View File

@ -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()