[2.0.x] Enable / disable PSU automatically (#9503)

This commit is contained in:
Scott Lahteine
2018-02-06 00:22:30 -06:00
committed by GitHub
parent db1ace5e82
commit b5e92f4f90
61 changed files with 664 additions and 4 deletions

View File

@ -63,10 +63,15 @@ Temperature thermalManager;
float Temperature::current_temperature[HOTENDS] = { 0.0 },
Temperature::current_temperature_bed = 0.0;
int16_t Temperature::current_temperature_raw[HOTENDS] = { 0 },
Temperature::target_temperature[HOTENDS] = { 0 },
Temperature::current_temperature_bed_raw = 0;
#if ENABLED(AUTO_POWER_E_FANS)
int16_t Temperature::autofan_speed[HOTENDS] = { 0 };
#endif
#if HAS_HEATER_BED
int16_t Temperature::target_temperature_bed = 0;
#endif
@ -529,6 +534,9 @@ int Temperature::getHeaterPower(int heater) {
const uint8_t bit = pgm_read_byte(&fanBit[f]);
if (pin >= 0 && !TEST(fanDone, bit)) {
uint8_t newFanSpeed = TEST(fanState, bit) ? EXTRUDER_AUTO_FAN_SPEED : 0;
#if ENABLED(AUTO_POWER_E_FANS)
autofan_speed[f] = newFanSpeed;
#endif
// this idiom allows both digital and PWM fan outputs (see M42 handling).
digitalWrite(pin, newFanSpeed);
analogWrite(pin, newFanSpeed);

View File

@ -28,11 +28,16 @@
#define TEMPERATURE_H
#include "thermistor/thermistors.h"
#include "../inc/MarlinConfig.h"
#if ENABLED(BABYSTEPPING)
extern bool axis_known_position[XYZ];
#endif
#if ENABLED(AUTO_POWER_CONTROL)
#include "power.h"
#endif
#if ENABLED(PID_EXTRUSION_SCALING)
#include "stepper.h"
#endif
@ -113,6 +118,10 @@ class Temperature {
target_temperature[HOTENDS],
current_temperature_bed_raw;
#if ENABLED(AUTO_POWER_E_FANS)
static int16_t autofan_speed[HOTENDS];
#endif
#if HAS_HEATER_BED
static int16_t target_temperature_bed;
#endif
@ -393,6 +402,9 @@ class Temperature {
else if (target_temperature[HOTEND_INDEX] == 0)
start_preheat_time(HOTEND_INDEX);
#endif
#if ENABLED(AUTO_POWER_CONTROL)
powerManager.power_on();
#endif
target_temperature[HOTEND_INDEX] = celsius;
#if WATCH_HOTENDS
start_watching_heater(HOTEND_INDEX);
@ -401,6 +413,9 @@ class Temperature {
static void setTargetBed(const int16_t celsius) {
#if HAS_HEATER_BED
#if ENABLED(AUTO_POWER_CONTROL)
powerManager.power_on();
#endif
target_temperature_bed =
#ifdef BED_MAXTEMP
min(celsius, BED_MAXTEMP)