Use Liangshan School to develop a game console with buttons, touch screen, and can be used to transplant games such as Contra.
According to the official tutorial, screen pictures, text display, headphone audio playback, vibration and other effects have been achieved. The handwritten Snake is only half completed, and the NES game has not been transplanted yet.
Summarize the experience of the training camp:
# Game console demand analysis and hardware selection
Check the official information, motor, speaker, screen, remote sensing button and other models.
Official link: [https://dri8c0qdfb.feishu.cn/mindnotes/bmncns6AYDXt7aRsdmwklyZaXwb#mindmap](https://dri8c0qdfb.feishu.cn/mindnotes/bmncns6AYDXt7aRsdmwklyZaXwb#mindmap)
# The PCB
remote sensing button was found on Taobao. It was not available in LiChuang Mall, so I had to draw a package myself; (**PSP game console 3D remote sensing button**), the directions of the two positioning holes of the remote sensing button in my PCB were drawn incorrectly, but it has little impact. When soldering, just cut off the two positioning protrusions on the button, which will not affect soldering.
Settings->System->General->Symbol Library Management->**Professional Mode**;
When drawing a package, the pin size should be slightly larger than the drawing size. For example, if the original pin hole is 1.1mm, the inner diameter should be 1.2mm when drawing the package;
The remote sensing button is essentially two sliding resistors, which determine the direction by the voltage in the XY direction;
**Button** In order to save costs, no pull-down resistor is drawn;
**Power supply**: Use LiChuang open source power supply, search: 5V charging and discharging integrated battery module; (touch to turn on, long press to turn off); Link: [https://oshwhub.com/li-chuang-kai-fa-ban/5v-chong-fang-yi-ti-dian-chi-mo-kuai](https://oshwhub.com/li-chuang-kai-fa-ban/5v-chong-fang-yi-ti-dian-chi-mo-kuai)
Diode: Classic diode 1n4148;
**Note**: The **wire-to-board converter** of the speaker and power supply in the schematic diagram is not well selected. You can change the model. Be sure to check the physical picture in the LiChuang Mall before selecting the model, otherwise it will be difficult to weld.
# Screen transplantation
## Basic operation
1. Copy the library function lighting project, copy the screen official program source code->05-2.0IPS display STM32F407ZG_SPI routine->Hardware->LCD folder to the library function lighting project->Hardware;
2. Add all the newly added file paths to the project;
3. Compile first, then there will definitely be an error, start solving from the first error (all subsequent errors may be due to the first error)
4. Keil selects a column, ALT+left mouse button, pulls down to select, releases the mouse, and observes whether the cursor flashes. At this time, you can directly enter (for example //), if the cursor does not move, click ALT until the cursor flashes.
## If the screen does not light up, how to troubleshoot
1. Check whether the IO port is configured correctly (you can buy a screen with pin headers for welding, and use Dupont wires to connect to the screen pins of Liangshan School, which can be used to rule out welding problems);
according to my experience, the first welding only turned on the backlight, and the screen would not light up. After welding back and forth many times, the wires on the PCB board fell off... Yes, the wires fell off... Three boards were scrapped. I ordered several more screens, and finally they lit up. It is recommended that beginners must buy several sets of components (especially screens), and generally they will not succeed at one time.
2. Is the initialization successful?
3. Is the wiring correct?
## Chinese character modulus tool PCtoLCD2002
usage tutorial: [https://blog.csdn.net/qq_32355021/article/details/130737158](https://blog.csdn.net/qq_32355021/article/details/130737158)
## Image modulus tool Image2Lcd 2.9 (cracked version)
1. Open the picture to be modulo:
2. After opening the picture, set as follows
* Output data type: C language array
* Scan mode: horizontal scan
* Output grayscale: 16-bit true color
* The color data in 16-bit color is arranged as: red green blue
* **The maximum width and height must be consistent with the pixels of the output image**;
* Check the high bit first
and click Save, then copy the generated array to the file of the routine pic.h
The complete interface is as follows:
![20230522133641.png]

## If the displayed image is not clear, the solution is
to open the Gui.c file and swap the codes of 622 and 623;
`Lcd_WriteData(pic[k*2+1]);
Lcd_WriteData(pic[k*2]);`
# Audio driver
## Audio material
Audio material network: [https://sc.chinaz.com/yinxiao/](https://sc.chinaz.com/yinxiao/)
Download and select **WAV** format;
## Audio conversion tool WaveShop
If the audio is too large, you can crop it appropriately in the tool. Because there is only one channel on the schematic diagram, you can delete the audio of one channel;
right-click -> delete channel;
Audio->Format record the sampling frequency, which is generally 22050;
DAC is up to 12 bits, and the sampling size can be set to 8bit;
![image.png]

Click Save after the settings are completed.
## Software WinHex
![image.png]

**Error**: When you first open the file, an error message will pop up, the file is not write-protected, and the system cannot find the specified path;
**Solution**: Click the menu Help – Settings – Initial Settings – Restore Default Settings;
select the start position and end position, right-click, set the block start position and block end respectively, and then select Edit;
![image.png]

Edit->Copy Block->C Source Code, and then paste it into the corresponding position of the Keil project to create the audio_source.c file. Remember to add a statement to the audio_source.h file;
![image.png]

Attached is the Snake source code and NES game, you can download and use it.