sync with upstream

parent 81e4f5c9
Pipeline #52 skipped
/*
flowmeter.cpp - Flowmeter control library for Arduino - Version 1
Copyright (c) 2016 Franco (nextime) Lanza. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../../base.h"
#include <Arduino.h>
#if ENABLED(FLOWMETER_SENSOR)
volatile int flowrate_pulsecount;
float flowrate;
static millis_t flowmeter_timer = 0;
static millis_t lastflow = 0;
void flowrate_pulsecounter();
void flow_init() {
flowrate = 0;
flowrate_pulsecount = 0;
pinMode(FLOWMETER_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(FLOWMETER_PIN), flowrate_pulsecounter, FALLING);
}
void flowrate_manage() {
millis_t now;
now = millis();
if(ELAPSED(now, flowmeter_timer)) {
detachInterrupt(digitalPinToInterrupt(FLOWMETER_PIN));
flowrate = (float)(((1000.0 / (float)((float)now - (float)lastflow)) * (float)flowrate_pulsecount) / (float)FLOWMETER_CALIBRATION);
#if ENABLED(FLOWMETER_DEBUG)
ECHO_M(" FLOWMETER DEBUG ");
ECHO_MV(" flowrate:", flowrate);
ECHO_MV(" flowrate_pulsecount:", flowrate_pulsecount);
ECHO_MV(" CALIBRATION:", FLOWMETER_CALIBRATION);
ECHO_E;
#endif
flowmeter_timer = now + 1000UL;
lastflow = now;
flowrate_pulsecount = 0;
attachInterrupt(digitalPinToInterrupt(FLOWMETER_PIN), flowrate_pulsecounter, FALLING);
}
}
float get_flowrate() {
return flowrate;
}
void flowrate_pulsecounter()
{
// Increment the pulse counter
flowrate_pulsecount++;
}
#endif // FLOWMETER_SENSOR
/*
flowmeter.h - Flowmeter control library for Arduino - Version 1
Copyright (c) 2016 Franco (nextime) Lanza. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FLOWMETER_H
#define FLOWMETER_H
#define FLOWMETER_CALIBRATION (FLOWMETER_MAXFREQ/FLOWMETER_MAXFLOW)
#if ENABLED(FLOWMETER_SENSOR)
void flowrate_manage();
void flow_init();
float get_flowrate();
#endif
#endif // FLOWMETER_H
...@@ -484,7 +484,6 @@ static void lcd_implementation_status_screen() { ...@@ -484,7 +484,6 @@ static void lcd_implementation_status_screen() {
#endif #endif
#endif // !LASERBEAM #endif // !LASERBEAM
#endif // DISABLED LASER
// Fan // Fan
u8g.setPrintPos(104, 27); u8g.setPrintPos(104, 27);
#if HAS(FAN) #if HAS(FAN)
......
...@@ -604,7 +604,7 @@ static void lcd_main_menu() { ...@@ -604,7 +604,7 @@ static void lcd_main_menu() {
MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu); MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu);
MENU_ITEM(submenu, MSG_STATS, lcd_stats_menu); MENU_ITEM(submenu, MSG_STATS, lcd_stats_menu);
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
if (card.cardOK) { if (card.cardOK) {
if (card.isFileOpen()) { if (card.isFileOpen()) {
if (card.sdprinting) if (card.sdprinting)
...@@ -626,15 +626,15 @@ static void lcd_main_menu() { ...@@ -626,15 +626,15 @@ static void lcd_main_menu() {
MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
#endif #endif
} }
#endif // SDSUPPORT #endif // SDSUPPORT
END_MENU(); END_MENU();
} }
#if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART) #if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
static void lcd_autostart_sd() { static void lcd_autostart_sd() {
card.checkautostart(true); card.checkautostart(true);
} }
#endif #endif
/** /**
...@@ -644,12 +644,12 @@ static void lcd_autostart_sd() { ...@@ -644,12 +644,12 @@ static void lcd_autostart_sd() {
*/ */
/** /**
* Set the home offset based on the current_position * Set the home offset based on the current_position
*/ */
void lcd_set_home_offsets() { void lcd_set_home_offsets() {
// M428 Command // M428 Command
enqueue_and_echo_commands_P(PSTR("M428")); enqueue_and_echo_commands_P(PSTR("M428"));
lcd_return_to_status(); lcd_return_to_status();
} }
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
...@@ -693,54 +693,54 @@ lcd_return_to_status(); ...@@ -693,54 +693,54 @@ lcd_return_to_status();
if (LCD_CLICKED) lcd_goto_previous_menu(true); if (LCD_CLICKED) lcd_goto_previous_menu(true);
} }
#if ENABLED(BABYSTEP_XY) #if ENABLED(BABYSTEP_XY)
static void _lcd_babystep_x() { _lcd_babystep(X_AXIS, PSTR(MSG_BABYSTEPPING_X)); } static void _lcd_babystep_x() { _lcd_babystep(X_AXIS, PSTR(MSG_BABYSTEPPING_X)); }
static void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); } static void _lcd_babystep_y() { _lcd_babystep(Y_AXIS, PSTR(MSG_BABYSTEPPING_Y)); }
static void lcd_babystep_x() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_x); } static void lcd_babystep_x() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_x); }
static void lcd_babystep_y() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_y); } static void lcd_babystep_y() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_y); }
#endif #endif
static void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); } static void _lcd_babystep_z() { _lcd_babystep(Z_AXIS, PSTR(MSG_BABYSTEPPING_Z)); }
static void lcd_babystep_z() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_z); } static void lcd_babystep_z() { babysteps_done = 0; lcd_goto_menu(_lcd_babystep_z); }
#endif // BABYSTEPPING #endif // BABYSTEPPING
static void lcd_tune_fixstep() { static void lcd_tune_fixstep() {
#if MECH(DELTA) #if MECH(DELTA)
enqueue_and_echo_commands_P(PSTR("G28 B")); enqueue_and_echo_commands_P(PSTR("G28 B"));
#else #else
enqueue_and_echo_commands_P(PSTR("G28 X Y B")); enqueue_and_echo_commands_P(PSTR("G28 X Y B"));
#endif #endif
} }
/** /**
* Watch temperature callbacks * Watch temperature callbacks
*/ */
#if ENABLED(THERMAL_PROTECTION_HOTENDS) #if ENABLED(THERMAL_PROTECTION_HOTENDS)
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
void watch_temp_callback_E0() { start_watching_heater(0); } void watch_temp_callback_E0() { start_watching_heater(0); }
#endif #endif
#if HOTENDS > 1 && TEMP_SENSOR_1 != 0 #if HOTENDS > 1 && TEMP_SENSOR_1 != 0
void watch_temp_callback_E1() { start_watching_heater(1); } void watch_temp_callback_E1() { start_watching_heater(1); }
#endif #endif
#if HOTENDS > 2 && TEMP_SENSOR_2 != 0 #if HOTENDS > 2 && TEMP_SENSOR_2 != 0
void watch_temp_callback_E2() { start_watching_heater(2); } void watch_temp_callback_E2() { start_watching_heater(2); }
#endif #endif
#if HOTENDS > 3 && TEMP_SENSOR_3 != 0 #if HOTENDS > 3 && TEMP_SENSOR_3 != 0
void watch_temp_callback_E3() { start_watching_heater(3); } void watch_temp_callback_E3() { start_watching_heater(3); }
#endif #endif
#else #else
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
void watch_temp_callback_E0() {} void watch_temp_callback_E0() {}
#endif #endif
#if HOTENDS > 1 && TEMP_SENSOR_1 != 0 #if HOTENDS > 1 && TEMP_SENSOR_1 != 0
void watch_temp_callback_E1() {} void watch_temp_callback_E1() {}
#endif #endif
#if HOTENDS > 2 && TEMP_SENSOR_2 != 0 #if HOTENDS > 2 && TEMP_SENSOR_2 != 0
void watch_temp_callback_E2() {} void watch_temp_callback_E2() {}
#endif #endif
#if HOTENDS > 3 && TEMP_SENSOR_3 != 0 #if HOTENDS > 3 && TEMP_SENSOR_3 != 0
void watch_temp_callback_E3() {} void watch_temp_callback_E3() {}
#endif #endif
#endif // !THERMAL_PROTECTION_HOTENDS #endif // !THERMAL_PROTECTION_HOTENDS
#if ENABLED(THERMAL_PROTECTION_BED) #if ENABLED(THERMAL_PROTECTION_BED)
...@@ -754,29 +754,48 @@ static void lcd_tune_fixstep() { ...@@ -754,29 +754,48 @@ static void lcd_tune_fixstep() {
#endif #endif
/** /**
* *
* "Tune" submenu * "Tune" submenu
* *
*/ */
static void lcd_tune_menu() { static void lcd_tune_menu() {
START_MENU(); START_MENU();
// //
// ^ Main // ^ Main
// //
MENU_ITEM(back, MSG_MAIN); MENU_ITEM(back, MSG_MAIN);
// //
// Speed: // Speed:
// //
MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999); MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
// //
// Laser: // Nozzle:
// //
#if ENABLED(LASER) && ENABLED(COOLER) #if HOTENDS == 1
MENU_ITEM_EDIT(int3, MSG_COOLER, &target_temperature_cooler, 0, COOLER_MAXTEMP - 15); #if TEMP_SENSOR_0 != 0
#endif MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE, &target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0);
#endif
#else // HOTENDS > 1
#if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 0", &target_temperature[0], 0, HEATER_0_MAXTEMP - 15, watch_temp_callback_E0);
#endif
#if TEMP_SENSOR_1 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 1", &target_temperature[1], 0, HEATER_1_MAXTEMP - 15, watch_temp_callback_E1);
#endif
#if HOTENDS > 2
#if TEMP_SENSOR_2 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 2", &target_temperature[2], 0, HEATER_2_MAXTEMP - 15, watch_temp_callback_E2);
#endif
#if HOTENDS > 3
#if TEMP_SENSOR_3 != 0
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_NOZZLE " 3", &target_temperature[3], 0, HEATER_3_MAXTEMP - 15, watch_temp_callback_E3);
#endif
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
// //
// Laser: // Laser:
...@@ -792,21 +811,21 @@ MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999); ...@@ -792,21 +811,21 @@ MENU_ITEM_EDIT(int3, MSG_SPEED, &feedrate_multiplier, 10, 999);
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed); MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(int3, MSG_BED, &target_temperature_bed, 0, BED_MAXTEMP - 15, watch_temp_callback_bed);
#endif #endif
// //
// Fan Speed: // Fan Speed:
// //
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
// //
// Flow: // Flow:
// Flow 1: // Flow 1:
// Flow 2: // Flow 2:
// Flow 3: // Flow 3:
// Flow 4: // Flow 4:
// //
#if EXTRUDERS == 1 #if EXTRUDERS == 1
MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[0], 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[0], 10, 999);
#else // EXTRUDERS > 1 #else // EXTRUDERS > 1
MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[active_extruder], 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW, &extruder_multiplier[active_extruder], 10, 999);
MENU_ITEM_EDIT(int3, MSG_FLOW " 0", &extruder_multiplier[0], 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW " 0", &extruder_multiplier[0], 10, 999);
MENU_ITEM_EDIT(int3, MSG_FLOW " 1", &extruder_multiplier[1], 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW " 1", &extruder_multiplier[1], 10, 999);
...@@ -816,22 +835,22 @@ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255); ...@@ -816,22 +835,22 @@ MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED, &fanSpeed, 0, 255);
MENU_ITEM_EDIT(int3, MSG_FLOW " 3", &extruder_multiplier[3], 10, 999); MENU_ITEM_EDIT(int3, MSG_FLOW " 3", &extruder_multiplier[3], 10, 999);
#endif // EXTRUDERS > 3 #endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2 #endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1 #endif // EXTRUDERS > 1
// //
// Babystep X: // Babystep X:
// Babystep Y: // Babystep Y:
// Babystep Z: // Babystep Z:
// //
#if ENABLED(BABYSTEPPING) #if ENABLED(BABYSTEPPING)
#if ENABLED(BABYSTEP_XY) #if ENABLED(BABYSTEP_XY)
MENU_ITEM(submenu, MSG_BABYSTEP_X, lcd_babystep_x); MENU_ITEM(submenu, MSG_BABYSTEP_X, lcd_babystep_x);
MENU_ITEM(submenu, MSG_BABYSTEP_Y, lcd_babystep_y); MENU_ITEM(submenu, MSG_BABYSTEP_Y, lcd_babystep_y);
#endif // BABYSTEP_XY #endif // BABYSTEP_XY
MENU_ITEM(submenu, MSG_BABYSTEP_Z, lcd_babystep_z); MENU_ITEM(submenu, MSG_BABYSTEP_Z, lcd_babystep_z);
#endif #endif
MENU_ITEM(function, MSG_FIX_LOSE_STEPS, lcd_tune_fixstep); MENU_ITEM(function, MSG_FIX_LOSE_STEPS, lcd_tune_fixstep);
// //
// Change filament // Change filament
...@@ -840,11 +859,11 @@ MENU_ITEM(function, MSG_FIX_LOSE_STEPS, lcd_tune_fixstep); ...@@ -840,11 +859,11 @@ MENU_ITEM(function, MSG_FIX_LOSE_STEPS, lcd_tune_fixstep);
MENU_ITEM(gcode, MSG_FILAMENT_CHANGE, PSTR("M600")); MENU_ITEM(gcode, MSG_FILAMENT_CHANGE, PSTR("M600"));
#endif #endif
END_MENU(); END_MENU();
} }
#if ENABLED(EASY_LOAD) #if ENABLED(EASY_LOAD)
static void lcd_extrude(float length, float feedrate) { static void lcd_extrude(float length, float feedrate) {
current_position[E_AXIS] += length; current_position[E_AXIS] += length;
#if MECH(DELTA) #if MECH(DELTA)
calculate_delta(current_position); calculate_delta(current_position);
...@@ -852,19 +871,19 @@ static void lcd_extrude(float length, float feedrate) { ...@@ -852,19 +871,19 @@ static void lcd_extrude(float length, float feedrate) {
#else #else
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder, active_driver); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder, active_driver);
#endif #endif
} }
static void lcd_purge() { lcd_extrude(LCD_PURGE_LENGTH, LCD_PURGE_FEEDRATE); } static void lcd_purge() { lcd_extrude(LCD_PURGE_LENGTH, LCD_PURGE_FEEDRATE); }
static void lcd_retract() { lcd_extrude(-LCD_RETRACT_LENGTH, LCD_RETRACT_FEEDRATE); } static void lcd_retract() { lcd_extrude(-LCD_RETRACT_LENGTH, LCD_RETRACT_FEEDRATE); }
static void lcd_easy_load() { static void lcd_easy_load() {
allow_lengthy_extrude_once = true; allow_lengthy_extrude_once = true;
lcd_extrude(BOWDEN_LENGTH, LCD_LOAD_FEEDRATE); lcd_extrude(BOWDEN_LENGTH, LCD_LOAD_FEEDRATE);
lcd_return_to_status(); lcd_return_to_status();
} }
static void lcd_easy_unload() { static void lcd_easy_unload() {
allow_lengthy_extrude_once = true; allow_lengthy_extrude_once = true;
lcd_extrude(-BOWDEN_LENGTH, LCD_UNLOAD_FEEDRATE); lcd_extrude(-BOWDEN_LENGTH, LCD_UNLOAD_FEEDRATE);
lcd_return_to_status(); lcd_return_to_status();
} }
#endif // EASY_LOAD #endif // EASY_LOAD
/** /**
...@@ -873,27 +892,27 @@ static void lcd_easy_unload() { ...@@ -873,27 +892,27 @@ static void lcd_easy_unload() {
* *
*/ */
void _lcd_preheat(int endnum, const float temph, const float tempb, const int fan) { void _lcd_preheat(int endnum, const float temph, const float tempb, const int fan) {
if (temph > 0) setTargetHotend(temph, endnum); if (temph > 0) setTargetHotend(temph, endnum);
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
setTargetBed(tempb); setTargetBed(tempb);
#else #else
UNUSED(tempb); UNUSED(tempb);
#endif #endif
fanSpeed = fan; fanSpeed = fan;
lcd_return_to_status(); lcd_return_to_status();
} }
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
void lcd_preheat_pla0() { _lcd_preheat(0, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); } void lcd_preheat_pla0() { _lcd_preheat(0, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); }
void lcd_preheat_abs0() { _lcd_preheat(0, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); } void lcd_preheat_abs0() { _lcd_preheat(0, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); }
void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); } void lcd_preheat_gum0() { _lcd_preheat(0, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); }
#endif #endif
#if HOTENDS > 1 #if HOTENDS > 1
void lcd_preheat_pla1() { _lcd_preheat(1, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); } void lcd_preheat_pla1() { _lcd_preheat(1, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); }
void lcd_preheat_abs1() { _lcd_preheat(1, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); } void lcd_preheat_abs1() { _lcd_preheat(1, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); }
void lcd_preheat_gum1() { _lcd_preheat(1, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); } void lcd_preheat_gum1() { _lcd_preheat(1, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); }
#if HOTENDS > 2 #if HOTENDS > 2
void lcd_preheat_pla2() { _lcd_preheat(2, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); } void lcd_preheat_pla2() { _lcd_preheat(2, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); }
void lcd_preheat_abs2() { _lcd_preheat(2, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); } void lcd_preheat_abs2() { _lcd_preheat(2, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); }
void lcd_preheat_gum2() { _lcd_preheat(2, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); } void lcd_preheat_gum2() { _lcd_preheat(2, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); }
...@@ -902,38 +921,38 @@ void lcd_preheat_gum1() { _lcd_preheat(1, gumPreheatHotendTemp, gumPreheatHPBTem ...@@ -902,38 +921,38 @@ void lcd_preheat_gum1() { _lcd_preheat(1, gumPreheatHotendTemp, gumPreheatHPBTem
void lcd_preheat_abs3() { _lcd_preheat(3, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); } void lcd_preheat_abs3() { _lcd_preheat(3, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); }
void lcd_preheat_gum3() { _lcd_preheat(3, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); } void lcd_preheat_gum3() { _lcd_preheat(3, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); }
#endif #endif
#endif #endif
void lcd_preheat_pla0123() { void lcd_preheat_pla0123() {
setTargetHotend0(plaPreheatHotendTemp); setTargetHotend0(plaPreheatHotendTemp);
setTargetHotend1(plaPreheatHotendTemp); setTargetHotend1(plaPreheatHotendTemp);
setTargetHotend2(plaPreheatHotendTemp); setTargetHotend2(plaPreheatHotendTemp);
_lcd_preheat(3, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed); _lcd_preheat(3, plaPreheatHotendTemp, plaPreheatHPBTemp, plaPreheatFanSpeed);
} }
void lcd_preheat_abs0123() { void lcd_preheat_abs0123() {
setTargetHotend0(absPreheatHotendTemp); setTargetHotend0(absPreheatHotendTemp);
setTargetHotend1(absPreheatHotendTemp); setTargetHotend1(absPreheatHotendTemp);
setTargetHotend2(absPreheatHotendTemp); setTargetHotend2(absPreheatHotendTemp);
_lcd_preheat(3, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed); _lcd_preheat(3, absPreheatHotendTemp, absPreheatHPBTemp, absPreheatFanSpeed);
} }
void lcd_preheat_gum0123() { void lcd_preheat_gum0123() {
setTargetHotend0(gumPreheatHotendTemp); setTargetHotend0(gumPreheatHotendTemp);
setTargetHotend1(gumPreheatHotendTemp); setTargetHotend1(gumPreheatHotendTemp);
setTargetHotend2(gumPreheatHotendTemp); setTargetHotend2(gumPreheatHotendTemp);
_lcd_preheat(3, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed); _lcd_preheat(3, gumPreheatHotendTemp, gumPreheatHPBTemp, gumPreheatFanSpeed);
} }
#endif // HOTENDS > 1 #endif // HOTENDS > 1
#if TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_BED != 0
void lcd_preheat_pla_bedonly() { _lcd_preheat(0, 0, plaPreheatHPBTemp, plaPreheatFanSpeed); } void lcd_preheat_pla_bedonly() { _lcd_preheat(0, 0, plaPreheatHPBTemp, plaPreheatFanSpeed); }
void lcd_preheat_abs_bedonly() { _lcd_preheat(0, 0, absPreheatHPBTemp, absPreheatFanSpeed); } void lcd_preheat_abs_bedonly() { _lcd_preheat(0, 0, absPreheatHPBTemp, absPreheatFanSpeed); }
void lcd_preheat_gum_bedonly() { _lcd_preheat(0, 0, gumPreheatHPBTemp, gumPreheatFanSpeed); } void lcd_preheat_gum_bedonly() { _lcd_preheat(0, 0, gumPreheatHPBTemp, gumPreheatFanSpeed); }
#endif #endif
#if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0) #if TEMP_SENSOR_0 != 0 && (TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0)
static void lcd_preheat_pla_menu() { static void lcd_preheat_pla_menu() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_PREPARE); MENU_ITEM(back, MSG_PREPARE);
#if HOTENDS == 1 #if HOTENDS == 1
...@@ -953,9 +972,9 @@ static void lcd_preheat_pla_menu() { ...@@ -953,9 +972,9 @@ static void lcd_preheat_pla_menu() {
MENU_ITEM(function, MSG_PREHEAT_PLA_BEDONLY, lcd_preheat_pla_bedonly); MENU_ITEM(function, MSG_PREHEAT_PLA_BEDONLY, lcd_preheat_pla_bedonly);
#endif #endif
END_MENU(); END_MENU();
} }
static void lcd_preheat_abs_menu() { static void lcd_preheat_abs_menu() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_TEMPERATURE); MENU_ITEM(back, MSG_TEMPERATURE);
#if HOTENDS == 1 #if HOTENDS == 1
...@@ -975,9 +994,9 @@ static void lcd_preheat_abs_menu() { ...@@ -975,9 +994,9 @@ static void lcd_preheat_abs_menu() {
MENU_ITEM(function, MSG_PREHEAT_ABS_BEDONLY, lcd_preheat_abs_bedonly); MENU_ITEM(function, MSG_PREHEAT_ABS_BEDONLY, lcd_preheat_abs_bedonly);
#endif #endif
END_MENU(); END_MENU();
} }
static void lcd_preheat_gum_menu() { static void lcd_preheat_gum_menu() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_TEMPERATURE); MENU_ITEM(back, MSG_TEMPERATURE);
#if HOTENDS == 1 #if HOTENDS == 1
...@@ -997,7 +1016,7 @@ static void lcd_preheat_gum_menu() { ...@@ -997,7 +1016,7 @@ static void lcd_preheat_gum_menu() {
MENU_ITEM(function, MSG_PREHEAT_GUM_BEDONLY, lcd_preheat_gum_bedonly); MENU_ITEM(function, MSG_PREHEAT_GUM_BEDONLY, lcd_preheat_gum_bedonly);
#endif #endif
END_MENU(); END_MENU();
} }
#endif // TEMP_SENSOR_0 && (TEMP_SENSOR_1 || TEMP_SENSOR_2 || TEMP_SENSOR_3 || TEMP_SENSOR_BED) #endif // TEMP_SENSOR_0 && (TEMP_SENSOR_1 || TEMP_SENSOR_2 || TEMP_SENSOR_3 || TEMP_SENSOR_BED)
...@@ -1009,10 +1028,10 @@ void lcd_cooldown() { ...@@ -1009,10 +1028,10 @@ void lcd_cooldown() {
} }
/** /**
* *
* "Prepare" submenu * "Prepare" submenu
* *
*/ */
static void lcd_prepare_menu() { static void lcd_prepare_menu() {
START_MENU(); START_MENU();
...@@ -1095,34 +1114,29 @@ static void lcd_prepare_menu() { ...@@ -1095,34 +1114,29 @@ static void lcd_prepare_menu() {
// //
MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown); MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
// //
// Cooldown // Switch power on/off
// //
MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown); #if HAS(POWER_SWITCH)
//
// Switch power on/off
//
#if HAS(POWER_SWITCH)
if (powersupply) if (powersupply)
MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81")); MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
else else
MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80")); MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
#endif #endif
// //
// Autostart // Autostart
// //
#if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART) #if ENABLED(SDSUPPORT) && ENABLED(MENU_ADDAUTOSTART)
MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd); MENU_ITEM(function, MSG_AUTOSTART, lcd_autostart_sd);
#endif #endif
END_MENU(); END_MENU();
} }
#if MECH(DELTA) #if MECH(DELTA)
static void lcd_delta_calibrate_menu() { static void lcd_delta_calibrate_menu() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_MAIN); MENU_ITEM(back, MSG_MAIN);
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
...@@ -1131,21 +1145,21 @@ static void lcd_delta_calibrate_menu() { ...@@ -1131,21 +1145,21 @@ static void lcd_delta_calibrate_menu() {
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Z, PSTR("G0 F8000 X0 Y90 Z0")); MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Z, PSTR("G0 F8000 X0 Y90 Z0"));
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_CENTER, PSTR("G0 F8000 X0 Y0 Z0")); MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_CENTER, PSTR("G0 F8000 X0 Y0 Z0"));
END_MENU(); END_MENU();
} }
#endif // DELTA #endif // DELTA
/** /**
* *
* "Prepare" > "Move Axis" submenu * "Prepare" > "Move Axis" submenu
* *
*/ */
float move_menu_scale; float move_menu_scale;
static void _lcd_move(const char* name, AxisEnum axis, int min, int max) { static void _lcd_move(const char* name, AxisEnum axis, int min, int max) {
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition != 0) { if (encoderPosition != 0) {
refresh_cmd_timeout(); refresh_cmd_timeout();
current_position[axis] += float((int)encoderPosition) * move_menu_scale; current_position[axis] += float((int)encoderPosition) * move_menu_scale;
if (SOFTWARE_MIN_ENDSTOPS) NOLESS(current_position[axis], min); if (SOFTWARE_MIN_ENDSTOPS) NOLESS(current_position[axis], min);
...@@ -1153,42 +1167,42 @@ if (encoderPosition != 0) { ...@@ -1153,42 +1167,42 @@ if (encoderPosition != 0) {
encoderPosition = 0; encoderPosition = 0;
line_to_current(axis); line_to_current(axis);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
encoderPosition = 0; encoderPosition = 0;
if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis])); if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr31(current_position[axis]));
if (LCD_CLICKED) lcd_goto_previous_menu(true); if (LCD_CLICKED) lcd_goto_previous_menu(true);
} }
#if MECH(DELTA) #if MECH(DELTA)
static float delta_clip_radius_2 = DELTA_PRINTABLE_RADIUS * DELTA_PRINTABLE_RADIUS; static float delta_clip_radius_2 = DELTA_PRINTABLE_RADIUS * DELTA_PRINTABLE_RADIUS;
static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - a * a); } static int delta_clip( float a ) { return sqrt(delta_clip_radius_2 - a * a); }
static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); } static void lcd_move_x() { int clip = delta_clip(current_position[Y_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); }
static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); } static void lcd_move_y() { int clip = delta_clip(current_position[X_AXIS]); _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, max(X_MIN_POS, -clip), min(X_MAX_POS, clip)); }
#else #else
static void lcd_move_x() { _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, X_MIN_POS, X_MAX_POS); } static void lcd_move_x() { _lcd_move(PSTR(MSG_MOVE_X), X_AXIS, X_MIN_POS, X_MAX_POS); }
static void lcd_move_y() { _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, Y_MIN_POS, Y_MAX_POS); } static void lcd_move_y() { _lcd_move(PSTR(MSG_MOVE_Y), Y_AXIS, Y_MIN_POS, Y_MAX_POS); }
#endif #endif
static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, Z_MIN_POS, Z_MAX_POS); } static void lcd_move_z() { _lcd_move(PSTR(MSG_MOVE_Z), Z_AXIS, Z_MIN_POS, Z_MAX_POS); }
static void lcd_move_e( static void lcd_move_e(
#if EXTRUDERS > 1 #if EXTRUDERS > 1
uint8_t e uint8_t e
#endif #endif
) { ) {
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
#if EXTRUDERS > 1 #if EXTRUDERS > 1
unsigned short original_active_extruder = active_extruder; unsigned short original_active_extruder = active_extruder;
active_extruder = e; active_extruder = e;
#endif #endif
if (encoderPosition != 0) { if (encoderPosition != 0) {
#if ENABLED(IDLE_OOZING_PREVENT) #if ENABLED(IDLE_OOZING_PREVENT)
IDLE_OOZING_retract(false); IDLE_OOZING_retract(false);
#endif #endif
current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale; current_position[E_AXIS] += float((int)encoderPosition) * move_menu_scale;
line_to_current(E_AXIS); line_to_current(E_AXIS);
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
encoderPosition = 0; encoderPosition = 0;
if (lcdDrawUpdate) { if (lcdDrawUpdate) {
PGM_P pos_label; PGM_P pos_label;
#if EXTRUDERS == 1 #if EXTRUDERS == 1
pos_label = PSTR(MSG_MOVE_E); pos_label = PSTR(MSG_MOVE_E);
...@@ -1205,46 +1219,46 @@ if (lcdDrawUpdate) { ...@@ -1205,46 +1219,46 @@ if (lcdDrawUpdate) {
} }
#endif // EXTRUDERS > 1 #endif // EXTRUDERS > 1
lcd_implementation_drawedit(pos_label, ftostr31(current_position[E_AXIS])); lcd_implementation_drawedit(pos_label, ftostr31(current_position[E_AXIS]));
} }
if (LCD_CLICKED) lcd_goto_previous_menu(true); if (LCD_CLICKED) lcd_goto_previous_menu(true);
#if EXTRUDERS > 1 #if EXTRUDERS > 1
active_extruder = original_active_extruder; active_extruder = original_active_extruder;
#endif #endif
} }
#if EXTRUDERS > 1 #if EXTRUDERS > 1
static void lcd_move_e0() { lcd_move_e(0); } static void lcd_move_e0() { lcd_move_e(0); }
static void lcd_move_e1() { lcd_move_e(1); } static void lcd_move_e1() { lcd_move_e(1); }
#if EXTRUDERS > 2 #if EXTRUDERS > 2
static void lcd_move_e2() { lcd_move_e(2); } static void lcd_move_e2() { lcd_move_e(2); }
#if EXTRUDERS > 3 #if EXTRUDERS > 3
static void lcd_move_e3() { lcd_move_e(3); } static void lcd_move_e3() { lcd_move_e(3); }
#endif // EXTRUDERS > 3 #endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2 #endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1 #endif // EXTRUDERS > 1
/** /**
* *
* "Prepare" > "Move Xmm" > "Move XYZ" submenu * "Prepare" > "Move Xmm" > "Move XYZ" submenu
* *
*/ */
#if MECH(DELTA) || MECH(SCARA) #if MECH(DELTA) || MECH(SCARA)
#define _MOVE_XYZ_ALLOWED (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) #define _MOVE_XYZ_ALLOWED (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
#else #else
#define _MOVE_XYZ_ALLOWED true #define _MOVE_XYZ_ALLOWED true
#endif #endif
static void lcd_move_menu_axis() { static void lcd_move_menu_axis() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_MOVE_AXIS); MENU_ITEM(back, MSG_MOVE_AXIS);
if (_MOVE_XYZ_ALLOWED) { if (_MOVE_XYZ_ALLOWED) {
MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x); MENU_ITEM(submenu, MSG_MOVE_X, lcd_move_x);
MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y); MENU_ITEM(submenu, MSG_MOVE_Y, lcd_move_y);
MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z); MENU_ITEM(submenu, MSG_MOVE_Z, lcd_move_z);
} }
if (move_menu_scale < 10.0) { if (move_menu_scale < 10.0) {
#if EXTRUDERS == 1 #if EXTRUDERS == 1
MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e); MENU_ITEM(submenu, MSG_MOVE_E, lcd_move_e);
#else #else
...@@ -1257,47 +1271,47 @@ if (move_menu_scale < 10.0) { ...@@ -1257,47 +1271,47 @@ if (move_menu_scale < 10.0) {
#endif // EXTRUDERS > 3 #endif // EXTRUDERS > 3
#endif // EXTRUDERS > 2 #endif // EXTRUDERS > 2
#endif // EXTRUDERS > 1 #endif // EXTRUDERS > 1
} }
END_MENU(); END_MENU();
} }
static void lcd_move_menu_10mm() { static void lcd_move_menu_10mm() {
move_menu_scale = 10.0; move_menu_scale = 10.0;
lcd_move_menu_axis(); lcd_move_menu_axis();
} }
static void lcd_move_menu_1mm() { static void lcd_move_menu_1mm() {
move_menu_scale = 1.0; move_menu_scale = 1.0;
lcd_move_menu_axis(); lcd_move_menu_axis();
} }
static void lcd_move_menu_01mm() { static void lcd_move_menu_01mm() {
move_menu_scale = 0.1; move_menu_scale = 0.1;
lcd_move_menu_axis(); lcd_move_menu_axis();
} }
/** /**
* *
* "Prepare" > "Move Axis" submenu * "Prepare" > "Move Axis" submenu
* *
*/ */
static void lcd_move_menu() { static void lcd_move_menu() {
START_MENU(); START_MENU();
MENU_ITEM(back, MSG_PREPARE); MENU_ITEM(back, MSG_PREPARE);
if (_MOVE_XYZ_ALLOWED) if (_MOVE_XYZ_ALLOWED)
MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm); MENU_ITEM(submenu, MSG_MOVE_10MM, lcd_move_menu_10mm);
MENU_ITEM(submenu, MSG_MOVE_1MM, lcd_move_menu_1mm); MENU_ITEM(submenu, MSG_MOVE_1MM, lcd_move_menu_1mm);
MENU_ITEM(submenu, MSG_MOVE_01MM, lcd_move_menu_01mm); MENU_ITEM(submenu, MSG_MOVE_01MM, lcd_move_menu_01mm);
// TODO:X,Y,Z,E // TODO:X,Y,Z,E
END_MENU(); END_MENU();
} }
/** /**
* *
* "Control" submenu * "Control" submenu
* *
*/ */
static void lcd_control_menu() { static void lcd_control_menu() {
START_MENU(); START_MENU();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment