Implementation Notes


Raycasted Maze Implementation Logic

To implement our maze, we made a programmable array into a 2D maze and made it appear in psuedo-3D projection by tracing rays from the point of view. The map is just a simple 2d array, and change the value from a 0 to a non-negative integer creates a block of a certain color. The 2d array simplifies a lot of calculations, specifically with hit detection, making it fast to run on any kind of processor. Given a field of view, rays are casted from the player until a wall is hit. For every direction the ray is cast, a corresponding line is drawn on the screen. The distance a wall is from a player is the inverse of the height of the corresponding line drawn on the screen.

SPI Implementation Logic

To begin a SPI connection with the LCD screen we needed to find the correct expansion pin in the LPC Development Board. Using the LPC User Guide and the LPC schematic PDF we were able to find the pins associated with the extension. Figure 1a and Figure 1b show relevant diagrams that we used in determining what pins we needed to use. For the LCD screen we needed a few addition pins; Reset and D/C . These pins were set by picking open GPIO pins and manually giving them a '0' or '1' bit value, this process was also done for setting the LCD CS pin.

Once we got the pins working properly, we then looked at the driver chip of the LCD screen. There was lots of useful information on this document and figures 2,3,5,6 and 7 are some screenshots of useful information involving a serial 4-line connection with the driver. For a SPI connection, the LCD screen needed to be first reset. This is done by having the reset pin high then lowering it then keeping the signal high. The D/C pin is used to differentiate from either a command or a data transmission. For example, to write a command the D/C pin needs to be set to zero, to write data the pin needs to be set to '1.' Lastly the LCD CS pin is maintained high then lowered when a frame is sent to the driver.

To test that a command was sent properly, we tried to send a sleep command which would turn off the display. Unfortunately we encountered a major roadblock in this part of our project. The screen would not respond to the commands we sent it and debugging the code was difficult. We tried to backwards engineer the Arduino code and driver that came with the LCD screen, but we eventually came to a function that was specific to the Arduino code. We also got some of example code from the T.A.'s since they didn't know how to help us too much, but we still couldn't get it working. The main issue we was getting the LCD to respond to a single command, since we were unable to send a command we were also unable to write any pixel values.

Joystick Implementation

To get the on board joy stick to work we first looked at the port and pin numbers that the joystick was associated with. The LPC user guide provided this information and we modified an example code that used a switch to trigger an interrupt. We got the joystick to work by setting an interrupt on every direction that the joystick could move to; up, down, left and right. To confirm that it works, we had our program print to the console the direction of the joystick whenever an interrupt was triggered.

Relevant Figures

Figure 1a.

This is the Serial Expansion Connector we used to connect the LCD to.

Figure 1b.

More in Depth info on the Serial Expansion Connector Pins.


Figure 2.

Serial Interface for connecting the micro-controller with the driver on the LCD screen.

Figure 3.

Write Cycle Sequence for LCD.


Figure 4.

Some Specifications for the micro-controller.

Figure 5.

Info on data and command signals.


Figure 6.

Various important signal diagrams needed for manual adjustment.

Figure 7.

Schematic for LCD.


Figure 8a.

Some of the given example code on Arduino to send commands to the LCD.

Figure 8b.

An extension of the example code.


Figure 9a.

SPI ports in the LCD screen

Figure 9b.

An example of a functioning LCD screen