Mini PacMan

Goal
As a fun project idea, me and my partner decided on the task of creating a working game of PacMan on a STM32 MCU. Our goal was to configure everything by hand, cramming as much functionality as we could within our limited time frame.
Hardware
Peripherals
Firmware
The most important task was to using STM32Cube IDE to configure the correct MCU bits.
And the backbone of the entire code is spent manipulating and referencing a
128 x 64 matrix.
A lot of thought was put into the logic of how PacMan would move and update
the display, but the general design could be summed into:
Initialization and play music ⇒ Get direction from joystick ⇒
Update the matrix/filter the Direction ⇒ Display Changes (if any) ⇒ loop back to joystick
Main Function

This initializes, shows title screen, and plays the music, then the function runs the systick loop. Taking in the buffer data and checks for if it is valid or not. PacMan's position is checked updates the matrix and displays it. Also the joystick button is used as a reset and can increase the speed.
Joycon Function

Takes in X and Y positions for the buffer. Determines the quadrant the position is in, then outputs the quadrant as a direction.
Movement Check Function

Takes in a direction along with and overhead matrix and fixes x and y coordinates referencing off of the inputted direction value mapping onto the matrix. Filters [All] edge cases for PacMan's eligibily for movement increasing the score if on pellet and outputting a direction if allowed.
Display Function

Displays PacMan's new position based off of the values given by the movement check function and updates pellet counter. This is all done atop the OLED display and contains differign cases for differing directions given.
The Matrix

This is the 128 x 64 Matrix maze.
- All of the code is posted on my github Here.
Demo
Here is the finished demo of the PacMan project.
Inspiration & Credit
- STM32L476RG Datasheet — This datasheet is required for everything.
- Of course the most important credit is given to Namco, the original developers of PacMan
A lot of credit goes out to my amazing partner. Without their help this project would have many times harder to acheive. I credit their work on the Display Function, the Joycon Function, and all the accumulative sweat and tears we both shed on the other functions. I'm fortunate to have worked with someone so helpful and positive.