122-28029 Parallax Inc, 122-28029 Datasheet - Page 184

GUIDE STUDENT SMART SENSORS

122-28029

Manufacturer Part Number
122-28029
Description
GUIDE STUDENT SMART SENSORS
Manufacturer
Parallax Inc
Datasheet

Specifications of 122-28029

Accessory Type
Manual
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
Smart Sensors
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
Page 172 · Smart Sensors and Applications
For example, where the axes of the graph intersect at coordinates (0, 0) is actually
CRSRXY
program we would like to be able to type “-3-3” in to the Debug Terminal and have the
asterisk appear at graph coordinate (-3, -3), which would be
another example, when you type in 2,2,
10,1. Now, it’s time to figure out how to do this mapping translation using scale and
offset.
For values ranging from -3 to 3, the X value has to be multiplied by 2 and added to 6 for
CRSRXY
offset of 6. Here is a PBASIC statement to make the conversion from X coordinate to
number of spaces.
The Y value has to be multiplied by -1, then added to 3. That’s a scale of -1 and an offset
of 3. Here is a PBASIC statement to make the conversion from Y coordinate to number
of carriage returns.
Example Program – PlotXYGraph.bs2
' Smart Sensors and Applications – PlotXYGraph.bs2
' Position cursor on plot interactively in Debug Terminal
'{$STAMP BS2}
'{$PBASIC 2.5}
x
y
temp
position 6,3. (Compare this with Figure 5-2 until you see how this is so.) For this
to place the asterisk the right number of spaces over. That’s a scale of 2, and an
x = (x * 2) + 6
y = 3 - y
Try substituting X and Y coordinates in the right side of each of these equations,
do the math, and verify that each equation yields the right number of spaces and
carriage returns.
Enter and run PlotXYGraph.bs2.
Try entering the sequence of values: -3-3, -2-2, -1-1, 00, 11, 22, 33, and verify
that it matches the Debug Terminal example in Figure 5-3.
Try some other sequences and/or drawing shapes by their coordinates.
VAR
VAR
VAR
Word
Word
Byte
CRSRXY
actually needs to position the asterisk at
CRSRXY
position 0,6. As

Related parts for 122-28029