Difference between revisions of "F24: Tilt Maze"
Proj user4 (talk | contribs) (→Hardware Interface) |
Proj user4 (talk | contribs) (→Implementation) |
||
Line 257: | Line 257: | ||
=== Implementation === | === Implementation === | ||
*LED Matrix Driver Functions: | *LED Matrix Driver Functions: | ||
− | **1. `matrix_init`: Initializes GPIO pins for the RGB LED matrix and sets up the synchronization mutex​ | + | **1. `matrix_init`: Initializes GPIO pins for the RGB LED matrix and sets up the synchronization mutex​ |
− | **2. `display_update`: Refreshes the LED matrix display to reflect any changes | + | **2. `display_update`: Refreshes the LED matrix display to reflect any changes |
− | **3. `display_clear`: Clears all active pixels on the matrix by setting them to zero | + | **3. `display_clear`: Clears all active pixels on the matrix by setting them to zero |
− | **4. `overwrite_pattern_to_screen`: Overwrites a specific pattern onto the LED matrix | + | **4. `overwrite_pattern_to_screen`: Overwrites a specific pattern onto the LED matrix |
− | * | + | **5. `append_pattern_to_screen`: Adds a pattern to the existing screen matrix without overwrite |
*Accelerometer Driver: | *Accelerometer Driver: | ||
− | **1. `accelerometer_init`: Configures the ADXL345 accelerometer with ±2g sensitivity and sets up I2C communication with semaphores for thread safety | + | **1. `accelerometer_init`: Configures the ADXL345 accelerometer with ±2g sensitivity and sets up I2C communication with semaphores for thread safety |
− | **2. `accelerometer_task`: Periodically reads acceleration data, applies smoothing, and updates player position based on tilt movements | + | **2. `accelerometer_task`: Periodically reads acceleration data, applies smoothing, and updates player position based on tilt movements |
*Maze Logic: | *Maze Logic: | ||
− | **1. `get_maze_layout`: Retrieves the maze pattern for the current level | + | **1. `get_maze_layout`: Retrieves the maze pattern for the current level |
− | **2. `is_wall_at`: Checks if a specific position in the maze contains a wall, used to constrain player movement | + | **2. `is_wall_at`: Checks if a specific position in the maze contains a wall, used to constrain player movement |
− | **3. `is_goal_at`: Determines if the player has reached the maze's goal position to proceed to the next level | + | **3. `is_goal_at`: Determines if the player has reached the maze's goal position to proceed to the next level{index=9}. |
*Game Logic: | *Game Logic: | ||
− | **1. `set_player_to_start`: Resets the player position to the starting point of the current level | + | **1. `set_player_to_start`: Resets the player position to the starting point of the current level |
− | **2. `handle_collisions`: Detects collisions with walls, traps, and goals, triggering state changes like `GAME_STATE_GAME_OVER` or `GAME_STATE_LEVEL_UP` | + | **2. `handle_collisions`: Detects collisions with walls, traps, and goals, triggering state changes like `GAME_STATE_GAME_OVER` or `GAME_STATE_LEVEL_UP` |
− | **3. `change_game_state`: Manages game states such as `GAME_STATE_TITLE`, `GAME_STATE_PLAYING`, and `GAME_STATE_WIN`, and handles music transitions | + | **3. `change_game_state`: Manages game states such as `GAME_STATE_TITLE`, `GAME_STATE_PLAYING`, and `GAME_STATE_WIN`, and handles music transitions |
*MP3 Decoder: | *MP3 Decoder: | ||
− | **1. `mp3_decoder__init`: Initializes the MP3 decoder, sets the default volume, and selects the storage device | + | **1. `mp3_decoder__init`: Initializes the MP3 decoder, sets the default volume, and selects the storage device |
− | **2. `mp3_decoder__play_song_at_index`: Plays a specific song based on its index in single-cycle mode | + | **2. `mp3_decoder__play_song_at_index`: Plays a specific song based on its index in single-cycle mode |
− | **3. `mp3_decoder__play_song_with_mode`: Allows playback in loop or single-cycle mode, depending on the game state | + | **3. `mp3_decoder__play_song_with_mode`: Allows playback in loop or single-cycle mode, depending on the game state |
− | **4. `mp3_decoder__stop_playback`: Stops any active song playback | + | **4. `mp3_decoder__stop_playback`: Stops any active song playback |
− | **5. `mp3_decoder__volume_set_level`: Adjusts the volume level of the MP3 decoder | + | **5. `mp3_decoder__volume_set_level`: Adjusts the volume level of the MP3 decoder |
== Testing & Technical Challenges == | == Testing & Technical Challenges == |
Revision as of 23:39, 19 December 2024
Contents
Project Title
Tilt Maze
Abstract
Tilt Maze is a motion-controlled puzzle game that challenges players to navigate a luminous ball through procedurally generated mazes using device tilting mechanics. Players must reach the exit within time constraints while maneuvering around obstacles and collecting power-ups that provide temporary advantages. The game combines physical device control with strategic gameplay elements, offering high replayability through its randomized level design and emphasizing skills in balance, spatial reasoning, and quick decision-making.
Objectives & Introduction
The Tilt Maze Game combines hardware and software to create an interactive puzzle experience. It uses an ADXL345 accelerometer for tilt-based movement control, navigating a character through a maze displayed on a 64x64 LED matrix. FreeRTOS manages concurrent tasks like accelerometer input, display updates, and game logic, ensuring smooth and responsive gameplay. Game states, collision detection, and immersive audio feedback via an MP3 decoder enhance the experience. Semaphores and mutexes ensure thread-safe resource management, while debug outputs provide insights during development. This project demonstrates advanced integration of peripherals and real-time systems in a cohesive gaming application.
Team Members & Responsibilities
- Shreya Belide
- Jyoshna Mallineni
- Pavan Charith
Schedule
Week# | Start Date | End Date | Task | Status |
---|---|---|---|---|
1 |
|
|
|
|
2 |
|
|
|
|
3 |
|
|
|
|
4 |
|
|
|
|
5 |
|
|
|
|
6 |
|
|
|
|
7 |
|
|
|
|
8 |
|
|
|
|
9 |
|
|
|
|
10 |
|
|
|
|
Parts List & Cost
Part | # | Cost | Source |
---|---|---|---|
SJ2 Board | 1 | $50.00 | Preet |
Sparkfun RGB (64x64) LED Matrix Display | 1 | $37.90 | Amazon |
Accerelometer | 1 | $10.99 | JLC PCB |
MP3 Decoder | 1 | $6.99 | JLC PCB |
5V/4A Power Adapter | 1 | $8.99 | Amazon |
12v DC Power Jack Adapter Connector | 1 | $10.90 | Amazon |
Packaging | 1 | $5.00 | Target |
Jumper Wires | 1 | $6.99 | Amazon |
Total Cost | $137.76 |
Design & Implementation
The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.
Hardware Design
Discuss your hardware design here. Show detailed schematics, and the interface here.
Hardware Interface
- LED Matrix Display: 13 GPIO channels on SJ2 microcontroller
- Accelerometer (ADXL345): I2C communication on SJ2 microcontroller (SCL, SDA)
- MP3 Decoder: SPI communication using MOSI, CS, SCK on SJ2 microcontroller
- Speaker: AUX cord for audio output
- Power Supply: 5V/4A adapter for powering the LED matrix and SJ2 microcontroller
Software Design
- LED Matrix:
- 1. Initialized LED matrix connected pins to board IOs.
- 2. Designed matrix driver for screen display by rendering maze patterns and player movements.
- Accelerometer:
- 1. Initialized I2C communication for ADXL345 accelerometer.
- 2. Configured accelerometer in measurement mode and set sensitivity to ±2g.
- 3. Processed tilt data to calculate real-time player movement commands.
- Mp3 Player:
- 1. Initialized using UART2.
- 2. Set the device to the selected SD card and configured volume level.
- 3. Played background music and sound effects based on game state.
Implementation
- LED Matrix Driver Functions:
- 1. `matrix_init`: Initializes GPIO pins for the RGB LED matrix and sets up the synchronization mutex​
- 2. `display_update`: Refreshes the LED matrix display to reflect any changes
- 3. `display_clear`: Clears all active pixels on the matrix by setting them to zero
- 4. `overwrite_pattern_to_screen`: Overwrites a specific pattern onto the LED matrix
- 5. `append_pattern_to_screen`: Adds a pattern to the existing screen matrix without overwrite
- Accelerometer Driver:
- 1. `accelerometer_init`: Configures the ADXL345 accelerometer with ±2g sensitivity and sets up I2C communication with semaphores for thread safety
- 2. `accelerometer_task`: Periodically reads acceleration data, applies smoothing, and updates player position based on tilt movements
- Maze Logic:
- 1. `get_maze_layout`: Retrieves the maze pattern for the current level
- 2. `is_wall_at`: Checks if a specific position in the maze contains a wall, used to constrain player movement
- 3. `is_goal_at`: Determines if the player has reached the maze's goal position to proceed to the next level{index=9}.
- Game Logic:
- 1. `set_player_to_start`: Resets the player position to the starting point of the current level
- 2. `handle_collisions`: Detects collisions with walls, traps, and goals, triggering state changes like `GAME_STATE_GAME_OVER` or `GAME_STATE_LEVEL_UP`
- 3. `change_game_state`: Manages game states such as `GAME_STATE_TITLE`, `GAME_STATE_PLAYING`, and `GAME_STATE_WIN`, and handles music transitions
- MP3 Decoder:
- 1. `mp3_decoder__init`: Initializes the MP3 decoder, sets the default volume, and selects the storage device
- 2. `mp3_decoder__play_song_at_index`: Plays a specific song based on its index in single-cycle mode
- 3. `mp3_decoder__play_song_with_mode`: Allows playback in loop or single-cycle mode, depending on the game state
- 4. `mp3_decoder__stop_playback`: Stops any active song playback
- 5. `mp3_decoder__volume_set_level`: Adjusts the volume level of the MP3 decoder
Testing & Technical Challenges
Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.
Include sub-sections that list out a problem and solution, such as:
<Bug/issue name>
Discuss the issue and resolution.
Conclusion
Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?
Project Video
Upload a video of your project and post the link here.
Project Source Code
References
Acknowledgement
Any acknowledgement that you may wish to provide can be included here.
References Used
List any references used in project.
Appendix
You can list the references you used.