PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Badge
03 Buttons
01 Check Two Buttons.c
1
/*
2
Check Two Buttons.c
3
Displays states of buttons by P27 (index = 0) and P25 (index = 2).
4
Uses those states to control adjacent LEDs.
5
*/
6
7
#include "
simpletools.h
"
// Include simpletools library
8
#include "
badgetools.h
"
// Include badgetools library
9
10
int
state27, state25;
// For storing button states
11
12
void
main
()
// Main function
13
{
14
badge_setup
();
// Call badge setup
15
while
(1)
// Main loop
16
{
17
state27 =
button
(0);
// Get button states
18
state25 =
button
(2);
19
20
cursor
(0, 0);
// Display button states
21
oledprint
(
"P27 = %d "
, state27);
22
oledprint
(
"P25 = %d "
, state25);
23
24
if
(state27 == 1)
// Control adjacent lights
25
{
26
led
(0,
ON
);
27
}
28
else
29
{
30
led
(0,
OFF
);
31
}
32
if
(state25 == 1)
33
{
34
led
(2,
ON
);
35
}
36
else
37
{
38
led
(2,
OFF
);
39
}
40
}
41
}
42
43
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,...
led
void led(int n, int state)
Set a blue LED (from 0 to 5) to a state (ON or OFF). Examples: led(1, ON) turns the blue LED next to ...
Definition:
leds_led.c:9
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
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.
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
ON
#define ON
ON can be used in place of a nonzero value to enabled parameters in functions like drive_feedback and...
Definition:
abdrive.h:212
button
int button(int pad)
Gets the state of a touch button (1) pressed, (0) not pressed. Numbering {6, 5, 4,...
Definition:
jm_touchpads.c:70
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17