PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Badge
04 Accelerometer
06 Held Steady vs Shaken.c
1
/*
2
Held Steady vs Shaken.c
3
Detecting a shaking event can take lots of code, but the accelerometer
4
chip can check automatically. To find out if the badge is being shaken,
5
simply use the accel_shaken function.
6
*/
7
8
#include "
simpletools.h
"
// Include simpletools library
9
#include "
badgetools.h
"
// Include badgetools library
10
11
int
shaken;
// Shaken variable
12
13
void
main
()
// Main function
14
{
15
badge_setup
();
// Call badge setup
16
17
while
(1)
// Main loop
18
{
19
shaken =
accel_shaken
();
// Check if shaken
20
cursor
(0, 0);
// Display if shaken
21
if
(shaken == 1)
22
{
23
oledprint
(
" Shaken"
);
24
pause
(500);
25
}
26
else
27
{
28
oledprint
(
"Steady "
);
29
}
30
pause
(20);
31
}
32
}
33
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
cursor
void cursor(int col, int row)
Position the cursor to a certain column and row for printing text on the oLED display....
Definition:
oled_cursor.c:7
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
main
int main(void)
Definition:
GraphicsTest.c:20
oledprint
int oledprint(const char *fmt,...)
Use to display strings on the oLED display in a manner similar to displaying combinations of strings ...
Definition:
peb_text.c:4
badge_setup
int badge_setup(void)
Set up all available badge drivers. Call this function at the start of any given program to allow acc...
Definition:
badgealpha.c:29
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
accel_shaken
int accel_shaken(void)
Check if accelerometer was shaken recently, within the last half second.
Definition:
accel_shaken.c:15
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17