PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Learn
Examples
Badge
04 Accelerometer
01 Check X and Y Axes.c
1
/*
2
Check X and Y axes.c
3
With the badge held flat, X is left/right tilt, Y is away from and toward
4
you tilt.
5
*/
6
7
#include "simpletools.h"
// Include simpletools library
8
#include "
badgetools.h
"
// Include badgetools library
9
10
int
x, y;
// X & Y axis variables
11
12
void
main
()
// Main function
13
{
14
badge_setup
();
// Call badge setup
15
while
(1)
// Main loop
16
{
17
x =
accel
(
AX
);
// Get accelerometer values
18
y =
accel
(
AY
);
19
20
cursor
(0, 0);
// Display
21
oledprint
(
"x = %03d "
, x);
22
cursor
(0, 1);
23
oledprint
(
"y = %03d "
, y);
24
25
pause(20);
// Wait 1/50 s before repeat
26
}
27
}
28
29
AY
#define AY
For choosing the accelerometer's y-axis. Example accel(AY) returns the component of the earth's gravi...
Definition:
badgetools.h:215
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
main
int main(void)
Definition:
GraphicsTest.c:20
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
AX
#define AX
For choosing the accelerometer's x-axis. Example accel(AX) returns the component of the earth's gravi...
Definition:
badgetools.h:223
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
cursor
void cursor(int col, int row)
Position the cursor to a certain column and row for printing text on the oLED display. Column can be 0 to 7 and row can be 0 or 1 in default LARGE text mode. In SMALL text mode, column can be 0 to 31, and row can be 0 to 7.
Definition:
oled_cursor.c:7
accel
int accel(int axis)
Measures acceleration and tilt on one of 3 axes (AX, AY, or AZ) in terms of centigravity (cg) units...
Definition:
accelerometer.c:42
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12