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
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
}
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Sat Aug 27 2016 00:58:03 for PropWare by
1.8.12