From c0b4f4eb47ee9d657581035737383d15b3706b79 Mon Sep 17 00:00:00 2001 From: Lucas Seiki Oshiro Date: Tue, 27 Oct 2020 22:41:12 -0300 Subject: [PATCH 1/7] "Sound: ON/OFF" menu item (#19901) Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 3 +++ Marlin/src/inc/Conditionals_post.h | 16 ++++++----- Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 1 + Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp | 1 + Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/marlinui.cpp | 5 ++++ Marlin/src/lcd/marlinui.h | 6 +++++ Marlin/src/lcd/menu/menu_configuration.cpp | 8 ++++++ Marlin/src/libs/buzzer.cpp | 8 +++--- Marlin/src/module/settings.cpp | 30 +++++++++++++++++++++ buildroot/tests/LPC1768-tests | 2 +- buildroot/tests/mega2560-tests | 4 +-- buildroot/tests/teensy35-tests | 2 +- 13 files changed, 74 insertions(+), 13 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 31661a582e..951aab7804 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1090,6 +1090,9 @@ // BACK menu items keep the highlight at the top //#define TURBO_BACK_MENU_ITEM + // Add a mute option to the LCD menu + //#define SOUND_MENU_ITEM + /** * LED Control Menu * Add LED Control to the LCD menu diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index bb717ba097..bbbcf6fb2f 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2505,11 +2505,11 @@ /** * Buzzer/Speaker */ -#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER) +#if PIN_EXISTS(BEEPER) + #define USE_BEEPER 1 +#endif +#if USE_BEEPER || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER) #define HAS_BUZZER 1 - #if PIN_EXISTS(BEEPER) - #define USE_BEEPER 1 - #endif #endif #if ENABLED(LCD_USE_I2C_BUZZER) @@ -2528,8 +2528,12 @@ #endif #endif -#if HAS_BUZZER && LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ - #define HAS_CHIRP 1 +#if HAS_BUZZER + #if LCD_FEEDBACK_FREQUENCY_DURATION_MS && LCD_FEEDBACK_FREQUENCY_HZ + #define HAS_CHIRP 1 + #endif +#else + #undef SOUND_MENU_ITEM // No buzzer menu item without a buzzer #endif /** diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 4b82458398..81862e1ddf 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -113,6 +113,7 @@ static void createChar_P(const char c, const byte * const ptr) { #if ENABLED(LCD_USE_I2C_BUZZER) void MarlinUI::buzz(const long duration, const uint16_t freq) { + if (!buzzer_enabled) return; lcd.buzz(duration, freq); } #endif diff --git a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp index c21c2ceb58..571d576bbc 100644 --- a/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp @@ -289,6 +289,7 @@ uint8_t MarlinUI::read_slow_buttons(void) { // Duration in ms, freq in Hz void MarlinUI::buzz(const long duration, const uint16_t freq) { if (!PanelDetected) return; + if (!buzzer_enabled) return; #if ENABLED(TFTGLCD_PANEL_SPI) WRITE(TFTGLCD_CS, LOW); SPI_SEND_ONE(BUZZER); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index e8b4769cc2..8bf4fa6b7e 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -659,6 +659,7 @@ namespace Language_en { PROGMEM Language_Str MSG_REHEATING = _UxGT("Reheating..."); PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Probe Wizard"); + PROGMEM Language_Str MSG_SOUND = _UxGT("Sound"); } #if FAN_COUNT == 1 diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 0a87965721..1994e4094b 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -74,12 +74,17 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif #endif +#if ENABLED(SOUND_MENU_ITEM) + bool MarlinUI::buzzer_enabled = true; +#endif + #if EITHER(PCA9632_BUZZER, USE_BEEPER) #include "../libs/buzzer.h" // for BUZZ() macro #if ENABLED(PCA9632_BUZZER) #include "../feature/leds/pca9632.h" #endif void MarlinUI::buzz(const long duration, const uint16_t freq) { + if (!buzzer_enabled) return; #if ENABLED(PCA9632_BUZZER) PCA9632_buzz(duration, freq); #elif USE_BEEPER diff --git a/Marlin/src/lcd/marlinui.h b/Marlin/src/lcd/marlinui.h index bf9e47e0c8..d0b66aee45 100644 --- a/Marlin/src/lcd/marlinui.h +++ b/Marlin/src/lcd/marlinui.h @@ -292,6 +292,12 @@ public: TERN_(HAS_LCD_MENU, currentScreen = status_screen); } + #if ENABLED(SOUND_MENU_ITEM) + static bool buzzer_enabled; // Initialized by settings.load() + #else + static constexpr bool buzzer_enabled = true; + #endif + #if HAS_BUZZER static void buzz(const long duration, const uint16_t freq); #endif diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 22947ee514..f667242bc1 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -45,6 +45,10 @@ #endif #endif +#if ENABLED(SOUND_MENU_ITEM) + #include "../../libs/buzzer.h" +#endif + #define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST) void menu_advanced_settings(); @@ -412,6 +416,10 @@ void menu_configuration() { SUBMENU_N_S(m, ui.get_preheat_label(m), MSG_PREHEAT_M_SETTINGS, _menu_configuration_preheat_settings); #endif + #if ENABLED(SOUND_MENU_ITEM) + EDIT_ITEM(bool, MSG_SOUND, &ui.buzzer_enabled, []{ ui.chirp(); }); + #endif + #if ENABLED(EEPROM_SETTINGS) ACTION_ITEM(MSG_STORE_EEPROM, ui.store_settings); if (!busy) ACTION_ITEM(MSG_LOAD_EEPROM, ui.load_settings); diff --git a/Marlin/src/libs/buzzer.cpp b/Marlin/src/libs/buzzer.cpp index 8459695359..57ed5fb419 100644 --- a/Marlin/src/libs/buzzer.cpp +++ b/Marlin/src/libs/buzzer.cpp @@ -26,6 +26,7 @@ #include "buzzer.h" #include "../module/temperature.h" +#include "../lcd/marlinui.h" #if ENABLED(EXTENSIBLE_UI) #include "../lcd/extui/ui_api.h" @@ -44,6 +45,7 @@ Buzzer buzzer; * @param frequency Frequency of the tone in hertz */ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { + if (!ui.buzzer_enabled) return; while (buffer.isFull()) { tick(); thermalManager.manage_heater(); @@ -53,6 +55,7 @@ void Buzzer::tone(const uint16_t duration, const uint16_t frequency/*=0*/) { } void Buzzer::tick() { + if (!ui.buzzer_enabled) return; const millis_t now = millis(); if (!state.endtime) { @@ -62,12 +65,11 @@ void Buzzer::tick() { state.endtime = now + state.tone.duration; if (state.tone.frequency > 0) { - #if ENABLED(EXTENSIBLE_UI) + #if ENABLED(EXTENSIBLE_UI) && DISABLED(EXTUI_LOCAL_BEEPER) CRITICAL_SECTION_START(); ExtUI::onPlayTone(state.tone.frequency, state.tone.duration); CRITICAL_SECTION_END(); - #endif - #if ENABLED(SPEAKER) && (DISABLED(EXTENSIBLE_UI) || ENABLED(EXTUI_LOCAL_BEEPER)) + #elif ENABLED(SPEAKER) CRITICAL_SECTION_START(); ::tone(BEEPER_PIN, state.tone.frequency, state.tone.duration); CRITICAL_SECTION_END(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index d01486a80d..5c646c85dd 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -153,6 +153,10 @@ #include "../feature/ethernet.h" #endif +#if ENABLED(SOUND_MENU_ITEM) + #include "../libs/buzzer.h" +#endif + #pragma pack(push, 1) // No padding between variables #if HAS_ETHERNET @@ -451,6 +455,12 @@ typedef struct SettingsDataStruct { ethernet_subnet; // M554 P #endif + // + // Buzzer enable/disable + // + #if ENABLED(SOUND_MENU_ITEM) + bool buzzer_enabled; + #endif } SettingsData; //static_assert(sizeof(SettingsData) <= MARLIN_EEPROM_SIZE, "EEPROM too small to contain SettingsData!"); @@ -1422,6 +1432,13 @@ void MarlinSettings::postprocess() { } #endif + // + // Buzzer enable/disable + // + #if ENABLED(SOUND_MENU_ITEM) + EEPROM_WRITE(ui.buzzer_enabled); + #endif + // // Report final CRC and Data Size // @@ -2293,6 +2310,14 @@ void MarlinSettings::postprocess() { EEPROM_READ(ethernet_subnet); ethernet.subnet = ethernet_subnet; #endif + // + // Buzzer enable/disable + // + #if ENABLED(SOUND_MENU_ITEM) + _FIELD_TEST(buzzer_enabled); + EEPROM_READ(ui.buzzer_enabled); + #endif + // // Validate Final Size and CRC // @@ -2603,6 +2628,11 @@ void MarlinSettings::reset() { // TERN_(TOUCH_SCREEN_CALIBRATION, touch.calibration_reset()); + // + // Buzzer enable/disable + // + TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true); + // // Magnetic Parking Extruder // diff --git a/buildroot/tests/LPC1768-tests b/buildroot/tests/LPC1768-tests index 2f206f02f2..7877b60721 100755 --- a/buildroot/tests/LPC1768-tests +++ b/buildroot/tests/LPC1768-tests @@ -38,7 +38,7 @@ opt_set EXTRUDERS 2 opt_set TEMP_SENSOR_1 -1 opt_set TEMP_SENSOR_BED 5 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \ - FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING \ + FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING SOUND_MENU_ITEM \ NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \ PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \ diff --git a/buildroot/tests/mega2560-tests b/buildroot/tests/mega2560-tests index d3fd5c0192..a6902b9d14 100755 --- a/buildroot/tests/mega2560-tests +++ b/buildroot/tests/mega2560-tests @@ -27,7 +27,7 @@ opt_set TEMP_SENSOR_4 1000 opt_set TEMP_SENSOR_BED 1 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING BOOT_MARLIN_LOGO_SMALL \ - SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS \ + SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_USER_MENUS \ MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \ @@ -82,7 +82,7 @@ restore_configs opt_set MOTHERBOARD BOARD_MEGACONTROLLER opt_set LCD_LANGUAGE de opt_enable EEPROM_SETTINGS EEPROM_CHITCHAT \ - MINIPANEL SDSUPPORT PCA9632 LCD_INFO_MENU \ + MINIPANEL SDSUPPORT PCA9632 LCD_INFO_MENU SOUND_MENU_ITEM \ AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY LCD_BED_LEVELING G26_MESH_VALIDATION MESH_EDIT_MENU \ LIN_ADVANCE EXTRA_LIN_ADVANCE_K \ INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT EXPERIMENTAL_I2CBUS M100_FREE_MEMORY_WATCHER \ diff --git a/buildroot/tests/teensy35-tests b/buildroot/tests/teensy35-tests index 20a0c19726..39ee4faf49 100755 --- a/buildroot/tests/teensy35-tests +++ b/buildroot/tests/teensy35-tests @@ -20,7 +20,7 @@ opt_set TEMP_SENSOR_0 1 opt_set TEMP_SENSOR_1 5 opt_set TEMP_SENSOR_BED 1 opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LCD_INFO_MENU SDSUPPORT SDCARD_SORT_ALPHA \ - FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE \ + FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY CALIBRATION_GCODE BAUD_RATE_GCODE SOUND_MENU_ITEM \ FIX_MOUNTED_PROBE Z_SAFE_HOMING AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \ BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BABYSTEP_ZPROBE_GFX_OVERLAY \ PRINTCOUNTER NOZZLE_PARK_FEATURE NOZZLE_CLEAN_FEATURE SLOW_PWM_HEATERS PIDTEMPBED EEPROM_SETTINGS INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT M100_FREE_MEMORY_WATCHER \ From e3f1f7cd857f9fbfdbf6d0872324cb37d069b3f6 Mon Sep 17 00:00:00 2001 From: Orel <37673727+0r31@users.noreply.github.com> Date: Wed, 28 Oct 2020 03:37:10 +0100 Subject: [PATCH 2/7] Fix DAC-related bugs (#19921) Co-authored-by: Scott Lahteine --- Marlin/src/feature/dac/dac_mcp4728.cpp | 2 +- Marlin/src/gcode/calibrate/G34.cpp | 4 ++-- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/module/settings.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/src/feature/dac/dac_mcp4728.cpp b/Marlin/src/feature/dac/dac_mcp4728.cpp index 81c465cf29..c7a6370e17 100644 --- a/Marlin/src/feature/dac/dac_mcp4728.cpp +++ b/Marlin/src/feature/dac/dac_mcp4728.cpp @@ -124,7 +124,7 @@ uint8_t MCP4728::getDrvPct(const uint8_t channel) { return uint8_t(100.0 * dac_v * DAC Values array and calls fastwrite to update the DAC. */ void MCP4728::setDrvPct(xyze_uint8_t &pct) { - dac_values *= 0.01 * pct * (DAC_STEPPER_MAX); + dac_values *= pct.asFloat() * 0.01f * (DAC_STEPPER_MAX); fastWrite(); } diff --git a/Marlin/src/gcode/calibrate/G34.cpp b/Marlin/src/gcode/calibrate/G34.cpp index 0ca4490eb6..315b2d7333 100644 --- a/Marlin/src/gcode/calibrate/G34.cpp +++ b/Marlin/src/gcode/calibrate/G34.cpp @@ -80,7 +80,7 @@ void GcodeSuite::G34() { const uint16_t target_current = parser.intval('S', GANTRY_CALIBRATION_CURRENT); const uint32_t previous_current = stepper.motor_current_setting[Z_AXIS]; stepper.set_digipot_current(1, target_current); - #elif HAS_MOTOR_CURRENT_DAC + #elif ENABLED(HAS_MOTOR_CURRENT_DAC) const float target_current = parser.floatval('S', GANTRY_CALIBRATION_CURRENT); const float previous_current = dac_amps(Z_AXIS, target_current); stepper_dac.set_current_value(Z_AXIS, target_current); @@ -126,7 +126,7 @@ void GcodeSuite::G34() { stepper.set_digipot_current(Z_AXIS, previous_current); #elif HAS_MOTOR_CURRENT_PWM stepper.set_digipot_current(1, previous_current); - #elif HAS_MOTOR_CURRENT_DAC + #elif ENABLED(HAS_MOTOR_CURRENT_DAC) stepper_dac.set_current_value(Z_AXIS, previous_current); #elif ENABLED(HAS_MOTOR_CURRENT_I2C) digipot_i2c.set_current(Z_AXIS, previous_current) diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 642d9d84d9..0e207ffc55 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -72,7 +72,7 @@ void menu_backlash(); EDIT_DAC_PERCENT(Y); EDIT_DAC_PERCENT(Z); EDIT_DAC_PERCENT(E); - ACTION_ITEM(MSG_DAC_EEPROM_WRITE, dac_commit_eeprom); + ACTION_ITEM(MSG_DAC_EEPROM_WRITE, stepper_dac.commit_eeprom); END_MENU(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 5c646c85dd..2ae4be5f49 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3821,7 +3821,7 @@ void MarlinSettings::reset() { #elif HAS_MOTOR_CURRENT_I2C // i2c-based has any number of values // Values sent over i2c are not stored. // Indexes map directly to drivers, not axes. - #elif HAS_MOTOR_CURRENT_DAC // DAC-based has 4 values, for X Y Z E + #elif ENABLED(HAS_MOTOR_CURRENT_DAC) // DAC-based has 4 values, for X Y Z E // Values sent over i2c are not stored. Uses indirect mapping. #endif From bdb3f1ae2fc48fd3f190d33b6dd84184e99f581c Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Tue, 27 Oct 2020 19:40:12 -0700 Subject: [PATCH 3/7] Fix LCD menus + DAC (#19907) --- Marlin/src/module/settings.cpp | 6 +++--- buildroot/tests/at90usb1286_dfu-tests | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 2ae4be5f49..fc432b7e9b 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -3800,7 +3800,7 @@ void MarlinSettings::reset() { #endif #endif - #if HAS_MOTOR_CURRENT_SPI || HAS_MOTOR_CURRENT_PWM + #if EITHER(HAS_MOTOR_CURRENT_SPI, HAS_MOTOR_CURRENT_PWM) CONFIG_ECHO_HEADING("Stepper motor currents:"); CONFIG_ECHO_START(); #if HAS_MOTOR_CURRENT_PWM @@ -3818,10 +3818,10 @@ void MarlinSettings::reset() { SERIAL_CHAR(' ', 'B'); // B (maps to E1 by default) SERIAL_ECHOLN(stepper.motor_current_setting[4]); #endif - #elif HAS_MOTOR_CURRENT_I2C // i2c-based has any number of values + #elif ENABLED(HAS_MOTOR_CURRENT_I2C) // i2c-based has any number of values // Values sent over i2c are not stored. // Indexes map directly to drivers, not axes. - #elif ENABLED(HAS_MOTOR_CURRENT_DAC) // DAC-based has 4 values, for X Y Z E + #elif ENABLED(HAS_MOTOR_CURRENT_DAC) // DAC-based has 4 values, for X Y Z E // Values sent over i2c are not stored. Uses indirect mapping. #endif diff --git a/buildroot/tests/at90usb1286_dfu-tests b/buildroot/tests/at90usb1286_dfu-tests index 7571994ec4..a9b7e2bbb0 100644 --- a/buildroot/tests/at90usb1286_dfu-tests +++ b/buildroot/tests/at90usb1286_dfu-tests @@ -11,7 +11,12 @@ set -e # restore_configs opt_set MOTHERBOARD BOARD_PRINTRBOARD -exec_test $1 $2 "Default Configuration" +exec_test $1 $2 "Printrboard Configuration" + +restore_configs +opt_set MOTHERBOARD BOARD_PRINTRBOARD_REVF +opt_enable MINIPANEL +exec_test $1 $2 "Printrboard RevF with MiniPanel and Stepper DAC (in pins file)" # clean up restore_configs From 94a68445215ee2a90afb7fedde1e522318824a6d Mon Sep 17 00:00:00 2001 From: Victor Oliveira Date: Tue, 27 Oct 2020 23:54:30 -0300 Subject: [PATCH 4/7] Color UI circular task queue (#19918) --- Marlin/src/lcd/tft/tft_queue.cpp | 52 ++++++++++++++++++-------------- Marlin/src/lcd/tft/tft_queue.h | 7 +++++ 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/Marlin/src/lcd/tft/tft_queue.cpp b/Marlin/src/lcd/tft/tft_queue.cpp index e178a59a2d..43628706a9 100644 --- a/Marlin/src/lcd/tft/tft_queue.cpp +++ b/Marlin/src/lcd/tft/tft_queue.cpp @@ -32,6 +32,7 @@ uint8_t TFT_Queue::queue[]; uint8_t *TFT_Queue::end_of_queue = queue; uint8_t *TFT_Queue::current_task = nullptr; uint8_t *TFT_Queue::last_task = nullptr; +uint8_t *TFT_Queue::last_parameter = nullptr; void TFT_Queue::reset() { tft.abort(); @@ -39,6 +40,7 @@ void TFT_Queue::reset() { end_of_queue = queue; current_task = nullptr; last_task = nullptr; + last_parameter = nullptr; } void TFT_Queue::async() { @@ -113,49 +115,28 @@ void TFT_Queue::canvas(queueTask_t *task) { switch (*item) { case CANVAS_SET_BACKGROUND: Canvas.SetBackground(((parametersCanvasBackground_t *)item)->color); - item += sizeof(parametersCanvasBackground_t); break; case CANVAS_ADD_TEXT: Canvas.AddText(((parametersCanvasText_t *)item)->x, ((parametersCanvasText_t *)item)->y, ((parametersCanvasText_t *)item)->color, item + sizeof(parametersCanvasText_t), ((parametersCanvasText_t *)item)->maxWidth); - item += sizeof(parametersCanvasText_t) + ((parametersCanvasText_t *)item)->stringLength; break; case CANVAS_ADD_IMAGE: MarlinImage image; uint16_t *colors; - colorMode_t color_mode; image = ((parametersCanvasImage_t *)item)->image; colors = (uint16_t *)(item + sizeof(parametersCanvasImage_t)); Canvas.AddImage(((parametersCanvasImage_t *)item)->x, ((parametersCanvasImage_t *)item)->y, image, colors); - - item = (uint8_t *)colors; - color_mode = Images[image].colorMode; - - switch (color_mode) { - case GREYSCALE1: - item += sizeof(uint16_t); - break; - case GREYSCALE2: - item += sizeof(uint16_t) * 3; - break; - case GREYSCALE4: - item += sizeof(uint16_t) * 15; - break; - default: - break; - } break; case CANVAS_ADD_BAR: Canvas.AddBar(((parametersCanvasBar_t *)item)->x, ((parametersCanvasBar_t *)item)->y, ((parametersCanvasBar_t *)item)->width, ((parametersCanvasBar_t *)item)->height, ((parametersCanvasBar_t *)item)->color); - item += sizeof(parametersCanvasBar_t); break; case CANVAS_ADD_RECTANGLE: Canvas.AddRectangle(((parametersCanvasRectangle_t *)item)->x, ((parametersCanvasRectangle_t *)item)->y, ((parametersCanvasRectangle_t *)item)->width, ((parametersCanvasRectangle_t *)item)->height, ((parametersCanvasRectangle_t *)item)->color); - item += sizeof(parametersCanvasRectangle_t); break; } + item = ((parametersCanvasBackground_t *)item)->nextParameter; } if (Canvas.ToScreen()) task->state = TASK_STATE_COMPLETED; @@ -172,6 +153,7 @@ void TFT_Queue::fill(uint16_t x, uint16_t y, uint16_t width, uint16_t height, ui parametersFill_t *task_parameters = (parametersFill_t *)end_of_queue; end_of_queue += sizeof(parametersFill_t); + last_parameter = end_of_queue; task_parameters->x = x; task_parameters->y = y; task_parameters->width = width; @@ -201,6 +183,7 @@ void TFT_Queue::canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) parametersCanvas_t *task_parameters = (parametersCanvas_t *)end_of_queue; end_of_queue += sizeof(parametersCanvas_t); + last_parameter = end_of_queue; task_parameters->x = x; task_parameters->y = y; task_parameters->width = width; @@ -211,19 +194,33 @@ void TFT_Queue::canvas(uint16_t x, uint16_t y, uint16_t width, uint16_t height) } void TFT_Queue::set_background(uint16_t color) { + handle_queue_overflow(sizeof(parametersCanvasBackground_t)); parametersCanvas_t *task_parameters = (parametersCanvas_t *)(((uint8_t *)last_task) + sizeof(queueTask_t)); parametersCanvasBackground_t *parameters = (parametersCanvasBackground_t *)end_of_queue; + last_parameter = end_of_queue; parameters->type = CANVAS_SET_BACKGROUND; parameters->color = color; end_of_queue += sizeof(parametersCanvasBackground_t); task_parameters->count++; + parameters->nextParameter = end_of_queue; +} + +#define QUEUE_SAFETY_FREE_SPACE 100 + +void TFT_Queue::handle_queue_overflow(uint16_t sizeNeeded) { + if (uintptr_t(end_of_queue) + sizeNeeded + (QUEUE_SAFETY_FREE_SPACE) - uintptr_t(queue) >= QUEUE_SIZE) { + end_of_queue = queue; + ((parametersCanvasText_t *)last_parameter)->nextParameter = end_of_queue; + } } void TFT_Queue::add_text(uint16_t x, uint16_t y, uint16_t color, uint8_t *string, uint16_t maxWidth) { + handle_queue_overflow(sizeof(parametersCanvasText_t) + maxWidth); parametersCanvas_t *task_parameters = (parametersCanvas_t *)(((uint8_t *)last_task) + sizeof(queueTask_t)); parametersCanvasText_t *parameters = (parametersCanvasText_t *)end_of_queue; + last_parameter = end_of_queue; uint8_t *pointer = string; @@ -239,13 +236,16 @@ void TFT_Queue::add_text(uint16_t x, uint16_t y, uint16_t color, uint8_t *string /* TODO: Deal with maxWidth */ while ((*(end_of_queue++) = *pointer++) != 0x00); + parameters->nextParameter = end_of_queue; parameters->stringLength = pointer - string; task_parameters->count++; } void TFT_Queue::add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *colors) { + handle_queue_overflow(sizeof(parametersCanvasImage_t)); parametersCanvas_t *task_parameters = (parametersCanvas_t *)(((uint8_t *)last_task) + sizeof(queueTask_t)); parametersCanvasImage_t *parameters = (parametersCanvasImage_t *)end_of_queue; + last_parameter = end_of_queue; parameters->type = CANVAS_ADD_IMAGE; parameters->x = x; @@ -254,6 +254,7 @@ void TFT_Queue::add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *col end_of_queue += sizeof(parametersCanvasImage_t); task_parameters->count++; + parameters->nextParameter = end_of_queue; colorMode_t color_mode = Images[image].colorMode; @@ -275,6 +276,7 @@ void TFT_Queue::add_image(int16_t x, int16_t y, MarlinImage image, uint16_t *col } end_of_queue = (uint8_t *)color; + parameters->nextParameter = end_of_queue; } uint16_t gradient(uint16_t colorA, uint16_t colorB, uint16_t factor) { @@ -314,8 +316,10 @@ void TFT_Queue::add_image(int16_t x, int16_t y, MarlinImage image, uint16_t colo } void TFT_Queue::add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { + handle_queue_overflow(sizeof(parametersCanvasBar_t)); parametersCanvas_t *task_parameters = (parametersCanvas_t *)(((uint8_t *)last_task) + sizeof(queueTask_t)); parametersCanvasBar_t *parameters = (parametersCanvasBar_t *)end_of_queue; + last_parameter = end_of_queue; parameters->type = CANVAS_ADD_BAR; parameters->x = x; @@ -326,11 +330,14 @@ void TFT_Queue::add_bar(uint16_t x, uint16_t y, uint16_t width, uint16_t height, end_of_queue += sizeof(parametersCanvasBar_t); task_parameters->count++; + parameters->nextParameter = end_of_queue; } void TFT_Queue::add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) { + handle_queue_overflow(sizeof(parametersCanvasRectangle_t)); parametersCanvas_t *task_parameters = (parametersCanvas_t *)(((uint8_t *)last_task) + sizeof(queueTask_t)); parametersCanvasRectangle_t *parameters = (parametersCanvasRectangle_t *)end_of_queue; + last_parameter = end_of_queue; parameters->type = CANVAS_ADD_RECTANGLE; parameters->x = x; @@ -341,6 +348,7 @@ void TFT_Queue::add_rectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t h end_of_queue += sizeof(parametersCanvasRectangle_t); task_parameters->count++; + parameters->nextParameter = end_of_queue; } #endif // HAS_GRAPHICAL_TFT diff --git a/Marlin/src/lcd/tft/tft_queue.h b/Marlin/src/lcd/tft/tft_queue.h index 9aa0d5b6c9..6cb3caf4a2 100644 --- a/Marlin/src/lcd/tft/tft_queue.h +++ b/Marlin/src/lcd/tft/tft_queue.h @@ -73,11 +73,13 @@ typedef struct __attribute__((__packed__)) { typedef struct __attribute__((__packed__)) { CanvasSubtype type; + uint8_t *nextParameter; uint16_t color; } parametersCanvasBackground_t; typedef struct __attribute__((__packed__)) { CanvasSubtype type; + uint8_t *nextParameter; uint16_t x; uint16_t y; uint16_t color; @@ -88,6 +90,7 @@ typedef struct __attribute__((__packed__)) { typedef struct __attribute__((__packed__)) { CanvasSubtype type; + uint8_t *nextParameter; int16_t x; int16_t y; MarlinImage image; @@ -95,6 +98,7 @@ typedef struct __attribute__((__packed__)) { typedef struct __attribute__((__packed__)) { CanvasSubtype type; + uint8_t *nextParameter; uint16_t x; uint16_t y; uint16_t width; @@ -104,6 +108,7 @@ typedef struct __attribute__((__packed__)) { typedef struct __attribute__((__packed__)) { CanvasSubtype type; + uint8_t *nextParameter; uint16_t x; uint16_t y; uint16_t width; @@ -117,10 +122,12 @@ class TFT_Queue { static uint8_t *end_of_queue; static uint8_t *current_task; static uint8_t *last_task; + static uint8_t *last_parameter; static void finish_sketch(); static void fill(queueTask_t *task); static void canvas(queueTask_t *task); + static void handle_queue_overflow(uint16_t sizeNeeded); public: static void reset(); From 90fcb82a3e5959a4c8ea86876c3b530e86f5c4da Mon Sep 17 00:00:00 2001 From: Gurmeet Athwal Date: Wed, 28 Oct 2020 08:25:49 +0530 Subject: [PATCH 5/7] Update ExtUI path in config comment (#19908) --- Marlin/Configuration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 5ec41c596b..054e90d8d9 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -2196,7 +2196,7 @@ // // Third-party or vendor-customized controller interfaces. -// Sources should be installed in 'src/lcd/extensible_ui'. +// Sources should be installed in 'src/lcd/extui'. // //#define EXTENSIBLE_UI From 603e4d66ac2fa9d8906356ce24202d6d731e0d79 Mon Sep 17 00:00:00 2001 From: ellensp Date: Wed, 28 Oct 2020 15:57:32 +1300 Subject: [PATCH 6/7] AZTEEG X5 mini LED pins (#19909) --- Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h index ad792447ea..6fddc16224 100644 --- a/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h +++ b/Marlin/src/pins/lpc1769/pins_AZTEEG_X5_MINI.h @@ -38,6 +38,9 @@ // LED // #define LED_PIN P1_18 +#define LED2_PIN P1_20 +#define LED3_PIN P1_19 +#define LED4_PIN P1_21 // // Servos @@ -79,14 +82,13 @@ #define E0_ENABLE_PIN P0_04 // -// DIGIPOT slave addresses +// DIGIPOT slave addresses (7-bit unshifted) // #ifndef DIGIPOT_I2C_ADDRESS_A - #define DIGIPOT_I2C_ADDRESS_A 0x2C // unshifted slave address for first DIGIPOT + #define DIGIPOT_I2C_ADDRESS_A 0x2C #endif - #ifndef DIGIPOT_I2C_ADDRESS_B - #define DIGIPOT_I2C_ADDRESS_B 0x2E // unshifted slave address for second DIGIPOT + #define DIGIPOT_I2C_ADDRESS_B 0x2E #endif // From 12dec2563afcc0f92333ce3ddbba28979bc0f865 Mon Sep 17 00:00:00 2001 From: Alexander Fomichev Date: Wed, 28 Oct 2020 05:59:22 +0300 Subject: [PATCH 7/7] Generalize BTT SKR E3-DIP version (#19910) --- Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h index 63b97b666f..c151b44bb7 100644 --- a/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h +++ b/Marlin/src/pins/stm32f1/pins_BTT_SKR_E3_DIP.h @@ -25,7 +25,7 @@ #error "Oops! Select an STM32F1 board in 'Tools > Board.'" #endif -#define BOARD_INFO_NAME "BTT SKR E3 DIP V1.0" +#define BOARD_INFO_NAME "BTT SKR E3 DIP V1.x" // Release PB3/PB4 (TMC_SW Pins) from JTAG pins #define DISABLE_JTAG