configtool: add FORCE_SOFTWARE_PWM to configtool

This commit is contained in:
Nico Tonnhofer 2017-03-21 10:23:04 +01:00
parent 4882d19215
commit fbe1af4013
25 changed files with 222 additions and 16 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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