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
03 Buttons
03 Check All Buttons.c
1
/*
2
Check All Buttons.c
3
A variable with binary digits can store the bit pattern returned by
4
the buttons function. The leftmost bit-6 is the state of the OSH button.
5
Pay close attention to the relationship of the 1's on the screen and the
6
buttons you are pressing.
7
*/
8
9
#include "simpletools.h"
// Include simpletools library
10
#include "
badgetools.h
"
// Include badgetools library
11
12
int
states;
// For all button states
13
14
void
main
()
// Main function
15
{
16
badge_setup
();
// Call badge setup
17
18
oledprint
(
"BUTTONS"
);
// Large display heading
19
text_size
(
SMALL
);
// Switch to small text
20
cursor
(0, 4);
// Small cursor row 4
21
oledprint
(
"PAD: 6543210"
);
// Display bit index
22
cursor
(0, 5);
// Next line
23
oledprint
(
"STATE:"
);
// Display state
24
cursor
(0, 7);
// Next line
25
oledprint
(
"EXIT: Press OSH"
);
// User prompt to exit
26
27
while
(1)
// States loop
28
{
29
states =
buttons
();
// Load buttons output to states
30
leds
(states);
// Light up corresponding LEDs
31
32
cursor
(7, 5);
// Position cursor
33
oledprint
(
"%07b"
, states);
// Display states as binary number
34
if
(states == 0b1000000)
break
;
// If OSH pressed, exit loop
35
}
36
37
pause(400);
// Wait for 4/10 s
38
39
text_size
(
LARGE
);
// Large text
40
clear
();
// Clear display
41
oledprint
(
"ALL DONE"
);
// Done message
42
}
43
44
buttons
int buttons(void)
Gets the states of all seven touch buttons, and returns them in a value with 1s and 0s that correspon...
Definition:
jm_touchpads.c:90
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
clear
int clear(void)
Clear the display.
Definition:
oled_clear.c:7
LARGE
#define LARGE
For setting oLED character size to 32x16 pixels. Example: text_size(LARGE).
Definition:
badgetools.h:192
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
leds
void leds(int bits)
Sets the on/off states of the 6 blue LEDs with a number that contains six binary 1/0 digits...
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
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
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12