PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
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
LARGE
#define LARGE
For setting oLED character size to 32x16 pixels. Example: text_size(LARGE).
Definition:
badgetools.h:192
clear
int clear(void)
Clear the display.
Definition:
oled_clear.c:7
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
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
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
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....
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
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17