Merge branch 'MK3' into MK3-new_lang
This commit is contained in:
commit
739de5224e
11 changed files with 2720 additions and 112 deletions
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
.settings
|
||||
.project
|
||||
.cproject
|
||||
Debug
|
||||
Firmware/Configuration_prusa.h
|
||||
Firmware/Doc
|
|
@ -170,9 +170,15 @@
|
|||
#define EEPROM_TMC2130_Z_MRES (EEPROM_TMC2130_Y_MRES - 1) // uint8
|
||||
#define EEPROM_TMC2130_E_MRES (EEPROM_TMC2130_Z_MRES - 1) // uint8
|
||||
|
||||
// HW
|
||||
#define EEPROM_PRINTER_TYPE (EEPROM_TMC2130_E_MRES - 2) // uint16
|
||||
#define EEPROM_BOARD_TYPE (EEPROM_PRINTER_TYPE - 2) // uint16
|
||||
|
||||
// Extruder multiplier for power panic
|
||||
#define EEPROM_EXTRUDER_MULTIPLIER_0 (EEPROM_BOARD_TYPE - 4) //float
|
||||
#define EEPROM_EXTRUDER_MULTIPLIER_1 (EEPROM_EXTRUDER_MULTIPLIER_0 - 4) //float
|
||||
#define EEPROM_EXTRUDER_MULTIPLIER_2 (EEPROM_EXTRUDER_MULTIPLIER_1 - 4) //float
|
||||
|
||||
//TMC2130 configuration
|
||||
#define EEPROM_TMC_AXIS_SIZE //axis configuration block size
|
||||
#define EEPROM_TMC_X (EEPROM_TMC + 0 * EEPROM_TMC_AXIS_SIZE) //X axis configuration blok
|
||||
|
|
|
@ -1,30 +1,46 @@
|
|||
/* -*- c++ -*- */
|
||||
|
||||
/*
|
||||
Reprap firmware based on Sprinter and grbl.
|
||||
Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
|
||||
/*
|
||||
This firmware is a mashup between Sprinter and grbl.
|
||||
(https://github.com/kliment/Sprinter)
|
||||
(https://github.com/simen/grbl/tree)
|
||||
|
||||
It has preliminary support for Matthew Roberts advance algorithm
|
||||
http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
|
||||
/**
|
||||
* @mainpage Reprap 3D printer firmware based on Sprinter and grbl.
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
*
|
||||
* This firmware is a mashup between Sprinter and grbl.
|
||||
* https://github.com/kliment/Sprinter
|
||||
* https://github.com/simen/grbl/tree
|
||||
*
|
||||
* It has preliminary support for Matthew Roberts advance algorithm
|
||||
* http://reprap.org/pipermail/reprap-dev/2011-May/003323.html
|
||||
*
|
||||
* Prusa Research s.r.o. https://www.prusa3d.cz
|
||||
*
|
||||
* @section copyright_sec Copyright
|
||||
*
|
||||
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @section notes_sec Notes
|
||||
*
|
||||
* * Do not create static objects in global functions.
|
||||
* Otherwise constructor guard against concurrent calls is generated costing
|
||||
* about 8B RAM and 14B flash.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Marlin.h"
|
||||
|
@ -119,6 +135,9 @@
|
|||
//Macro for print fan speed
|
||||
#define FAN_PULSE_WIDTH_LIMIT ((fanSpeed > 100) ? 3 : 4) //time in ms
|
||||
|
||||
#define PRINTING_TYPE_SD 0
|
||||
#define PRINTING_TYPE_USB 1
|
||||
|
||||
// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html
|
||||
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
|
||||
|
||||
|
@ -305,6 +324,7 @@ float pause_lastpos[4];
|
|||
unsigned long pause_time = 0;
|
||||
unsigned long start_pause_print = millis();
|
||||
unsigned long t_fan_rising_edge = millis();
|
||||
static LongTimer safetyTimer;
|
||||
|
||||
//unsigned long load_filament_time;
|
||||
|
||||
|
@ -486,6 +506,7 @@ boolean chdkActive = false;
|
|||
|
||||
// save/restore printing
|
||||
static uint32_t saved_sdpos = 0;
|
||||
static uint8_t saved_printing_type = PRINTING_TYPE_SD;
|
||||
static float saved_pos[4] = { 0, 0, 0, 0 };
|
||||
// Feedrate hopefully derived from an active block of the planner at the time the print has been canceled, in mm/min.
|
||||
static float saved_feedrate2 = 0;
|
||||
|
@ -629,12 +650,12 @@ void crashdet_disable()
|
|||
|
||||
void crashdet_stop_and_save_print()
|
||||
{
|
||||
stop_and_save_print_to_ram(10, 0); //XY - no change, Z 10mm up, E - no change
|
||||
stop_and_save_print_to_ram(10, -2); //XY - no change, Z 10mm up, E -2mm retract
|
||||
}
|
||||
|
||||
void crashdet_restore_print_and_continue()
|
||||
{
|
||||
restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change
|
||||
restore_print_from_ram_and_continue(2); //XYZ = orig, E +2mm unretract
|
||||
// babystep_apply();
|
||||
}
|
||||
|
||||
|
@ -1781,6 +1802,14 @@ void loop()
|
|||
sei();
|
||||
}
|
||||
}
|
||||
else if((*ptr == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR) && !IS_SD_PRINTING){
|
||||
|
||||
cli();
|
||||
*ptr ++ = CMDBUFFER_CURRENT_TYPE_TO_BE_REMOVED;
|
||||
// and one for each command to previous block in the planner queue.
|
||||
planner_add_sd_length(1);
|
||||
sei();
|
||||
}
|
||||
// Now it is safe to release the already processed command block. If interrupted by the power panic now,
|
||||
// this block's SD card length will not be counted twice as its command type has been replaced
|
||||
// by CMDBUFFER_CURRENT_TYPE_TO_BE_REMOVED.
|
||||
|
@ -2936,7 +2965,7 @@ static void gcode_PRUSA_SN()
|
|||
selectedSerialPort = 0;
|
||||
MSerial.write(";S");
|
||||
int numbersRead = 0;
|
||||
Timer timeout;
|
||||
ShortTimer timeout;
|
||||
timeout.start();
|
||||
|
||||
while (numbersRead < 19) {
|
||||
|
@ -2947,7 +2976,7 @@ static void gcode_PRUSA_SN()
|
|||
numbersRead++;
|
||||
selectedSerialPort = 0;
|
||||
}
|
||||
if (timeout.expired(100)) break;
|
||||
if (timeout.expired(100u)) break;
|
||||
}
|
||||
selectedSerialPort = 1;
|
||||
MSerial.write('\n');
|
||||
|
@ -3310,10 +3339,10 @@ void process_commands()
|
|||
if( !(code_seen('X') || code_seen('Y') || code_seen('Z')) && code_seen('E')) {
|
||||
float echange=destination[E_AXIS]-current_position[E_AXIS];
|
||||
|
||||
if((echange<-MIN_RETRACT && !retracted) || (echange>MIN_RETRACT && retracted)) { //move appears to be an attempt to retract or recover
|
||||
if((echange<-MIN_RETRACT && !retracted[active_extruder]) || (echange>MIN_RETRACT && retracted[active_extruder])) { //move appears to be an attempt to retract or recover
|
||||
current_position[E_AXIS] = destination[E_AXIS]; //hide the slicer-generated retract/recover from calculations
|
||||
plan_set_e_position(current_position[E_AXIS]); //AND from the planner
|
||||
retract(!retracted);
|
||||
retract(!retracted[active_extruder]);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -6437,10 +6466,10 @@ Sigma_Exit:
|
|||
#ifdef PINDA_THERMISTOR
|
||||
case 860: // M860 - Wait for PINDA thermistor to reach target temperature.
|
||||
{
|
||||
int setTargetPinda = 0;
|
||||
int set_target_pinda = 0;
|
||||
|
||||
if (code_seen('S')) {
|
||||
setTargetPinda = code_value();
|
||||
set_target_pinda = code_value();
|
||||
}
|
||||
else {
|
||||
break;
|
||||
|
@ -6449,19 +6478,24 @@ Sigma_Exit:
|
|||
LCD_MESSAGERPGM(_T(MSG_PLEASE_WAIT));
|
||||
|
||||
SERIAL_PROTOCOLPGM("Wait for PINDA target temperature:");
|
||||
SERIAL_PROTOCOL(setTargetPinda);
|
||||
SERIAL_PROTOCOL(set_target_pinda);
|
||||
SERIAL_PROTOCOLLN("");
|
||||
|
||||
codenum = millis();
|
||||
cancel_heatup = false;
|
||||
|
||||
while ((!cancel_heatup) && current_temperature_pinda < setTargetPinda) {
|
||||
bool is_pinda_cooling = false;
|
||||
if ((degTargetBed() == 0) && (degTargetHotend(0) == 0)) {
|
||||
is_pinda_cooling = true;
|
||||
}
|
||||
|
||||
while ( ((!is_pinda_cooling) && (!cancel_heatup) && (current_temperature_pinda < set_target_pinda)) || (is_pinda_cooling && (current_temperature_pinda > set_target_pinda)) ) {
|
||||
if ((millis() - codenum) > 1000) //Print Temp Reading every 1 second while waiting.
|
||||
{
|
||||
SERIAL_PROTOCOLPGM("P:");
|
||||
SERIAL_PROTOCOL_F(current_temperature_pinda, 1);
|
||||
SERIAL_PROTOCOLPGM("/");
|
||||
SERIAL_PROTOCOL(setTargetPinda);
|
||||
SERIAL_PROTOCOL(set_target_pinda);
|
||||
SERIAL_PROTOCOLLN("");
|
||||
codenum = millis();
|
||||
}
|
||||
|
@ -6473,6 +6507,7 @@ Sigma_Exit:
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
case 861: // M861 - Set/Read PINDA temperature compensation offsets
|
||||
if (code_seen('?')) { // ? - Print out current EEPROM offset values
|
||||
uint8_t cal_status = calibration_status_pinda();
|
||||
|
@ -6981,7 +7016,7 @@ void FlushSerialRequestResend()
|
|||
void ClearToSend()
|
||||
{
|
||||
previous_millis_cmd = millis();
|
||||
if (CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB)
|
||||
if ((CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB) || (CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR))
|
||||
SERIAL_PROTOCOLLNRPGM(_T(MSG_OK));
|
||||
}
|
||||
|
||||
|
@ -7277,7 +7312,6 @@ static void handleSafetyTimer()
|
|||
#if (EXTRUDERS > 1)
|
||||
#error Implemented only for one extruder.
|
||||
#endif //(EXTRUDERS > 1)
|
||||
static Timer safetyTimer;
|
||||
if (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == 4) || saved_printing
|
||||
|| (lcd_commands_type == LCD_COMMAND_V2_CAL) || (!degTargetBed() && !degTargetHotend(0)))
|
||||
{
|
||||
|
@ -8142,7 +8176,6 @@ void uvlo_()
|
|||
// Conserve power as soon as possible.
|
||||
disable_x();
|
||||
disable_y();
|
||||
disable_e0();
|
||||
|
||||
#ifdef TMC2130
|
||||
tmc2130_set_current_h(Z_AXIS, 20);
|
||||
|
@ -8242,11 +8275,19 @@ void uvlo_()
|
|||
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 0), current_position[X_AXIS]);
|
||||
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION + 4), current_position[Y_AXIS]);
|
||||
eeprom_update_float((float*)(EEPROM_UVLO_CURRENT_POSITION_Z), current_position[Z_AXIS]);
|
||||
// Store the current feed rate, temperatures and fan speed.
|
||||
// Store the current feed rate, temperatures, fan speed and extruder multipliers (flow rates)
|
||||
EEPROM_save_B(EEPROM_UVLO_FEEDRATE, &feedrate_bckp);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND, target_temperature[active_extruder]);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO_TARGET_BED, target_temperature_bed);
|
||||
eeprom_update_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED, fanSpeed);
|
||||
eeprom_update_float((float*)(EEPROM_EXTRUDER_MULTIPLIER_0), extruder_multiplier[0]);
|
||||
#if EXTRUDERS > 1
|
||||
eeprom_update_float((float*)(EEPROM_EXTRUDER_MULTIPLIER_1), extruder_multiplier[1]);
|
||||
#if EXTRUDERS > 2
|
||||
eeprom_update_float((float*)(EEPROM_EXTRUDER_MULTIPLIER_2), extruder_multiplier[2]);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Finaly store the "power outage" flag.
|
||||
if(sd_print) eeprom_update_byte((uint8_t*)EEPROM_UVLO, 1);
|
||||
|
||||
|
@ -8350,13 +8391,7 @@ void recover_print(uint8_t automatic) {
|
|||
lcd_update(2);
|
||||
lcd_setstatuspgm(_i("Recovering print "));////MSG_RECOVERING_PRINT c=20 r=1
|
||||
|
||||
recover_machine_state_after_power_panic();
|
||||
|
||||
// Set the target bed and nozzle temperatures.
|
||||
sprintf_P(cmd, PSTR("M104 S%d"), target_temperature[active_extruder]);
|
||||
enquecommand(cmd);
|
||||
sprintf_P(cmd, PSTR("M140 S%d"), target_temperature_bed);
|
||||
enquecommand(cmd);
|
||||
recover_machine_state_after_power_panic(); //recover position, temperatures and extrude_multipliers
|
||||
|
||||
// Lift the print head, so one may remove the excess priming material.
|
||||
if (current_position[Z_AXIS] < 25)
|
||||
|
@ -8458,6 +8493,16 @@ void recover_machine_state_after_power_panic()
|
|||
// 7) Recover the target temperatures.
|
||||
target_temperature[active_extruder] = eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_HOTEND);
|
||||
target_temperature_bed = eeprom_read_byte((uint8_t*)EEPROM_UVLO_TARGET_BED);
|
||||
|
||||
// 8) Recover extruder multipilers
|
||||
extruder_multiplier[0] = eeprom_read_float((float*)(EEPROM_EXTRUDER_MULTIPLIER_0));
|
||||
#if EXTRUDERS > 1
|
||||
extruder_multiplier[1] = eeprom_read_float((float*)(EEPROM_EXTRUDER_MULTIPLIER_1));
|
||||
#if EXTRUDERS > 2
|
||||
extruder_multiplier[2] = eeprom_read_float((float*)(EEPROM_EXTRUDER_MULTIPLIER_2));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void restore_print_from_eeprom() {
|
||||
|
@ -8544,13 +8589,34 @@ void restore_print_from_eeprom() {
|
|||
void stop_and_save_print_to_ram(float z_move, float e_move)
|
||||
{
|
||||
if (saved_printing) return;
|
||||
unsigned char nplanner_blocks;
|
||||
unsigned char nlines;
|
||||
uint16_t sdlen_planner;
|
||||
uint16_t sdlen_cmdqueue;
|
||||
|
||||
|
||||
cli();
|
||||
unsigned char nplanner_blocks = number_of_blocks();
|
||||
if (card.sdprinting) {
|
||||
nplanner_blocks = number_of_blocks();
|
||||
saved_sdpos = sdpos_atomic; //atomic sd position of last command added in queue
|
||||
uint16_t sdlen_planner = planner_calc_sd_length(); //length of sd commands in planner
|
||||
sdlen_planner = planner_calc_sd_length(); //length of sd commands in planner
|
||||
saved_sdpos -= sdlen_planner;
|
||||
uint16_t sdlen_cmdqueue = cmdqueue_calc_sd_length(); //length of sd commands in cmdqueue
|
||||
sdlen_cmdqueue = cmdqueue_calc_sd_length(); //length of sd commands in cmdqueue
|
||||
saved_sdpos -= sdlen_cmdqueue;
|
||||
saved_printing_type = PRINTING_TYPE_SD;
|
||||
|
||||
}
|
||||
else if (is_usb_printing) { //reuse saved_sdpos for storing line number
|
||||
saved_sdpos = gcode_LastN; //start with line number of command added recently to cmd queue
|
||||
//reuse planner_calc_sd_length function for getting number of lines of commands in planner:
|
||||
nlines = planner_calc_sd_length(); //number of lines of commands in planner
|
||||
saved_sdpos -= nlines;
|
||||
saved_sdpos -= buflen; //number of blocks in cmd buffer
|
||||
saved_printing_type = PRINTING_TYPE_USB;
|
||||
}
|
||||
else {
|
||||
//not sd printing nor usb printing
|
||||
}
|
||||
|
||||
#if 0
|
||||
SERIAL_ECHOPGM("SDPOS_ATOMIC="); MYSERIAL.println(sdpos_atomic, DEC);
|
||||
|
@ -8559,7 +8625,8 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
|
|||
SERIAL_ECHOPGM("SDLEN_CMDQ="); MYSERIAL.println(sdlen_cmdqueue, DEC);
|
||||
SERIAL_ECHOPGM("PLANNERBLOCKS="); MYSERIAL.println(int(nplanner_blocks), DEC);
|
||||
SERIAL_ECHOPGM("SDSAVED="); MYSERIAL.println(saved_sdpos, DEC);
|
||||
SERIAL_ECHOPGM("SDFILELEN="); MYSERIAL.println(card.fileSize(), DEC);
|
||||
//SERIAL_ECHOPGM("SDFILELEN="); MYSERIAL.println(card.fileSize(), DEC);
|
||||
|
||||
|
||||
{
|
||||
card.setIndex(saved_sdpos);
|
||||
|
@ -8571,7 +8638,6 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
|
|||
MYSERIAL.print(char(card.get()));
|
||||
SERIAL_ECHOLNPGM("End of command buffer");
|
||||
}
|
||||
|
||||
{
|
||||
// Print the content of the planner buffer, line by line:
|
||||
card.setIndex(saved_sdpos);
|
||||
|
@ -8666,11 +8732,17 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
|
|||
#if 1
|
||||
// Rather than calling plan_buffer_line directly, push the move into the command queue,
|
||||
char buf[48];
|
||||
|
||||
// First unretract (relative extrusion)
|
||||
strcpy_P(buf, PSTR("G1 E"));
|
||||
dtostrf(e_move, 6, 3, buf + strlen(buf));
|
||||
strcat_P(buf, PSTR(" F"));
|
||||
dtostrf(retract_feedrate*60, 8, 3, buf + strlen(buf));
|
||||
enquecommand(buf, false);
|
||||
|
||||
// Then lift Z axis
|
||||
strcpy_P(buf, PSTR("G1 Z"));
|
||||
dtostrf(saved_pos[Z_AXIS] + z_move, 8, 3, buf + strlen(buf));
|
||||
strcat_P(buf, PSTR(" E"));
|
||||
// Relative extrusion
|
||||
dtostrf(e_move, 6, 3, buf + strlen(buf));
|
||||
strcat_P(buf, PSTR(" F"));
|
||||
dtostrf(homing_feedrate[Z_AXIS], 8, 3, buf + strlen(buf));
|
||||
// At this point the command queue is empty.
|
||||
|
@ -8700,11 +8772,20 @@ void restore_print_from_ram_and_continue(float e_move)
|
|||
st_synchronize();
|
||||
memcpy(current_position, saved_pos, sizeof(saved_pos));
|
||||
memcpy(destination, current_position, sizeof(destination));
|
||||
if (saved_printing_type == PRINTING_TYPE_SD) { //was sd printing
|
||||
card.setIndex(saved_sdpos);
|
||||
sdpos_atomic = saved_sdpos;
|
||||
card.sdprinting = true;
|
||||
}
|
||||
else if (saved_printing_type == PRINTING_TYPE_USB) { //was usb printing
|
||||
gcode_LastN = saved_sdpos; //saved_sdpos was reused for storing line number when usb printing
|
||||
FlushSerialRequestResend();
|
||||
}
|
||||
else {
|
||||
//not sd printing nor usb printing
|
||||
}
|
||||
saved_printing = false;
|
||||
printf_P(PSTR("ok\n")); //dummy response because of octoprint is waiting for this
|
||||
|
||||
}
|
||||
|
||||
void print_world_coordinates()
|
||||
|
|
|
@ -12,14 +12,16 @@
|
|||
* It is guaranteed, that construction is equivalent with zeroing all members.
|
||||
* This property can be exploited in MenuData union.
|
||||
*/
|
||||
Timer::Timer() : m_isRunning(false), m_started()
|
||||
template<typename T>
|
||||
Timer<T>::Timer() : m_isRunning(false), m_started()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start timer
|
||||
*/
|
||||
void Timer::start()
|
||||
template<typename T>
|
||||
void Timer<T>::start()
|
||||
{
|
||||
m_started = millis();
|
||||
m_isRunning = true;
|
||||
|
@ -29,19 +31,21 @@ void Timer::start()
|
|||
* @brief Timer has expired
|
||||
*
|
||||
* Timer is considered expired after msPeriod has passed from time the timer was started.
|
||||
* This function must be called at least each (unsigned long maximum value - msPeriod) milliseconds to be sure to
|
||||
* Timer is stopped after expiration.
|
||||
* This function must be called at least each (T maximum value - msPeriod) milliseconds to be sure to
|
||||
* catch first expiration.
|
||||
* This function is expected to handle wrap around of time register well.
|
||||
*
|
||||
* @param msPeriod Time interval in milliseconds.
|
||||
* @param msPeriod Time interval in milliseconds. Do not omit "ul" when using constant literal with LongTimer.
|
||||
* @retval true Timer has expired
|
||||
* @retval false Timer not expired yet, or is not running, or time window in which is timer considered expired passed.
|
||||
*/
|
||||
bool Timer::expired(unsigned long msPeriod)
|
||||
template<typename T>
|
||||
bool Timer<T>::expired(T msPeriod)
|
||||
{
|
||||
if (!m_isRunning) return false;
|
||||
bool expired = false;
|
||||
const unsigned long now = millis();
|
||||
const T now = millis();
|
||||
if (m_started <= m_started + msPeriod)
|
||||
{
|
||||
if ((now >= m_started + msPeriod) || (now < m_started))
|
||||
|
@ -59,3 +63,6 @@ bool Timer::expired(unsigned long msPeriod)
|
|||
if (expired) m_isRunning = false;
|
||||
return expired;
|
||||
}
|
||||
|
||||
template class Timer<unsigned long>;
|
||||
template class Timer<unsigned short>;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/**
|
||||
* @file
|
||||
* @author Marek Bel
|
||||
*/
|
||||
|
@ -10,10 +10,10 @@
|
|||
* @brief simple timer
|
||||
*
|
||||
* Simple and memory saving implementation. Should handle timer register wrap around well.
|
||||
* Maximum period is at least 49 days. Resolution is one millisecond. To save memory, doesn't store timer period.
|
||||
* If you wish timer which is storing period, derive from this. If you need time intervals smaller than 65 seconds
|
||||
* consider implementing timer with smaller underlying type.
|
||||
* Resolution is one millisecond. To save memory, doesn't store timer period.
|
||||
* If you wish timer which is storing period, derive from this.
|
||||
*/
|
||||
template <class T>
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
|
@ -21,10 +21,31 @@ public:
|
|||
void start();
|
||||
void stop(){m_isRunning = false;}
|
||||
bool running(){return m_isRunning;}
|
||||
bool expired(unsigned long msPeriod);
|
||||
bool expired(T msPeriod);
|
||||
private:
|
||||
bool m_isRunning;
|
||||
unsigned long m_started;
|
||||
T m_started;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Timer unsigned long specialization
|
||||
*
|
||||
* Maximum period is at least 49 days.
|
||||
*/
|
||||
#if __cplusplus>=201103L
|
||||
using LongTimer = Timer<unsigned long>;
|
||||
#else
|
||||
typedef Timer<unsigned long> LongTimer;
|
||||
#endif
|
||||
/**
|
||||
* @brief Timer unsigned short specialization
|
||||
*
|
||||
* Maximum period is at least 65 seconds.
|
||||
*/
|
||||
#if __cplusplus>=201103L
|
||||
using ShortTimer = Timer<unsigned short>;
|
||||
#else
|
||||
typedef Timer<unsigned short> ShortTimer;
|
||||
#endif
|
||||
|
||||
#endif /* TIMER_H */
|
||||
|
|
|
@ -413,6 +413,9 @@ void get_command()
|
|||
}
|
||||
cmdbuffer[bufindw+serial_count+CMDHDRSIZE] = 0; //terminate string
|
||||
if(!comment_mode){
|
||||
|
||||
gcode_N = 0;
|
||||
|
||||
// Line numbers must be first in buffer
|
||||
|
||||
if ((strstr(cmdbuffer+bufindw+CMDHDRSIZE, "PRUSA") == NULL) &&
|
||||
|
@ -494,7 +497,8 @@ void get_command()
|
|||
kill("", 2);
|
||||
|
||||
// Store the current line into buffer, move to the next line.
|
||||
cmdbuffer[bufindw] = CMDBUFFER_CURRENT_TYPE_USB;
|
||||
// Store type of entry
|
||||
cmdbuffer[bufindw] = gcode_N ? CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR : CMDBUFFER_CURRENT_TYPE_USB;
|
||||
#ifdef CMDBUFFER_DEBUG
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHOPGM("Storing a command line to buffer: ");
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
// to the planner queue, but not yet removed from the cmdqueue.
|
||||
// This is a temporary state to reduce stepper interrupt locking time.
|
||||
#define CMDBUFFER_CURRENT_TYPE_TO_BE_REMOVED 5
|
||||
//Command in cmdbuffer was sent over USB and contains line number
|
||||
#define CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR 6
|
||||
|
||||
// How much space to reserve for the chained commands
|
||||
// of type CMDBUFFER_CURRENT_TYPE_CHAINED,
|
||||
|
|
2494
Firmware/doxyfile
Normal file
2494
Firmware/doxyfile
Normal file
File diff suppressed because it is too large
Load diff
|
@ -111,7 +111,7 @@ union MenuData
|
|||
|
||||
struct AutoLoadFilamentMenu
|
||||
{
|
||||
//Timer timer;
|
||||
//ShortTimer timer;
|
||||
char dummy;
|
||||
} autoLoadFilamentMenu;
|
||||
struct _Lcd_moveMenu
|
||||
|
@ -168,14 +168,13 @@ uint8_t farm_mode = 0;
|
|||
int farm_no = 0;
|
||||
int farm_timer = 8;
|
||||
int farm_status = 0;
|
||||
unsigned long allert_timer = millis();
|
||||
bool printer_connected = true;
|
||||
|
||||
unsigned long display_time; //just timer for showing pid finished message on lcd;
|
||||
float pid_temp = DEFAULT_PID_TEMP;
|
||||
|
||||
bool long_press_active = false;
|
||||
long long_press_timer = millis();
|
||||
static ShortTimer longPressTimer;
|
||||
unsigned long button_blanking_time = millis();
|
||||
bool button_pressed = false;
|
||||
|
||||
|
@ -2090,7 +2089,7 @@ static void lcd_menu_AutoLoadFilament()
|
|||
}
|
||||
else
|
||||
{
|
||||
Timer* ptimer = (Timer*)&(menuData.autoLoadFilamentMenu.dummy);
|
||||
ShortTimer* ptimer = (ShortTimer*)&(menuData.autoLoadFilamentMenu.dummy);
|
||||
if (!ptimer->running()) ptimer->start();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd_printPGM(_T(MSG_ERROR));
|
||||
|
@ -2675,7 +2674,7 @@ bool lcd_wait_for_pinda(float temp) {
|
|||
lcd_set_custom_characters_degree();
|
||||
setTargetHotend(0, 0);
|
||||
setTargetBed(0);
|
||||
Timer pinda_timeout;
|
||||
LongTimer pinda_timeout;
|
||||
pinda_timeout.start();
|
||||
bool target_temp_reached = true;
|
||||
|
||||
|
@ -5104,20 +5103,6 @@ static void lcd_disable_farm_mode() {
|
|||
|
||||
}
|
||||
|
||||
static void lcd_ping_allert() {
|
||||
if ((abs(millis() - allert_timer)*0.001) > PING_ALLERT_PERIOD) {
|
||||
allert_timer = millis();
|
||||
SET_OUTPUT(BEEPER);
|
||||
for (int i = 0; i < 2; i++) {
|
||||
WRITE(BEEPER, HIGH);
|
||||
delay(50);
|
||||
WRITE(BEEPER, LOW);
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
#ifdef SNMM
|
||||
|
||||
|
@ -7725,7 +7710,6 @@ void lcd_ping() { //chceck if printer is connected to monitoring when in farm mo
|
|||
//if there are comamnds in buffer, some long gcodes can delay execution of ping command
|
||||
//therefore longer period is used
|
||||
printer_connected = false;
|
||||
//lcd_ping_allert(); //acustic signals
|
||||
}
|
||||
else {
|
||||
lcd_printer_connected();
|
||||
|
@ -7816,12 +7800,11 @@ void lcd_buttons_update()
|
|||
if (millis() > button_blanking_time) {
|
||||
button_blanking_time = millis() + BUTTON_BLANKING_TIME;
|
||||
if (button_pressed == false && long_press_active == false) {
|
||||
long_press_timer = millis();
|
||||
longPressTimer.start();
|
||||
button_pressed = true;
|
||||
}
|
||||
else {
|
||||
if (millis() - long_press_timer > LONG_PRESS_TIME) { //long press activated
|
||||
|
||||
if (longPressTimer.expired(LONG_PRESS_TIME)) {
|
||||
long_press_active = true;
|
||||
move_menu_scale = 1.0;
|
||||
menu_action_submenu(lcd_move_z);
|
||||
|
|
|
@ -263,7 +263,6 @@ static float count_e(float layer_heigth, float extrusion_width, float extrusion_
|
|||
static void lcd_babystep_z();
|
||||
|
||||
void stack_error();
|
||||
static void lcd_ping_allert();
|
||||
void lcd_printer_connected();
|
||||
void lcd_ping();
|
||||
|
||||
|
|
|
@ -830,8 +830,12 @@ if (print_sd_status)
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef CMD_DIAGNOSTICS
|
||||
lcd.setCursor(LCD_WIDTH - 8 -1, 2);
|
||||
lcd_printPGM(PSTR(" C"));
|
||||
lcd.print(buflen); // number of commands in cmd buffer
|
||||
if (buflen < 9) lcd_printPGM(" ");
|
||||
#else
|
||||
//Print time elapsed
|
||||
lcd.setCursor(LCD_WIDTH - 8 -1, 2);
|
||||
lcd_printPGM(PSTR(" "));
|
||||
|
@ -846,6 +850,7 @@ if (print_sd_status)
|
|||
lcd_printPGM(PSTR("--:--"));
|
||||
}
|
||||
lcd_printPGM(PSTR(" "));
|
||||
#endif //CMD_DIAGNOSTICS
|
||||
|
||||
#ifdef DEBUG_DISABLE_LCD_STATUS_LINE
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue