PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
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
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
rotate180
void rotate180()
Rotate the screen image 180 degrees. See 05 Display Upside- Down.side for example.
Definition:
peb_image180.c:6
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.
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
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:204
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17