Parallax Boe-Bot Student Manual page 167

Hide thumbs Also See for Boe-Bot:
Table of Contents

Advertisement

Example Program – EepromNavigationWithWordValues.bs2
This next example program looks complicated at first, but it is a very efficient way to
design programs for custom Boe-Bot choreography. This example program uses
EEPROM data storage, but does not use subroutines. Instead, a single code block is
used, with variables in place of the
arguments.
By default, the
directive stores bytes of information in EEPROM. To store word-
DATA
sized data items, you can add the
item in your string. Each word-sized data item will use two bytes of EEPROM storage,
so the data will be accessed via every other address location. When using more than one
directive, it is most convenient to assign a label to each one. This way, your
DATA
commands can refer to the label to retrieve data items without you having to figure out at
which EEPROM address each string of data items begins.
snippet:
' addressOffset
Pulses_Count DATA Word 64,
Pulses_Left
Pulses_Right DATA Word 650, Word 650, Word 850, Word 850
Each of the three
DATA
before each data item, and the items are separated by commas. These three strings of
data will be stored in EEPROM one after another. We don't have to do the math to
figure out the address number of a given data item, because the labels and the
variable will do that automatically. The
addressOffset
to determine the EEPROM address where that string begins, and then adds the value of
the
variable to know how many address numbers to shift over to find the
addressOffset
correct
. The
DataItem
command's
READ
Variable
the variable that stores the value fetched from EEPROM.
DO
READ Pulses_Count + addressOffset, Word pulseCount
READ Pulses_Left + addressOffset, Word pulseLeft
READ Pulses_Right + addressOffset, Word pulseRight
addressOffset = addressOffset + 2
' PBASIC code block omitted here.
...
loop's
FOR
NEXT
modifier to the
Word
0
2
Word 24,
DATA Word 850, Word 650, Word 850, Word 650
statements begins with its own label. The
found at the resulting
DataItem
argument. Notice that the
Chapter 4: Boe-Bot Navigation · Page 153
and
EndValue
PULSOUT Duration
directive, before each data
DATA
Take a look at this code
4
6
Word 24,
Word 64, Word 0
modifier goes
Word
command uses each label
READ
will be stored in the
Address
modifier also comes before
Word
READ
8

Advertisement

Table of Contents
loading

Table of Contents