PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Devices
Memory
EEPROM Progam Modes.c
1
/*
2
EEPROM Program Modes.c
3
4
Use EEPROM to advance modes with each press/release of the reset button.
5
Also advances with each power-off, power-on cycle.
6
7
IMPORTANT: Make sure to use SimpleIDE's Load EEPROM & Run button. The
8
program has to be in EEPROM first. After that, you can optionally use
9
the Run with Terminal button to view the print output.
10
11
http://learn.parallax.com/propeller-c-tutorials
12
*/
13
14
#include "
simpletools.h
"
// Include simpletools header .
15
16
int
main
(
void
)
// main function code starts here
17
{
18
int
addr = 32768;
// Lowest user EEPROM address
19
char
mode =
ee_get_byte
(addr);
// Value at address 32768 -> mode
20
mode += 1;
// Add one
21
mode %= 3;
// Modulus (remainder of mode / 3)
22
ee_put_byte
(mode, addr);
// New mode -> EEPROM addr 32768
23
24
print
(
"Startup mode = %d \n"
, mode);
// Display mode
25
26
switch
(mode)
// Decide how the program behaves
27
{
28
case
0:
// If mode == 0, P26 light on
29
high
(26);
30
break
;
31
case
1:
// If mode == 1, P27 light on
32
high
(27);
33
break
;
34
case
2:
35
high
(26);
// If mode == 2, both lights on
36
high
(27);
37
break
;
38
}
39
40
while
(1);
// Keep light(s) on
41
}
ee_put_byte
#define ee_put_byte
ee_put_byte renamed ee_putByte.
Definition:
simpletools.h:477
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
ee_get_byte
#define ee_get_byte
ee_get_byte renamed ee_getByte.
Definition:
simpletools.h:483
main
int main(void)
Definition:
GraphicsTest.c:20
high
void high(int pin)
Set an I/O pin to output-high.
Definition:
high.c:19
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17