diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index e36c78c5..886b296a 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -9,8 +9,8 @@ // Firmware version #define FW_version "3.0.12-RC2" -//#define FW_build 107 -#define FW_build --BUILD-NUMBER-- +#define FW_build 108 +//#define FW_build --BUILD-NUMBER-- #define FW_version_build FW_version " b" STR(FW_build) diff --git a/Firmware/Configuration_prusa.h b/Firmware/Configuration_prusa.h index edc6c04c..b002dd4e 100644 --- a/Firmware/Configuration_prusa.h +++ b/Firmware/Configuration_prusa.h @@ -84,7 +84,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o //#define _NO_ASM #define DEBUG_DCODES //D codes #if 1 -//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial +#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial //#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD //#define DEBUG_RESUME_PRINT //Resume/save print debug enable //#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index e7889bf4..b8002761 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -1,5 +1,7 @@ #include "Dcodes.h" #include "Marlin.h" +# +#include "ConfigurationStore.h" #include "cmdqueue.h" #include "pat9125.h" #include @@ -16,6 +18,10 @@ #define BOOT_APP_FLG_COPY 0x02 #define BOOT_APP_FLG_FLASH 0x04 +extern uint8_t fsensor_log; +extern float current_temperature_pinda; +extern float axis_steps_per_unit[NUM_AXIS]; + inline void serial_print_hex_nibble(uint8_t val) { @@ -77,11 +83,12 @@ void dcode_0() void dcode_1() { - MYSERIAL.println("D1 - Clear EEPROM"); + MYSERIAL.println("D1 - Clear EEPROM and RESET"); cli(); - for (int i = 0; i < 4096; i++) - eeprom_write_byte((unsigned char*)i, (unsigned char)0); - sei(); + for (int i = 0; i < 8192; i++) + eeprom_write_byte((unsigned char*)i, (unsigned char)0xff); + wdt_enable(WDTO_15MS); + while(1); } void dcode_2() @@ -128,6 +135,7 @@ void dcode_2() MYSERIAL.write('\n'); } } + void dcode_3() { MYSERIAL.println("D3 - Read/Write EEPROM"); @@ -272,6 +280,13 @@ void dcode_5() void dcode_6() { + MYSERIAL.println("D6 - Read/Write external FLASH"); +} + +void dcode_7() +{ + MYSERIAL.println("D7 - Read/Write Bootloader"); +/* cli(); boot_app_magic = 0x55aa55aa; boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY | BOOT_APP_FLG_FLASH; @@ -280,17 +295,68 @@ void dcode_6() boot_dst_addr = (uint32_t)0x0003f400; wdt_enable(WDTO_15MS); while(1); - -/* MYSERIAL.println("D6 - Test"); - MYSERIAL.print("REGx90=0x"); - MYSERIAL.println(REGx90, HEX); - REGx90 = 100; - MYSERIAL.print("REGx90=0x"); - MYSERIAL.println(REGx90, HEX);*/ +*/ } -void dcode_7() +void dcode_8() { + MYSERIAL.println("D8 - Read/Write PINDA"); + uint8_t cal_status = calibration_status_pinda(); + float temp_pinda = current_temperature_pinda; + float offset_z = temp_compensation_pinda_thermistor_offset(temp_pinda); + if ((strchr_pointer[1+1] == '?') || (strchr_pointer[1+1] == 0)) + { + MYSERIAL.print("cal_status="); + MYSERIAL.println(cal_status?"1":"0"); + for (uint8_t i = 0; i < 6; i++) + { + MYSERIAL.print("temp_pinda="); + MYSERIAL.print(35 + i * 5, DEC); + MYSERIAL.print("C, temp_shift="); + uint16_t offs = 0; + if (i > 0) offs = eeprom_read_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + (i - 1)); + MYSERIAL.print(((float)offs) / axis_steps_per_unit[Z_AXIS], 3); + MYSERIAL.println("mm"); + } + } + else if (strchr_pointer[1+1] == '!') + { + cal_status = 1; + eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, cal_status); + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 50); //40C - + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 100); //45C - + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 150); //50C - + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 200); //55C - + eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 250); //60C - + } + else + { + if (code_seen('P')) // Pinda temperature [C] + temp_pinda = code_value(); + offset_z = temp_compensation_pinda_thermistor_offset(temp_pinda); + if (code_seen('Z')) // Z Offset [mm] + { + offset_z = code_value(); + } + } + MYSERIAL.print("temp_pinda="); + MYSERIAL.println(temp_pinda); + MYSERIAL.print("offset_z="); + MYSERIAL.println(offset_z, 3); +} + +void dcode_10() +{//Tell the printer that XYZ calibration went OK + MYSERIAL.println("D10 - XYZ calibration = OK"); + calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST); +} + +void dcode_12() +{//Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print ) + MYSERIAL.println("D12 - Reset failstat counters"); + eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, 0x00); + eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00); + eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00); } void dcode_2130() @@ -350,5 +416,8 @@ void dcode_9125() MYSERIAL.print("pat9125_y="); MYSERIAL.print(pat9125_y, DEC); } + if (code_seen('L')) + { + fsensor_log = (int)code_value(); + } } - diff --git a/Firmware/Dcodes.h b/Firmware/Dcodes.h index 92b69add..59288b53 100644 --- a/Firmware/Dcodes.h +++ b/Firmware/Dcodes.h @@ -7,9 +7,12 @@ extern void dcode_2(); //D2 - Read/Write RAM extern void dcode_3(); //D3 - Read/Write EEPROM extern void dcode_4(); //D4 - Read/Write PIN extern void dcode_5(); //D5 - Read/Write FLASH +extern void dcode_6(); //D6 - Read/Write external FLASH +extern void dcode_7(); //D7 - Read/Write Bootloader +extern void dcode_8(); //D8 - Read/Write PINDA -extern void dcode_6(); //D6 -extern void dcode_7(); //D7 +extern void dcode_10(); //D10 - XYZ calibration = OK +extern void dcode_12(); //D12 - Reset failstat counters extern void dcode_2130(); //D2130 - TMC2130 extern void dcode_9125(); //D9125 - PAT9125 diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 469081dd..f4b4a5c8 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -362,7 +362,7 @@ void temp_compensation_apply(); void temp_compensation_start(); #ifdef PINDA_THERMISTOR -float temp_compensation_pinda_thermistor_offset(); +float temp_compensation_pinda_thermistor_offset(float temperature_pinda); #endif //PINDA_THERMISTOR void wait_for_heater(long codenum); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 772234d2..6d4b1b4e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3252,17 +3252,18 @@ void process_commands() float offset_z = 0; #ifdef PINDA_THERMISTOR - offset_z = temp_compensation_pinda_thermistor_offset(); + offset_z = temp_compensation_pinda_thermistor_offset(current_temperature_pinda); #endif //PINDA_THERMISTOR - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 1) { +// #ifdef SUPPORT_VERBOSITY +// if (verbosity_level >= 1) + { SERIAL_ECHOPGM("mesh bed leveling: "); MYSERIAL.print(current_position[Z_AXIS], 5); SERIAL_ECHOPGM(" offset: "); MYSERIAL.print(offset_z, 5); SERIAL_ECHOLNPGM(""); } - #endif // SUPPORT_VERBOSITY +// #endif // SUPPORT_VERBOSITY mbl.set_z(ix, iy, current_position[Z_AXIS] - offset_z); //store measured z values z_values[iy][ix] = z - offset_z; custom_message_state--; @@ -5768,24 +5769,25 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp dcode_4(); break; case 5: // D5 - Read/Write FLASH dcode_5(); break; - case 6: // D6 - Test + case 6: // D6 - Read/Write external FLASH dcode_6(); break; - case 7: // D7 - Test + case 7: // D7 - Read/Write Bootloader dcode_7(); break; + case 8: // D8 - Read/Write PINDA + dcode_8(); break; + + case 10: // D10 - XYZ calibration = OK + dcode_10(); break; + + case 12: //D12 - Reset failstat counters + dcode_12(); break; + case 2130: // D9125 - TMC2130 dcode_2130(); break; case 9125: // D9125 - PAT9125 dcode_9125(); break; - case 10: // D10 - Tell the printer that XYZ calibration went OK - calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST); - break; - - case 12: //D12 - Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print ) - eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, 0x00); - eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00); - eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00); case 999: { MYSERIAL.println("D999 - crash"); @@ -6880,11 +6882,11 @@ float temp_comp_interpolation(float inp_temperature) { } #ifdef PINDA_THERMISTOR -float temp_compensation_pinda_thermistor_offset() +float temp_compensation_pinda_thermistor_offset(float temperature_pinda) { if (!temp_cal_active) return 0; if (!calibration_status_pinda()) return 0; - return temp_comp_interpolation(current_temperature_pinda) / axis_steps_per_unit[Z_AXIS]; + return temp_comp_interpolation(temperature_pinda) / axis_steps_per_unit[Z_AXIS]; } #endif //PINDA_THERMISTOR diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 0d6ec5fd..18fefb7f 100644 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -35,6 +35,7 @@ bool fsensor_enabled = true; bool fsensor_M600 = false; uint8_t fsensor_err_cnt = 0; int16_t fsensor_st_cnt = 0; +uint8_t fsensor_log = 0; void fsensor_enable() @@ -86,35 +87,46 @@ ISR(PCINT2_vect) if (st_cnt != 0) { #ifdef DEBUG_FSENSOR_LOG - MYSERIAL.print("cnt="); - MYSERIAL.print(st_cnt, DEC); - MYSERIAL.print(" dy="); - MYSERIAL.print(pat9125_y, DEC); + if (fsensor_log) + { + MYSERIAL.print("cnt="); + MYSERIAL.print(st_cnt, DEC); + MYSERIAL.print(" dy="); + MYSERIAL.print(pat9125_y, DEC); + } #endif //DEBUG_FSENSOR_LOG if (st_cnt != 0) { if( (pat9125_y == 0) || ((pat9125_y > 0) && (st_cnt < 0)) || ((pat9125_y < 0) && (st_cnt > 0))) { //invalid movement - fsensor_err_cnt++; + if (st_cnt > 0) //only positive movements + fsensor_err_cnt++; #ifdef DEBUG_FSENSOR_LOG + if (fsensor_log) + { MYSERIAL.print("\tNG ! err="); MYSERIAL.println(fsensor_err_cnt, DEC); + } #endif //DEBUG_FSENSOR_LOG } else { //propper movement -// if (fsensor_err_cnt > 0) -// fsensor_err_cnt--; - fsensor_err_cnt = 0; + if (fsensor_err_cnt > 0) + fsensor_err_cnt--; +// fsensor_err_cnt = 0; #ifdef DEBUG_FSENSOR_LOG - MYSERIAL.print("\tOK err="); - MYSERIAL.println(fsensor_err_cnt, DEC); + if (fsensor_log) + { + MYSERIAL.print("\tOK err="); + MYSERIAL.println(fsensor_err_cnt, DEC); + } #endif //DEBUG_FSENSOR_LOG } } else { //no movement #ifdef DEBUG_FSENSOR_LOG + if (fsensor_log) MYSERIAL.println("\tOK 0"); #endif //DEBUG_FSENSOR_LOG } diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 2dc8f09e..5a057eb0 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3047,7 +3047,7 @@ static void prusa_stat_printinfo() SERIAL_ECHO("]"); } - +/* void lcd_pick_babystep(){ int enc_dif = 0; int cursor_pos = 1; @@ -3149,7 +3149,7 @@ void lcd_pick_babystep(){ lcd_implementation_clear(); lcd_return_to_status(); } - +*/ void lcd_move_menu_axis() { START_MENU(); @@ -3668,6 +3668,11 @@ static void lcd_settings_menu() END_MENU(); } +static void lcd_selftest_() +{ + lcd_selftest(); +} + static void lcd_calibration_menu() { START_MENU(); @@ -3675,7 +3680,7 @@ static void lcd_calibration_menu() if (!isPrintPaused) { MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28 W")); - MENU_ITEM(function, MSG_SELFTEST, lcd_selftest); + MENU_ITEM(function, MSG_SELFTEST, lcd_selftest_); #ifdef MK1BP // MK1 // "Calibrate Z"