Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
marlin-anet-a8
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
marlin-anet-a8
Commits
8093c5f5
Commit
8093c5f5
authored
8 years ago
by
João Brázio
Browse files
Options
Downloads
Patches
Plain Diff
Non-blocking speaker now uses arduino's tone()
parent
3367e79f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Marlin/speaker.h
+7
-23
7 additions, 23 deletions
Marlin/speaker.h
with
7 additions
and
23 deletions
Marlin/speaker.h
+
7
−
23
View file @
8093c5f5
...
...
@@ -31,8 +31,7 @@ class Speaker: public Buzzer {
struct
state_t
{
tone_t
tone
;
uint16_t
period
;
uint16_t
counter
;
millis_t
next
;
}
state
;
protected
:
...
...
@@ -42,8 +41,7 @@ class Speaker: public Buzzer {
*/
void
reset
()
{
super
::
reset
();
this
->
state
.
period
=
0
;
this
->
state
.
counter
=
0
;
this
->
state
.
next
=
0
;
}
public
:
...
...
@@ -60,29 +58,15 @@ class Speaker: public Buzzer {
* playing the tones in the queue.
*/
virtual
void
tick
()
{
if
(
!
this
->
state
.
counter
)
{
const
uint32_t
now
=
millis
();
if
(
now
>=
this
->
state
.
next
)
{
if
(
this
->
buffer
.
isEmpty
())
return
;
this
->
reset
();
this
->
state
.
tone
=
this
->
buffer
.
dequeue
();
// Period is uint16, min frequency will be ~16Hz
this
->
state
.
period
=
1000000UL
/
this
->
state
.
tone
.
frequency
;
this
->
state
.
counter
=
(
this
->
state
.
tone
.
duration
*
1000L
)
/
this
->
state
.
period
;
this
->
state
.
period
>>=
1
;
this
->
state
.
counter
<<=
1
;
}
else
{
const
uint32_t
now
=
micros
();
static
uint32_t
next
=
now
+
this
->
state
.
period
;
if
(
now
>=
next
)
{
--
this
->
state
.
counter
;
next
=
now
+
this
->
state
.
period
;
if
(
this
->
state
.
tone
.
frequency
>
0
)
this
->
invert
();
}
this
->
state
.
next
=
now
+
this
->
state
.
tone
.
duration
;
::
tone
(
BEEPER_PIN
,
this
->
state
.
tone
.
frequency
,
this
->
state
.
tone
.
duration
);
}
}
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment