PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
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
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
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
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
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,...
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
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
x
int x
Definition:
07 Box and Lines.c:13
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17