From 868aacc7d5ab3000bdfe4114e43a8d841c0932c2 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 8 Dec 2017 16:56:06 +0100 Subject: [PATCH] turn on second serial line from settings menu --- Firmware/Configuration.h | 1 + Firmware/Marlin_main.cpp | 5 +++-- Firmware/language_all.cpp | 10 ++++++++++ Firmware/language_all.h | 4 ++++ Firmware/language_en.h | 3 +++ Firmware/ultralcd.cpp | 14 ++++++++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 7a31986d..46239409 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -81,6 +81,7 @@ #define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17) #define EEPROM_DIR_DEPTH (EEPROM_POWER_COUNT-1) #define EEPROM_DIRS (EEPROM_DIR_DEPTH-80) //8 chars for each dir name, max 10 levels +#define EEPROM_SECOND_SERIAL_ACTIVE (EEPROM_DIRS - 1) //0: use only USART0; 1: use both USART0 and USART1 //TMC2130 configuration #define EEPROM_TMC_AXIS_SIZE //axis configuration block size diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 99328679..092429e6 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -813,13 +813,14 @@ void setup() EEPROM_read_B(EEPROM_FARM_NUMBER, &farm_no); if ((farm_mode == 0xFF && farm_no == 0) || (farm_no == 0xFFFF)) farm_mode = false; //if farm_mode has not been stored to eeprom yet and farm number is set to zero or EEPROM is fresh, deactivate farm mode if (farm_no == 0xFFFF) farm_no = 0; + + selectedSerialPort = eeprom_read_byte((uint8_t*)EEPROM_SECOND_SERIAL_ACTIVE); + if (selectedSerialPort == 0xFF) selectedSerialPort = 0; if (farm_mode) { prusa_statistics(8); selectedSerialPort = 1; } - else - selectedSerialPort = 0; MYSERIAL.begin(BAUDRATE); fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream stdout = uartout; diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index c437e1f6..aac351a6 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -1505,6 +1505,16 @@ const char * const MSG_SD_WRITE_TO_FILE_LANG_TABLE[1] PROGMEM = { MSG_SD_WRITE_TO_FILE_EN }; +const char MSG_SECOND_SERIAL_OFF_EN[] PROGMEM = "2nd USART [off]"; +const char * const MSG_SECOND_SERIAL_OFF_LANG_TABLE[1] PROGMEM = { + MSG_SECOND_SERIAL_OFF_EN +}; + +const char MSG_SECOND_SERIAL_ON_EN[] PROGMEM = "2nd USART [on]"; +const char * const MSG_SECOND_SERIAL_ON_LANG_TABLE[1] PROGMEM = { + MSG_SECOND_SERIAL_ON_EN +}; + const char MSG_SELFTEST_EN[] PROGMEM = "Selftest "; const char * const MSG_SELFTEST_LANG_TABLE[1] PROGMEM = { MSG_SELFTEST_EN diff --git a/Firmware/language_all.h b/Firmware/language_all.h index 6fb1275a..42fffe94 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -512,6 +512,10 @@ extern const char* const MSG_SD_WORKDIR_FAIL_LANG_TABLE[1]; #define MSG_SD_WORKDIR_FAIL LANG_TABLE_SELECT_EXPLICIT(MSG_SD_WORKDIR_FAIL_LANG_TABLE, 0) extern const char* const MSG_SD_WRITE_TO_FILE_LANG_TABLE[1]; #define MSG_SD_WRITE_TO_FILE LANG_TABLE_SELECT_EXPLICIT(MSG_SD_WRITE_TO_FILE_LANG_TABLE, 0) +extern const char* const MSG_SECOND_SERIAL_OFF_LANG_TABLE[1]; +#define MSG_SECOND_SERIAL_OFF LANG_TABLE_SELECT_EXPLICIT(MSG_SECOND_SERIAL_OFF_LANG_TABLE, 0) +extern const char* const MSG_SECOND_SERIAL_ON_LANG_TABLE[1]; +#define MSG_SECOND_SERIAL_ON LANG_TABLE_SELECT_EXPLICIT(MSG_SECOND_SERIAL_ON_LANG_TABLE, 0) extern const char* const MSG_SELFTEST_LANG_TABLE[1]; #define MSG_SELFTEST LANG_TABLE_SELECT_EXPLICIT(MSG_SELFTEST_LANG_TABLE, 0) extern const char* const MSG_SELFTEST_AXIS_LANG_TABLE[LANG_NUM]; diff --git a/Firmware/language_en.h b/Firmware/language_en.h index e011e12c..b0eb0b2c 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -370,3 +370,6 @@ #define(length=20, lines=2) MSG_UNLOAD_SUCCESSFULL "Repeat unloading filament?" #define(length=20, lines=2) MSG_FILE_INCOMPLETE "File incomplete. Continue anyway?" +#define(length=17, lines=1) MSG_SECOND_SERIAL_ON "2nd USART [on]" +#define(length=17, lines=1) MSG_SECOND_SERIAL_OFF "2nd USART [off]" + diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index c1dac0ff..b00d1a51 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -3330,6 +3330,13 @@ void lcd_temp_calibration_set() { lcd_goto_menu(lcd_settings_menu, 10); } +void lcd_second_serial_set() { + if(selectedSerialPort == 1) selectedSerialPort = 0; + else selectedSerialPort = 1; + eeprom_update_byte((unsigned char *)EEPROM_SECOND_SERIAL_ACTIVE, selectedSerialPort); + lcd_goto_menu(lcd_settings_menu, 11); +} + void lcd_calibrate_pinda() { enquecommand_P(PSTR("G76")); lcd_return_to_status(); @@ -3688,6 +3695,13 @@ static void lcd_settings_menu() else { MENU_ITEM(function, MSG_TEMP_CALIBRATION_ON, lcd_temp_calibration_set); } + if (selectedSerialPort == false) { + MENU_ITEM(function, MSG_SECOND_SERIAL_OFF, lcd_second_serial_set); + } + else { + MENU_ITEM(function, MSG_SECOND_SERIAL_ON, lcd_second_serial_set); + } + if (SilentModeMenu == 0) { MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set); }