Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2016-10-19 17:30:41 +0300
committerDavid Crocker <dcrocker@eschertech.com>2016-10-19 17:30:41 +0300
commitef4f962afae999b7be5d2d5ccfb48e319b225866 (patch)
tree9ac6a682df18a451ff4f775148004e0248c6bbe9 /src/Fan.cpp
parent1a7ba2c805438c5cb76810401340227b695341dc (diff)
Version 1.16 beta 2
Implemented X axis set and report mapping in M563 command and in web and M408 status responses (but mapping doesn;t do anything yet) Report number of axes to DWC M307 H# A-1 C-1 D-1 disables the pid controller for that heater to free up the pin Debug print of matrixes during delta calibration is now to 4dp Implemented fan blip
Diffstat (limited to 'src/Fan.cpp')
-rw-r--r--src/Fan.cpp47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/Fan.cpp b/src/Fan.cpp
index 4e66b713..1e638632 100644
--- a/src/Fan.cpp
+++ b/src/Fan.cpp
@@ -5,12 +5,14 @@
* Author: David
*/
-#include "Fan.h"
#include "RepRapFirmware.h"
void Fan::Init(Pin p_pin, bool hwInverted)
{
val = 0.0;
+ minVal = 0.1; // 10% minimum fan speed
+ blipTime = 100; // 100ms fan blip
+ blipStartTime = 0;
freq = DefaultFanPwmFreq;
pin = p_pin;
hardwareInverted = hwInverted;
@@ -26,10 +28,31 @@ void Fan::SetValue(float speed)
{
speed /= 255.0;
}
- val = constrain<float>(speed, 0.0, 1.0);
+ const float newVal = (speed > 0.0) ? constrain<float>(speed, minVal, 1.0) : 0.0;
+ if (val == 0.0 && newVal < 1.0 && blipTime != 0)
+ {
+ // Starting the fan from standstill, so blip the fan
+ blipStartTime = millis();
+ }
+ val = newVal;
Refresh();
}
+void Fan::SetMinValue(float speed)
+{
+ if (speed > 1.0)
+ {
+ speed /= 255.0;
+ }
+ minVal = constrain<float>(speed, 0.0, 1.0);
+ Refresh();
+}
+
+void Fan::SetBlipTime(float t)
+{
+ blipTime = (uint32_t)(max<float>(t, 0.0) * SecondsToMillis);
+}
+
void Fan::SetInverted(bool inv)
{
inverted = inv;
@@ -63,22 +86,28 @@ void Fan::SetHeatersMonitored(uint16_t h)
void Fan::Refresh()
{
- if (heatersMonitored != 0)
+ float reqVal = (heatersMonitored == 0)
+ ? val
+ : (reprap.GetPlatform()->AnyHeaterHot(heatersMonitored, triggerTemperature))
+ ? max<float>(0.5, val) // make sure that thermostatic fans always run at 50% speed or more
+ : 0.0;
+ if (reqVal > 0.0 && millis() - blipStartTime < blipTime)
+ {
+ SetHardwarePwm(1.0);
+ }
+ else if (reqVal > 0.0 && reqVal < minVal)
{
- const float pwmVal = (reprap.GetPlatform()->AnyHeaterHot(heatersMonitored, triggerTemperature))
- ? max<float>(0.5, val) // make sure that thermostatic fans always run at 50% speed or more
- : 0.0;
- SetHardwarePwm(pwmVal);
+ SetHardwarePwm(minVal);
}
else
{
- SetHardwarePwm(val);
+ SetHardwarePwm(reqVal);
}
}
void Fan::Check()
{
- if (heatersMonitored != 0)
+ if (heatersMonitored != 0 || blipTime != 0)
{
Refresh();
}