A Touchscreen Chinese Chess App Using Atmega1284

With the increasing popularity of smartphones and tablet computers, touchscreen has become one of the most common user interfaces encountered today. The idea of this project came from some apps on the smart phone. It is very interesting to play a virtual Chinese chess on the mobile phone. People can take them everywhere and play it whenever they want. So we decided to build the electronic Chinese Chess game in our project. Meanwhile, LCD touch screen is a very popular thing used in electronic products, and doing the project will give us experience in utilizing a set of devices that is popular in modern devices. So in our final project, we designed a Chinese chess game application on touchscreen. Users can play Chinese chess on it. In addition, they can set the background as they like. Meanwhile, this project will also provide ECE4760 course a library for initializing and developing LCD touch screens of the same configuration for reference.
A Touchscreen Chinese Chess App Using Atmega1284

High Level Design

Rationale

It is quite meaningful for us to do this project. On one hand, with the increasing popularity of touch-screen mobile phones and tablet PCs, touch screen becomes more and more important in our lives. It is much more convenient and flexible than the traditional keyboard. On the other hand, Chinese Chess is a traditional Chinese intellectual game which can be dating back to Warring States Period in China. This old game can help people to improve their consciousness ability, thinking ability and add much fun to our life.

Logical structure

At the high level, our project mainly consists of two parts: the ATmega1284p microcontroller, the LCD touch screen. Atmega1284p is the main control part. When user presses on the screen, the signal will be sent to the MCU and some movements would be made. Also the MCU will control what is shown on the LCD screen and the state mode, based on the screen interrupt.
The connection between MCU and touch screen needs a LCD driver and an ADC chip. They are already on the touch screen board.
And we use putty to show that it’s which player’s turn to make a movement.

Hardware/Software tradeoffs

The hardware part of our project is not very complex. We soldered our Atmega1284p MCU and the LCD touch screen together. The LCD touch screen consists of two chips, SSD1289 LCD control chip and ADS7843 touch panel controller chip.
For the software part, the tricky part is to drive the LCD touch screen to work. Based on the driver code of similar lcd touch screen but of different configurations as ours, we read the datasheet of SSD1289 LCD control chip carefully, and changed the driver code so that it can be used to drive our LCD, and made it work. The other main part is to implement Chinese chess game rules, we defined a structure to store the chessmen’s information, so it is not that difficult. Another fussy part is to debounce each touch and adjust coordinates of touched points, because of the size limitation of the touch screen, we requires a high resolution, so the coordinates adjustment part is important. We figured a way out to debounce each touch with the help of a timer and adjust the coordinates by Putty.

Standards and Patents

Our design uses the SPI(serial peripheral interface) to realize the communication of touchpanel and AVR. Devices communicate in master/slave mode where the master device initiates the data frame.

Hardware Design and Implementation

Hardware Overview

From the high-level discussed above, our hardware consists of two parts, which include the LCD touch screen and the Atmega1284 prototype board. Below we will discuss each part separately.

LCD touch screen

The TFT 3.2′ LCD touch screen we use contains three parts, the touch panel, the TFT LCD screen and SD card. This touch screen has 40 pins. The TFT LCD use the control chip, SSD1289, while the touch panel uses the Analog Device ADS7843 touch screen controller. With our project, we can provide ECE4760 class the drive code for the LCD touch screen of such configuration.
Pin 4 to pin 17 ,pin 21 to pin 28 are for the TFT LCD screen display, pin 29 to pin 34 are for the touch panel, and pin 35 to pin 40 are for the sd card. Still there are some very important pins to be introduced. For the reason that microcontroller is always getting two hot if the VCC and GND of this touch screen is connected to the VCC and GND of the microcontroller, so we use additional voltage source for the touch screen. The VCC pin of the touch screen is connected to 5V. And the most important pin is the one for LCD back light. The LED-A pin for back light should be connected to 5V through a resistor of 75 ohm. This is a very important protection for the microcontroller and TFT LCD touch screen, or else both of them would be very hot.
SSD1289 TFT Driver is an all in one driver that integrated the RAM, power circuits, gate driver and source driver into single chip. It can drive a 262k color a-TFT panel with resolution of 240 RGB x 320. It also integrated the controller function and consists of up to 172,800 bytes (240 x 320 x 18 / 8) Graphic Display Data RAM (GDDRAM) such that it interfaced with common MCU through 8/9/16/18-bits 6800-series /8080-series compatible Parallel Interface or Serial Interface and stored the data in the GDDRAM. Auxiliary 18-bits video interface (VSYNC, HSYNC, DOTCLK, ENABLE) are integrated into SSD1289 for displays animated image.

A Touchscreen Chinese Chess App Using Atmega1284 Schemetic

The ADS7843 is a 12-bit sampling Analog-to-Digital Converter (ADC) with a synchronous serial interface and low on resistance switches for driving touch screens. By using this LCD, we can avoid refreshing the screen all the time compared with using a TV. The existence of GRAM in ADS7843 helps us to save the time in refreshing the screen. When we need to change what will be shown on screen, we just need to write the GRAM which replace the dots on the LCD.

Software Design and Implementation

Overview

The most important part for the software design is the touch screen control and the rule implementations.

LCD drawing

The LCD we use is a 3.2″ TFT screen. It has a resolution of 320 × 240, as the following figure shows. There are 240 pixels each line and 320 pixels each column. We can use (x, y) coordinate to represent each pixel on screen.
Key control signals for SSD1289 TFT Driver are listed: lcd_reset, lcd_cs(chip select), lcd_rs(0 for register address, 1 for value), lcd_wr(0 for write), lcd_rd(set 0 all the time in this project).

Parts List:

Part Unit Cost Vendor Quantity Total Cost
Atmega 1284p $5 Lab Stock 1 $5
small solder board $1 Lab Stock 2 $2
Power Supply $5 Lab Stock 1 $5
Resistors $0 Lab stock 6 $0
Wire $0 Lab Stock 30 $0
LCD touch screen $15 Sainsmart 1 $15
Total Cost $27

For more detail: A Touchscreen Chinese Chess App Using Atmega1284


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top