PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Badge
03 Buttons
00 Check One Button.c
1
/*
2
Check One Button.c
3
Displays the state of button 0, the button adjacent to the P27 label.
4
The button function returns 1 if pressed, or 0 if not pressed. The
5
button(index) function also has 0 to 6 options. 0 to 5 are are the
6
same as the LEDs, from top-right clockwise. Button 6 is the OSH
7
button just below the screen.
8
*/
9
10
#include "
simpletools.h
"
// Include simpletools library
11
#include "
badgetools.h
"
// Include badgetools library
12
13
int
state27;
14
15
void
main
()
// Main function
16
{
17
badge_setup
();
// Call badge setup
18
while
(1)
// Main loop
19
{
20
state27 =
button
(0);
// Check button 0 (by P27)
21
22
cursor
(0, 0);
// Cursor -> top-left
23
oledprint
(
"P27 = %d"
, state27);
// Display label, state
24
25
if
(state27 == 1)
// If pressed
26
{
27
led
(0,
ON
);
// Adjacent light on
28
}
29
else
// If not pressed
30
{
31
led
(0,
OFF
);
// Adjacent light off
32
}
33
}
34
}
35
36
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