Difference between revisions of "F21: Juvenile Jumpers"
Proj user6 (talk | contribs) (→Conclusion) |
Proj user6 (talk | contribs) (→References) |
||
Line 528: | Line 528: | ||
* [https://gitlab.com/sourabgupta3/juvenilejumpers Gitlab link] | * [https://gitlab.com/sourabgupta3/juvenilejumpers Gitlab link] | ||
− | == References == | + | == '''References''' == |
=== Acknowledgement === | === Acknowledgement === | ||
We would like to sincerely thank Professor Preetpal Kang for designing such a fantastic course and for his continuous guidance and support throughout the implementation of this project. Further, we would like to thank the ISA team for their advice. | We would like to sincerely thank Professor Preetpal Kang for designing such a fantastic course and for his continuous guidance and support throughout the implementation of this project. Further, we would like to thank the ISA team for their advice. |
Revision as of 21:04, 17 December 2021
Contents
JUVENILE JUMPERS
ABSTRACT
Juvenile Jumper is a single player, endless platform game in which there are enemies and obstacles on various platforms. The doodle is a four-legged creature and has a trunk that he uses to shoot at enemies. The objective of the game is to go as high as you can without falling while avoiding/killing monsters and random obstacles. After each level, the difficulty of the game increases with more enemies and obstacles.
OBJECTIVES & INTRODUCTION
The idea is to build the doodle jump game on a 64x64 RGB LED Screen. The game is played using a joystick. The doodle keeps on jumping and its direction can be controlled using left and right control of the joystick, which can also be used in forward direction as gun to shoot the enemies. MP3 decoder is used for different sound effects in the background of game.
Team Members & Responsibilities
Ritika Beniwal
- MP3 decoder driver
- Game Logic
- PCB design verification
- WiKi page handling
Anuja Sapkal
- Joystick driver
- Game Logic
- PCB Schematic and Board Design
- WiKi page handling
Sourab Gupta
- LED driver
- Game Logic
- PCB design verification
- WiKi page handling
SCHEDULE
Week# | Start Date | End Date | Task | Status |
---|---|---|---|---|
1 |
|
|
|
|
2 |
|
|
|
|
3 |
|
|
|
|
4 |
|
|
|
|
5 |
|
|
|
|
6 |
|
|
|
|
7 |
|
|
|
|
8 |
|
|
|
|
8 |
|
|
|
|
9 |
|
|
|
|
PARTS LIST & COST
Item# | Part Name | Part Supplier | Quantity | Cost |
---|---|---|---|---|
1 |
64x64 RGB LED Matrix |
1 |
$ 87.4 | |
2 |
Sjtwo board |
1 |
$ 50 | |
3 |
Two-axis Joystick |
1 |
$ 4.25 | |
4 |
MP3 Decoder |
1 |
$ 8.05 | |
5 |
Power Supply |
1 |
$ 7.99 | |
6 |
PCB |
5 |
$14.21 |
HARDWARE DESIGN
The game has been designed using SJtwo-c board, RGB LED- for visuals, MP3 decoder- for background music, joystick and PCB. The game is controlled by using a two-axis joystick and to play the music we have used an MP3 decoder.
Printed Circuit Board
All the essential hardware is retained using a printed circuit board. For this game, we have designed a two-layer PCB and the schematic & layout is designed using Autodesk's Eagle software. The PCB fabrication vendor is JLCPCB.
PIN Configuration
PIN number | Pin Description | SJTwo Board Pin |
---|---|---|
LED Matrix | ||
R1 | Upper half (Section 1) | p2_0 |
G1 | Upper half (Section 1) | p2_1 |
B1 | Upper half (Section 1) | p2_2 |
R2 | Lower half (Section 2) | p2_4 |
G2 | Lower half (Section 2) | p2_5 |
B2 | Lower half (Section 2) | p2_6 |
A | Address Line | p2_7 |
B | Address Line | p2_8 |
C | Address Line | p2_9 |
D | Address Line | p0_16 |
E | Address Line | p0_15 |
GND | Connected to ground | GND |
Clk | For upper half and lower half | p1_28 |
Latch | For upper half and lower half | p1_23 |
OE | For upper half and lower half | p1_20 |
Joystick | ||
MP3 Decoder | ||
Power Supply | ||
Interfacing and Layout
LED Matrix
A 64x64 RGB LED Matrix, with a total of 4096 pixels is used for display. Each LED can be fully controlled independently using 13 digital GPIOs. This matrix has six 64-bit shift registers for R1, G1, B1 R2, G2, B2 where each color of the LED is controlled by one bit of the shift register. By combing RGB colors we can make different colors such as YELLOW, CYAN, RED, WHITE, MAGENTA.
Technical Specifications
Specification | Remarks |
---|---|
Pitch | 3 mm |
Resolution | 64x64 =4096 pixels |
Volt/Amp | 5V/60A |
Scan Rate | 1/16 |
LED Matrix Panel
Dual Axis Joystick
We have used 2-axis joystick to control the movements of the jumper. The joystick operates on 5V power and provides analog output, hence it is connected to the ADC pins of SJtwo-c board. X-axis values are used to define the left and right directions of the doodle. The switch on the joystick controls the start and stop actions of the game.
MP3 Decoder
The MP3 decoder that we used is serial MP3 player model by Catalex (version v1.0.1). It's a simple MP3 player device which is based on a high-quality MP3 audio chip---YX5300. It can support 8k Hz ~ 48k Hz sampling frequency MP3 and WAV file formats. There is a TF card socket on board, so you can plug the micro SD card that stores audio files. MCU can control the MP3 playback state by sending commands to the module via UART port, such as switch songs, change the volume and play mode and so on.
SOFTWARE DESIGN
This game has two levels. Following is the overview of a game play.
1. Level_1:
- In the first level, the jumper needs to jump on the tiles. Some tiles have an additional spring and if the jumper lands on the spring, the jumper will jump much higher than it generally would on landing on the standard tiles.
- With each jump to the next level the score gets incremented by 10 and appropriate music is played
- After jumping on the next level the background screen and the jumper are shifted down to the bottom most position
- The jumper again starts to jump from this position
- If while coming down, the jumper is not able to find a tile to land on the game is finished
- If the score is more than 150 then the second level will begin.
2. Level_2:
- This level adds some difficulty to the game. This level move adds enemies to the game.
- Jumper has a gun functionality. By using a gun jumper can kill the enemy.
- If the jumper collides with the enemy game will be over.
- Rest all stays like Level 1
There is a total of five tasks involved in this game in order to ensure full functionality.
1. Start and stop task:
- This task displays the game's start screen. To start the game player need to press the onboard switch on the joystick.
- After the game is finished, if the player presses the button again, the game would start again. This is also handled by this task.
2. Background task:
- This task creates background tiles for the jumper to jump on.
- It keeps on refreshing the led_matrix frame buffer with background data buffer.
3. Game logic task:
- When the game starts this task detects the jumper's initial position and starts jumping up.
- Jumper will start going down after reaching a certain height.
- It checks for the collision with tiles. If a collision is not detected then the jumper will keep going down.
- If a collision is detected then it shifts the background screen and jumpers down.
- It will update the score and check the level.
- If the score is more than 150, it will start level 2 of the game.
4 LED Matrix task:
- This task keeps displaying frame data every 1ms.
- This is a high-priority task.
5 Enemy tasks:
- This task creates enemies at a random position.
- It moves enemies from column 0 to 63
6 Gun Task:
- This task keeps on monitoring the joystick data for Y-axis
- If this task detects a y-axis value greater than 4000, a gun will be shot.
Implementation
LED Driver
A 64*64 led matrix is used for this project. The led matrix is divided into two halves of 32*64 each. It has 3 R,G,B pins and 3 64-bits registers (shift registers) for each upper and lower halves. The address lines provided are 5. This means that at a time same row from the upper half and the lower half will be selected. So in order to display a particular row appropriate row should be selected and appropriate data needs to be fed to the RGB shift registers of both top and bottom halves. LED matrix is initialized by configuring the required pins as output. The led matrix has 3 more pins enable which are essential to display a pixel on the matrix. The clk pin that should used as a clk to the shift registers to shift the data out, the latch pin is used to latch the data from the shift registers onto the matrix's buffer, the output enable pin that is used to display the latched data on the selected row.
- Before feeding matrix data disable Output Enable (OE) GPIO
- Set bits on A, B, C, D GPIO pins to select the particular row.
- Loop through the pixels (columns) in the selected row and set the pixel color on R, G, B GPIO pins
- To mask that particular pixel set zero on R, G, B GPIO pins
- Set and Reset the clock for pushing the R, G, B bits for each column
- Issue latch to mark the row's completion
- Set OE
- Small delay
- Reset latch before going to next row
MP3 Decoder
- mp3 music changes according to the state of the game.
- To get the game state sound flags are checked.
- Music is placed in the file so need to find the respective file.
- Open the mp3 file.
- Read the contents of the file.
Code snippet for MP3:
void mp3_play_sound(int num) { mp3__send_command(PLAY_FILE_WITH_FOLDER, 0x01, num); }
void mp3_play_jump_up_sound() {
mp3_play_sound(2);
vTaskDelay(50);
}
Joystick
- Initialized the ADC Peripheral
- Set the appropriate pin functionality using the IOCON registers.
- Set the ADC pin functionality as input.
- Select ADC channels to read.
- Enable burst mode for a fast conversion.
Code snippet for Joystick:
void initialize_joystick() {
enable_joystick(GPIO__PORT_0, 25, GPIO__PORT_1, 30, GPIO__PORT_1, 31);
button_press = p1;
}
TESTING & TECHNICAL CHALLENGES
PCB Design
We struggled to get the dimensions of the power supply module to design the PCB as the exact module was not available in the library. We have selected the pin dimensions for the power supply module by referencing other pin headers and using a general approximation to make it work satisfactorily. Because of this, the PCB went through a lot of internal revisions. While testing hardware on the PCB for the first time we faced a problem related to ribbon cable. To solve this problem we just replace the ribbon cable but we spent too much time realizing the problem.
LED Matrix
1. Collision detection with tiles not working after the 32nd column. This is due to the variable was not typed cast to uint64_t.
2. The random number generator generates the same pattern and hence the tiles. Seeding just once with xTaskGetTickCount() did not generate randomness.
3. Led buffer overwrite due to collision leaves background screen in an inconsistent state. To resolve this issue keep refreshing the background screen in a task.
MP3 Decoder
Conclusion
We successfully designed the Juvenile Jumper game using the RGB LED Matrix and the SJ2 board. Implementing this project from scratch gave us more practical exposure in developing real-time embedded applications. This project helped us to better understand all the FreeRTOS APIs and their functioning. We learned about PCB design and various driver implementation.
Project Video
Project Source Code
References
Acknowledgement
We would like to sincerely thank Professor Preetpal Kang for designing such a fantastic course and for his continuous guidance and support throughout the implementation of this project. Further, we would like to thank the ISA team for their advice.