Difference between revisions of "F22: Embedded Gamers"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Joystick and Buttons)
(Implementation)
Line 317: Line 317:
  
 
* Buttons driver:
 
* Buttons driver:
**1. Button 1: starts a game.
+
**1. Button 1: starts a game, shots a missile, and start the game all over.
**2. Button 2: ends existing game.
 
**3. Button 3: shuts out bullet.
 
  
 
== '''RGB LED Matrix''' ==
 
== '''RGB LED Matrix''' ==

Revision as of 22:27, 5 December 2022

Guardians of the Galaxy

Abstract

A horizontal type of space invader game. Players can control the spaceship on the screen composed of an LED matrix in a rectangular shape. The spaceship can shoot horizontally from left to right in order to destroy its enemies. The entire map will flow in the opposite direction of where the spaceship is flying. The speed of the map flow and the number of enemies will increase at higher difficulty levels. The spaceship takes damage from colliding with enemies themselves or their bullets. The game will end when the health of the controlled spaceship is depleted.

Objectives & Introduction

Technical Responsibilities

Technical Roles
  • Game Logic Development
Bruce Jiang
  • LED Display Driver
Bruce Jiang
  • Joystick Controller Driver
Ritu Patil
  • MP3 Decoder
Phil Bloxom
  • Enclosure
Phil Bloxom
  • Hardware Integration
Bruce Jiang & Phil Bloxom

Administrative Responsibilities

Administrative Roles
  • Team Leader
Ritu Patil
  • Git Repository Managers
Bruce Jiang
  • Code Reviewers
Phil Bloxom
  • Wiki Report Manager
Bruce Jiang
  • Bill of Materials Manager
Ritu Patil

Schedule

Week# Start Date End Date Task Status
1
  • 10/03/2022
  • 10/8/2022
  • Read previous projects, gather information and discuss among the group member
  • Create GitLab repository for project
  • Completed
  • Completed
2
  • 10/10/2022
  • 10/15/2022
  • Order necessary parts
  • Completed
3
  • 10/17/2022
  • 10/22/2022
  • Read and familiarize with LED Matrix Datasheet
  • Completed
4
  • 10/31/2022
  • 11/05/2022
  • Develop graphics driver for LED matrix and implement initial game objects
  • Research how to create objects pattern for display from PNG
  • Completed
  • Completed
5
  • 11/07/2022
  • 11/12/2022
  • Finalize wiki schedule
  • Display objects on screen
  • Develop ADC driver for joystick interfacing control dynamic movement of player spaceship
  • Create screen scenes in 32x64 matrices
  • Completed
  • Completed
  • Completed
  • Completed
6
  • 11/14/2022
  • 11/19/2022
  • Integration of circuit boards and microcontroller
  • Develop enemy spaceships game algorithm
  • Control dynamic movement of player spaceship.
  • Create MP3 Driver
  • Completed
  • Completed
  • Completed
  • Completed
7
  • 11/21/2022
  • 11/26/2022
  • Integrate game logic flow from start to end
  • Develop missile collision and player life algorithm
  • Integrate game sounds with game logic
  • Completed
  • Completed
  • In Progress
8
  • 11/28/2022
  • 12/03/2022
  • Integrate subsystem
  • Finalizing the video game
  • Update the wiki page
  • Not started
  • Not started
  • Not started
9
  • 12/05/2022
  • 12/10/2022
  • Address bugs during testing of integrated system
  • Test pause/play functionality
  • Not started
  • Not started
10
  • 12/11/2022
  • 12/11/2022
  • Final Demo
  • Update Gitlab repo with final code
  • Update test video
  • Update the wiki page
  • Not started
  • Not started
  • Not started
  • Not started

Bill of Materials (General Parts)

Part Name Part Model & Source Quantity Cost Per Unit (USD)
  • Micro-Controller SJ2 Board
  • SJ2 Board (Purchased from Preet Kang)
  • 1
  • 50.00
  • RGB LED Matrix
  • 1
  • 44.95
  • Power Supply
  • 1
  • 15.98
  • IDC Socket Male
  • 1
  • 0.3
  • HC-05 Bluetooth
  • 2
  • 10
  • Analog Joystick
  • 1
  • 6

Overall Design

Hardware Design

LED Matrix Rear

Hardware Interface

  • LED Matrix Display: 13 GPIO channel on SJ2 (1)
  • Joystick connection: 2 ADC channel on SJ2 (1)
  • Bluetooth sender connection: 1 set UART, RX and TX on SJ2 (1)
  • Bluetooth receiver connection: 1 set UART, RX and TX on SJ2 (2)
  • MP3 Decoder connection: SPI communication, MOSI, CS, SCK, on SJ2 (2)
  • Speaker connection: AUX cord

Software Design

  • LED Matrix:
    • 1. Initialized LED matrix connected pins to board IOs.
    • 2. Designed matrix driver for screen display by reading an matrix.
  • Joystick:
    • 1. Initialized 2 ADC channels for taking the x reading and y reading from joystick.
    • 2. Decoded voltage readings into joystick movement commands.
  • Buttons:
    • 1. Initialized several gpio for taking binary command from button pressed.
    • 2. Enabled interrupts for each botton pressed.

Implementation

  • LED Matrix driver functions:
    • 1. display_update: reload matrix display for refreshing the changes from the backend matrix.
    • 2. display_clear: erase all matrix values, and sets them to zeros.
    • 3. overwrite_pattern_to_screen: overite a given pattern onto the existing matrix
    • 4. append_pattern_to_screen: append a given pattern onto the existing matrix
    • 5. clear_pattern_on_screen: clear the pattern from screen by giving the pattern's current location and width and height.
  • Joystick driver:
    • 1. joystick_running: run ADC capture on joystick continuesly to monitor user inputs.
  • Buttons driver:
    • 1. Button 1: starts a game, shots a missile, and start the game all over.

RGB LED Matrix

Hardware Design

Below are symbol and footprint for custom component-part in EasyEDA tool. These parts would be used in future PCB design.

LED Matrix and SJ2 Board Connections Schematics
LED Matrix and SJ2 Board Connections PCB



Hardware Interface

The 32x64 LED matrix is from Adafruit, with user mannual. It is composed of two upper and lower sectional LED pannels. Each pannel has R, G, B led channels and A, B, C, and D row control registers. Addtionally, column shift is controlled by Latch bit, clock is controled by CLK, and OE turns LED off when switching rows.

Connectivity Table LED Matrix to Sj2 Board:

RGB LED Matrix Pin Description SJ2 Board
R1 GPIO P2_0
G1 GPIO P2_2
B1 GPIO P2_5
R2 GPIO P2_1
G2 GPIO P2_4
B2 GPIO P2_6
A GPIO P0_6
B GPIO P0_26
C GPIO P0_16
D GPIO P0_22
CLK GPIO P2_9
LAT GPIO P1_20
OE GPIO P1_28
VCC 5VIN External Power Supply
GND GND On Board
LED Matrix Front
LED Matrix Rear

Software Design

LED matrix io and driver is developed for communication between boards and LED matrix. IO driver consists of pin inialization by using gpio.h for each rgb channels, row selection register, CLK, LAT, and OE pins. By using "led_matrix_io.h" developers can using public function led_matrix_io_init and other basic controller functions.
For LED matrix driver, it is based on the previous IO driver to provide LED screen update, clean, init, and draw functionalities.

Implementation

Rtos Tasks:

  • Updating Display: for display to continuously updating screen, a task is assigned for running the display_update function from the driver every 500 milliseconds.

Joystick and Buttons

Hardware Interface and Connections

Connectivity Table LED Matrix to Sj2 Board:

Joystick Pin Description SJ2 Board
Vcc Voltage +3.3V
Xout Analog X Channel P0_25
Yout Analog Y Channel P1_30
Button GPIO P1_14
GND GND GND

Software Design

Joystick with voltage input produces two analog channels of outputs from the x and y axises of the joystick. Designed a driver to convert these two analog outputs and convert them into digital signals, then decoded as user movment such as move up, move down, move left, move right, move right up, move right down, move left up, and move left down.

Implementation

Rtos Tasks:

  • JoyStick Running: Keep recieving two channels of analog signals and decode them into agent moves corresponding to right, left, up, down, right up, right left, left up, and left down.

Mp3 Decoder

Hardware Interface and Connections

Connectivity Table Mp3 Player to Sj2 Board:

Mp3 Decoder Pin Description SJ2 Board
Vcc Voltage +3.3V
Rx UART3 P4_28
Tx UART3 P4_29
GND GND GND

Software Design

Mp3 player driver was created. It initialized UART3 and configured IO connections of RX and Tx. To send command for adust volume, play songs by number, play songs by folder name, and set play songs in cycle, please find the user manual here: mp3 player user manual

Implementation

Public Tasks:

  • Initialize device: Select the sd card which has songs on the player
  • Cycle play mode: play a song in single cycle
  • Pause a song
  • Resume playback

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.