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