Tim Says
Based on the 4 Button Simon Game, This is a 6 Button version using 6 colours of the Rainbow.
- Red, Orange, Yellow, Green, Blue, and Purple.
It is a simple version.
- The level is the number of random colours to remember.
- levels 1 to 100 (good luck with that).
- Uses and Arduino UNO.
- Uses a TFT LCD with touch screen Shield.
How to play.
- Set the level.
- Press play.
- watch the colours appear and remember the sequence.
- Using the coloured buttons, enter the sequence of colours.
- Tap the screen quickly, if you hold the stylus on the screen it will think you are clicking again.
This was mostly an exercise on how to write code for a Colour Display with a Touch Screen.
Using Arduino IDE
- I see no reason for repeats.
- Uploading the code to an Arduino Device is well covered at the official site of Arduino.
Warning
- Video could send you to sleep.
- It's all about code. (I do tend to forget and repeat things)
Supplies
I am using the:
- Arduino UNO R3
- 2.4 Inch TFT LCD Touch Screen Display Shield Module for the Arduino UNO R3
This keeps thing simple.
Other Arduino Modules and Displays could be used if you know how to change the relevant setting in the code
- Arduino Architecture is a very flexible system.
- This shield can be used with an Arduino Mega 2560 Rev3
I have attached the code below
- Remember to place it in a folder of the same name.
Downloads
Arduino
Arduino is a well established architecture.
- The Best place to learn about it is there official site. Arduino - Home
- I still use the Legacy IDE (1.8.X), well for compiling and uploading (See video)
- If New to the IDE go here: Overview of the Arduino IDE 1 | Arduino Documentation
There are libraries from Adafruit that need to be installed.
- Adafruit_GFX.h
- Adafruit_TFTLCD.h
- TouchScreen.h
- The official guide is here: Get to know Arduino Libraries | Arduino Documentation
If you search in the Library manager for Adafruit TFTLCD, and install it.
- This will probably ask if you want to also install support libraries? Say Yes.
- This will probably install the other libraries needed.
Load my code and upload it to the Arduino UNO.
- I cant say more than it says here: Overview of the Arduino IDE 1 | Arduino Documentation
- Just remember in TOOLS to choose the correct Arduino Board and the USB port you have it plugged into.
Code
This is the first time I have done anything for the touch screen.
- There is probably an easy way to compensate for the continues stream of data being detected by a touch.
- Normally this is not an issue as when an area is defined to be used as a button it does not matter.
- The problem does not arise for the Play, Level up and down buttons.
- For the colour selection it is an issue and I have done my best to overcome it. (we need to touch briefly)
- And of course these are the cheep/will do touch screens.
I have tried to explain how the code works in the video. Here are the main points.
- I have tried to separate things to make the code easy to read.
- I have put lots of comments to explain parts of the code.
As mentioned, some Libraries are used.
#include <Adafruit_GFX.h>
#include <Adafruit_TFTLCD.h>
#include <TouchScreen.h>
Some calibration of the touch screen may need to be done.
/* Touch Screen */
#define TS_SENSE_PIN 13
#define TS_XP 7
#define TS_XM A1
#define TS_YP A2
#define TS_YM 6
#define TS_MIN_X 145
#define TS_MAX_X 860
#define TS_MIN_Y 110
#define TS_MAX_Y 960
#define TS_MAX_Y_SCREEN 890
#define TS_OFF_PRESSURE 20
#define TS_MIN_PRESSURE 500
#define TS_MAX_PRESSURE 1000
The raw min and max values of the Touch screen need to be found.
To do this the code needs to be uploaded in CALIBRATE mode.
- To do this, uncomment the definition CALIBRATE.
#define CALIBRATE
With this uncommented.
- When you touch the screen, a message is sent via the serial connection.
- Open the Serial Monitor to see the values.
- Use the values to set the defined values shown above.
Once you have the values set correctly, you need to comment out CALIBRATE and upload the code again.
//#define CALIBRATE
There are things you may want to change.
The Logo
/*
128x128 Bitmap.
Modify to change My Logo.
*/
const uint8_t PROGMEM MeLogo128x128[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x03, 0xF0, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x7E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x1C, 0x1F, 0x81, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x1B, 0xE7, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x7F, 0xFE, 0xFE, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x7C, 0x1F, 0xEF, 0x0E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x9B, 0x03, 0xF8, 0x03, 0x7F, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x2E, 0x78, 0x00, 0x3F, 0xE1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3F, 0xFE, 0x78, 0x1E, 0x01, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7D, 0xFF, 0x7C, 0x1E, 0xE1, 0xF8, 0x70, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xF0, 0x07, 0xFF, 0xFF, 0xFF, 0xFE, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x07, 0xFB, 0xE8, 0x1F, 0xF6, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x07, 0x78, 0x00, 0x01, 0xFB, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x07, 0x78, 0x00, 0x01, 0xFF, 0xF8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x07, 0x40, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x06, 0xC0, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xFD, 0x80, 0x00, 0x00, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x03, 0x3C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x01, 0xBC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x07, 0xF7, 0xC0, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xDF, 0xE3, 0xC0, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0xFF, 0xE3, 0xC0, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0xFF, 0x01, 0x80, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0xFF, 0xF1, 0x80, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x70, 0xF7, 0x80, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x3F, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xDF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7B, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xFF, 0xFE, 0x00, 0x00, 0x30, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xEF, 0xFF, 0x80, 0x07, 0xF0, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xFF, 0xFF, 0xE0, 0x07, 0xDC, 0x00, 0x1E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0xFF, 0xFF, 0xF8, 0x01, 0x8F, 0x80, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFC, 0xFE, 0x00, 0xC7, 0xE0, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xDF, 0xF8, 0x1F, 0xDF, 0xF7, 0xF8, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xD8, 0x07, 0xFF, 0xFF, 0xBC, 0x0F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7B, 0xFF, 0xD8, 0x01, 0xFF, 0xFF, 0xF8, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFB, 0xB0, 0x00, 0x7F, 0xFB, 0xF8, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xDF, 0xB0, 0x00, 0x17, 0xFF, 0xF1, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x60, 0x00, 0x0F, 0xCC, 0x7F, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0xC0, 0x00, 0x0F, 0x8C, 0x7F, 0xBF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0xFE, 0xC0, 0x00, 0x0F, 0xFE, 0x7F, 0xF8, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0xE0, 0x00, 0x0E, 0x7E, 0x37, 0xF1, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x60, 0x00, 0x0C, 0x3C, 0x67, 0x03, 0xF0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x3C, 0xF8, 0x00, 0x0F, 0xF8, 0xE7, 0x87, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1E, 0xF8, 0x00, 0x03, 0xFF, 0xC7, 0x8F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFE, 0x30, 0x00, 0x00, 0x7F, 0x83, 0x9F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x7E, 0x78, 0x00, 0x00, 0x00, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x6F, 0x7C, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8C, 0x6F, 0x9F, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8C, 0x67, 0xFD, 0x80, 0x00, 0x00, 0x0C, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xD8, 0x67, 0x7D, 0x80, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF0, 0x67, 0x7F, 0x00, 0x00, 0x01, 0xCF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xF0, 0x67, 0xFF, 0x60, 0x00, 0x01, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xE0, 0x7F, 0xBE, 0xE0, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3C, 0xE0, 0x7F, 0xBE, 0xF0, 0x00, 0x03, 0xCF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEC, 0xF0, 0x7F, 0xBE, 0xF8, 0x3F, 0xE7, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEC, 0x78, 0x7F, 0xCF, 0xB9, 0xFF, 0xFF, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE6, 0x78, 0xFF, 0xCF, 0xBF, 0xFF, 0xDF, 0xDE, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0x80, 0x66, 0x7C, 0xDD, 0xCF, 0xFF, 0xFF, 0xC7, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x7E, 0x3C, 0xDE, 0xDF, 0xFF, 0x9C, 0xE7, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x7C, 0x1B, 0x3E, 0xCF, 0x7F, 0xEF, 0x3F, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1F, 0x19, 0x9F, 0xCF, 0x7F, 0xCF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x03, 0xD9, 0x9F, 0xB7, 0x9E, 0xEF, 0xFF, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xFC, 0xDF, 0xBF, 0xFF, 0xFF, 0xE3, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x3F, 0xCF, 0xBF, 0xFF, 0xFF, 0xE3, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x07, 0xCF, 0xFF, 0xFF, 0xFB, 0xE3, 0xF3, 0xE0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0E, 0x00, 0x00, 0xC7, 0xF1, 0xFF, 0xFB, 0xFF, 0xFB, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x67, 0xC0, 0xFF, 0xFE, 0xFF, 0xFE, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x63, 0xE0, 0xFE, 0xFF, 0xC7, 0x86, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0xC3, 0xE0, 0xFF, 0x03, 0xF1, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xE0, 0x00, 0xC1, 0xF0, 0xE7, 0xC1, 0xF8, 0xF3, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x70, 0x00, 0x41, 0xF8, 0xC3, 0xF3, 0xFF, 0xFB, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x38, 0x00, 0x60, 0xF8, 0x03, 0xFB, 0xEF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x18, 0x60, 0xF8, 0x1E, 0x7E, 0xFF, 0xBF, 0xC0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xEF, 0x78, 0x60, 0x7C, 0x7F, 0xFE, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0xEC, 0x60, 0x6C, 0x63, 0xFC, 0x7F, 0xFB, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3E, 0x06, 0x60, 0x26, 0xE0, 0x7C, 0x00, 0x07, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xC0, 0x03, 0xB0, 0x37, 0xE7, 0xF8, 0x38, 0x3E, 0x67, 0xC0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0xE0, 0x01, 0xFE, 0x1B, 0xC7, 0xD8, 0x38, 0xF8, 0x63, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x6F, 0x1B, 0xCF, 0xB0, 0x66, 0xC0, 0x63, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x9E, 0x00, 0x67, 0xCD, 0xDF, 0x30, 0x36, 0xC0, 0x21, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x07, 0x80, 0x06, 0xEC, 0xDC, 0x60, 0x33, 0xC0, 0x31, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0F, 0x81, 0xE0, 0x06, 0x7C, 0xFC, 0xE0, 0x1B, 0xC0, 0x31, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x70, 0x06, 0x1E, 0x71, 0xC0, 0x1D, 0xC0, 0x3D, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x60, 0x1C, 0x02, 0x06, 0x3B, 0xC0, 0x1D, 0xC0, 0x2F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xE0, 0x06, 0x03, 0x00, 0x3F, 0xC0, 0xD8, 0xC0, 0x6F, 0xF0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0C, 0xF0, 0x0F, 0x03, 0x00, 0x1F, 0xC0, 0x78, 0x00, 0x6D, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xF0, 0x0F, 0x83, 0x00, 0x77, 0xC0, 0x78, 0x00, 0x79, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x78, 0x0F, 0xC3, 0x00, 0x77, 0xC0, 0x38, 0x18, 0x71, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x38, 0x1B, 0xC3, 0x00, 0x6F, 0xC0, 0x0F, 0x3C, 0x71, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x1C, 0x1B, 0xC1, 0x80, 0x7F, 0xE0, 0x07, 0xFC, 0xF1, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1C, 0x1B, 0x41, 0x80, 0x3F, 0xFC, 0x0F, 0xEC, 0xF1, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x8E, 0x19, 0xE1, 0xF0, 0x0C, 0xFC, 0x0F, 0xD8, 0xE3, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x8F, 0x19, 0xE1, 0xF0, 0x0E, 0x6C, 0x1F, 0x18, 0xC3, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0D, 0xC7, 0x19, 0xE1, 0xB0, 0x0C, 0xCC, 0x3F, 0x18, 0xC3, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xC7, 0x99, 0xE0, 0x18, 0x0C, 0xCC, 0x1F, 0x19, 0xE3, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xE3, 0x99, 0xB0, 0x18, 0x18, 0xCC, 0x1F, 0x19, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x7B, 0xD9, 0xB0, 0x18, 0x0C, 0xCC, 0x1F, 0x19, 0xBF, 0x60, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x79, 0xD9, 0xB0, 0x18, 0x0C, 0xCC, 0x1F, 0x19, 0x9F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3F, 0xF9, 0xB0, 0x18, 0x06, 0xCC, 0x1F, 0x31, 0x9F, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x37, 0xF9, 0xB0, 0x18, 0x03, 0xCC, 0x3F, 0x31, 0xBF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x18, 0x39, 0xB0, 0x18, 0x01, 0xCC, 0x3F, 0x31, 0x9F, 0x30, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0C, 0x18, 0x3D, 0xB0, 0x18, 0x00, 0x18, 0x7F, 0x33, 0x9E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0E, 0x3D, 0xB0, 0x0C, 0x00, 0x18, 0x7E, 0x63, 0x1F, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x1D, 0x98, 0x0C, 0x00, 0x18, 0xDE, 0x63, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x83, 0x1D, 0x98, 0x0C, 0x00, 0x18, 0xFE, 0x67, 0x1F, 0xF0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x81, 0xB9, 0x98, 0x0C, 0x00, 0x18, 0xFE, 0x67, 0x3F, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC1, 0xB9, 0x98, 0x0C, 0x00, 0x19, 0xFE, 0xCF, 0x3B, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xB9, 0x98, 0x0E, 0x00, 0x19, 0x9E, 0xCE, 0x38, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x39, 0xB9, 0x98, 0x06, 0x00, 0x1B, 0x9E, 0xCE, 0x78, 0x1B, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x19, 0xB8, 0xD8, 0x06, 0x00, 0x37, 0xB6, 0xDE, 0x78, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xB0, 0xD8, 0x03, 0x00, 0x3F, 0xBD, 0xDE, 0x78, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x78, 0x01, 0x80, 0x3C, 0xFD, 0xDF, 0xD8, 0x09, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x38, 0x01, 0xC0, 0x3C, 0xFF, 0x7F, 0x98, 0x05, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xFB, 0xF8, 0x0F, 0x30, 0x18, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x3F, 0xD8, 0x03, 0x00, 0x18, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
I have made a little program for editing small bitmaps into Hexadecimal code.
- You can get a copy here: Tim's PC Applications: Tim's Image Pixel Editor
- You may want to read this about my software: Tim's PC Applications: Trust Me or Not
The actual image is Black and White.
- I have wrote a modified method to show an image to give it the rainbow effect.
/* Draw Logo */
void Draw_Logo(int16_t x, int16_t y, uint8_t* imageData, int16_t width, int16_t height) {
uint8_t _rowColour = 0;
uint8_t _colourSwitch = 0;
/* Iterate through each row */
for (int row = 0; row < height; row++) {
int rowByteIndex = row * ((width + 7) / 8); /* Calculate the byte index for the current row */
/* Iterate through each column */
for (int col = 0; col < width; col++) {
/*Calculate the bit position within the current byte (MSB first) */
int bitPosition = 7 - (col % 8); /*Subtract from 7 to reverse the order */
uint8_t currentByte = pgm_read_byte(&imageData[rowByteIndex + (col / 8)]); /* Get the byte containing the current pixel */
bool pixelValue = (currentByte >> bitPosition) & 1; /* Extract the bit for the current pixel (MSB first) */
/* Assuming 'color' represents the color value for the pixel */
if (pixelValue) {
MyDisplay.drawPixel(x + col, y + row, Colours[_rowColour]); /* Draw the pixel at (x + col, y + row) with the specified color */
/* This is to get a rainbow effect on the image */
_colourSwitch++;
if (_colourSwitch >= 4) {
_colourSwitch = 0;
_rowColour++;
}
if (_rowColour >= 5) {
_rowColour = 0;
}
}
}
}
}
- As with most of my code I have put lots of comments to show what does what.
The "Tick" and the "X" are also images, you can you my application to change these.
/*
40x40 Bitmap
Cross 'X'
*/
const uint8_t PROGMEM Fail[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x07, 0x00, 0x01, 0xF8, 0x00, 0x0F, 0x80, 0x01, 0xFC, 0x00, 0x1F, 0x80, 0x01, 0xFC, 0x00, 0x3F, 0x80, 0x00, 0xFE,
0x00, 0x3F, 0x80, 0x00, 0xFF, 0x00, 0x7F, 0x80, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0x00, 0x7F, 0x80, 0xFE, 0x00, 0x00, 0x3F, 0x81, 0xFE, 0x00, 0x00, 0x3F, 0xC3, 0xFC, 0x00, 0x00, 0x1F, 0xE3, 0xF8,
0x00, 0x00, 0x0F, 0xE7, 0xF8, 0x00, 0x00, 0x0F, 0xF7, 0xF0, 0x00, 0x00, 0x07, 0xFF, 0xE0, 0x00, 0x00, 0x03, 0xFF, 0xE0, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00,
0x00, 0xFF, 0x80, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x07, 0xFF, 0xE0, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x0F, 0xFF,
0xF0, 0x00, 0x00, 0x1F, 0xE7, 0xF8, 0x00, 0x00, 0x3F, 0xC3, 0xFC, 0x00, 0x00, 0x7F, 0xC3, 0xFE, 0x00, 0x00, 0x7F, 0x81, 0xFE, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0xFF, 0x80,
0x01, 0xFE, 0x00, 0x7F, 0x80, 0x03, 0xFC, 0x00, 0x3F, 0xC0, 0x03, 0xF8, 0x00, 0x3F, 0xC0, 0x03, 0xF8, 0x00, 0x1F, 0xC0, 0x03, 0xF0, 0x00, 0x0F, 0xC0, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/*
40x40 Bitmap
Tick
*/
const uint8_t PROGMEM Win[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,
0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x78,
0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00,
0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x03, 0x80, 0x7C, 0x00, 0x00, 0x0F, 0xC0, 0xF8, 0x00, 0x00, 0x1F, 0xE1, 0xF8, 0x00, 0x00, 0x07, 0xE1, 0xF0, 0x00, 0x00, 0x03, 0xF3, 0xE0,
0x00, 0x00, 0x03, 0xF7, 0xE0, 0x00, 0x00, 0x01, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00,
0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
Keep them 40x40 in size.
- you may want to create your own type of e-mote.
The other thing you may wish to change is the name.
uint8_t Title[] = { 'T', 'i', 'm', ' ', 'S', 'a', 'y', 's' };
- This is in an array so that each letter can be printed in a different colour.
/* Draw Title Tim Says */
void Draw_Title() {
uint8_t _charColour = 0; /* Colour Counter */
uint8_t _x = 24; /* Start position X */
uint8_t _y = 170; /* Start position Y */
uint8_t _charZoom = 4; /* Charector Magnification */
uint8_t _nextChar = _charZoom * 6; /* Distance to next Charector */
/* Print each charector one at a time so that we can change the colour of each */
for (size_t i = 0; i < sizeof(Title) / sizeof(Title[0]); i++) {
MyDisplay.setTextColor(Colours[i]);
MyDisplay.drawChar((i * _nextChar) + _x, _y, Title[i], Colours[_charColour], 0, _charZoom, _charZoom);
_charColour++;
if (_charColour >= 5) {
_charColour = 0;
}
}
}
With this, try to keep the array the same length. The screen is only so wide.
- If you want more characters you can reduce the zoom.
This code may work with other TFT Shields.
- This method checks for different TFT Display Drivers.
uint16_t Check_Which_LCD_Drver_Display_Uses() {
Serial.println(F("Checking LCD Driver"));
MyDisplay.reset();
uint16_t identifier = MyDisplay.readID();
if (identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
}
else if (identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
}
else if (identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
}
else if (identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
}
else if (identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
}
else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.4\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
}
return identifier;
}
Have DEBUG uncommented so you see any messages when you first use the code.
#define DEBUG
The Complete code
The Code file is attached in Supplies above.
- Here it is for you to view.
- I tend to write code in many languages, you may find I have not completely written it all in Arduino, Arduino uses C and C++ so all is fine.
/*
By: Tim Jackson.1960 https://www.timsnet.co.uk/
This is based on Simple Simon Game.
Simple Simon uses four colours, I have inceased the number of colours to 6.
I have used an Arduino UNO with a 2.4" TFT LCD SHIELD from WWW.mcufriend.com
The shield uses a 320 x 240 Display. Has the ILI9325 LCD driver
The display has a TouchScreen.
Also on the shield has an SD Card slot, I am not using this.
Credits:
Adafruit https://learn.adafruit.com/arduino-tips-tricks-and-techniques/arduino-libraries
I have tried to put some flexability in the code so you can customize it.
ATMega328p
Sketch uses 25908 bytes (80%) of program storage space. Maximum is 32256 bytes.
Global variables use 925 bytes (45%) of dynamic memory, leaving 1123 bytes for local variables. Maximum is 2048 bytes.
DEBUG Will serial print touched X Y Z Points. (Z being pressure)
On its own will give Mapped XY screen cooardinates.
CALIBRATE If CALIBRATE is defined the coordinates will be Raw Touch Screen Coordinates,
used for setting the Min and Max values of the thouch screen.
#include <Tims_Arduino_UNO.h>
*/
#define DEBUG
//#define CALIBRATE
#include <Adafruit_GFX.h>
#include <Adafruit_TFTLCD.h>
#include <TouchScreen.h>
/* Touch Screen */
#define TS_SENSE_PIN 13
#define TS_XP 7
#define TS_XM A1
#define TS_YP A2
#define TS_YM 6
#define TS_MIN_X 145
#define TS_MAX_X 860
#define TS_MIN_Y 110
#define TS_MAX_Y 960
#define TS_MAX_Y_SCREEN 890
#define TS_OFF_PRESSURE 20
#define TS_MIN_PRESSURE 500
#define TS_MAX_PRESSURE 1000
TouchScreen MyTouchScreen = TouchScreen(TS_XP, TS_YP, TS_XM, TS_YM, 400);
TSPoint LastPoint;
/* Display */
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET A4
Adafruit_TFTLCD MyDisplay(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
/*
Colours to use.
Rainbow, Red, Orange, Yellow, Green, Blue, and Purple
*/
#define BLACK 0x0000
#define WHITE 0xFFFF
#define RED 0xF800
#define ORANGE 0xFD20
#define YELLOW 0xFFE0
#define GREEN 0x07E0
#define BLUE 0x001F
#define PURPLE 0xF81F
int16_t Colours[] = { RED ,ORANGE ,YELLOW ,GREEN ,BLUE ,PURPLE };
const uint8_t NumberOfColors = sizeof(Colours) / sizeof(Colours[0]);
uint8_t Title[] = { 'T', 'i', 'm', ' ', 'S', 'a', 'y', 's' };
/* Buttons */
struct Round_Button {
uint16_t x;
uint16_t y;
uint8_t r;
uint16_t col;
String name;
Round_Button(uint16_t posX, uint16_t posY, uint8_t r, uint16_t col, String name) : x(posX), y(posY), r(r), col(col), name(name) {}
};
bool ShowButtons = true;
Round_Button Red_Button(70, 225, 20, RED, "RED");
Round_Button Orange_Button(120, 225, 20, ORANGE, "ORANGE");
Round_Button Yellow_Button(170, 225, 20, YELLOW, "YELLOW");
Round_Button Green_Button(70, 270, 20, GREEN, "GREEN");
Round_Button Blue_Button(120, 270, 20, BLUE, "BLUE");
Round_Button Purple_Button(170, 270, 20, PURPLE, "PURPLE");
Round_Button Buttons[] = { Red_Button ,Orange_Button ,Yellow_Button ,Green_Button ,Blue_Button ,Purple_Button };
/* Game */
#define MAX_LEVEL 100
uint8_t Level = 3;
uint8_t PlayerCount = 0;
int16_t GeneratedSequence[MAX_LEVEL];
int16_t PlayerSequence[MAX_LEVEL];
/*
128x128 Bitmap.
Modify to change My Logo.
*/
const uint8_t PROGMEM MeLogo128x128[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xF0, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x03, 0xF0, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x7E, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x1C, 0x1F, 0x81, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x1B, 0xE7, 0xF0, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x7F, 0xFE, 0xFE, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x03, 0x7C, 0x1F, 0xEF, 0x0E, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x9B, 0x03, 0xF8, 0x03, 0x7F, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1F, 0x2E, 0x78, 0x00, 0x3F, 0xE1, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3F, 0xFE, 0x78, 0x1E, 0x01, 0xF0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x7D, 0xFF, 0x7C, 0x1E, 0xE1, 0xF8, 0x70, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xF0, 0x07, 0xFF, 0xFF, 0xFF, 0xFE, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x07, 0xFB, 0xE8, 0x1F, 0xF6, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x07, 0x78, 0x00, 0x01, 0xFB, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x07, 0x78, 0x00, 0x01, 0xFF, 0xF8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x07, 0x40, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x06, 0xC0, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0xFD, 0x80, 0x00, 0x00, 0x03, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x03, 0x3C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x01, 0xBC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x07, 0xF7, 0xC0, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xDF, 0xE3, 0xC0, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0xFF, 0xE3, 0xC0, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0xFF, 0x01, 0x80, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x71, 0xFF, 0xF1, 0x80, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x70, 0xF7, 0x80, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x76, 0x77, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x3F, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xDF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7B, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0xFF, 0xFE, 0x00, 0x00, 0x30, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xEF, 0xFF, 0x80, 0x07, 0xF0, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xFF, 0xFF, 0xE0, 0x07, 0xDC, 0x00, 0x1E, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0xFF, 0xFF, 0xF8, 0x01, 0x8F, 0x80, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xFC, 0xFE, 0x00, 0xC7, 0xE0, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xDF, 0xF8, 0x1F, 0xDF, 0xF7, 0xF8, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xD8, 0x07, 0xFF, 0xFF, 0xBC, 0x0F, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7B, 0xFF, 0xD8, 0x01, 0xFF, 0xFF, 0xF8, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFB, 0xB0, 0x00, 0x7F, 0xFB, 0xF8, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xDF, 0xB0, 0x00, 0x17, 0xFF, 0xF1, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0x60, 0x00, 0x0F, 0xCC, 0x7F, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFE, 0xC0, 0x00, 0x0F, 0x8C, 0x7F, 0xBF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7D, 0xFE, 0xC0, 0x00, 0x0F, 0xFE, 0x7F, 0xF8, 0xD0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFE, 0xE0, 0x00, 0x0E, 0x7E, 0x37, 0xF1, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x3E, 0x60, 0x00, 0x0C, 0x3C, 0x67, 0x03, 0xF0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x3C, 0xF8, 0x00, 0x0F, 0xF8, 0xE7, 0x87, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1E, 0xF8, 0x00, 0x03, 0xFF, 0xC7, 0x8F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFE, 0x30, 0x00, 0x00, 0x7F, 0x83, 0x9F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0x30, 0x00, 0x00, 0x00, 0x03, 0xFF, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x7E, 0x78, 0x00, 0x00, 0x00, 0x01, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x6F, 0x7C, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8C, 0x6F, 0x9F, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x8C, 0x67, 0xFD, 0x80, 0x00, 0x00, 0x0C, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xD8, 0x67, 0x7D, 0x80, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xF0, 0x67, 0x7F, 0x00, 0x00, 0x01, 0xCF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xF0, 0x67, 0xFF, 0x60, 0x00, 0x01, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0xE0, 0x7F, 0xBE, 0xE0, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3C, 0xE0, 0x7F, 0xBE, 0xF0, 0x00, 0x03, 0xCF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEC, 0xF0, 0x7F, 0xBE, 0xF8, 0x3F, 0xE7, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xEC, 0x78, 0x7F, 0xCF, 0xB9, 0xFF, 0xFF, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xE6, 0x78, 0xFF, 0xCF, 0xBF, 0xFF, 0xDF, 0xDE, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0x80, 0x66, 0x7C, 0xDD, 0xCF, 0xFF, 0xFF, 0xC7, 0xDE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x7E, 0x3C, 0xDE, 0xDF, 0xFF, 0x9C, 0xE7, 0xBE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x7C, 0x1B, 0x3E, 0xCF, 0x7F, 0xEF, 0x3F, 0xFC, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1F, 0x19, 0x9F, 0xCF, 0x7F, 0xCF, 0xFF, 0xFF, 0xFC, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x03, 0xD9, 0x9F, 0xB7, 0x9E, 0xEF, 0xFF, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0xFC, 0xDF, 0xBF, 0xFF, 0xFF, 0xE3, 0x3F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x3F, 0xCF, 0xBF, 0xFF, 0xFF, 0xE3, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x07, 0xCF, 0xFF, 0xFF, 0xFB, 0xE3, 0xF3, 0xE0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0E, 0x00, 0x00, 0xC7, 0xF1, 0xFF, 0xFB, 0xFF, 0xFB, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x67, 0xC0, 0xFF, 0xFE, 0xFF, 0xFE, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x63, 0xE0, 0xFE, 0xFF, 0xC7, 0x86, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x00, 0xC3, 0xE0, 0xFF, 0x03, 0xF1, 0x83, 0xE0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xE0, 0x00, 0xC1, 0xF0, 0xE7, 0xC1, 0xF8, 0xF3, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x70, 0x00, 0x41, 0xF8, 0xC3, 0xF3, 0xFF, 0xFB, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x38, 0x00, 0x60, 0xF8, 0x03, 0xFB, 0xEF, 0xFF, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFC, 0x18, 0x60, 0xF8, 0x1E, 0x7E, 0xFF, 0xBF, 0xC0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0xEF, 0x78, 0x60, 0x7C, 0x7F, 0xFE, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x77, 0xEC, 0x60, 0x6C, 0x63, 0xFC, 0x7F, 0xFB, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x3E, 0x06, 0x60, 0x26, 0xE0, 0x7C, 0x00, 0x07, 0xC7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0xC0, 0x03, 0xB0, 0x37, 0xE7, 0xF8, 0x38, 0x3E, 0x67, 0xC0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x07, 0xE0, 0x01, 0xFE, 0x1B, 0xC7, 0xD8, 0x38, 0xF8, 0x63, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x6F, 0x1B, 0xCF, 0xB0, 0x66, 0xC0, 0x63, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0x9E, 0x00, 0x67, 0xCD, 0xDF, 0x30, 0x36, 0xC0, 0x21, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x07, 0x80, 0x06, 0xEC, 0xDC, 0x60, 0x33, 0xC0, 0x31, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0F, 0x81, 0xE0, 0x06, 0x7C, 0xFC, 0xE0, 0x1B, 0xC0, 0x31, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x70, 0x06, 0x1E, 0x71, 0xC0, 0x1D, 0xC0, 0x3D, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x60, 0x1C, 0x02, 0x06, 0x3B, 0xC0, 0x1D, 0xC0, 0x2F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xE0, 0x06, 0x03, 0x00, 0x3F, 0xC0, 0xD8, 0xC0, 0x6F, 0xF0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0C, 0xF0, 0x0F, 0x03, 0x00, 0x1F, 0xC0, 0x78, 0x00, 0x6D, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xF0, 0x0F, 0x83, 0x00, 0x77, 0xC0, 0x78, 0x00, 0x79, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x78, 0x0F, 0xC3, 0x00, 0x77, 0xC0, 0x38, 0x18, 0x71, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x38, 0x1B, 0xC3, 0x00, 0x6F, 0xC0, 0x0F, 0x3C, 0x71, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x1C, 0x1B, 0xC1, 0x80, 0x7F, 0xE0, 0x07, 0xFC, 0xF1, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1C, 0x1B, 0x41, 0x80, 0x3F, 0xFC, 0x0F, 0xEC, 0xF1, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x8E, 0x19, 0xE1, 0xF0, 0x0C, 0xFC, 0x0F, 0xD8, 0xE3, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x8F, 0x19, 0xE1, 0xF0, 0x0E, 0x6C, 0x1F, 0x18, 0xC3, 0xE0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0D, 0xC7, 0x19, 0xE1, 0xB0, 0x0C, 0xCC, 0x3F, 0x18, 0xC3, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xC7, 0x99, 0xE0, 0x18, 0x0C, 0xCC, 0x1F, 0x19, 0xE3, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0xE3, 0x99, 0xB0, 0x18, 0x18, 0xCC, 0x1F, 0x19, 0xFF, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x7B, 0xD9, 0xB0, 0x18, 0x0C, 0xCC, 0x1F, 0x19, 0xBF, 0x60, 0x00, 0x00, 0x00,
0x00, 0x00, 0x18, 0x79, 0xD9, 0xB0, 0x18, 0x0C, 0xCC, 0x1F, 0x19, 0x9F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3F, 0xF9, 0xB0, 0x18, 0x06, 0xCC, 0x1F, 0x31, 0x9F, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x37, 0xF9, 0xB0, 0x18, 0x03, 0xCC, 0x3F, 0x31, 0xBF, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x18, 0x39, 0xB0, 0x18, 0x01, 0xCC, 0x3F, 0x31, 0x9F, 0x30, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0C, 0x18, 0x3D, 0xB0, 0x18, 0x00, 0x18, 0x7F, 0x33, 0x9E, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x0E, 0x3D, 0xB0, 0x0C, 0x00, 0x18, 0x7E, 0x63, 0x1F, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x06, 0x1D, 0x98, 0x0C, 0x00, 0x18, 0xDE, 0x63, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x83, 0x1D, 0x98, 0x0C, 0x00, 0x18, 0xFE, 0x67, 0x1F, 0xF0, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x81, 0xB9, 0x98, 0x0C, 0x00, 0x18, 0xFE, 0x67, 0x3F, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC1, 0xB9, 0x98, 0x0C, 0x00, 0x19, 0xFE, 0xCF, 0x3B, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0xB9, 0x98, 0x0E, 0x00, 0x19, 0x9E, 0xCE, 0x38, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x39, 0xB9, 0x98, 0x06, 0x00, 0x1B, 0x9E, 0xCE, 0x78, 0x1B, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x19, 0xB8, 0xD8, 0x06, 0x00, 0x37, 0xB6, 0xDE, 0x78, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0D, 0xB0, 0xD8, 0x03, 0x00, 0x3F, 0xBD, 0xDE, 0x78, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x78, 0x01, 0x80, 0x3C, 0xFD, 0xDF, 0xD8, 0x09, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x38, 0x01, 0xC0, 0x3C, 0xFF, 0x7F, 0x98, 0x05, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xFB, 0xF8, 0x0F, 0x30, 0x18, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x3F, 0xD8, 0x03, 0x00, 0x18, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/*
40x40 Bitmap
Cross 'X'
*/
const uint8_t PROGMEM Fail[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x07, 0x00, 0x01, 0xF8, 0x00, 0x0F, 0x80, 0x01, 0xFC, 0x00, 0x1F, 0x80, 0x01, 0xFC, 0x00, 0x3F, 0x80, 0x00, 0xFE,
0x00, 0x3F, 0x80, 0x00, 0xFF, 0x00, 0x7F, 0x80, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0x00, 0x7F, 0x80, 0xFE, 0x00, 0x00, 0x3F, 0x81, 0xFE, 0x00, 0x00, 0x3F, 0xC3, 0xFC, 0x00, 0x00, 0x1F, 0xE3, 0xF8,
0x00, 0x00, 0x0F, 0xE7, 0xF8, 0x00, 0x00, 0x0F, 0xF7, 0xF0, 0x00, 0x00, 0x07, 0xFF, 0xE0, 0x00, 0x00, 0x03, 0xFF, 0xE0, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00,
0x00, 0xFF, 0x80, 0x00, 0x00, 0x01, 0xFF, 0x80, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x03, 0xFF, 0xC0, 0x00, 0x00, 0x07, 0xFF, 0xE0, 0x00, 0x00, 0x0F, 0xFF, 0xF0, 0x00, 0x00, 0x0F, 0xFF,
0xF0, 0x00, 0x00, 0x1F, 0xE7, 0xF8, 0x00, 0x00, 0x3F, 0xC3, 0xFC, 0x00, 0x00, 0x7F, 0xC3, 0xFE, 0x00, 0x00, 0x7F, 0x81, 0xFE, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x01, 0xFF, 0x00, 0xFF, 0x80,
0x01, 0xFE, 0x00, 0x7F, 0x80, 0x03, 0xFC, 0x00, 0x3F, 0xC0, 0x03, 0xF8, 0x00, 0x3F, 0xC0, 0x03, 0xF8, 0x00, 0x1F, 0xC0, 0x03, 0xF0, 0x00, 0x0F, 0xC0, 0x01, 0xE0, 0x00, 0x07, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/*
40x40 Bitmap
Tick
*/
const uint8_t PROGMEM Win[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00,
0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x78,
0x00, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0xF0, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x0F, 0x80, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00,
0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x03, 0x80, 0x7C, 0x00, 0x00, 0x0F, 0xC0, 0xF8, 0x00, 0x00, 0x1F, 0xE1, 0xF8, 0x00, 0x00, 0x07, 0xE1, 0xF0, 0x00, 0x00, 0x03, 0xF3, 0xE0,
0x00, 0x00, 0x03, 0xF7, 0xE0, 0x00, 0x00, 0x01, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00,
0x00, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void setup(void) {
#if defined(DEBUG) || defined(CALIBRATE)
Serial.begin(115200);
#endif // DEBUG || CALIBRATE
pinMode(TS_SENSE_PIN, OUTPUT);
MyDisplay.begin(Check_Which_LCD_Drver_Display_Uses());
MyDisplay.fillScreen(BLACK);
DrawThickRoundRectangle();
Draw_Logo(50, 40, MeLogo128x128, 128, 128);
Draw_Title();
Clear_Button_Area();
Draw_All_Buttons();
Print_Level();
}
void loop() {
/* Check if Screen is being touched */
digitalWrite(TS_SENSE_PIN, HIGH);
TSPoint _touchPoint = MyTouchScreen.getPoint();
digitalWrite(TS_SENSE_PIN, LOW);
pinMode(TS_XM, OUTPUT);
pinMode(TS_YP, OUTPUT);
if (_touchPoint.z > TS_MIN_PRESSURE && _touchPoint.z < TS_MAX_PRESSURE) {
Touch_Check(_touchPoint);
}
if (_touchPoint.z < TS_OFF_PRESSURE) {
LastPoint.y = 0; /* This resets Y so that a repeat button can be pressed */
}
delay(10);
}
/* Draw Border */
void DrawThickRoundRectangle() {
uint8_t _lineThickness = 4; /* Draw rectangle has no thickness, so to get thickness a rectangle needs to be draw several times */
for (size_t ii = 0; ii < sizeof(Colours) / sizeof(Colours[0]); ii++) { /* A loop for each colour drawn */
for (size_t i = 0; i < _lineThickness; i++) { /* A loop for thickness of a line */
int16_t adjustedRad = max(60 - i, 0); /* Ensure rad - i is non-negative */
MyDisplay.drawRoundRect(ii * _lineThickness + i,
ii * _lineThickness + i,
MyDisplay.width() - (_lineThickness * ii * 2) - (i * 2),
MyDisplay.height() - (_lineThickness * ii * 2) - (i * 2),
adjustedRad,
Colours[ii]);
}
}
}
/* Draw Logo */
void Draw_Logo(int16_t x, int16_t y, uint8_t* imageData, int16_t width, int16_t height) {
uint8_t _rowColour = 0;
uint8_t _colourSwitch = 0;
/* Iterate through each row */
for (int row = 0; row < height; row++) {
int rowByteIndex = row * ((width + 7) / 8); /* Calculate the byte index for the current row */
/* Iterate through each column */
for (int col = 0; col < width; col++) {
/*Calculate the bit position within the current byte (MSB first) */
int bitPosition = 7 - (col % 8); /*Subtract from 7 to reverse the order */
uint8_t currentByte = pgm_read_byte(&imageData[rowByteIndex + (col / 8)]); /* Get the byte containing the current pixel */
bool pixelValue = (currentByte >> bitPosition) & 1; /* Extract the bit for the current pixel (MSB first) */
/* Assuming 'color' represents the color value for the pixel */
if (pixelValue) {
MyDisplay.drawPixel(x + col, y + row, Colours[_rowColour]); /* Draw the pixel at (x + col, y + row) with the specified color */
/* This is to get a rainbow effect on the image */
_colourSwitch++;
if (_colourSwitch >= 4) {
_colourSwitch = 0;
_rowColour++;
}
if (_rowColour >= 5) {
_rowColour = 0;
}
}
}
}
}
/* Draw Title Tim Says */
void Draw_Title() {
uint8_t _charColour = 0; /* Colour Counter */
uint8_t _x = 24; /* Start position X */
uint8_t _y = 170; /* Start position Y */
uint8_t _charZoom = 4; /* Charector Magnification */
uint8_t _nextChar = _charZoom * 6; /* Distance to next Charector */
/* Print each charector one at a time so that we can change the colour of each */
for (size_t i = 0; i < sizeof(Title) / sizeof(Title[0]); i++) {
MyDisplay.setTextColor(Colours[i]);
MyDisplay.drawChar((i * _nextChar) + _x, _y, Title[i], Colours[_charColour], 0, _charZoom, _charZoom);
_charColour++;
if (_charColour >= 5) {
_charColour = 0;
}
}
}
/* Draw A Button refernced by its colour */
void Draw_Button(Round_Button button) {
MyDisplay.fillCircle(button.x, button.y, button.r, button.col);
}
/* Draw All Buttons */
void Draw_All_Buttons() {
for (size_t i = 0; i < sizeof(Buttons) / sizeof(Buttons[0]); i++) {
Draw_Button(Buttons[i]);
}
ShowButtons = true;
}
/* Clear Button Area */
void Clear_Button_Area() {
MyDisplay.fillRoundRect(50, 205, 141, 86, 20, BLACK);
ShowButtons = false;
}
/* Colour Tim Say */
void Colour_Select_Show(int16_t colour) {
MyDisplay.fillRoundRect(160, 120, 50, 50, 1, colour);
}
/*
Draw Result
This Draws
Tick = Win,
Cross = Fail.
*/
void Draw_Result(bool win) {
if (win) MyDisplay.drawBitmap(165, 70, Win, 40, 40, GREEN, BLACK);
else MyDisplay.drawBitmap(165, 70, Fail, 40, 40, RED, BLACK);
}
/* Clear Result */
void Clear_Result() {
MyDisplay.fillRect(165, 70, 40, 40, BLACK);
}
/* Print Level */
void Print_Level() {
uint8_t _xPos = 60;
uint8_t _textWidth = 12; /* Text width is 6, but I doubleing the text size. */
MyDisplay.setTextColor(WHITE, BLACK); /* Set the text color (forcolour, backcolour) */
MyDisplay.setTextSize(2); /* Set the text size */
MyDisplay.setCursor(30, 64); /* Set the position */
MyDisplay.print("Level"); /* Clear unused x10 and X100 */
MyDisplay.setCursor(36, 80); /* Set the position */
MyDisplay.print(" "); /* Clear unused x10 and X100 */
/* This is to give text alighnment */
if (Level > 9) {
_xPos -= _textWidth;
}
if (Level > 99) {
_xPos -= _textWidth;
}
MyDisplay.setCursor(_xPos, 80); /* Set the position */
MyDisplay.print(Level); /* Print Level to the screen */
}
/* Generat a sequence */
void generate_sequence() {
randomSeed(millis()); /* Using current millis as the seed. */
for (size_t i = 0; i < MAX_LEVEL; i++) {
uint8_t randomIndex = random(NumberOfColors); /* Get a random index */
GeneratedSequence[i] = Colours[randomIndex]; /* Use the random index for choice of colour */
}
}
/* Show Sequence */
void Show_Sequence() {
Clear_Result();
Clear_Button_Area();
Colour_Select_Show(BLACK);
delay(600);
for (size_t i = 0; i < Level; i++) {
Colour_Select_Show(GeneratedSequence[i]);
delay(600);
Colour_Select_Show(BLACK);
delay(600);
}
Draw_All_Buttons();
}
/* Button Result */
void ButtonResult(Round_Button button) {
#ifdef DEBUG
Serial.println(button.name);
Serial.println(PlayerCount);
Serial.println();
#endif // DEBUG
PlayerSequence[PlayerCount] = button.col;
if (PlayerSequence[PlayerCount] != GeneratedSequence[PlayerCount]) {
Draw_Result(false);
Clear_Button_Area();
return;
}
PlayerCount++;
if (PlayerCount >= Level) {
Draw_Result(true);
Clear_Button_Area();
}
delay(100);
}
/*
Do Touch
You can Use DEBUG to check the bounderies of the Buttons.
The magic formula for finding if somthing is inside a circle (credit to https://github.com/educ8s)
X²+Y²<=r² ?
*/
void Touch_Check(TSPoint _currentTouchPoint) {
#ifndef CALIBRATE
/* Map current touch to the screen */
_currentTouchPoint.x = map(_currentTouchPoint.x, TS_MIN_X, TS_MAX_X, 0, MyDisplay.width());
_currentTouchPoint.y = map(_currentTouchPoint.y, TS_MIN_Y, TS_MAX_Y_SCREEN, 0, MyDisplay.height());
#endif // !CALIBRATE
#if defined(DEBUG) || defined(CALIBRATE)
Serial.print("X = ");
Serial.println(_currentTouchPoint.x);
Serial.print("Y = ");
Serial.println(_currentTouchPoint.y);
Serial.print("Z = ");
Serial.println(_currentTouchPoint.z);
Serial.println();
#endif // DEBUG || CALIBRATE
/* ===== Do off screen menu stuff here ===== */
if (_currentTouchPoint.y > MyDisplay.height()) {
#ifdef DEBUG
Serial.println("menu");
#endif // DEBUG
/*
There are 5 icons on the touch screen.
This splits the area off screen into 5.
*/
if (_currentTouchPoint.x < 45) {
#ifdef DEBUG
Serial.println("start");
#endif // DEBUG
PlayerCount = 0;
generate_sequence();
Show_Sequence();
}
if (_currentTouchPoint.x > 45 && _currentTouchPoint.x < 95) {
#ifdef DEBUG
Serial.println("2");
#endif // DEBUG
}
if (_currentTouchPoint.x > 95 && _currentTouchPoint.x < 140) {
#ifdef DEBUG
Serial.println("3");
#endif // DEBUG
}
if (_currentTouchPoint.x > 140 && _currentTouchPoint.x < 190) {
#ifdef DEBUG
Serial.println("Level -");
#endif // DEBUG
Level--;
if (Level <= 1) Level = 1;
Print_Level();
}
if (_currentTouchPoint.x > 190) {
#ifdef DEBUG
Serial.println("Level +");
#endif // DEBUG
Level++;
if (Level >= 100) Level = 100;
Print_Level();
}
delay(100);
}
/* ===== Do on screen stuff here ===== */
if (ShowButtons) { /* Only if game is playing */
/* We need to set a condition that we are not reciving the same touch, has to be a diffeent location. */
if ((abs(_currentTouchPoint.x - LastPoint.x) >= 30) || (abs(_currentTouchPoint.y - LastPoint.y) >= 30)) {
/* Red Button */
if (((Red_Button.x - _currentTouchPoint.x) * (Red_Button.x - _currentTouchPoint.x)) +
((Red_Button.y - _currentTouchPoint.y) * (Red_Button.y - _currentTouchPoint.y)) <= (Red_Button.r * Red_Button.r)) {
Colour_Select_Show(Red_Button.col);
ButtonResult(Red_Button);
}
/* Orange_Button */
if (((Orange_Button.x - _currentTouchPoint.x) * (Orange_Button.x - _currentTouchPoint.x)) +
((Orange_Button.y - _currentTouchPoint.y) * (Orange_Button.y - _currentTouchPoint.y)) <= (Orange_Button.r * Orange_Button.r)) {
Colour_Select_Show(Orange_Button.col);
ButtonResult(Orange_Button);
}
/* Yellow_Button */
if (((Yellow_Button.x - _currentTouchPoint.x) * (Yellow_Button.x - _currentTouchPoint.x)) +
((Yellow_Button.y - _currentTouchPoint.y) * (Yellow_Button.y - _currentTouchPoint.y)) <= (Yellow_Button.r * Yellow_Button.r)) {
Colour_Select_Show(Yellow_Button.col);
ButtonResult(Yellow_Button);
}
/* Green_Button */
if (((Green_Button.x - _currentTouchPoint.x) * (Green_Button.x - _currentTouchPoint.x)) +
((Green_Button.y - _currentTouchPoint.y) * (Green_Button.y - _currentTouchPoint.y)) <= (Green_Button.r * Green_Button.r)) {
Colour_Select_Show(Green_Button.col);
ButtonResult(Green_Button);
}
/* Blue_Button */
if (((Blue_Button.x - _currentTouchPoint.x) * (Blue_Button.x - _currentTouchPoint.x)) +
((Blue_Button.y - _currentTouchPoint.y) * (Blue_Button.y - _currentTouchPoint.y)) <= (Blue_Button.r * Blue_Button.r)) {
Colour_Select_Show(Blue_Button.col);
ButtonResult(Blue_Button);
}
/* Purple_Button */
if (((Purple_Button.x - _currentTouchPoint.x) * (Purple_Button.x - _currentTouchPoint.x)) +
((Purple_Button.y - _currentTouchPoint.y) * (Purple_Button.y - _currentTouchPoint.y)) <= (Purple_Button.r * Purple_Button.r)) {
Colour_Select_Show(Purple_Button.col);
ButtonResult(Purple_Button);
}
LastPoint = _currentTouchPoint;
}
}
}
/*
This is An Adafruit Method.
Having this method gives a good chance different TFT displays will work with this code.
It relizes on the Adafruit Library,
*/
uint16_t Check_Which_LCD_Drver_Display_Uses() {
Serial.println(F("Checking LCD Driver"));
MyDisplay.reset();
uint16_t identifier = MyDisplay.readID();
if (identifier == 0x9325) {
Serial.println(F("Found ILI9325 LCD driver"));
}
else if (identifier == 0x9328) {
Serial.println(F("Found ILI9328 LCD driver"));
}
else if (identifier == 0x7575) {
Serial.println(F("Found HX8347G LCD driver"));
}
else if (identifier == 0x9341) {
Serial.println(F("Found ILI9341 LCD driver"));
}
else if (identifier == 0x8357) {
Serial.println(F("Found HX8357D LCD driver"));
}
else {
Serial.print(F("Unknown LCD driver chip: "));
Serial.println(identifier, HEX);
Serial.println(F("If using the Adafruit 2.4\" TFT Arduino shield, the line:"));
Serial.println(F(" #define USE_ADAFRUIT_SHIELD_PINOUT"));
Serial.println(F("should appear in the library header (Adafruit_TFT.h)."));
Serial.println(F("If using the breakout board, it should NOT be #defined!"));
Serial.println(F("Also if using the breakout, double-check that all wiring"));
Serial.println(F("matches the tutorial."));
}
return identifier;
}