PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
peb_already_stored.c
1 #include "simpletools.h"
2 #include "badgetools.h"
3 
4 int i2cLock;
5 volatile int eei2cLock;
6 volatile int eei2cLockFlag;
7 volatile int eeRecCount, eeNextAddr, eeBadgeOk,
8  eeNext, eeRecsAddr, eeRecs,
9  eeRecHome, eeRecOffice;
10 volatile int eeHome;
11 
12 int stored(char * s)
13 {
14  if(!eeBadgeOk) ee_badgeCheck();
15  int numRecs = contacts_count();
16  char buf[128];
17  //while(lockset(eei2cLock));
18  for(int i = 0; i < numRecs; i++)
19  {
20  retrieve(buf, i);
21  if(!strcmp(buf, s)) return 1;
22  }
23  //lockclr(eei2cLock);
24  return 0;
25 }
26 
27 /*
28  TERMS OF USE: MIT License
29 
30  Permission is hereby granted, free of charge, to any person obtaining a
31  copy of this software and associated documentation files (the "Software"),
32  to deal in the Software without restriction, including without limitation
33  the rights to use, copy, modify, merge, publish, distribute, sublicense,
34  and/or sell copies of the Software, and to permit persons to whom the
35  Software is furnished to do so, subject to the following conditions:
36 
37  The above copyright notice and this permission notice shall be included in
38  all copies or substantial portions of the Software.
39 
40  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
43  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
45  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
46  DEALINGS IN THE SOFTWARE.
47 */
48 
contacts_count
int contacts_count()
Find out how many contacts are currently stored in EEPROM. This is useful for setting up a loop to fe...
Definition: peb_contacts_count.c:11
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
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
retrieve
void retrieve(char *contact, int recIdx)
Copy string with a certain index number from EEPROM to a character array.
Definition: peb_retrieve.c:12
badgetools.h
This library provides convenient functions for a variety of Parallax eBadge operations.