Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
D
dance-ctl
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Martin Natano
dance-ctl
Commits
6901ad75
Commit
6901ad75
authored
Dec 14, 2019
by
Martin Natano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debounce
parent
20377810
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
dance_ctl.c/dance_ctl.c.ino
dance_ctl.c/dance_ctl.c.ino
+25
-2
No files found.
dance_ctl.c/dance_ctl.c.ino
View file @
6901ad75
...
...
@@ -39,8 +39,9 @@ void setup() {
// the loop function runs over and over again forever
void
loop
()
{
uint8_t
reportData
;
uint8_t
debounceBuffer
[
15
];
static
uint8_t
previousReportData
;
int
i
;
int
i
,
j
;
reportData
=
0
;
...
...
@@ -50,6 +51,28 @@ void loop() {
reportData
|=
(
1
<<
i
);
}
for
(
i
=
14
;
i
>
0
;
i
--
)
{
debounceBuffer
[
i
]
=
debounceBuffer
[
i
-
1
];
}
debounceBuffer
[
0
]
=
reportData
;
reportData
=
previousReportData
;
for
(
i
=
0
;
i
<
NBUTTONS
;
i
++
)
{
int
n
=
0
;
for
(
j
=
0
;
j
<
15
;
j
++
)
{
if
(
debounceBuffer
[
j
]
&
(
1
<<
i
))
n
++
;
}
if
(
reportData
&
(
1
<<
i
))
{
if
(
n
==
0
)
reportData
&=
~
(
1
<<
i
);
}
else
{
if
(
n
==
15
)
reportData
|=
(
1
<<
i
);
}
}
if
(
reportData
!=
previousReportData
)
{
HID
().
SendReport
(
0x03
,
&
reportData
,
sizeof
(
reportData
));
...
...
@@ -61,5 +84,5 @@ void loop() {
previousReportData
=
reportData
;
}
delayMicroseconds
(
100
0
);
delayMicroseconds
(
100
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment