Search form

Main Menu

More Display Fun

You can make large, predefined lists with DAT blocks. You will see numerous applications of this in the lessons. This first application is simply storing some character art.

Open “7 More Display Fun.spin”, load it into the Propeller chip with F11, and click the Parallax Serial Terminal’s Enable button to view the output.

How it Works

Unlike the String operator, which stores a list of characters in program memory, the DAT block is more like a pre-defined variable array. The values are loaded into RAM, and can even be modified while the program is running, much like an array.

Remember that the Parallax Serial Terminal Plus object’s Str method’s stringptr parameter expects the memory address of a zero-terminated string. Take a look at the last value in the DAT block, it’s zero. Also, take a look at the pst.Str call. It’s pst.Str(@Win). The @ opereator in @Win gives the Str method the memory address of the first byte (a space character) at the beginning of the rows of characters. So, the Str method does its job of fetching and transmitting characters until it runs into that zero at the end of the list.

Did you know? The 13 character code makes the Parallax Serial Terminal’s cursor jump to the beginning of the next line.

Your Turn

You can also treat DAT blocks like arrays. For example, here is a loop that sends each character in the DAT block, one at a time.

Save the program as 7a Send Characters.spin.

Add the variable i to the list of long variables in the VAR block. It should read long x, y, i.