Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RF24
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
RF24
Commits
ee4568ed
Commit
ee4568ed
authored
May 10, 2011
by
maniacbug
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added server time to printout. Power disable/enable before/after sleeping. Changed timer to 4s.
parent
0d20f831
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
examples/pingpair_sleepy/pingpair_sleepy.pde
examples/pingpair_sleepy/pingpair_sleepy.pde
+9
-4
No files found.
examples/pingpair_sleepy/pingpair_sleepy.pde
View file @
ee4568ed
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <SPI.h>
#include <SPI.h>
#include <avr/sleep.h>
#include <avr/sleep.h>
#include <avr/power.h>
#include "nRF24L01.h"
#include "nRF24L01.h"
#include "RF24.h"
#include "RF24.h"
#include "printf.h"
#include "printf.h"
...
@@ -103,9 +104,9 @@ void setup(void)
...
@@ -103,9 +104,9 @@ void setup(void)
// Prepare sleep parameters
// Prepare sleep parameters
//
//
// Only the ping out role sleeps. Wake up every
2
s to send a ping
// Only the ping out role sleeps. Wake up every
4
s to send a ping
if
(
role
==
role_ping_out
)
if
(
role
==
role_ping_out
)
setup_watchdog
(
wdt_
2
s
);
setup_watchdog
(
wdt_
4
s
);
//
//
// Setup and configure rf radio
// Setup and configure rf radio
...
@@ -219,8 +220,9 @@ void loop(void)
...
@@ -219,8 +220,9 @@ void loop(void)
// Fetch the payload, and see if this was the last one.
// Fetch the payload, and see if this was the last one.
done
=
radio
.
read
(
&
got_time
,
sizeof
(
unsigned
long
)
);
done
=
radio
.
read
(
&
got_time
,
sizeof
(
unsigned
long
)
);
// Spew it
// Spew it. Include our time, because the ping_out millis counter is unreliable
printf
(
"Got payload %lu..."
,
got_time
);
// due to it sleeping
printf
(
"Got payload %lu @ %lu..."
,
got_time
,
millis
());
}
}
// First, stop listening so we can talk
// First, stop listening so we can talk
...
@@ -265,9 +267,12 @@ void do_sleep(void)
...
@@ -265,9 +267,12 @@ void do_sleep(void)
set_sleep_mode
(
SLEEP_MODE_PWR_DOWN
);
// sleep mode is set here
set_sleep_mode
(
SLEEP_MODE_PWR_DOWN
);
// sleep mode is set here
sleep_enable
();
sleep_enable
();
power_all_disable
();
sleep_mode
();
// System sleeps here
sleep_mode
();
// System sleeps here
sleep_disable
();
// System continues execution here when watchdog timed out
sleep_disable
();
// System continues execution here when watchdog timed out
power_all_enable
();
}
}
// vim:ai:cin:sts=2 sw=2 ft=cpp
// vim:ai:cin:sts=2 sw=2 ft=cpp
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