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
06 Infrared Data
02 Receive and Store IR Strings.c
1
/*
2
Receive Strings with IR.c
3
For receiving IR strings, use the receive function. 128 is your
4
maxiumum buffer size.
5
*/
6
7
#include "simpletools.h"
// Include simpletools library
8
#include "
badgetools.h
"
// Include badgetools library
9
10
char
irbuf[128];
// Receive buffer
11
int
irlen, states, exist;
// IR, button and EEPROM status
12
13
void
main
()
// Main function
14
{
15
badge_setup
();
// Call badge setup
16
while
(1)
17
{
18
clear
();
// Menu
19
text_size
(
LARGE
);
20
oledprint
(
" IR Rcv "
);
21
text_size
(
SMALL
);
22
cursor
(0, 5);
23
oledprint
(
" Receive-P27\n"
);
24
oledprint
(
"P15-Upload "
);
25
text_size
(
LARGE
);
26
27
while
(1)
// Wait for button press
28
{
29
states =
buttons
();
30
if
(states)
break
;
31
}
32
33
if
(states == 0b0001000)
// If P15, upload contacts
34
{
35
clear
();
36
oledprint
(
"Upload ..."
);
37
contacts_displayAll
();
38
oledprint
(
"Done"
);
39
pause(250);
40
continue
;
// Back to while(1)
41
}
42
if
(states != 0b0000001)
// Not P27?, try again
43
{
44
cursor
(0, 0);
45
text_size
(
LARGE
);
46
oledprint
(
" Try Again "
);
47
pause(1000);
48
continue
;
// Back to while(1)
49
}
50
51
// P27 has to have been pressed to get to here
52
clear
();
53
oledprint
(
"Ready for IR "
);
// Display ready for IR
54
55
// Wait for IR message
56
irclear
();
// Clear ir com buffers
57
while
(1)
58
{
59
irlen =
receive
(irbuf);
// Check for incoming IR
60
if
(irlen > 0)
// Yes? Break from while loop
61
{
62
break
;
63
}
64
}
65
66
clear
();
// Menu, what to do with data
67
text_size
(
SMALL
);
68
oledprint
(irbuf);
69
cursor
(0, 5);
70
oledprint
(
" Store-P26"
);
71
cursor
(0, 6);
72
oledprint
(
" Discard-P25"
);
73
74
while
((states =
buttons
()) == 0);
// Wait for button press
75
76
text_size
(
LARGE
);
77
clear
();
78
if
(states == 0b0000010)
// If P26, store to EEPROM
79
{
80
if
(!
stored
(irbuf))
store
(irbuf);
81
oledprint
(
"Stored"
);
82
}
83
if
(states == 0b0000100)
// if(P25), discard
84
{
85
oledprint
(
"Discard"
);
86
}
87
pause(500);
// Pause before repeat
88
}
89
}
90
91
contacts_displayAll
void contacts_displayAll()
Display all contacts in SimpleIDE Terminal.
Definition:
peb_contacts_displayAll.c:12
store
int store(char *contact)
Store a character string of up to 128 characters to EEPROM. Example: char s[] = "abcd"; store(s);...
Definition:
peb_store.c:12
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
irclear
void irclear(void)
Clear the infrared send/receive buffers. The most common use of this function is to clear any stray m...
Definition:
peb_irclear.c:4
LARGE
#define LARGE
For setting oLED character size to 32x16 pixels. Example: text_size(LARGE).
Definition:
badgetools.h:192
stored
int stored(char *s)
Check if a string has already been stored in EEPROM. Example: if(!stored("abcd")) store("abcd");...
Definition:
peb_already_stored.c:12
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
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
receive
int receive(char *s)
Receive a character string from another badge.
Definition:
peb_ir_receive.c:6
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12