Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
duck
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
jp7g21
duck
Commits
82cec962
Commit
82cec962
authored
3 years ago
by
jp7g21
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'refs/remotes/origin/master'
parents
e5949c0b
41d5eb4a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
emb/command.c
+1
-1
1 addition, 1 deletion
emb/command.c
emb/servos.cpp
+3
-1
3 additions, 1 deletion
emb/servos.cpp
emb/time.cpp
+29
-0
29 additions, 0 deletions
emb/time.cpp
emb/time.hpp
+16
-0
16 additions, 0 deletions
emb/time.hpp
with
49 additions
and
2 deletions
emb/command.c
+
1
−
1
View file @
82cec962
...
...
@@ -2,7 +2,7 @@
#include
<stdlib.h>
#include
"command.h"
#define NUM_COMMANDS 20
#define NUM_COMMANDS 20
0
/* Cyclic buffer; when comm_start == comm_end, length = 0 */
struct
command
command_buf
[
NUM_COMMANDS
];
...
...
This diff is collapsed.
Click to expand it.
emb/servos.cpp
+
3
−
1
View file @
82cec962
...
...
@@ -5,6 +5,8 @@
#include
<stdint.h>
#define NUM_SERVOS 3
#define MIN_PULSE 999
#define MAX_PULSE 4999
static
void
reorderServos
();
static
void
initTimer1
();
...
...
@@ -41,7 +43,7 @@ void initServos()
void
setServoAngle
(
uint8_t
servo
,
int16_t
arcMin
)
{
if
(
0
<=
servo
&&
servo
<
NUM_SERVOS
)
servos
[
servo
].
tempValue
=
2999
+
(
int32_t
)
arcMin
*
1
000
/
(
18
0
*
60
);
servos
[
servo
].
tempValue
=
MIN_PULSE
+
(
int32_t
)
(
arcMin
+
1
80
*
60
)
*
(
MAX_PULSE
-
MIN_PULSE
)
/
(
36
0
*
60
);
}
void
updateServos
()
...
...
This diff is collapsed.
Click to expand it.
emb/time.cpp
0 → 100644
+
29
−
0
View file @
82cec962
#include
"time.hpp"
#include
<avr/io.h>
#include
<avr/interrupt.h>
#include
<stdint.h>
static
uint32_t
millis
;
void
initTime
()
{
cli
();
TCCR0A
=
(
1
<<
WGM01
);
// CTC mode, TOP = OCRA
TCCR0B
=
(
1
<<
CS01
)
|
(
1
<<
CS00
);
// 64th prescaler
OCR0A
=
249
;
// set TOP for 1 kHz interrupts
TIMSK0
=
(
1
<<
OCIE0A
);
// enable compare A interrupt
sei
();
}
uint32_t
getCurrentMillis
()
{
return
millis
;
}
ISR
(
TIMER0_COMPA_vect
)
{
millis
++
;
}
This diff is collapsed.
Click to expand it.
emb/time.hpp
0 → 100644
+
16
−
0
View file @
82cec962
#ifndef TIME_H
#define TIME_H
#include
<stdint.h>
/**
* Initialises time.
*/
void
initTime
();
/**
* Gets the number of milliseconds since program start.
*/
uint32_t
getCurrentMillis
();
#endif
/* TIME_H */
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