Skip to content

Commit

Permalink
Merge branch 'bugfix-2.0.x' into pr/24147
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed May 12, 2022
2 parents a3f66c4 + 84b9de9 commit 9ebf09f
Show file tree
Hide file tree
Showing 34 changed files with 164 additions and 161 deletions.
9 changes: 5 additions & 4 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,7 @@

#if ANY(HAS_DISPLAY, DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
//#define SOUND_MENU_ITEM // Add a mute option to the LCD menu
#define SOUND_ON_DEFAULT // Buzzer/speaker default enabled state
#endif

#if EITHER(HAS_DISPLAY, DWIN_LCD_PROUI)
Expand Down Expand Up @@ -1678,11 +1679,11 @@
//#define XYZ_NO_FRAME
#define XYZ_HOLLOW_FRAME

// A bigger font is available for edit items. Costs 3120 bytes of PROGMEM.
// A bigger font is available for edit items. Costs 3120 bytes of flash.
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_BIG_EDIT_FONT

// A smaller font may be used on the Info Screen. Costs 2434 bytes of PROGMEM.
// A smaller font may be used on the Info Screen. Costs 2434 bytes of flash.
// Western only. Not available for Cyrillic, Kana, Turkish, Greek, or Chinese.
//#define USE_SMALL_INFOFONT

Expand Down Expand Up @@ -1738,7 +1739,7 @@
//#define STATUS_ALT_FAN_BITMAP // Use the alternative fan bitmap
//#define STATUS_FAN_FRAMES 3 // :[0,1,2,3,4] Number of fan animation frames
//#define STATUS_HEAT_PERCENT // Show heating in a progress bar
//#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of PROGMEM.
//#define BOOT_MARLIN_LOGO_ANIMATED // Animated Marlin logo. Costs ~3260 (or ~940) bytes of flash.

// Frivolous Game Options
//#define MARLIN_BRICKOUT
Expand Down Expand Up @@ -2299,7 +2300,7 @@
#define BUFSIZE 4

// Transmission to Host Buffer Size
// To save 386 bytes of PROGMEM (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0.
// To save 386 bytes of flash (and TX_BUFFER_SIZE+3 bytes of RAM) set to 0.
// To buffer a simple "ok" you need 4 bytes.
// For ADVANCED_OK (M105) you need 32 bytes.
// For debug-echo: 128 bytes for the optimal speed.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* here we define this default string as the date where the latest release
* version was tagged.
*/
//#define STRING_DISTRIBUTION_DATE "2022-05-08"
//#define STRING_DISTRIBUTION_DATE "2022-05-12"

/**
* Defines a generic printer name to be output to the LCD after booting Marlin.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/HAL/LPC1768/eeprom_wired.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include "../shared/eeprom_api.h"

#ifndef MARLIN_EEPROM_SIZE
#define MARLIN_EEPROM_SIZE 0x8000 // 32KB‬
#define MARLIN_EEPROM_SIZE 0x8000 // 32K
#endif
size_t PersistentStore::capacity() { return MARLIN_EEPROM_SIZE; }

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
#include "feature/host_actions.h"
#endif

#if USE_BEEPER
#if HAS_BEEPER
#include "libs/buzzer.h"
#endif

Expand Down Expand Up @@ -827,7 +827,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
TERN_(PRINTCOUNTER, print_job_timer.tick());

// Update the Beeper queue
TERN_(USE_BEEPER, buzzer.tick());
TERN_(HAS_BEEPER, buzzer.tick());

// Handle UI input / draw events
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
Expand Down Expand Up @@ -1287,7 +1287,7 @@ void setup() {
calibrate_delay_loop();

// Init buzzer pin(s)
#if USE_BEEPER
#if HAS_BEEPER
SETUP_RUN(buzzer.init());
#endif

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/spindle_laser.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#include "spindle_laser_types.h"

#if USE_BEEPER
#if HAS_BEEPER
#include "../libs/buzzer.h"
#endif

Expand Down Expand Up @@ -272,7 +272,7 @@ class SpindleLaser {
* If not set defaults to 80% power
*/
static void test_fire_pulse() {
TERN_(USE_BEEPER, buzzer.tone(30, 3000));
TERN_(HAS_BEEPER, buzzer.tone(30, 3000));
enable_forward(); // Turn Laser on (Spindle speak but same funct)
delay(testPulse); // Delay for time set by user in pulse ms menu screen.
disable(); // Turn laser off
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,8 @@

#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864)

#define IS_DOGM_12864 1

#define DOGLCD
#define IS_DOGM_12864 1
#define IS_ULTIPANEL 1

#if ENABLED(miniVIKI)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -3552,9 +3552,9 @@
* Buzzer/Speaker
*/
#if PIN_EXISTS(BEEPER)
#define USE_BEEPER 1
#define HAS_BEEPER 1
#endif
#if USE_BEEPER || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
#if ANY(HAS_BEEPER, LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
#define HAS_BUZZER 1
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* version was tagged.
*/
#ifndef STRING_DISTRIBUTION_DATE
#define STRING_DISTRIBUTION_DATE "2022-05-08"
#define STRING_DISTRIBUTION_DATE "2022-05-12"
#endif

/**
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Warnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@
#endif

/**
* Maple environent
* Maple environment
*/
#ifdef __STM32F1__
#warning "Maple build environments are deprecated. Please use a non-Maple build environment. Report issues to the Marlin Firmware project."
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/HD44780/marlinui_HD44780.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,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;
if (!sound_on) return;
lcd.buzz(duration, freq);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ uint8_t MarlinUI::read_slow_buttons() {
// Duration in ms, freq in Hz
void MarlinUI::buzz(const long duration, const uint16_t freq) {
if (!PanelDetected) return;
if (!buzzer_enabled) return;
if (!sound_on) return;
#if ENABLED(TFTGLCD_PANEL_SPI)
WRITE(TFTGLCD_CS, LOW);
SPI_SEND_ONE(BUZZER);
Expand Down
6 changes: 1 addition & 5 deletions Marlin/src/lcd/e3v2/common/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,7 @@ ENCODER_Rate EncoderRate;
// TODO: Replace with ui.quick_feedback
void Encoder_tick() {
#if PIN_EXISTS(BEEPER)
if (ui.buzzer_enabled) {
WRITE(BEEPER_PIN, HIGH);
delay(10);
WRITE(BEEPER_PIN, LOW);
}
if (ui.sound_on) buzzer.click(10);
#endif
}

Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2587,11 +2587,11 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
case ADVANCED_BEEPER:
if (draw) {
Draw_Menu_Item(row, ICON_Version, F("LCD Beeper"));
Draw_Checkbox(row, ui.buzzer_enabled);
Draw_Checkbox(row, ui.sound_on);
}
else {
ui.buzzer_enabled = !ui.buzzer_enabled;
Draw_Checkbox(row, ui.buzzer_enabled);
ui.sound_on = !ui.sound_on;
Draw_Checkbox(row, ui.sound_on);
}
break;
#endif
Expand Down Expand Up @@ -4602,7 +4602,7 @@ void CrealityDWINClass::Screen_Update() {
}

void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
if (ui.buzzer_enabled)
if (ui.sound_on)
DONE_BUZZ(success);
else
Update_Status(success ? "Success" : "Failed");
Expand Down Expand Up @@ -4646,7 +4646,7 @@ void CrealityDWINClass::Reset_Settings() {
eeprom_settings.coordinates_split_line = 0;
TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
corner_pos = eeprom_settings.corner_pos / 10.0f;
TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
TERN_(SOUND_MENU_ITEM, ui.sound_on = ENABLED(SOUND_ON_DEFAULT));
Redraw_Screen();
}

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2106,8 +2106,8 @@ void SetPID(celsius_t t, heater_id_t h) {

#if ENABLED(SOUND_MENU_ITEM)
void SetEnableSound() {
ui.buzzer_enabled = !ui.buzzer_enabled;
Draw_Chkb_Line(CurrentMenu->line(), ui.buzzer_enabled);
ui.sound_on = !ui.sound_on;
Draw_Chkb_Line(CurrentMenu->line(), ui.sound_on);
DWIN_UpdateLCD();
}
#endif
Expand Down Expand Up @@ -2638,7 +2638,7 @@ void onDrawLanguage(MenuItemClass* menuitem, int8_t line) {
#endif

#if ENABLED(SOUND_MENU_ITEM)
void onDrawEnableSound(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, ui.buzzer_enabled); }
void onDrawEnableSound(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, ui.sound_on); }
#endif

#ifdef BLTOUCH_HS_MODE
Expand Down
9 changes: 4 additions & 5 deletions Marlin/src/lcd/extui/anycubic_chiron/Tunes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

#include "../../../inc/MarlinConfigPre.h"

// TODO: Use Marlin's built-in tone player instead.

#if ENABLED(ANYCUBIC_LCD_CHIRON)

#include "Tunes.h"
Expand All @@ -44,15 +46,12 @@ namespace Anycubic {

void PlayTune(uint8_t beeperPin, const uint16_t *tune, uint8_t speed=1) {
uint8_t pos = 1;
uint16_t wholenotelen = tune[0] / speed;
const uint16_t wholenotelen = tune[0] / speed;
do {
uint16_t freq = tune[pos];
uint16_t notelen = wholenotelen / tune[pos + 1];

const uint16_t freq = tune[pos], notelen = wholenotelen / tune[pos + 1];
::tone(beeperPin, freq, notelen);
ExtUI::delay_ms(notelen);
pos += 2;

if (pos >= MAX_TUNE_LENGTH) break;
} while (tune[pos] != n_END);
}
Expand Down
4 changes: 1 addition & 3 deletions Marlin/src/lcd/extui/anycubic_i3mega/anycubic_extui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ namespace ExtUI {
void onMediaError() { AnycubicTFT.OnSDCardError(); }
void onMediaRemoved() { AnycubicTFT.OnSDCardStateChange(false); }
void onPlayTone(const uint16_t frequency, const uint16_t duration) {
#if ENABLED(SPEAKER)
::tone(BEEPER_PIN, frequency, duration);
#endif
TERN_(SPEAKER, ::tone(BEEPER_PIN, frequency, duration));
}
void onPrintTimerStarted() { AnycubicTFT.OnPrintTimerStarted(); }
void onPrintTimerPaused() { AnycubicTFT.OnPrintTimerPaused(); }
Expand Down
9 changes: 3 additions & 6 deletions Marlin/src/lcd/extui/mks_ui/mks_hardware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@
#endif
}

#include "../../../libs/buzzer.h"

void init_test_gpio() {
endstops.init();

Expand Down Expand Up @@ -201,12 +203,7 @@
#endif
}

void mks_test_beeper() {
WRITE(BEEPER_PIN, HIGH);
delay(100);
WRITE(BEEPER_PIN, LOW);
delay(100);
}
void mks_test_beeper() { buzzer.click(100); }

#if ENABLED(SDSUPPORT)

Expand Down
15 changes: 7 additions & 8 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,18 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
#endif

#if ENABLED(SOUND_MENU_ITEM)
bool MarlinUI::buzzer_enabled = true;
bool MarlinUI::sound_on = ENABLED(SOUND_ON_DEFAULT);
#endif

#if EITHER(PCA9632_BUZZER, USE_BEEPER)
#include "../libs/buzzer.h" // for BUZZ() macro
#if EITHER(PCA9632_BUZZER, HAS_BEEPER)
#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 (!sound_on) return;
#if ENABLED(PCA9632_BUZZER)
PCA9632_buzz(duration, freq);
#elif USE_BEEPER
#elif HAS_BEEPER
buzzer.tone(duration, freq);
#endif
}
Expand Down Expand Up @@ -694,7 +693,7 @@ void MarlinUI::init() {
const millis_t ms = millis();
#endif
if (ELAPSED(ms, next_beep)) {
buzz(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY);
BUZZ(FEEDRATE_CHANGE_BEEP_DURATION, FEEDRATE_CHANGE_BEEP_FREQUENCY);
next_beep = ms + 500UL;
}
#endif
Expand Down Expand Up @@ -748,7 +747,7 @@ void MarlinUI::init() {

#if HAS_CHIRP
chirp(); // Buzz and wait. Is the delay needed for buttons to settle?
#if BOTH(HAS_MARLINUI_MENU, USE_BEEPER)
#if BOTH(HAS_MARLINUI_MENU, HAS_BEEPER)
for (int8_t i = 5; i--;) { buzzer.tick(); delay(2); }
#elif HAS_MARLINUI_MENU
delay(10);
Expand Down Expand Up @@ -1646,7 +1645,7 @@ void MarlinUI::init() {

void MarlinUI::flow_fault() {
LCD_ALERTMESSAGE(MSG_FLOWMETER_FAULT);
TERN_(HAS_BUZZER, buzz(1000, 440));
BUZZ(1000, 440);
TERN_(HAS_MARLINUI_MENU, return_to_status());
}

Expand Down
20 changes: 9 additions & 11 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@
*/
#pragma once

#include "../inc/MarlinConfig.h"
#include "../sd/cardreader.h"
#include "../module/motion.h"
#include "buttons.h"
#include "../libs/buzzer.h"

#include "../inc/MarlinConfig.h"

#if HAS_BUZZER
#include "../libs/buzzer.h"
#endif
#include "buttons.h"

#if ENABLED(TOUCH_SCREEN_CALIBRATION)
#include "tft_io/touch_calibration.h"
Expand Down Expand Up @@ -192,6 +189,9 @@ typedef bool (*statusResetFunc_t)();
//////////// MarlinUI Singleton ////////////
////////////////////////////////////////////

class MarlinUI;
extern MarlinUI ui;

class MarlinUI {
public:

Expand Down Expand Up @@ -225,17 +225,17 @@ class MarlinUI {
#endif

#if ENABLED(SOUND_MENU_ITEM)
static bool buzzer_enabled; // Initialized by settings.load()
static bool sound_on; // Initialized by settings.load()
#else
static constexpr bool buzzer_enabled = true;
static constexpr bool sound_on = true;
#endif

#if HAS_BUZZER
static void buzz(const long duration, const uint16_t freq);
#endif

FORCE_INLINE static void chirp() {
TERN_(HAS_CHIRP, buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ));
TERN_(HAS_CHIRP, TERN(HAS_BUZZER, buzz, BUZZ)(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ));
}

#if ENABLED(LCD_HAS_STATUS_INDICATORS)
Expand Down Expand Up @@ -786,8 +786,6 @@ class MarlinUI {
#endif
};

extern MarlinUI ui;

#define LCD_MESSAGE_F(S) ui.set_status(F(S))
#define LCD_MESSAGE(M) ui.set_status(GET_TEXT_F(M))
#define LCD_ALERTMESSAGE_F(S) ui.set_alert_status(F(S))
Expand Down
Loading

0 comments on commit 9ebf09f

Please sign in to comment.