diff --git a/config/board.3drag.h b/config/board.3drag.h index 08bbbc6..db7292f 100644 --- a/config/board.3drag.h +++ b/config/board.3drag.h @@ -194,6 +194,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO14, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.cnc-shield-v3.h b/config/board.cnc-shield-v3.h index de25da1..8da11a9 100644 --- a/config/board.cnc-shield-v3.h +++ b/config/board.cnc-shield-v3.h @@ -196,6 +196,14 @@ DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, AIO3, THERMISTOR_EXTRUDER) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.gen3.h b/config/board.gen3.h index 8dba806..e4bf792 100644 --- a/config/board.gen3.h +++ b/config/board.gen3.h @@ -190,6 +190,14 @@ DEFINE_TEMP_SENSOR(noheater, TT_INTERCOM, AIO0, 0) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.gen6.h b/config/board.gen6.h index 4831b44..3b73fc9 100644 --- a/config/board.gen6.h +++ b/config/board.gen6.h @@ -191,6 +191,14 @@ DEFINE_TEMP_SENSOR(extruder, TT_THERMISTOR, AIO5, THERMISTOR_EXTRUDER) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.gen7-arm.h b/config/board.gen7-arm.h index afee8dc..f99182c 100644 --- a/config/board.gen7-arm.h +++ b/config/board.gen7-arm.h @@ -194,6 +194,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, PIO1_0,THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.gen7-v1.1-v1.3.h b/config/board.gen7-v1.1-v1.3.h index 3cef5e0..25bd32f 100644 --- a/config/board.gen7-v1.1-v1.3.h +++ b/config/board.gen7-v1.1-v1.3.h @@ -198,6 +198,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO2, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.gen7-v1.4.h b/config/board.gen7-v1.4.h index 81c8b24..107ec2d 100644 --- a/config/board.gen7-v1.4.h +++ b/config/board.gen7-v1.4.h @@ -199,6 +199,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO0, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.melzi.h b/config/board.melzi.h index 4d681e7..8ec6145 100644 --- a/config/board.melzi.h +++ b/config/board.melzi.h @@ -197,6 +197,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO6, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.nanoheart-v1.0.h b/config/board.nanoheart-v1.0.h index da83220..6465b4d 100644 --- a/config/board.nanoheart-v1.0.h +++ b/config/board.nanoheart-v1.0.h @@ -197,6 +197,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO7, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.pcbscriber.h b/config/board.pcbscriber.h index 919f09a..ef7a8dd 100644 --- a/config/board.pcbscriber.h +++ b/config/board.pcbscriber.h @@ -194,6 +194,14 @@ * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.ramps-v1.2.h b/config/board.ramps-v1.2.h index 3b20dac..3ea478e 100644 --- a/config/board.ramps-v1.2.h +++ b/config/board.ramps-v1.2.h @@ -195,6 +195,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO1, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.ramps-v1.3.h b/config/board.ramps-v1.3.h index 313c65e..0ec175c 100644 --- a/config/board.ramps-v1.3.h +++ b/config/board.ramps-v1.3.h @@ -196,6 +196,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO14, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.rumba.h b/config/board.rumba.h index 3a438ac..c2b9fb3 100644 --- a/config/board.rumba.h +++ b/config/board.rumba.h @@ -197,6 +197,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO11, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.sanguinololu-v1.1.h b/config/board.sanguinololu-v1.1.h index f87420f..f6285eb 100644 --- a/config/board.sanguinololu-v1.1.h +++ b/config/board.sanguinololu-v1.1.h @@ -197,6 +197,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO6, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.sanguinololu-v1.2.h b/config/board.sanguinololu-v1.2.h index 574ba54..c0e5297 100644 --- a/config/board.sanguinololu-v1.2.h +++ b/config/board.sanguinololu-v1.2.h @@ -197,6 +197,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO6, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.sanguish.h b/config/board.sanguish.h index 60810d0..439efaa 100644 --- a/config/board.sanguish.h +++ b/config/board.sanguish.h @@ -197,6 +197,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO0, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.sinaptec-at328-02.h b/config/board.sinaptec-at328-02.h index 538da00..fabee2d 100644 --- a/config/board.sinaptec-at328-02.h +++ b/config/board.sinaptec-at328-02.h @@ -197,6 +197,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO6, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.teensy++-v2.0.h b/config/board.teensy++-v2.0.h index 03ceee1..3f96d3e 100644 --- a/config/board.teensy++-v2.0.h +++ b/config/board.teensy++-v2.0.h @@ -194,6 +194,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO6, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.teensy-v2.0.h b/config/board.teensy-v2.0.h index d3b1bfe..ef8aeb3 100644 --- a/config/board.teensy-v2.0.h +++ b/config/board.teensy-v2.0.h @@ -194,6 +194,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO0, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/config/board.tronxy.h b/config/board.tronxy.h index 4e88471..74b27d9 100644 --- a/config/board.tronxy.h +++ b/config/board.tronxy.h @@ -195,6 +195,14 @@ DEFINE_TEMP_SENSOR(bed, TT_THERMISTOR, AIO6, THERMISTOR_BED) * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/configtool/addheaterdlg.py b/configtool/addheaterdlg.py index a663931..f6a12e2 100644 --- a/configtool/addheaterdlg.py +++ b/configtool/addheaterdlg.py @@ -15,6 +15,7 @@ class AddHeaterDlg(wx.Dialog): self.nameValid = (name != "") self.maxPWMValid = (max_pwm != "") + self.pwmValid = (pwm != "") sz = wx.BoxSizer(wx.VERTICAL) gsz = wx.GridBagSizer() @@ -78,14 +79,24 @@ class AddHeaterDlg(wx.Dialog): gsz.Add(self.cbInv, pos = (3, 3)) - self.cbPwm = wx.CheckBox(self, wx.ID_ANY, "PWM") - self.cbPwm.SetFont(font) - self.cbPwm.SetValue(int(pwm) != 0) - self.cbPwm.SetToolTipString("Use Pulse Width Modulation in case the " - "choosen pin allows to do so.") + lsz = wx.BoxSizer(wx.HORIZONTAL) + st = wx.StaticText(self, wx.ID_ANY, "PWM:", size = (60, -1), + style = wx.ALIGN_RIGHT) + st.SetFont(font) + lsz.Add(st, 1, wx.TOP, offsetChLabel) + + self.tcPwm = wx.TextCtrl(self, wx.ID_ANY, pwm, size=(60, -1)) + self.tcPwm.SetFont(font) + self.tcPwm.Bind(wx.EVT_TEXT, self.onPWM) + lsz.Add(self.tcPwm) + self.tcPwm.SetToolTipString("Use Pulse Width Modulation. " + "Hardware PWM if available or " + "Software PWM. When FORCE_SOFTWARE_PWM " + "is set, always software PWM for 1 and " + "hardware PWM for >= 2.") gsz.AddSpacer((50, 15), pos = (1, 2)) - gsz.Add(self.cbPwm, pos = (1, 3)) + gsz.Add(lsz, pos = (1, 3)) gsz.AddSpacer((20, 20), pos = (4, 4)) sz.Add(gsz) @@ -156,8 +167,29 @@ class AddHeaterDlg(wx.Dialog): if evt is not None: evt.Skip() + def onPWM(self, evt): + tc = evt.GetEventObject() + w = tc.GetValue().strip() + if w == "": + self.pwmValid = False + else: + if int(w) >= 0: + self.pwmValid = True + else: + self.pwmValid = False + + if self.pwmValid: + tc.SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) + else: + tc.SetBackgroundColour("pink") + tc.Refresh() + + self.checkDlgValidity() + if evt is not None: + evt.Skip() + def checkDlgValidity(self): - if (self.nameValid and self.maxPWMValid): + if (self.nameValid and self.maxPWMValid and self.pwmValid): self.bSave.Enable(True) else: self.bSave.Enable(False) @@ -170,11 +202,8 @@ class AddHeaterDlg(wx.Dialog): invert = "1" else: invert = "0" - - if self.cbPwm.IsChecked(): - pwm = "1" - else: - pwm = "0" + + pwm = self.tcPwm.GetValue() max_pwm = self.tcMaxPWM.GetValue() diff --git a/configtool/board.generic.h b/configtool/board.generic.h index ec67eb6..a30345f 100644 --- a/configtool/board.generic.h +++ b/configtool/board.generic.h @@ -188,6 +188,14 @@ * * \***************************************************************************/ +/** \def FORCE_SOFTWARE_PWM + Force software pwm when pwm is sets to 1. + + Normally any pwm value >= 1 will set the pin to hardware pwm, if available. + When FORCE_SOFTWARE_PWM is defined, pwm = 1 is always set to software pwm. +*/ +// #define FORCE_SOFTWARE_PWM + /** \def HEATER_PIN Heater pins a user should be able to choose from in configtool. All commented out. diff --git a/configtool/heaterlist.py b/configtool/heaterlist.py index 28c7b4f..75e0c08 100644 --- a/configtool/heaterlist.py +++ b/configtool/heaterlist.py @@ -82,9 +82,6 @@ class HeaterList(wx.ListCtrl): else: return "False" elif col == 3: - if int(s[3]): - return "True" - else: - return "False" + return s[3] elif col == 4: return s[4] diff --git a/configtool/heaterspage.py b/configtool/heaterspage.py index 0feddfa..6491d7b 100644 --- a/configtool/heaterspage.py +++ b/configtool/heaterspage.py @@ -14,6 +14,8 @@ class HeatersPage(wx.Panel, Page): self.font = font self.id = idPg + self.labels = {'FORCE_SOFTWARE_PWM':"Force software PWM"} + sz = wx.GridBagSizer() sz.AddSpacer((30, 30), pos = (0, 0)) @@ -24,6 +26,12 @@ class HeatersPage(wx.Panel, Page): sz.Add(self.lb, pos = (1, 1)) sz.AddSpacer((20, 20), pos = (1, 2)) + k = 'FORCE_SOFTWARE_PWM' + cb = self.addCheckBox(k, self.onCheckBox) + + sz.Add(cb, pos = (2, 1)) + sz.AddSpacer((20, 20), pos = (2, 2)) + bsz = wx.BoxSizer(wx.VERTICAL) self.bAdd = wx.Button(self, wx.ID_ANY, "Add", size = BSIZESMALL) diff --git a/heater.h b/heater.h index 81d8d69..608efda 100644 --- a/heater.h +++ b/heater.h @@ -76,8 +76,12 @@ typedef enum { HARDWARE_PWM = 2 } pwm_type_t; +#ifndef FORCE_SOFTWARE_PWM // Force hardware PWM if available. #define HARDWARE_PWM_START SOFTWARE_PWM +#else +#define HARDWARE_PWM_START HARDWARE_PWM +#endif void heater_init(void); void pid_init(void);