PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Badge
04 Accelerometer
02 Check XYZ with One Call.c
1
/*
2
Check XYZ with One Call.c
3
BE CAREFUL with accels, you must pass the addresses of the variables
4
you want it to store tilt/acceleration measurements in, not the values.
5
In other words, use &x, &y, &z, not x, y, z.
6
*/
7
8
#include "
simpletools.h
"
// Include simpletools library
9
#include "
badgetools.h
"
// Include badgetools library
10
11
int
x
, y, z;
// Axis variables
12
13
void
main
()
// Main function
14
{
15
badge_setup
();
// Call badge setup
16
oledprint
(
" 3-Axis "
);
17
text_size
(
SMALL
);
18
19
while
(1)
// Main loop
20
{
21
accels
(&
x
, &y, &z);
// Get all 3 acceleration/tilts
22
23
cursor
(5, 4);
// Display all 3 values
24
oledprint
(
"x = %3d "
,
x
);
25
cursor
(5, 5);
26
oledprint
(
"y = %3d "
, y);
27
cursor
(5, 6);
28
oledprint
(
"z = %3d "
, z);
29
pause
(100);
30
31
pause
(20);
32
}
33
}
34
35
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
x
int x
Definition:
07 Box and Lines.c:13
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
text_size
void text_size(int size)
Set the text size to either 32x16 pixel (LARGE) or 7x5 (SMALL) characters. Examples: text_size(LARGE)...
Definition:
oled_text_size.c:7
SMALL
#define SMALL
For setting oLED character size to 7x5 pixels. Example: text_size(SMALL).
Definition:
badgetools.h:200
accels
void accels(int *x, int *y, int *z)
Measures acceleration and tilt on all 3 axes (x, y, and z) in terms of centigravity (cg) units,...
Definition:
accelerometer.c:56
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17