From 9e1a61cebc648456d135c7ae84f8581f07c2d05c Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 15 Sep 2017 18:04:19 +0200 Subject: [PATCH 1/3] initial version --- Firmware/Marlin_main.cpp | 40 ++++++++++++++++++++++++++++++++++++++- Firmware/language_all.cpp | 5 +++++ Firmware/language_all.h | 2 ++ Firmware/language_en.h | 1 + Firmware/ultralcd.cpp | 31 ++++++++++++++++++++---------- Firmware/ultralcd.h | 1 + 6 files changed, 69 insertions(+), 11 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index f7ab5dbc8..968b87e25 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5964,14 +5964,52 @@ void ClearToSend() SERIAL_PROTOCOLLNRPGM(MSG_OK); } +update_currents() { + float current_high[3] = DEFAULT_PWM_MOTOR_CURRENT_LOUD; + float current_low[3] = DEFAULT_PWM_MOTOR_CURRENT; + float tmp_motor[3]; + + SERIAL_ECHOLNPGM("Currents updated: "); + + if (destination[Z_AXIS] < Z_SILENT) { + SERIAL_ECHOLNPGM("LOW"); + for (uint8_t i = 0; i < 3; i++) { + digipot_current(i, current_low[i]); + MYSERIAL.print(int(i)); + SERIAL_ECHOPGM(": "); + MYSERIAL.println(current_low[i]); + } + } + else if (destination[Z_AXIS] > Z_HIGH_POWER) { + SERIAL_ECHOLNPGM("HIGH"); + for (uint8_t i = 0; i < 3; i++) { + digipot_current(i, current_high[i]); + MYSERIAL.print(int(i)); + SERIAL_ECHOPGM(": "); + MYSERIAL.println(current_high[i]); + } + } + else { + for (uint8_t i = 0; i < 3; i++) { + float q = current_low[i] - Z_SILENT*((current_high[i] - current_low[i]) / (Z_HIGH_POWER - Z_SILENT)); + tmp_motor[i] = ((current_high[i] - current_low[i]) / (Z_HIGH_POWER - Z_SILENT))*destination[Z_AXIS] + q; + digipot_current(i, tmp_motor[i]); + MYSERIAL.print(int(i)); + SERIAL_ECHOPGM(": "); + MYSERIAL.println(tmp_motor[i]); + } + } +} + void get_coordinates() { bool seen[4]={false,false,false,false}; for(int8_t i=0; i < NUM_AXIS; i++) { if(code_seen(axis_codes[i])) { - destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i]; + destination[i] = (float)code_value() + (axis_relative_modes[i] || relative_mode)*current_position[i]; seen[i]=true; + if (i == Z_AXIS && SilentModeMenu == 2) update_currents(); } else destination[i] = current_position[i]; //Are these else lines really needed? } diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index db86f577d..6beaa3513 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -63,6 +63,11 @@ const char * const MSG_AUTO_HOME_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_AUTO_HOME_DE }; +const char MSG_AUTO_MODE_ON_EN[] PROGMEM = "Mode [auto power]"; +const char * const MSG_AUTO_MODE_ON_LANG_TABLE[1] PROGMEM = { + MSG_AUTO_MODE_ON_EN +}; + const char MSG_A_RETRACT_EN[] PROGMEM = "A-retract"; const char * const MSG_A_RETRACT_LANG_TABLE[1] PROGMEM = { MSG_A_RETRACT_EN diff --git a/Firmware/language_all.h b/Firmware/language_all.h index e5cebaa3d..b35579e92 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -38,6 +38,8 @@ extern const char* const MSG_AUTHOR_LANG_TABLE[1]; #define MSG_AUTHOR LANG_TABLE_SELECT_EXPLICIT(MSG_AUTHOR_LANG_TABLE, 0) extern const char* const MSG_AUTO_HOME_LANG_TABLE[LANG_NUM]; #define MSG_AUTO_HOME LANG_TABLE_SELECT(MSG_AUTO_HOME_LANG_TABLE) +extern const char* const MSG_AUTO_MODE_ON_LANG_TABLE[1]; +#define MSG_AUTO_MODE_ON LANG_TABLE_SELECT_EXPLICIT(MSG_AUTO_MODE_ON_LANG_TABLE, 0) extern const char* const MSG_A_RETRACT_LANG_TABLE[1]; #define MSG_A_RETRACT LANG_TABLE_SELECT_EXPLICIT(MSG_A_RETRACT_LANG_TABLE, 0) extern const char* const MSG_BABYSTEPPING_X_LANG_TABLE[1]; diff --git a/Firmware/language_en.h b/Firmware/language_en.h index 61f2ef89e..752722867 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -103,6 +103,7 @@ #define MSG_SILENT_MODE_ON "Mode [silent]" #define MSG_SILENT_MODE_OFF "Mode [high power]" +#define MSG_AUTO_MODE_ON "Mode [auto power]" #define(length=20) MSG_REBOOT "Reboot the printer" #define(length=20) MSG_TAKE_EFFECT " for take effect" diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7c5b98708..7a2fc682d 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2754,7 +2754,12 @@ static void lcd_sort_type_set() { #endif //SDCARD_SORT_ALPHA static void lcd_silent_mode_set() { - SilentModeMenu = !SilentModeMenu; + switch (SilentModeMenu) { + case 0: SilentModeMenu = 1; break; + case 1: SilentModeMenu = 2; break; + case 2: SilentModeMenu = 0; break; + default: SilentModeMenu = 0; break; + } eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu); digipot_init(); lcd_goto_menu(lcd_settings_menu, 7); @@ -3157,11 +3162,14 @@ static void lcd_settings_menu() { MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84")); } - - if ((SilentModeMenu == 0) || (farm_mode) ) { - MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); - } else { - MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set); + + if (!farm_mode) { //dont show in menu if we are in farm mode + switch (SilentModeMenu) { + case 0: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break; + case 1: MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set); break; + case 2: MENU_ITEM(function, MSG_AUTO_MODE_ON, lcd_silent_mode_set); break; + default: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break; + } } if (!isPrintPaused && !homing_flag) @@ -4530,10 +4538,13 @@ static void lcd_tune_menu() MENU_ITEM(function, MSG_FILAMENTCHANGE, lcd_colorprint_change);//7 #endif - if (SilentModeMenu == 0) { - MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set_tune); - } else { - MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set_tune); + if (!farm_mode) { //dont show in menu if we are in farm mode + switch (SilentModeMenu) { + case 0: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break; + case 1: MENU_ITEM(function, MSG_SILENT_MODE_ON, lcd_silent_mode_set); break; + case 2: MENU_ITEM(function, MSG_AUTO_MODE_ON, lcd_silent_mode_set); break; + default: MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); break; + } } END_MENU(); } diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index 7ff4ab805..c344512be 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -105,6 +105,7 @@ void lcd_mylang(); extern int farm_no; extern int farm_timer; extern int farm_status; + extern int8_t SilentModeMenu; #ifdef SNMM extern uint8_t snmm_extruder; From b24e12143e093f31fc0700c1045d649116ae0dfb Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 18 Sep 2017 12:46:50 +0200 Subject: [PATCH 2/3] tune menu updated --- Firmware/stepper.cpp | 5 ++--- Firmware/ultralcd.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index 1528f46f1..53bc7f5a5 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -1156,10 +1156,9 @@ void EEPROM_read_st(int pos, uint8_t* value, uint8_t size) void digipot_init() //Initialize Digipot Motor Current -{ - +{ EEPROM_read_st(EEPROM_SILENT,(uint8_t*)&SilentMode,sizeof(SilentMode)); - + SilentModeMenu = SilentMode; #if defined(DIGIPOTSS_PIN) && DIGIPOTSS_PIN > -1 if(SilentMode == 0){ const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT_LOUD; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7a2fc682d..5879af1c8 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4502,8 +4502,13 @@ static void lcd_autostart_sd() static void lcd_silent_mode_set_tune() { - SilentModeMenu = !SilentModeMenu; - eeprom_update_byte((unsigned char*)EEPROM_SILENT, SilentModeMenu); + switch (SilentModeMenu) { + case 0: SilentModeMenu = 1; break; + case 1: SilentModeMenu = 2; break; + case 2: SilentModeMenu = 0; break; + default: SilentModeMenu = 0; break; + } + eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu); digipot_init(); lcd_goto_menu(lcd_tune_menu, 9); } From 1d187062e4888127a60be213f056a2ab5cc0a60b Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 18 Sep 2017 12:48:49 +0200 Subject: [PATCH 3/3] info on serial not used --- Firmware/Marlin_main.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 968b87e25..82a48cb75 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5969,24 +5969,24 @@ update_currents() { float current_low[3] = DEFAULT_PWM_MOTOR_CURRENT; float tmp_motor[3]; - SERIAL_ECHOLNPGM("Currents updated: "); + //SERIAL_ECHOLNPGM("Currents updated: "); if (destination[Z_AXIS] < Z_SILENT) { - SERIAL_ECHOLNPGM("LOW"); + //SERIAL_ECHOLNPGM("LOW"); for (uint8_t i = 0; i < 3; i++) { digipot_current(i, current_low[i]); - MYSERIAL.print(int(i)); + /*MYSERIAL.print(int(i)); SERIAL_ECHOPGM(": "); - MYSERIAL.println(current_low[i]); + MYSERIAL.println(current_low[i]);*/ } } else if (destination[Z_AXIS] > Z_HIGH_POWER) { - SERIAL_ECHOLNPGM("HIGH"); + //SERIAL_ECHOLNPGM("HIGH"); for (uint8_t i = 0; i < 3; i++) { digipot_current(i, current_high[i]); - MYSERIAL.print(int(i)); + /*MYSERIAL.print(int(i)); SERIAL_ECHOPGM(": "); - MYSERIAL.println(current_high[i]); + MYSERIAL.println(current_high[i]);*/ } } else { @@ -5994,9 +5994,9 @@ update_currents() { float q = current_low[i] - Z_SILENT*((current_high[i] - current_low[i]) / (Z_HIGH_POWER - Z_SILENT)); tmp_motor[i] = ((current_high[i] - current_low[i]) / (Z_HIGH_POWER - Z_SILENT))*destination[Z_AXIS] + q; digipot_current(i, tmp_motor[i]); - MYSERIAL.print(int(i)); + /*MYSERIAL.print(int(i)); SERIAL_ECHOPGM(": "); - MYSERIAL.println(tmp_motor[i]); + MYSERIAL.println(tmp_motor[i]);*/ } } }