Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

At times buzzer continues to Beep #4248

Closed
lavato opened this issue Jul 9, 2016 · 11 comments
Closed

At times buzzer continues to Beep #4248

lavato opened this issue Jul 9, 2016 · 11 comments
Assignees
Milestone

Comments

@lavato
Copy link

lavato commented Jul 9, 2016

When selecting menu items at times buzzer continues to Beep, the only way to stop it is to press the LCD control button again.

This is prevalent in the SD menu section.

@lavato lavato changed the title At times buzzer sounds continues to Beep At times buzzer continues to Beep Jul 9, 2016
@thinkyhead
Copy link
Member

thinkyhead commented Jul 10, 2016

I suggest this change to buzzer.h. The best maths to test for time elapsed uses subtraction.

-      else if (millis() >= this->state.timestamp) this->reset();
+      else if (ELAPSED(millis(), this->state.timestamp)) this->reset();
#define PENDING(NOW,SOON) ((long)(NOW-(SOON))<0)
#define ELAPSED(NOW,SOON) (!PENDING(NOW,SOON))

@thinkyhead
Copy link
Member

I note that lcd_buzz is still defined, but never used.

@thinkyhead
Copy link
Member

thinkyhead commented Jul 10, 2016

Another thing that may help in ultralcd.cpp…? This will set the tone (if the first) end-time before the added delay.

    #if ENABLED(LCD_USE_I2C_BUZZER)
      lcd.buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
    #elif PIN_EXISTS(BEEPER)
      buzzer.tone(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
+     buzzer.tick();
    #endif

@thinkyhead
Copy link
Member

thinkyhead commented Jul 10, 2016

Alternatively… the delay in lcd_quick_feedback could be done as a loop which calls buzzer.tick every one or two ms. Sometimes these "buzz" click sounds are only 2ms long anyway.

    #if ENABLED(LCD_USE_I2C_BUZZER)
      lcd.buzz(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
+     delay(10);
    #elif PIN_EXISTS(BEEPER)
      buzzer.tone(LCD_FEEDBACK_FREQUENCY_DURATION_MS, LCD_FEEDBACK_FREQUENCY_HZ);
+     for (int8_t i=5; i--;) { buzzer.tick(); delay(2); }
    #endif

@jbrazio
Copy link
Contributor

jbrazio commented Jul 10, 2016

@lavato is it related with the SD card menu item(s) ?

@lavato
Copy link
Author

lavato commented Jul 10, 2016

@jbrazio
I would say yes.
Also, It appears that the sound will stop on its own if you leave it long enough.
I have a feeling that when the CPU is busy it just cannot stop the sound.

@thinkyhead
I'll try replacing lines with your suggested changes to see and get back.

@lavato
Copy link
Author

lavato commented Jul 10, 2016

Solution in issue #4249 also "fixed" my buzzer problem.

However, I still think there is an issue with the way how buzzer code stops the sound, as any delay or "hang" appears to cause this issue.

As I said above, I will try thinkyhead's code before closing this.

@lavato
Copy link
Author

lavato commented Jul 10, 2016

@thinkyhead

For me this worked with the "bad" SD card. Thank you!

-      else if (millis() >= this->state.timestamp) this->reset();
+      else if (ELAPSED(millis(), this->state.timestamp)) this->reset();
#define PENDING(NOW,SOON) ((long)(NOW-(SOON))<0)
#define ELAPSED(NOW,SOON) (!PENDING(NOW,SOON))

BTW: How do you paste colored code into the comment?

@thinkyhead
Copy link
Member

thinkyhead commented Jul 11, 2016

BTW: How do you paste colored code into the comment?

When making a code block, after the three backticks you can append a file-extension for the language whose highlighting you want.

Start a block with ```cpp for C++ highlighting
Start a block with ```diff or ```patch for diff highlighting
et-cetera!
#define SOME_C_CODE true
if (SOME_C_CODE) {
  printf("Hello %s\n", "world!");
}

@lavato
Copy link
Author

lavato commented Jul 11, 2016

@thinkyhead Cheers for that.

@jbrazio jbrazio modified the milestone: 1.1.0 Jul 16, 2016
@github-actions
Copy link

github-actions bot commented Apr 6, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants