PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Badge
05 EEPROM Data Storage
04 Avoid Repeats.c
1
/*
2
Avoid Repeats.c
3
The previous example program allows you to store the same information
4
to EEPROM repeatedly. If you'd prefer to have your program check before
5
saving the data, use if(!stored...). Here's an example. Remember to
6
use SimpleIDE's Run with Terminal button to view the results.
7
8
You have already saved wilma and betty to EEPROM with the previous program.
9
If this program did not use the if(!stored...) statements, you would end up
10
with 6 contacts instead of just four.
11
*/
12
13
#include "
simpletools.h
"
// Include simpletools library
14
#include "
badgetools.h
"
// Include badgetools library
15
16
// badge num name
17
char
fred[] = {
"123\n Fred\n"
};
18
char
wilma[] = {
"456\n Wilma\n"
};
19
char
barney[] = {
"789\n Barney\n"
};
20
char
betty[] = {
"147\n Betty\n"
};
21
22
char
their[16];
// Array for retrieved strings
23
24
void
main
()
// Main function
25
{
26
badge_setup
();
// Call badge setup
27
text_size
(
SMALL
);
28
oledprint
(
"Use SimpleIDE\nTerminal."
);
29
30
if
(!
stored
(wilma))
// Check first, if repeat skip
31
store
(wilma);
32
if
(!
stored
(betty))
33
store
(betty);
34
if
(!
stored
(fred))
// ...but if not repeat, store
35
store
(fred);
36
if
(!
stored
(barney))
37
store
(barney);
38
39
contacts_displayAll
();
// Display contacts
40
}
contacts_displayAll
void contacts_displayAll()
Display all contacts in SimpleIDE Terminal.
Definition:
peb_contacts_displayAll.c:12
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
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.
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
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
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17