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
909e98b1
Commit
909e98b1
authored
8 years ago
by
João Brázio
Browse files
Options
Downloads
Patches
Plain Diff
A little cleanup at speaker.h
parent
8684570f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Marlin/buzzer.h
+0
-1
0 additions, 1 deletion
Marlin/buzzer.h
Marlin/speaker.h
+13
-15
13 additions, 15 deletions
Marlin/speaker.h
with
13 additions
and
16 deletions
Marlin/buzzer.h
+
0
−
1
View file @
909e98b1
...
@@ -104,7 +104,6 @@ class Buzzer {
...
@@ -104,7 +104,6 @@ class Buzzer {
*/
*/
void
tone
(
uint16_t
const
&
duration
,
uint16_t
const
&
frequency
=
0
)
{
void
tone
(
uint16_t
const
&
duration
,
uint16_t
const
&
frequency
=
0
)
{
while
(
buffer
.
isFull
())
{
while
(
buffer
.
isFull
())
{
delay
(
5
);
this
->
tick
();
this
->
tick
();
thermalManager
.
manage_heater
();
thermalManager
.
manage_heater
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Marlin/speaker.h
+
13
−
15
View file @
909e98b1
...
@@ -32,7 +32,7 @@ class Speaker: public Buzzer {
...
@@ -32,7 +32,7 @@ class Speaker: public Buzzer {
struct
state_t
{
struct
state_t
{
tone_t
tone
;
tone_t
tone
;
uint16_t
period
;
uint16_t
period
;
uint16_t
c
ycles
;
uint16_t
c
ounter
;
}
state
;
}
state
;
protected
:
protected
:
...
@@ -43,7 +43,7 @@ class Speaker: public Buzzer {
...
@@ -43,7 +43,7 @@ class Speaker: public Buzzer {
void
reset
()
{
void
reset
()
{
super
::
reset
();
super
::
reset
();
this
->
state
.
period
=
0
;
this
->
state
.
period
=
0
;
this
->
state
.
c
ycles
=
0
;
this
->
state
.
c
ounter
=
0
;
}
}
public
:
public
:
...
@@ -60,7 +60,7 @@ class Speaker: public Buzzer {
...
@@ -60,7 +60,7 @@ class Speaker: public Buzzer {
* playing the tones in the queue.
* playing the tones in the queue.
*/
*/
virtual
void
tick
()
{
virtual
void
tick
()
{
if
(
!
this
->
state
.
c
ycles
)
{
if
(
!
this
->
state
.
c
ounter
)
{
if
(
this
->
buffer
.
isEmpty
())
return
;
if
(
this
->
buffer
.
isEmpty
())
return
;
this
->
reset
();
this
->
reset
();
...
@@ -69,20 +69,18 @@ class Speaker: public Buzzer {
...
@@ -69,20 +69,18 @@ class Speaker: public Buzzer {
// Period is uint16, min frequency will be ~16Hz
// Period is uint16, min frequency will be ~16Hz
this
->
state
.
period
=
1000000UL
/
this
->
state
.
tone
.
frequency
;
this
->
state
.
period
=
1000000UL
/
this
->
state
.
tone
.
frequency
;
this
->
state
.
c
ycles
=
this
->
state
.
c
ounter
=
(
this
->
state
.
tone
.
duration
*
1000L
)
/
this
->
state
.
period
;
(
this
->
state
.
tone
.
counter
*
1000L
)
/
this
->
state
.
period
;
this
->
state
.
period
>>=
1
;
this
->
state
.
period
>>=
1
;
this
->
state
.
cycles
<<=
1
;
this
->
state
.
counter
<<=
1
;
}
else
{
const
uint32_t
now
=
micros
();
static
uint32_t
next
=
now
+
this
->
state
.
period
;
}
if
(
now
>=
next
)
{
else
{
--
this
->
state
.
counter
;
uint32_t
const
us
=
micros
();
next
=
now
+
this
->
state
.
period
;
static
uint32_t
next
=
us
+
this
->
state
.
period
;
if
(
us
>=
next
)
{
--
this
->
state
.
cycles
;
next
=
us
+
this
->
state
.
period
;
if
(
this
->
state
.
tone
.
frequency
>
0
)
this
->
invert
();
if
(
this
->
state
.
tone
.
frequency
>
0
)
this
->
invert
();
}
}
}
}
...
...
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