diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index af89dea9..7a782d71 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -16,8 +16,8 @@ extern uint16_t nPrinterType; extern PGM_P sPrinterName; // Firmware version -#define FW_VERSION "3.7.2-RC1" -#define FW_COMMIT_NR 2359 +#define FW_VERSION "3.7.2" +#define FW_COMMIT_NR 2363 // FW_VERSION_UNKNOWN means this is an unofficial build. // The firmware should only be checked into github with this symbol. #define FW_DEV_VERSION FW_VERSION_UNKNOWN diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index afc01859..a4434661 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -172,6 +172,17 @@ void manage_inactivity(bool ignore_stepper_queue=false); #define disable_z() {} #endif +#ifdef PSU_Delta + void init_force_z(); + void check_force_z(); + #undef disable_z + #define disable_z() disable_force_z() + void disable_force_z(); + #undef enable_z + #define enable_z() enable_force_z() + void enable_force_z(); +#endif // PSU_Delta + diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index e536df96..8ac1aaf5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -775,12 +775,8 @@ int uart_putchar(char c, FILE *) void lcd_splash() { -// lcd_puts_at_P(0, 1, PSTR(" Original Prusa ")); -// lcd_puts_at_P(0, 2, PSTR(" 3D Printers ")); -// lcd_puts_P(PSTR("\x1b[1;3HOriginal Prusa\x1b[2;4H3D Printers")); -// fputs_P(PSTR(ESC_2J ESC_H(1,1) "Original Prusa i3" ESC_H(3,2) "Prusa Research"), lcdout); - lcd_puts_P(PSTR(ESC_2J ESC_H(1,1) "Original Prusa i3" ESC_H(3,2) "Prusa Research")); -// lcd_printf_P(_N(ESC_2J "x:%.3f\ny:%.3f\nz:%.3f\ne:%.3f"), _x, _y, _z, _e); + lcd_clear(); // clears display and homes screen + lcd_puts_P(PSTR("\n Original Prusa i3\n Prusa Research")); } @@ -910,7 +906,7 @@ void update_sec_lang_from_external_flash() uint32_t src_addr; if (lang_get_header(lang, &header, &src_addr)) { - fputs_P(PSTR(ESC_H(1,3) "Language update."), lcdout); + lcd_puts_at_P(1,3,PSTR("Language update.")); for (uint8_t i = 0; i < state; i++) fputc('.', lcdout); _delay(100); boot_reserved = (state + 1) | (lang << 4); @@ -984,8 +980,8 @@ void list_sec_lang_from_external_flash() static void w25x20cl_err_msg() { - lcd_puts_P(_n(ESC_2J ESC_H(0,0) "External SPI flash" ESC_H(0,1) "W25X20CL is not res-" - ESC_H(0,2) "ponding. Language" ESC_H(0,3) "switch unavailable.")); + lcd_clear(); + lcd_puts_P(_n("External SPI flash\nW25X20CL is not res-\nponding. Language\nswitch unavailable.")); } // "Setup" function is called by the Arduino framework on startup. @@ -1298,6 +1294,9 @@ void setup() update_mode_profile(); tmc2130_init(); #endif //TMC2130 +#ifdef PSU_Delta + init_force_z(); // ! important for correct Z-axis initialization +#endif // PSU_Delta setup_photpin(); @@ -1335,7 +1334,7 @@ void setup() } #endif //TMC2130 -#if defined(Z_AXIS_ALWAYS_ON) +#if defined(Z_AXIS_ALWAYS_ON) && !defined(PSU_Delta) enable_z(); #endif farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE); @@ -9466,10 +9465,11 @@ void stop_and_save_print_to_ram(float z_move, float e_move) //! @brief Restore print from ram //! -//! Restore print saved by stop_and_save_print_to_ram(). Is blocking, -//! waits for extruder temperature restore, then restores position and continues -//! print moves. -//! Internaly lcd_update() is called by wait_for_heater(). +//! Restore print saved by stop_and_save_print_to_ram(). Is blocking, restores +//! print fan speed, waits for extruder temperature restore, then restores +//! position and continues print moves. +//! +//! Internally lcd_update() is called by wait_for_heater(). //! //! @param e_move void restore_print_from_ram_and_continue(float e_move) @@ -9484,7 +9484,9 @@ void restore_print_from_ram_and_continue(float e_move) // for (int axis = X_AXIS; axis <= E_AXIS; axis++) // current_position[axis] = st_get_position_mm(axis); active_extruder = saved_active_extruder; //restore active_extruder - if (saved_extruder_temperature) { + fanSpeed = saved_fanSpeed; + if (degTargetHotend(saved_active_extruder) != saved_extruder_temperature) + { setTargetHotendSafe(saved_extruder_temperature, saved_active_extruder); heating_status = 1; wait_for_heater(_millis(), saved_active_extruder); @@ -9492,9 +9494,13 @@ void restore_print_from_ram_and_continue(float e_move) } feedrate = saved_feedrate2; //restore feedrate axis_relative_modes[E_AXIS] = saved_extruder_relative_mode; - fanSpeed = saved_fanSpeed; float e = saved_pos[E_AXIS] - e_move; plan_set_e_position(e); + + #ifdef FANCHECK + fans_check_enabled = false; + #endif + //first move print head in XY to the saved position: plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], current_position[Z_AXIS], saved_pos[E_AXIS] - e_move, homing_feedrate[Z_AXIS]/13, active_extruder); st_synchronize(); @@ -9505,6 +9511,10 @@ void restore_print_from_ram_and_continue(float e_move) plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS], 35, active_extruder); st_synchronize(); + #ifdef FANCHECK + fans_check_enabled = true; + #endif + memcpy(current_position, saved_pos, sizeof(saved_pos)); memcpy(destination, current_position, sizeof(destination)); if (saved_printing_type == PRINTING_TYPE_SD) { //was sd printing @@ -9812,3 +9822,69 @@ void marlin_wait_for_click() } #define FIL_LOAD_LENGTH 60 + +#ifdef PSU_Delta +bool bEnableForce_z; + +void init_force_z() +{ +WRITE(Z_ENABLE_PIN,Z_ENABLE_ON); +bEnableForce_z=true; // "true"-value enforce "disable_force_z()" executing +disable_force_z(); +} + +void check_force_z() +{ +if(!(bEnableForce_z||eeprom_read_byte((uint8_t*)EEPROM_SILENT))) + init_force_z(); // causes enforced switching into disable-state +} + +void disable_force_z() +{ +uint16_t z_microsteps=0; + +if(!bEnableForce_z) + return; // motor already disabled (may be ;-p ) +bEnableForce_z=false; + +// alignment to full-step +#ifdef TMC2130 +z_microsteps=tmc2130_rd_MSCNT(Z_TMC2130_CS); +#endif // TMC2130 +planner_abort_hard(); +sei(); +plan_buffer_line( + current_position[X_AXIS], + current_position[Y_AXIS], + current_position[Z_AXIS]+float((1024-z_microsteps+7)>>4)/cs.axis_steps_per_unit[Z_AXIS], + current_position[E_AXIS], + 40, active_extruder); +st_synchronize(); + +// switching to silent mode +#ifdef TMC2130 +tmc2130_mode=TMC2130_MODE_SILENT; +update_mode_profile(); +tmc2130_init(true); +#endif // TMC2130 + +axis_known_position[Z_AXIS]=false; +} + + +void enable_force_z() +{ +if(bEnableForce_z) + return; // motor already enabled (may be ;-p ) +bEnableForce_z=true; + +// mode recovering +#ifdef TMC2130 +tmc2130_mode=eeprom_read_byte((uint8_t*)EEPROM_SILENT)?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL; +update_mode_profile(); +tmc2130_init(true); +#endif // TMC2130 + +WRITE(Z_ENABLE_PIN,Z_ENABLE_ON); // slightly redundant ;-p +} +#endif // PSU_Delta diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index fd7936ee..f20f647d 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -522,19 +522,6 @@ void fsensor_st_block_chunk(block_t* bl, int cnt) } } -//! This ensures generating z-position at least 25mm above the heat bed. -//! Making this a template enables changing the computation data type easily at all spots where necessary. -//! @param current_z current z-position -//! @return z-position at least 25mm above the heat bed plus FILAMENTCHANGE_ZADD -template -inline T fsensor_clamp_z(float current_z){ - T z( current_z ); - if(z < T(25)){ // make sure the compiler understands, that the constant 25 is of correct type - // - necessary for uint8_t -> results in shorter code - z = T(25); // move to at least 25mm above heat bed - } - return z + T(FILAMENTCHANGE_ZADD); // always move above the printout by FILAMENTCHANGE_ZADD (default 2mm) -} //! Common code for enqueing M600 and supplemental codes into the command queue. //! Used both for the IR sensor and the PAT9125 @@ -545,22 +532,6 @@ void fsensor_enque_M600(){ enquecommand_front_P(PSTR("PRUSA fsensor_recover")); fsensor_m600_enqueued = true; enquecommand_front_P((PSTR("M600"))); -#define xstr(a) str(a) -#define str(a) #a - static const char gcodeMove[] PROGMEM = - "G1 X" xstr(FILAMENTCHANGE_XPOS) - " Y" xstr(FILAMENTCHANGE_YPOS) - " Z%u"; -#undef str -#undef xstr - char buf[32]; - // integer arithmetics is far shorter, I don't need a precise float position here, just move a bit above - // 8bit arithmetics in fsensor_clamp_z is 10B shorter than 16bit (not talking about float ;) ) - // The compile-time static_assert here ensures, that the computation gets enough bits in case of Z-range too high, - // i.e. makes the user change the data type, which also results in larger code - static_assert(Z_MAX_POS < (255 - FILAMENTCHANGE_ZADD), "Z-range too high, change fsensor_clamp_z to "); - sprintf_P(buf, gcodeMove, fsensor_clamp_z(current_position[Z_AXIS]) ); - enquecommand_front(buf, false); } //! @brief filament sensor update (perform M600 on filament runout) diff --git a/Firmware/io_atmega2560.h b/Firmware/io_atmega2560.h index e8c756ff..e353eb05 100644 --- a/Firmware/io_atmega2560.h +++ b/Firmware/io_atmega2560.h @@ -368,6 +368,7 @@ #define PIN_SET(pin) PORT(pin) |= __MSK(pin) #define PIN_VAL(pin, val) if (val) PIN_SET(pin); else PIN_CLR(pin); #define PIN_GET(pin) (PIN(pin) & __MSK(pin)) +#define PIN_INQ(pin) (PORT(pin) & __MSK(pin)) #endif //_IO_ATMEGA2560 diff --git a/Firmware/lcd.cpp b/Firmware/lcd.cpp index 5bd7cad6..b2f90c6c 100644 --- a/Firmware/lcd.cpp +++ b/Firmware/lcd.cpp @@ -10,12 +10,19 @@ #include "Configuration.h" #include "pins.h" #include -//#include +#include #include "Marlin.h" #include "fastio.h" //-// #include "sound.h" +#define LCD_DEFAULT_DELAY 100 + +#if (defined(LCD_PINS_D0) && defined(LCD_PINS_D1) && defined(LCD_PINS_D2) && defined(LCD_PINS_D3)) + #define LCD_8BIT +#endif + +// #define VT100 // commands #define LCD_CLEARDISPLAY 0x01 @@ -55,242 +62,189 @@ #define LCD_5x10DOTS 0x04 #define LCD_5x8DOTS 0x00 +// bitmasks for flag argument settings +#define LCD_RS_FLAG 0x01 +#define LCD_HALF_FLAG 0x02 FILE _lcdout; // = {0}; Global variable is always zero initialized, no need to explicitly state that. +uint8_t lcd_displayfunction = 0; +uint8_t lcd_displaycontrol = 0; +uint8_t lcd_displaymode = 0; -uint8_t lcd_rs_pin; // LOW: command. HIGH: character. -uint8_t lcd_rw_pin; // LOW: write to LCD. HIGH: read from LCD. -uint8_t lcd_enable_pin; // activated by a HIGH pulse. -uint8_t lcd_data_pins[8]; - -uint8_t lcd_displayfunction; -uint8_t lcd_displaycontrol; -uint8_t lcd_displaymode; - -uint8_t lcd_numlines; uint8_t lcd_currline; +#ifdef VT100 uint8_t lcd_escape[8]; +#endif +static void lcd_display(void); -void lcd_pulseEnable(void) -{ - digitalWrite(lcd_enable_pin, LOW); - delayMicroseconds(1); - digitalWrite(lcd_enable_pin, HIGH); - delayMicroseconds(1); // enable pulse must be >450ns - digitalWrite(lcd_enable_pin, LOW); - delayMicroseconds(100); // commands need > 37us to settle +#if 0 +static void lcd_no_display(void); +static void lcd_no_cursor(void); +static void lcd_cursor(void); +static void lcd_no_blink(void); +static void lcd_blink(void); +static void lcd_scrollDisplayLeft(void); +static void lcd_scrollDisplayRight(void); +static void lcd_leftToRight(void); +static void lcd_rightToLeft(void); +static void lcd_autoscroll(void); +static void lcd_no_autoscroll(void); +#endif + +#ifdef VT100 +void lcd_escape_write(uint8_t chr); +#endif + +static void lcd_pulseEnable(void) +{ + WRITE(LCD_PINS_ENABLE,HIGH); + _delay_us(1); // enable pulse must be >450ns + WRITE(LCD_PINS_ENABLE,LOW); } -void lcd_write4bits(uint8_t value) +static void lcd_writebits(uint8_t value) { - for (int i = 0; i < 4; i++) - { - pinMode(lcd_data_pins[i], OUTPUT); - digitalWrite(lcd_data_pins[i], (value >> i) & 0x01); - } +#ifdef LCD_8BIT + WRITE(LCD_PINS_D0, value & 0x01); + WRITE(LCD_PINS_D1, value & 0x02); + WRITE(LCD_PINS_D2, value & 0x04); + WRITE(LCD_PINS_D3, value & 0x08); +#endif + WRITE(LCD_PINS_D4, value & 0x10); + WRITE(LCD_PINS_D5, value & 0x20); + WRITE(LCD_PINS_D6, value & 0x40); + WRITE(LCD_PINS_D7, value & 0x80); + lcd_pulseEnable(); } -void lcd_write8bits(uint8_t value) +static void lcd_send(uint8_t data, uint8_t flags, uint16_t duration = LCD_DEFAULT_DELAY) { - for (int i = 0; i < 8; i++) + WRITE(LCD_PINS_RS,flags&LCD_RS_FLAG); + _delay_us(5); + lcd_writebits(data); +#ifndef LCD_8BIT + if (!(flags & LCD_HALF_FLAG)) { - pinMode(lcd_data_pins[i], OUTPUT); - digitalWrite(lcd_data_pins[i], (value >> i) & 0x01); + _delay_us(LCD_DEFAULT_DELAY); + lcd_writebits(data<<4); } - lcd_pulseEnable(); +#endif + delayMicroseconds(duration); } -// write either command or data, with automatic 4/8-bit selection -void lcd_send(uint8_t value, uint8_t mode) +static void lcd_command(uint8_t value, uint16_t delayExtra = 0) { - digitalWrite(lcd_rs_pin, mode); - // if there is a RW pin indicated, set it low to Write - if (lcd_rw_pin != 255) digitalWrite(lcd_rw_pin, LOW); - if (lcd_displayfunction & LCD_8BITMODE) - lcd_write8bits(value); - else - { - lcd_write4bits(value>>4); - lcd_write4bits(value); - } + lcd_send(value, LOW, LCD_DEFAULT_DELAY + delayExtra); } -void lcd_command(uint8_t value) +static void lcd_write(uint8_t value) { - lcd_send(value, LOW); -} - -void lcd_clear(void); -void lcd_home(void); -void lcd_no_display(void); -void lcd_display(void); -void lcd_no_cursor(void); -void lcd_cursor(void); -void lcd_no_blink(void); -void lcd_blink(void); -void lcd_scrollDisplayLeft(void); -void lcd_scrollDisplayRight(void); -void lcd_leftToRight(void); -void lcd_rightToLeft(void); -void lcd_autoscroll(void); -void lcd_no_autoscroll(void); -void lcd_set_cursor(uint8_t col, uint8_t row); -void lcd_createChar_P(uint8_t location, const uint8_t* charmap); - -uint8_t lcd_escape_write(uint8_t chr); - -uint8_t lcd_write(uint8_t value) -{ - if (value == '\n') + if (value == '\n' || value == '\r') { if (lcd_currline > 3) lcd_currline = -1; lcd_set_cursor(0, lcd_currline + 1); // LF - return 1; + return; } - if (lcd_escape[0] || (value == 0x1b)) - return lcd_escape_write(value); + #ifdef VT100 + if (lcd_escape[0] || (value == 0x1b)){ + lcd_escape_write(value); + return; + } + #endif lcd_send(value, HIGH); - return 1; // assume sucess } -static void lcd_begin(uint8_t lines, uint8_t dotsize, uint8_t clear) +static void lcd_begin(uint8_t clear) { - if (lines > 1) lcd_displayfunction |= LCD_2LINE; - lcd_numlines = lines; lcd_currline = 0; - // for some 1 line displays you can select a 10 pixel high font - if ((dotsize != 0) && (lines == 1)) lcd_displayfunction |= LCD_5x10DOTS; - // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! - // according to datasheet, we need at least 40ms after power rises above 2.7V - // before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 - _delay_us(50000); - // Now we pull both RS and R/W low to begin commands - digitalWrite(lcd_rs_pin, LOW); - digitalWrite(lcd_enable_pin, LOW); - if (lcd_rw_pin != 255) - digitalWrite(lcd_rw_pin, LOW); - //put the LCD into 4 bit or 8 bit mode - if (!(lcd_displayfunction & LCD_8BITMODE)) - { - // this is according to the hitachi HD44780 datasheet - // figure 24, pg 46 - // we start in 8bit mode, try to set 4 bit mode - lcd_write4bits(0x03); - _delay_us(4500); // wait min 4.1ms - // second try - lcd_write4bits(0x03); - _delay_us(4500); // wait min 4.1ms - // third go! - lcd_write4bits(0x03); - _delay_us(150); - // finally, set to 4-bit interface - lcd_write4bits(0x02); - } - else - { - // this is according to the hitachi HD44780 datasheet - // page 45 figure 23 - // Send function set command sequence - lcd_command(LCD_FUNCTIONSET | lcd_displayfunction); - _delay_us(4500); // wait more than 4.1ms - // second try - lcd_command(LCD_FUNCTIONSET | lcd_displayfunction); - _delay_us(150); - // third go - lcd_command(LCD_FUNCTIONSET | lcd_displayfunction); - } - // finally, set # lines, font size, etc. - lcd_command(LCD_FUNCTIONSET | lcd_displayfunction); - _delay_us(60); + + lcd_send(LCD_FUNCTIONSET | LCD_8BITMODE, LOW | LCD_HALF_FLAG, 4500); // wait min 4.1ms + // second try + lcd_send(LCD_FUNCTIONSET | LCD_8BITMODE, LOW | LCD_HALF_FLAG, 150); + // third go! + lcd_send(LCD_FUNCTIONSET | LCD_8BITMODE, LOW | LCD_HALF_FLAG, 150); +#ifndef LCD_8BIT + // set to 4-bit interface + lcd_send(LCD_FUNCTIONSET | LCD_4BITMODE, LOW | LCD_HALF_FLAG, 150); +#endif + + // finally, set # lines, font size, etc.0 + lcd_command(LCD_FUNCTIONSET | lcd_displayfunction); // turn the display on with no cursor or blinking default - lcd_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; + lcd_displaycontrol = LCD_CURSOROFF | LCD_BLINKOFF; lcd_display(); - _delay_us(60); // clear it off if (clear) lcd_clear(); - _delay_us(3000); // Initialize to default text direction (for romance languages) lcd_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; // set the entry mode lcd_command(LCD_ENTRYMODESET | lcd_displaymode); - _delay_us(60); + + #ifdef VT100 lcd_escape[0] = 0; + #endif } -int lcd_putchar(char c, FILE *) +static void lcd_putchar(char c, FILE *) { lcd_write(c); - return 0; } void lcd_init(void) { - uint8_t fourbitmode = 1; - lcd_rs_pin = LCD_PINS_RS; - lcd_rw_pin = 255; - lcd_enable_pin = LCD_PINS_ENABLE; - lcd_data_pins[0] = LCD_PINS_D4; - lcd_data_pins[1] = LCD_PINS_D5; - lcd_data_pins[2] = LCD_PINS_D6; - lcd_data_pins[3] = LCD_PINS_D7; - lcd_data_pins[4] = 0; - lcd_data_pins[5] = 0; - lcd_data_pins[6] = 0; - lcd_data_pins[7] = 0; - pinMode(lcd_rs_pin, OUTPUT); - // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin# - if (lcd_rw_pin != 255) pinMode(lcd_rw_pin, OUTPUT); - pinMode(lcd_enable_pin, OUTPUT); - if (fourbitmode) lcd_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; - else lcd_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS; - lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 1); - //lcd_clear(); + SET_OUTPUT(LCD_PINS_RS); + SET_OUTPUT(LCD_PINS_ENABLE); +#ifdef LCD_8BIT + lcd_displayfunction |= LCD_8BITMODE; +#endif + lcd_displayfunction |= LCD_2LINE; + _delay_us(50000); + lcd_begin(1); //first time init fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream } void lcd_refresh(void) { - lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 1); + lcd_begin(1); lcd_set_custom_characters(); } void lcd_refresh_noclear(void) { - lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 0); + lcd_begin(0); lcd_set_custom_characters(); } - - void lcd_clear(void) { - lcd_command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero - _delay_us(1600); // this command takes a long time + lcd_command(LCD_CLEARDISPLAY, 1600); // clear display, set cursor position to zero + lcd_currline = 0; } void lcd_home(void) { - lcd_command(LCD_RETURNHOME); // set cursor position to zero - _delay_us(1600); // this command takes a long time! + lcd_command(LCD_RETURNHOME, 1600); // set cursor position to zero + lcd_currline = 0; } // Turn the display on/off (quickly) +void lcd_display(void) +{ + lcd_displaycontrol |= LCD_DISPLAYON; + lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); +} + +#if 0 void lcd_no_display(void) { lcd_displaycontrol &= ~LCD_DISPLAYON; lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); } -void lcd_display(void) -{ - lcd_displaycontrol |= LCD_DISPLAYON; - lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol); -} - // Turns the underline cursor on/off void lcd_no_cursor(void) { @@ -355,12 +309,13 @@ void lcd_no_autoscroll(void) lcd_displaymode &= ~LCD_ENTRYSHIFTINCREMENT; lcd_command(LCD_ENTRYMODESET | lcd_displaymode); } +#endif void lcd_set_cursor(uint8_t col, uint8_t row) { int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 }; - if ( row >= lcd_numlines ) - row = lcd_numlines-1; // we count rows starting w/0 + if (row >= LCD_HEIGHT) + row = LCD_HEIGHT - 1; // we count rows starting w/0 lcd_currline = row; lcd_command(LCD_SETDDRAMADDR | (col + row_offsets[row])); } @@ -375,12 +330,14 @@ void lcd_createChar_P(uint8_t location, const uint8_t* charmap) lcd_send(pgm_read_byte(&charmap[i]), HIGH); } +#ifdef VT100 + //Supported VT100 escape codes: //EraseScreen "\x1b[2J" //CursorHome "\x1b[%d;%dH" //CursorShow "\x1b[?25h" //CursorHide "\x1b[?25l" -uint8_t lcd_escape_write(uint8_t chr) +void lcd_escape_write(uint8_t chr) { #define escape_cnt (lcd_escape[0]) //escape character counter #define is_num_msk (lcd_escape[1]) //numeric character bit mask @@ -410,26 +367,26 @@ uint8_t lcd_escape_write(uint8_t chr) switch (escape_cnt++) { case 0: - if (chr == 0x1b) return 1; // escape = "\x1b" + if (chr == 0x1b) return; // escape = "\x1b" break; case 1: is_num_msk = 0x00; // reset 'is number' bit mask - if (chr == '[') return 1; // escape = "\x1b[" + if (chr == '[') return; // escape = "\x1b[" break; case 2: switch (chr) { - case '2': return 1; // escape = "\x1b[2" - case '?': return 1; // escape = "\x1b[?" + case '2': return; // escape = "\x1b[2" + case '?': return; // escape = "\x1b[?" default: - if (chr_is_num) return 1; // escape = "\x1b[%1d" + if (chr_is_num) return; // escape = "\x1b[%1d" } break; case 3: switch (lcd_escape[2]) { case '?': // escape = "\x1b[?" - if (chr == '2') return 1; // escape = "\x1b[?2" + if (chr == '2') return; // escape = "\x1b[?2" break; case '2': if (chr == 'J') // escape = "\x1b[2J" @@ -438,20 +395,20 @@ uint8_t lcd_escape_write(uint8_t chr) if (e_2_is_num && // escape = "\x1b[%1d" ((chr == ';') || // escape = "\x1b[%1d;" chr_is_num)) // escape = "\x1b[%2d" - return 1; + return; } break; case 4: switch (lcd_escape[2]) { case '?': // "\x1b[?" - if ((lcd_escape[3] == '2') && (chr == '5')) return 1; // escape = "\x1b[?25" + if ((lcd_escape[3] == '2') && (chr == '5')) return; // escape = "\x1b[?25" break; default: if (e_2_is_num) // escape = "\x1b[%1d" { - if ((lcd_escape[3] == ';') && chr_is_num) return 1; // escape = "\x1b[%1d;%1d" - else if (e_3_is_num && (chr == ';')) return 1; // escape = "\x1b[%2d;" + if ((lcd_escape[3] == ';') && chr_is_num) return; // escape = "\x1b[%1d;%1d" + else if (e_3_is_num && (chr == ';')) return; // escape = "\x1b[%2d;" } } break; @@ -478,10 +435,10 @@ uint8_t lcd_escape_write(uint8_t chr) if (chr == 'H') // escape = "\x1b%1d;%1dH" lcd_set_cursor(e4_num, e2_num); // CursorHome else if (chr_is_num) - return 1; // escape = "\x1b%1d;%2d" + return; // escape = "\x1b%1d;%2d" } else if (e_3_is_num && (lcd_escape[4] == ';') && chr_is_num) - return 1; // escape = "\x1b%2d;%1d" + return; // escape = "\x1b%2d;%1d" } } break; @@ -495,7 +452,7 @@ uint8_t lcd_escape_write(uint8_t chr) if (chr == 'H') // escape = "\x1b%2d;%1dH" lcd_set_cursor(e5_num, e23_num); // CursorHome else if (chr_is_num) // "\x1b%2d;%2d" - return 1; + return; } } break; @@ -506,10 +463,9 @@ uint8_t lcd_escape_write(uint8_t chr) break; } escape_cnt = 0; // reset escape - return 1; // assume sucess } - +#endif //VT100 int lcd_putc(int c) @@ -648,16 +604,6 @@ void lcd_printFloat(double number, uint8_t digits) } - - - - - - - - - - uint8_t lcd_draw_update = 2; int32_t lcd_encoder = 0; uint8_t lcd_encoder_bits = 0; @@ -710,7 +656,7 @@ Sound_MakeSound(e_SOUND_TYPE_ButtonEcho); for(int8_t i = 0; i < 10; i++) { Sound_MakeCustom(100,0,false); - delayMicroseconds(100); + _delay_us(100); } */ } @@ -722,13 +668,6 @@ void lcd_quick_feedback(void) lcd_beeper_quick_feedback(); } - - - - - - - void lcd_update(uint8_t lcdDrawUpdateOverride) { if (lcd_draw_update < lcdDrawUpdateOverride) diff --git a/Firmware/lcd.h b/Firmware/lcd.h index 9f3eb5c1..307e9486 100644 --- a/Firmware/lcd.h +++ b/Firmware/lcd.h @@ -11,8 +11,7 @@ extern FILE _lcdout; #define lcdout (&_lcdout) -extern int lcd_putchar(char c, FILE *stream); - +extern void lcd_putchar(char c, FILE *stream); extern void lcd_init(void); @@ -20,13 +19,10 @@ extern void lcd_refresh(void); extern void lcd_refresh_noclear(void); - - extern void lcd_clear(void); extern void lcd_home(void); - /*extern void lcd_no_display(void); extern void lcd_display(void); extern void lcd_no_blink(void); @@ -45,7 +41,6 @@ extern void lcd_set_cursor(uint8_t col, uint8_t row); extern void lcd_createChar_P(uint8_t, const uint8_t*); - extern int lcd_putc(int c); extern int lcd_puts_P(const char* str); extern int lcd_puts_at_P(uint8_t c, uint8_t r, const char* str); @@ -66,7 +61,9 @@ extern void lcd_print(double, int = 2); //! @brief Clear screen #define ESC_2J "\x1b[2J" +//! @brief Show cursor #define ESC_25h "\x1b[?25h" +//! @brief Hide cursor #define ESC_25l "\x1b[?25l" //! @brief Set cursor to //! @param c column @@ -118,9 +115,6 @@ extern lcd_lcdupdate_func_t lcd_lcdupdate_func; - - - extern uint8_t lcd_clicked(void); extern void lcd_beeper_quick_feedback(void); @@ -128,13 +122,6 @@ extern void lcd_beeper_quick_feedback(void); //Cause an LCD refresh, and give the user visual or audible feedback that something has happened extern void lcd_quick_feedback(void); - - - - - - - extern void lcd_update(uint8_t lcdDrawUpdateOverride); extern void lcd_update_enable(uint8_t enabled); @@ -165,29 +152,6 @@ private: }; - - - - - - - - - - - - - - - - - -/** -* Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays. -* When selecting the Russian language, a slightly different LCD implementation is used to handle UTF8 characters. -**/ - - //////////////////////////////////// // Setup button and encode mappings for each panel (into 'lcd_buttons' variable // @@ -223,8 +187,6 @@ private: #define encrot3 1 - - //Custom characters defined in the first 8 characters of the LCD #define LCD_STR_BEDTEMP "\x00" #define LCD_STR_DEGREE "\x01" diff --git a/Firmware/messages.c b/Firmware/messages.c index 5c6cb796..1c36e43c 100644 --- a/Firmware/messages.c +++ b/Firmware/messages.c @@ -84,6 +84,7 @@ const char MSG_SELFTEST_MOTOR[] PROGMEM_I1 = ISTR("Motor"); //// const char MSG_SELFTEST_FILAMENT_SENSOR[] PROGMEM_I1 = ISTR("Filament sensor"); ////c=17 const char MSG_SELFTEST_WIRINGERROR[] PROGMEM_I1 = ISTR("Wiring error"); //// const char MSG_SETTINGS[] PROGMEM_I1 = ISTR("Settings"); //// +const char MSG_HW_SETUP[] PROGMEM_I1 = ISTR("HW Setup"); //// const char MSG_SILENT_MODE_OFF[] PROGMEM_I1 = ISTR("Mode [high power]"); //// const char MSG_SILENT_MODE_ON[] PROGMEM_I1 = ISTR("Mode [silent]"); //// const char MSG_STEALTH_MODE_OFF[] PROGMEM_I1 = ISTR("Mode [Normal]"); //// diff --git a/Firmware/messages.h b/Firmware/messages.h index 1dc4880c..b48337ef 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -84,6 +84,7 @@ extern const char MSG_SELFTEST_MOTOR[]; extern const char MSG_SELFTEST_FILAMENT_SENSOR[]; extern const char MSG_SELFTEST_WIRINGERROR[]; extern const char MSG_SETTINGS[]; +extern const char MSG_HW_SETUP[]; extern const char MSG_SILENT_MODE_OFF[]; extern const char MSG_SILENT_MODE_ON[]; extern const char MSG_STEALTH_MODE_OFF[]; diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index 74d25777..860d761c 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -1122,7 +1122,7 @@ void clear_current_adv_vars() { } #endif // LIN_ADVANCE - + void st_init() { #ifdef TMC2130 @@ -1306,6 +1306,9 @@ void st_init() SET_OUTPUT(Z2_STEP_PIN); WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN); #endif + #ifdef PSU_Delta + init_force_z(); + #endif // PSU_Delta disable_z(); #endif #if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 1ef85549..42d294c4 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -498,8 +498,9 @@ void checkFanSpeed() max_print_fan_errors = 15; //15 seconds max_extruder_fan_errors = 5; //5 seconds #endif //FAN_SOFT_PWM - - fans_check_enabled = (eeprom_read_byte((uint8_t*)EEPROM_FAN_CHECK_ENABLED) > 0); + + if(fans_check_enabled != false) + fans_check_enabled = (eeprom_read_byte((uint8_t*)EEPROM_FAN_CHECK_ENABLED) > 0); static unsigned char fan_speed_errors[2] = { 0,0 }; #if (defined(FANCHECK) && defined(TACH_0) && (TACH_0 >-1)) if ((fan_speed[0] == 0) && (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)) fan_speed_errors[0]++; @@ -554,6 +555,8 @@ void fanSpeedError(unsigned char _fan) { else { SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSE); //for octoprint setTargetHotend0(0); + heating_status = 0; + fan_check_error = EFCE_REPORTED; } switch (_fan) { case 0: // extracting the same code from case 0 and case 1 into a function saves 72B diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 27a7e713..e9ba11b4 100755 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -122,6 +122,7 @@ inline void babystepsTodoZsubtract(int n) //inline so that there is no performance decrease. //deg=degreeCelsius +// Doesn't save FLASH when FORCE_INLINE removed. FORCE_INLINE float degHotend(uint8_t extruder) { return current_temperature[extruder]; }; @@ -140,6 +141,7 @@ FORCE_INLINE float degBed() { return current_temperature_bed; }; +// Doesn't save FLASH when FORCE_INLINE removed. FORCE_INLINE float degTargetHotend(uint8_t extruder) { return target_temperature[extruder]; }; @@ -148,11 +150,13 @@ FORCE_INLINE float degTargetBed() { return target_temperature_bed; }; +// Doesn't save FLASH when FORCE_INLINE removed. FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) { target_temperature[extruder] = celsius; resetPID(extruder); }; +// Doesn't save FLASH when not inlined. static inline void setTargetHotendSafe(const float &celsius, uint8_t extruder) { if (extruderCancel" diff --git a/lang/lang_en_cz.txt b/lang/lang_en_cz.txt index 027d0409..74bf63d0 100755 --- a/lang/lang_en_cz.txt +++ b/lang/lang_en_cz.txt @@ -11,12 +11,12 @@ "[0;0] odsazeni bodu" #MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4 -"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode" -"\x1b[2JCrash detekce muze\x1b[1;0Hbyt zapnuta pouze v\x1b[2;0HNormal modu" +"Crash detection can\rbe turned on only in\rNormal mode" +"Crash detekce muze\rbyt zapnuta pouze v\rNormal modu" #MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 -"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode" -"\x1b[2JPOZOR:\x1b[1;0HCrash detekce\x1b[2;0Hdeaktivovana ve\x1b[3;0HStealth modu" +"WARNING:\rCrash detection\rdisabled in\rStealth mode" +"POZOR:\rCrash detekce\rdeaktivovana ve\rStealth modu" # ">Cancel" diff --git a/lang/lang_en_de.txt b/lang/lang_en_de.txt index c4c80d93..3c2c8a14 100755 --- a/lang/lang_en_de.txt +++ b/lang/lang_en_de.txt @@ -11,12 +11,12 @@ "[0;0] Punktversatz" #MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4 -"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode" -"\x1b[2JCrash Erkennung kann\x1b[1;0Hnur im Modus Normal\x1b[2;0Hgenutzt werden" +"Crash detection can\rbe turned on only in\rNormal mode" +"Crash Erkennung kann\rnur im Modus Normal\rgenutzt werden" #MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 -"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode" -"\x1b[2JWARNUNG:\x1b[1;0HCrash Erkennung\x1b[2;0Hdeaktiviert im\x1b[3;0HStealth Modus" +"WARNING:\rCrash detection\rdisabled in\rStealth mode" +"WARNUNG:\rCrash Erkennung\rdeaktiviert im\rStealth Modus" # ">Cancel" diff --git a/lang/lang_en_es.txt b/lang/lang_en_es.txt index 2f4dc251..3f4629e9 100755 --- a/lang/lang_en_es.txt +++ b/lang/lang_en_es.txt @@ -11,12 +11,12 @@ "[0;0] punto offset" #MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4 -"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode" -"\x1b[2JDec. choque\x1b[1;0Hpuede ser activada solo en\x1b[2;0HModo normal" +"Crash detection can\rbe turned on only in\rNormal mode" +"Dec. choque\rpuede ser activada solo en\rModo normal" #MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 -"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode" -"\x1b[2JATENCION:\x1b[1;0HDec. choque\x1b[2;0Hdesactivada en\x1b[3;0HModo silencio" +"WARNING:\rCrash detection\rdisabled in\rStealth mode" +"ATENCION:\rDec. choque\rdesactivada en\rModo silencio" # ">Cancel" diff --git a/lang/lang_en_fr.txt b/lang/lang_en_fr.txt index dfb0dd85..2919f11f 100755 --- a/lang/lang_en_fr.txt +++ b/lang/lang_en_fr.txt @@ -11,12 +11,12 @@ "Offset point [0;0]" #MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4 -"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode" -"\x1b[2JLa detection de crash peut etre\x1b[1;0Hactive seulement\x1b[2;0Hen mode Normal" +"Crash detection can\rbe turned on only in\rNormal mode" +"La detection de crash peut etre\ractive seulement\ren mode Normal" #MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 -"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode" -"\x1b[2JATTENTION :\x1b[1;0HDetection de crash\x1b[2;0H desactivee en\x1b[3;0Hmode Furtif" +"WARNING:\rCrash detection\rdisabled in\rStealth mode" +"ATTENTION :\rDetection de crash\r desactivee en\rmode Furtif" # ">Cancel" diff --git a/lang/lang_en_it.txt b/lang/lang_en_it.txt index 9637777f..0726fef2 100755 --- a/lang/lang_en_it.txt +++ b/lang/lang_en_it.txt @@ -11,12 +11,12 @@ "[0;0] punto offset" #MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4 -"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode" -"\x1b[2JRilev. impatto\x1b[1;0Hattivabile solo\x1b[2;0Hin Modalita normale" +"Crash detection can\rbe turned on only in\rNormal mode" +"Rilev. impatto\rattivabile solo\rin Modalita normale" #MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 -"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode" -"\x1b[2JATTENZIONE:\x1b[1;0HRilev. impatto\x1b[2;0Hdisattivato in\x1b[3;0HModalita silenziosa" +"WARNING:\rCrash detection\rdisabled in\rStealth mode" +"ATTENZIONE:\rRilev. impatto\rdisattivato in\rModalita silenziosa" # ">Cancel" diff --git a/lang/lang_en_pl.txt b/lang/lang_en_pl.txt index fe422cc3..6919d057 100755 --- a/lang/lang_en_pl.txt +++ b/lang/lang_en_pl.txt @@ -11,12 +11,12 @@ "[0;0] przesuniecie punktu" #MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4 -"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode" -"\x1b[2JWykrywanie zderzen moze\x1b[1;0Hbyc wlaczone tylko w\x1b[2;0Htrybie Normalnym" +"Crash detection can\rbe turned on only in\rNormal mode" +"Wykrywanie zderzen moze\rbyc wlaczone tylko w\rtrybie Normalnym" #MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4 -"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode" -"\x1b[2JUWAGA:\x1b[1;0HWykrywanie zderzen\x1b[2;0Hwylaczone w\x1b[3;0Htrybie Stealth" +"WARNING:\rCrash detection\rdisabled in\rStealth mode" +"UWAGA:\rWykrywanie zderzen\rwylaczone w\rtrybie Stealth" # ">Cancel"