PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
peb_ir_send.c
1 #include "simpletools.h"
2 #include "badgetools.h"
3 
4 int send(char *s)
5 {
6  int len = 1 + strlen(s);
7  ir_send(s, len);
8  return len;
9 }
10 
11 void ir_send(char *s, int ssize)
12 {
13  int checksum = 0;
14  ircom_tx(STX);
15  pause(1);
16  for(int i = 0; i < ssize; i++)
17  {
18  ircom_tx(s[i]);
19  checksum += s[i];
20  pause(1);
21  }
22  ircom_tx(ETX);
23  pause(1);
24  checksum %= 256;
25  ircom_tx(checksum);
26  ircom_txflush();
27  pause(20);
28  //return len;
29 }
30 
31 /*
32  TERMS OF USE: MIT License
33 
34  Permission is hereby granted, free of charge, to any person obtaining a
35  copy of this software and associated documentation files (the "Software"),
36  to deal in the Software without restriction, including without limitation
37  the rights to use, copy, modify, merge, publish, distribute, sublicense,
38  and/or sell copies of the Software, and to permit persons to whom the
39  Software is furnished to do so, subject to the following conditions:
40 
41  The above copyright notice and this permission notice shall be included in
42  all copies or substantial portions of the Software.
43 
44  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
47  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
48  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
49  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
50  DEALINGS IN THE SOFTWARE.
51 */
52 
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition: libws2812.c:125
send
int send(char *s)
Send a character string to another badge. Example: char s[] = "Hello other badge"; send(s);.
Definition: peb_ir_send.c:4
ir_send
void ir_send(char *s, int ssize)
Transmits a string with a specified number of characters over IR.
Definition: peb_ir_send.c:11
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.