XY Coordinates

XY Function

In order to address a two dimensional array we decided to make what was effectively a table of arrays which, when given a row and column index, would return the address of the byte in question. To implement this each row’s ByteArray was first created, as these are functions and consume a value from the stack, only the function’s address was stored in a table with each index corresponding to the row number of the associated data (e.g. row5 Array is 5 Row ).

This function is labelled XY as it is expecting the column byte number to be entered first, then the row number before execution of the function. The row number is then consumed first by the function to return the address of the corresponding row array of columns, as the row array function’s address is executed it will consume the corresponding column index and return that byte’s address to the stack.

When setting up the data arrays, one byte on each side of the visible screen and one row above and below were added to allow for metadata and/or staging/scrolling.


\ -Sets Up an XY Byte Address System, X 1->4 and Y 1->16 are displayed--\
6 ByteArray Row0
6 ByteArray Row1
6 ByteArray Row2
6 ByteArray Row3
6 ByteArray Row4
6 ByteArray Row5
6 ByteArray Row6
6 ByteArray Row7
6 ByteArray Row8
6 ByteArray Row9
6 ByteArray Row10
6 ByteArray Row11
6 ByteArray Row12
6 ByteArray Row13
6 ByteArray Row14
6 ByteArray Row15
6 ByteArray Row16
6 ByteArray Row17

\ Stores the address of the Row word array word \
Table Row ' Row0 , ' Row1 , ' Row2 , ' Row3 , ' Row4 , ' Row5 , ' Row6 , ' Row7 , ' Row8 , ' Row9 , ' Row10 , ' Row11 , ' Row12 , ' Row13 , ' Row14 , ' Row15 , ' Row16 , ' Row17 ,

\ Takes the byte of interest 0->5 and Row number 0->17 and returns  memory address of CHARACTER \
: XY ( byte row -- ByteAddr ) Row execute ;

Screen Display Functions

In order to allow development of the screen utilization before the dot matrix display was interfaced with the micro controller two functions were created the current values in memory to the developer.

These functions share very similar code, essentially each turns a byte in to its bit components and emits those to the screen.

ByteShow returns the binary values of the byte given whereas Byte2Char returns a series of hashes and/or spaces dependant upon the binary values found.

Display utilises the ByteShow function to draw a representation of the all values stored and a box around the visible screen; DisplayClean returns the same data as Display in the style of Byte2Char.


: ByteShow ( n -- ) 2 /mod 2 /mod 2 /mod 2 /mod 2 /mod 2 /mod 2 /mod . . . . . . . . ;

: Byte2Char ( n -- ) 2 /mod 2 /mod 2 /mod 2 /mod 2 /mod 2 /mod 2 /mod 8 0 DO IF 35 ELSE 32 THEN emit ."  " LOOP ;

: Display ( Displays All Matrix Data in Binary ) CR
." ---=== Inside the box is the data to be loaded to the Panel, Columns 1 to 4 and Rows 1 to 16 ===---" CR
#0 #0 XY C@ ByteShow ."   " #5 #1 DO i #0 XY C@ ByteShow LOOP ."   " #5 #0 XY C@ ByteShow CR
."                 /-----------------------------------------------------------------\" CR
#17 #1 DO #0 i XY c@ ByteShow ." | " #5 #1 DO i j XY c@ ByteShow LOOP ." | " #5 i XY c@ ByteShow CR LOOP
."                 \-----------------------------------------------------------------/" CR
#0 #17 XY C@ ByteShow ."   " #5 #1 DO i #17 XY c@ ByteShow LOOP ."   " #5 #17 XY C@ ByteShow CR ;


: DisplayClean ( Displays All Matrix Data in Binary Star ) CR
." ---=== Inside the box is the data to be loaded to the Panel, Columns 1 to 4 and Rows 1 to 16 ===---" CR
#0 #0 XY C@ Byte2Char ."   " #5 #1 DO i #0 XY C@ Byte2Char LOOP ."   " #5 #0 XY C@ Byte2Char CR
."                 /-----------------------------------------------------------------\" CR
#17 #1 DO #0 i XY c@ Byte2Char ." | " #5 #1 DO i j XY c@ Byte2Char LOOP ." | " #5 i XY c@ Byte2Char CR LOOP
."                 \-----------------------------------------------------------------/" CR
#0 #17 XY C@ Byte2Char ."   " #5 #1 DO i #17 XY c@ Byte2Char LOOP ."   " #5 #17 XY C@ Byte2Char CR ;

Display Function Example


---=== Inside the box is the data to be loaded to the Panel, Columns 1 to 4 and Rows 1 to 16 ===---
0 0 0 0 0 0 0 0   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0   0 0 0 0 0 0 0 0
                /-----------------------------------------------------------------\
0 0 0 0 0 0 0 0 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | 0 0 0 0 0 0 0 0
0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 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 | 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 | 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 | 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 | 0 0 0 0 0 0 0 0
                \-----------------------------------------------------------------/
0 0 0 0 0 0 0 0   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0   0 0 0 0 0 0 0 0

DisplayClean Function Example

---=== Inside the box is the data to be loaded to the Panel, Columns 1 to 4 and Rows 1 to 16 ===---

                /-----------------------------------------------------------------\
                | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
                | #                                                             # |
                | #                                 # #                         # |
                | #                               # #   #                       # |
                | #                   # #         # # # # #                     # |
                | #                   # # # #       # #                         # |
                | #                     # # # # # # # #                         # |
                | #                     # # # # # # # # #                       # |
                | #                     # # # # # # # # #                       # |
                | #                       # # # # # # #                         # |
                | #                       # # # # # # #                         # |
                | #                         # # # # #                           # |
                | #                         # # # #                             # |
                | #                             #                               # |
                | #                           #   #                             # |
                | # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # |
                \-----------------------------------------------------------------/

Each display style was found to be useful in different development scenarios for viewing and/or debugging the data to be displayed.