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
05 Flip Text if Upside Down.c
1
/*
2
Flip Text if Upside Down.c
3
Detect when tilted upside-down and rotate the screen 180 for viewing.
4
Screen auto-update is disabled since writing text and rotating it is two
5
steps, but the final result is all that should be visible.
6
*/
7
8
#include "simpletools.h"
// Include simpletools library
9
#include "
badgetools.h
"
// Include badgetools library
10
11
int
y;
// Y-axis variable
12
13
void
main
()
// Main function
14
{
15
badge_setup
();
// Call badge setup
16
screen_auto
(
OFF
);
// Disable screen auto-update
17
while
(1)
// Main loop
18
{
19
y =
accel
(
AY
);
// Get y tilt
20
21
cursor
(0, 0);
// Start setting up display
22
oledprint
(
"y = %03d "
, y);
23
cursor
(0, 1);
24
oledprint
(
" "
, y);
25
26
if
(y < -40)
// If tilt < -40, rotate it
27
{
28
rotate180
();
29
}
30
31
screen_update
();
// Now copy screen buffer to screen
32
pause(20);
33
}
34
}
35
36
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
screen_update
int screen_update(void)
Manually update the screen image after. Typically used after multiple oLED function calls after scree...
Definition:
oled_asmfast.c:426
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
rotate180
void rotate180()
Rotate the screen image 180 degrees. See 05 Display Upside- Down.side for example.
Definition:
peb_image180.c:6
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
screen_auto
void screen_auto(int state)
Cause function calls like oledprint, point, and others to appear immediately after the function is ca...
Definition:
oled_auto.c:7
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
OFF
#define OFF
OFF can be used in place of zero to enabled parameters in functions like drive_feedback and drive_tri...
Definition:
abdrive.h:139
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12