Hardware components | ||||||
| × | 1 | ||||
![]() |
| × | 1 | |||
![]() |
| × | 1 | |||
Software apps and online services | ||||||
![]() |
| |||||
Need another words
Read moreSometimes we need to show special word or symbol in the LCD monitor, and we will spend more time to design or create it. If we have an easy and rapid editable program to help us, it's very good.
We have 2 ways to achieve the purpose with or without MicroSD card adapter showing below.
Use matrix_pixel_taiwan_40x40 Excel file to encodeIn the Excel file, you just only put your 40*40 word in prototype area, and then press button on the top of left. You will get a series of encode values on the most right table, then you copy them into Arduino make_word.ino file to decode, Things done.
// Written by ChihNan Chuang
#include <SoftwareSerial.h> //
#include <Adafruit_GFX.h> // , points, lines, circles, etc
#include <Adafruit_TFTLCD.h> // , 8-bit 16-channel PWM & Servo driver, shield or FeatherWing
#include <TouchScreen.h> // , 4-wire resistive touch screen firmware
#define YP A2 // HX8347G , , "An" !
#define XM A1 // HX8347G , , "An" !
#define YM 6 // HX8347G ,
#define XP 7 // HX8347G ,
//#define YP A3 // ILI9328 , , "An" !
//#define XM A2 // ILI9328 , , "An" !
//#define YM 9 // ILI9328 ,
//#define XP 8 // ILI9328 ,
#define TS_MINX 250 // , ;USB 150
#define TS_MINY 210 // , ;USB 120
#define TS_MAXX 870 // , ;USB 920
#define TS_MAXY 940 // , ;USB 940
#define MINPRESSURE 10 // , z
#define MAXPRESSURE 1000 // , z
#define LCD_CS A3 // , Chip Select
#define LCD_CD A2 // , Command/Data
#define LCD_WR A1 // , LCD Write
#define LCD_RD A0 // , LCD Read
#define LCD_RESET A4 // , connect to Arduino RESET pin,
// 16-bit:
#define BLACK 0x0000 // ,
#define WHITE 0xFFFF // ,
#define RED 0xF800 // ,
#define ORANGE 0xFD20 // ,
#define YELLOW 0xFFE0 // ,
#define GREEN 0x07E0 // ,
#define CYAN 0x07FF // ,
#define BLUE 0x001F // ,
#define PURPLE 0x780F // ,
#define PINK 0xF81F // ,
// For better pressure precision, we need to know the resistance between X+ and X- using any multimeter
// to read it. For the one we're using, it's 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); // X300
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); //
Adafruit_GFX_Button buttons[1]; // 1
int TFT_WIDTH; // 2.4" TFT LCD width pixels
int TFT_HEIGHT; // 2.4" TFT LCD height pixels
void setup() {
Serial.begin(9600); // most baud rate set 9600 for touch panel
Serial.println("TFT LCD TEST...");
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
Serial.println("Using Adafruit 2.4\" TFT Arduino Shield Pinout");
#else
Serial.println("Using Adafruit 2.4\" TFT Breakout Board Pinout");
#endif
TFT_WIDTH = tft.width(); // 2.4" TFT LCD width pixels = 240
TFT_HEIGHT = tft.height(); // 2.4" TFT LCD height pixels = 320
Serial.print("TFT size is ");
Serial.print(TFT_WIDTH);
Serial.print("x");
Serial.println(TFT_HEIGHT);
tft.reset(); // reset touch screen
uint16_t identifier = tft.readID(); //
if (identifier == 0x0101) identifier = 0x9341;
if (identifier == 0x6767) identifier = 0x7575;
if (identifier == 0x9325) {
Serial.println("Found ILI9325 LCD driver");
} else if (identifier == 0x4535) {
Serial.println("Found LGDP4535 LCD driver");
} else if (identifier == 0x9328) {
ts = TouchScreen(8, A3, A2, 9, 300);
Serial.println("Found ILI9328 LCD driver");
} else if (identifier == 0x7575) {
ts = TouchScreen(7, A2, A1, 6, 300);
Serial.println("Found HX8347G LCD driver");
} else if (identifier == 0x9341) {
Serial.println("Found ILI9341 LCD driver");
} else if (identifier == 0x8357) {
Serial.println("Found HX8357D LCD driver");
} else {
Serial.print("Unknown LCD driver chip: ");
Serial.println(identifier, HEX);
return;
}
tft.begin(identifier); // touch panel begin to start touch panel
key_menu(); // key menu
}
void loop() {
int i = 10;
TSPoint p;
do {
i--;
digitalWrite(13, HIGH);
p = ts.getPoint(); // Get the touch value on the panel
digitalWrite(13, LOW);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
} while ((p.z == 0) && (i > 0));
if (p.z > MINPRESSURE && p.z < MAXPRESSURE) { // get p.x and p.y
p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0); // scale from 0->1023
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
Serial.print("(");
Serial.print(p.x);
Serial.print(", ");
Serial.print(p.y);
Serial.print(", ");
Serial.print(p.z);
Serial.println(") ");
}
// Which button is touched?
for (uint8_t bt = 0; bt < 1; bt++) {
delay(50);
if (buttons[bt].contains(p.x, p.y)) {
buttons[bt].press(true); // touch down
if (bt == 0) {
show_word();
key_menu(); // key menu
break;
}
} else {
buttons[bt].press(false); // no touch
}
}
}
//
void key_menu() {
tft.fillScreen(BLACK); // touch panel background set to black
//
buttons[0].initButton(&tft, 120, 160, 240, 130, RED, YELLOW, BLACK,"", 1);
buttons[0].drawButton();
tftChineseLibrary( 40,120,"please",BLUE,YELLOW,4,0);
tftChineseLibrary(100,120,"press",BLUE,YELLOW,4,0);
tftChineseLibrary(160,120,"key",BLUE,YELLOW,4,0);
tft.setTextSize(4); //
tft.setTextColor(BLUE); //
tft.setCursor(30, 175); //
tft.print("Press Me"); //
}
void show_word() {
tft.fillScreen(WHITE);
tft.fillRect(10, 10, 220, 140, PURPLE); // rectangle
tftChineseLibrary(30 ,40 ,"make",RED,YELLOW,8,0);
tftChineseLibrary(130,40 ,"word",RED,YELLOW,8,0);
tft.drawLine(0, 160, 239, 160, RED); // line
tft.fillRect(10, 170, 220, 140, PURPLE);
tft.fillRect(12 , 220, 98, 46, YELLOW);
tft.fillRect(130, 220, 98, 46, YELLOW);
tft.setTextSize(4);
tft.setTextColor(RED);
tft.setCursor(14, 230);
tft.print("MAKE WORD");
delay(2000);
tft.fillScreen(GREEN);
tftChineseLibrary(10 ,30 ,"I",BLACK,GREEN,4,0);
tftChineseLibrary(55 ,30 ,"from1",BLACK,GREEN,4,0);
tftChineseLibrary(100,30 ,"from2",BLACK,GREEN,4,0);
tftChineseLibrary(145,30 ,"tai",BLACK,GREEN,4,0);
tftChineseLibrary(190,30 ,"wan",BLACK,GREEN,4,0);
tftChineseLibrary(25 ,80 ,"welcome1",BLACK,GREEN,4,0);
tftChineseLibrary(75 ,80 ,"welcome2",BLACK,GREEN,4,0);
tftChineseLibrary(125,80 ,"welcome3",BLACK,GREEN,4,0);
tftChineseLibrary(175,80 ,"welcome4",BLACK,GREEN,4,0);
tftChineseLibrary(105,130,"Taiwan1",BLACK,GREEN,4,0);
tftChineseLibrary(105,170,"Taiwan2",BLACK,GREEN,4,0);
tft.setTextSize(2);
tft.setTextColor(BLACK);
tft.setCursor(30, 220);
tft.print("I'm from Taiwan");
tft.setTextSize(4);
tft.setCursor(40, 250);
tft.print("Welcome");
delay(2000);
// 0 degree
tft.fillScreen(BLUE);
tft.setTextSize(2);
tft.setTextColor(YELLOW);
tft.setCursor(0, 3);
tft.print("20*20");
tft.setCursor(0, 35);
tft.print("30*30");
tft.setCursor(0, 73);
tft.print("40*40");
tft.setCursor(0,128);
tft.print("80*80");
tftChineseLibrary(60 ,0 ,"welcome1",YELLOW,BLUE,2,0);
tftChineseLibrary(85 ,0 ,"welcome2",YELLOW,BLUE,2,0);
tftChineseLibrary(60 ,25 ,"welcome1",YELLOW,BLUE,3,0);
tftChineseLibrary(95 ,25 ,"welcome2",YELLOW,BLUE,3,0);
tftChineseLibrary(60 ,58 ,"welcome1",YELLOW,BLUE,4,0);
tftChineseLibrary(105,58 ,"welcome2",YELLOW,BLUE,4,0);
tftChineseLibrary(60 ,95 ,"welcome1",YELLOW,BLUE,8,0);
tftChineseLibrary(145,95 ,"welcome2",YELLOW,BLUE,8,0);
tftChineseLibrary(80 ,169,"Taiwan1",YELLOW,BLUE,8,0);
tftChineseLibrary(80 ,249,"Taiwan2",YELLOW,BLUE,8,0);
delay(2000);
// 90 degree
tft.fillScreen(ORANGE);
tft.setTextSize(2);
tft.setTextColor(PURPLE);
tft.setCursor(0, 3);
tft.print("20*20");
tft.setCursor(0, 35);
tft.print("30*30");
tft.setCursor(0, 73);
tft.print("40*40");
tft.setCursor(0, 128);
tft.print("80*80");
tftChineseLibrary(85 ,0 ,"welcome1",PURPLE,ORANGE,2,1);
tftChineseLibrary(60 ,0 ,"welcome2",PURPLE,ORANGE,2,1);
tftChineseLibrary(95 ,25 ,"welcome1",PURPLE,ORANGE,3,1);
tftChineseLibrary(60 ,25 ,"welcome2",PURPLE,ORANGE,3,1);
tftChineseLibrary(105,58 ,"welcome1",PURPLE,ORANGE,4,1);
tftChineseLibrary(60 ,58 ,"welcome2",PURPLE,ORANGE,4,1);
tftChineseLibrary(145,95 ,"welcome1",PURPLE,ORANGE,8,1);
tftChineseLibrary(60 ,95 ,"welcome2",PURPLE,ORANGE,8,1);
tftChineseLibrary(120,209,"Taiwan1",PURPLE,ORANGE,8,1);
tftChineseLibrary(40 ,209,"Taiwan2",PURPLE,ORANGE,8,1);
delay(2000);
// 180 degree
tft.fillScreen(CYAN);
tft.setTextSize(2);
tft.setTextColor(RED);
tft.setCursor(0, 3);
tft.print("20*20");
tft.setCursor(0, 35);
tft.print("30*30");
tft.setCursor(0, 73);
tft.print("40*40");
tft.setCursor(0, 128);
tft.print("80*80");
tftChineseLibrary(85 ,0 ,"welcome1",RED,CYAN,2,2);
tftChineseLibrary(60 ,0 ,"welcome2",RED,CYAN,2,2);
tftChineseLibrary(95 ,25 ,"welcome1",RED,CYAN,3,2);
tftChineseLibrary(60 ,25 ,"welcome2",RED,CYAN,3,2);
tftChineseLibrary(105,58 ,"welcome1",RED,CYAN,4,2);
tftChineseLibrary(60 ,58 ,"welcome2",RED,CYAN,4,2);
tftChineseLibrary(145,95 ,"welcome1",RED,CYAN,8,2);
tftChineseLibrary(60 ,95 ,"welcome2",RED,CYAN,8,2);
tftChineseLibrary(80 ,249,"Taiwan1",RED,CYAN,8,2);
tftChineseLibrary(80 ,169,"Taiwan2",RED,CYAN,8,2);
delay(2000);
// 270 degree
tft.fillScreen(PINK);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(0, 3);
tft.print("20*20");
tft.setCursor(0, 35);
tft.print("30*30");
tft.setCursor(0, 73);
tft.print("40*40");
tft.setCursor(0, 128);
tft.print("80*80");
tftChineseLibrary(60 ,0 ,"welcome1",WHITE,PINK,2,3);
tftChineseLibrary(85 ,0 ,"welcome2",WHITE,PINK,2,3);
tftChineseLibrary(60 ,25 ,"welcome1",WHITE,PINK,3,3);
tftChineseLibrary(95 ,25 ,"welcome2",WHITE,PINK,3,3);
tftChineseLibrary(60 ,58 ,"welcome1",WHITE,PINK,4,3);
tftChineseLibrary(105,58 ,"welcome2",WHITE,PINK,4,3);
tftChineseLibrary(60 ,95 ,"welcome1",WHITE,PINK,8,3);
tftChineseLibrary(145,95 ,"welcome2",WHITE,PINK,8,3);
tftChineseLibrary(40 ,209,"Taiwan1",WHITE,PINK,8,3);
tftChineseLibrary(120,209,"Taiwan2",WHITE,PINK,8,3);
delay(2000);
}
// , (xx,yy), chinese_word, text_color,
// back_color, times10times*10times(2,3,4,8),
// rotate =0~3, 0,90,180,270rotation
void tftChineseLibrary(int xx, int yy, char chinese_word[], uint16_t text_color,
uint16_t back_color, int times, int rotate)
{
int encode1[400], temp1[400]; // , 400
int i = 0, x = 0, y = 0, sum1 = 0;
boolean num = false;
boolean chinese[40][40]; //
//
if (chinese_word == "make") {
int temp1[145] = {102,4,36,4,36,4,37,3,18,4,15,3,18,5,8,3,3,3,19,5,7,4,2,3,19,5,7,4,2,3,20,4,6,4,3,8,16,3,6,4,
3,8,25,14,26,11,28,3,5,3,29,3,5,3,20,4,4,2,7,3,3,6,10,7,2,2,7,13,6,10,1,23,6,9,2,15,18,4,4,3,
29,3,19,3,15,2,9,16,13,3,8,16,14,3,8,3,7,5,15,3,7,3,7,4,16,3,7,3,7,4,16,3,7,3,7,4,16,2,8,14,
16,2,9,13,8,16,3,2,20,19,22,2,10,25,17,23,21,17,25,14,30,6,128,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "word") {
int temp1[107] = {96,4,36,5,36,5,35,5,8,2,15,2,9,16,13,2,6,19,12,15,8,6,11,10,12,8,9,4,19,6,11,4,18,4,14,3,11,7,19,3,
8,11,24,9,2,6,23,6,4,6,33,5,35,4,33,5,35,4,37,3,8,5,24,3,3,12,15,26,6,34,5,12,4,4,22,7,7,4,36,4,
36,4,36,4,36,4,36,4,36,4,36,4,32,2,2,4,32,8,33,6,35,5,36,3,100,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "I") {
int temp1[191] = {100,3,37,4,36,4,36,4,36,4,31,3,3,3,2,3,25,5,2,3,3,5,21,6,2,3,4,4,18,7,4,3,4,4,18,6,6,2,5,3,
14,10,6,2,22,5,1,4,6,2,28,3,7,2,2,7,19,3,7,11,19,18,21,14,19,14,4,4,4,3,11,11,8,3,4,4,12,4,2,3,
8,3,4,4,18,3,8,3,4,4,18,3,9,2,3,5,18,6,6,3,2,4,18,6,7,3,1,4,18,6,8,8,14,9,10,6,13,11,10,5,
12,8,2,3,9,5,13,6,4,4,8,6,6,2,6,2,6,4,6,8,6,2,14,4,6,4,1,4,5,2,14,4,4,4,4,4,4,2,10,3,
1,4,2,5,5,5,2,3,11,6,3,2,10,8,12,5,15,8,13,4,17,6,13,3,18,6,36,4,42,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "from1") {
int temp1[175] = {56,2,37,5,36,4,36,4,36,4,36,4,2,5,29,12,20,20,20,17,24,5,2,4,5,3,28,4,4,5,20,4,3,4,4,4,21,4,3,4,
4,4,20,5,3,4,4,3,21,4,4,4,3,3,22,4,4,4,2,6,19,7,2,4,2,8,16,9,1,3,1,4,2,5,15,3,2,4,1,3,
1,3,3,5,13,4,4,2,2,5,7,3,13,3,8,5,8,3,12,2,9,8,32,9,29,7,1,4,28,7,1,5,25,5,1,3,3,5,23,4,
2,3,3,6,20,5,3,3,5,6,18,4,4,3,5,8,14,5,5,4,5,10,10,5,6,4,6,11,6,5,8,4,7,11,4,4,10,4,8,8,
19,5,35,5,35,5,36,3,37,3,37,2,22,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "from2") {
int temp1[121] = {97,2,37,4,36,6,34,6,34,4,36,4,35,3,36,4,36,3,5,6,25,3,3,10,20,21,19,12,4,5,20,4,12,3,21,3,13,3,21,3,
13,3,21,3,13,3,21,3,3,13,21,19,21,10,6,3,21,6,10,3,21,3,13,3,21,3,13,3,21,2,6,11,21,2,2,15,21,13,3,3,
21,8,8,3,21,2,14,3,21,2,14,3,20,3,13,4,20,3,13,5,19,21,19,21,19,9,6,5,20,3,12,5,21,2,13,3,37,3,92,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "tai") {
int temp1[107] = {98,2,38,2,37,5,35,5,34,5,35,5,34,5,35,5,34,4,7,2,27,4,7,3,24,4,10,5,21,4,10,6,18,5,13,5,17,4,14,6,
13,6,5,16,12,28,12,18,6,4,12,15,10,3,13,7,33,4,95,3,29,13,19,22,18,10,6,6,18,6,10,5,19,4,12,4,21,3,12,4,
21,3,12,4,21,3,12,4,21,3,10,5,22,3,8,7,23,18,22,18,22,2,38,2,106,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "wan") {
int temp1[255] = {61,2,31,2,5,4,5,3,21,2,5,4,5,3,11,4,5,3,6,6,1,3,1,2,9,6,3,3,4,12,1,3,10,4,2,3,1,9,3,2,
2,4,10,4,2,3,1,3,8,8,12,3,1,3,1,3,2,6,1,7,14,10,2,6,1,7,16,7,5,4,3,3,1,3,15,7,2,6,2,8,
16,3,1,3,5,2,1,6,1,2,6,3,7,8,2,10,2,2,6,6,3,8,1,7,1,5,1,4,5,5,3,3,2,1,3,2,2,14,6,4,
5,1,2,3,1,6,2,2,1,3,1,3,6,4,5,6,1,6,2,2,2,2,2,2,8,2,2,6,1,2,2,1,5,3,20,3,1,2,8,6,
18,5,3,15,17,2,1,2,3,10,1,4,17,2,16,4,17,3,12,8,16,3,6,15,16,3,6,11,19,3,8,3,10,2,13,4,8,3,5,8,
12,4,8,18,8,5,8,9,4,6,8,4,9,3,11,4,9,4,9,3,11,3,10,4,23,3,10,4,22,4,11,2,17,3,2,5,12,1,17,10,
32,7,33,6,35,4,36,3,12,0,36,3,12,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "welcome1") {
int temp1[223] = {96,3,37,4,6,3,19,3,5,4,6,4,18,3,5,4,6,4,18,4,4,8,2,4,18,4,4,6,1,1,2,4,14,8,4,2,7,4,15,8,
4,2,7,4,21,2,3,2,7,4,22,2,3,2,2,2,3,4,22,12,2,12,12,14,2,13,8,12,2,3,1,5,4,5,9,2,2,3,1,3,
1,4,1,3,6,4,10,2,2,3,2,10,6,3,12,7,2,9,2,2,3,2,13,5,2,2,6,2,3,4,17,4,2,3,5,1,4,4,18,4,
2,6,6,4,18,3,3,8,4,3,17,15,5,3,17,12,8,3,16,5,4,6,6,4,14,6,3,8,5,4,13,3,2,12,5,6,11,4,2,8,
9,7,8,3,5,2,4,7,3,4,1,3,8,2,6,13,3,3,3,3,15,8,8,2,4,4,13,3,4,2,7,3,4,5,12,3,4,12,6,5,
10,18,7,6,8,10,4,4,9,7,6,4,9,3,11,7,7,3,37,3,110,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "welcome2") {
int temp1[181] = {182,4,36,5,17,5,12,5,19,5,10,5,21,6,7,4,23,6,6,4,10,2,14,3,3,6,4,2,2,8,12,3,4,4,5,12,20,3,5,4,
4,4,20,2,6,4,4,4,11,3,6,2,6,4,4,4,10,5,5,2,6,4,4,4,6,10,4,2,6,4,4,4,6,10,4,2,6,4,4,4,
10,4,6,2,4,6,4,3,11,4,6,2,3,9,2,3,11,3,6,7,2,3,1,7,11,2,7,7,2,3,2,6,11,4,5,5,4,3,3,4,
13,3,5,5,4,3,3,4,14,3,4,3,6,3,21,3,4,3,6,3,21,3,13,3,21,3,13,3,14,11,12,3,14,13,10,3,15,16,6,2,
16,4,6,9,3,2,30,17,24,23,20,19,24,14,28,9,32,6,88,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "welcome3") {
int temp1[153] = {96,4,36,5,36,5,35,5,35,4,36,4,5,3,28,4,5,5,26,4,4,6,18,4,4,3,4,7,18,5,3,3,4,6,20,5,2,3,2,5,
23,5,2,3,2,3,27,3,2,3,32,3,2,3,37,3,37,3,6,6,22,20,12,28,10,14,1,5,21,12,2,5,29,4,3,4,29,4,3,4,
28,4,4,3,29,4,4,3,28,4,5,3,13,1,14,4,5,3,13,1,13,4,6,3,13,2,11,5,6,3,12,3,10,4,8,3,12,3,10,4,
8,3,11,4,8,5,9,4,10,4,8,4,10,4,9,5,6,4,13,17,5,5,13,17,4,3,17,15,27,11,85,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "welcome4") {
int temp1[209] = {102,3,37,4,36,4,36,4,27,3,6,4,23,8,5,4,16,16,3,3,4,7,7,13,5,4,1,11,7,4,3,4,6,11,13,3,3,3,7,7,
17,3,3,3,6,3,22,3,3,3,5,4,6,4,12,3,3,6,2,2,1,13,10,3,3,9,2,7,1,5,10,14,4,3,5,3,11,7,3,4,
4,3,4,4,11,3,6,3,6,3,4,3,12,3,6,3,6,3,3,4,12,2,6,4,7,10,11,2,4,6,7,7,14,12,28,9,21,2,8,2,
4,3,9,16,6,2,4,2,4,2,2,18,6,2,4,2,4,11,1,2,4,4,6,2,4,2,5,3,3,3,2,2,4,4,6,2,4,2,5,3,
3,3,2,2,4,3,7,2,4,2,6,2,3,3,2,2,4,3,6,17,2,4,2,3,1,4,7,17,1,5,2,9,7,5,7,1,1,8,2,7,
9,2,12,4,7,2,249,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "please") {
int temp1[161] = {103,5,35,5,20,3,13,4,20,4,12,3,21,5,11,10,14,5,7,14,15,4,5,10,22,6,2,9,19,12,6,9,9,16,6,10,7,9,10,10,
12,6,12,7,37,3,5,6,12,4,10,15,7,34,6,6,3,16,25,5,29,4,14,4,14,9,3,15,13,8,4,15,27,3,7,3,27,3,7,3,
16,7,4,13,11,12,4,13,11,5,3,4,4,5,5,3,12,3,4,3,5,2,8,3,13,2,4,2,6,13,13,2,4,2,6,13,13,8,6,2,
8,3,13,8,6,2,8,3,13,4,9,3,8,3,14,1,11,3,8,3,25,3,5,7,25,3,5,7,24,3,8,4,25,2,9,4,37,2,49,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "press") {
int temp1[197] = {129,3,37,5,35,5,8,4,24,4,9,5,22,4,9,5,22,3,11,4,22,3,11,4,22,3,5,2,5,12,13,3,5,20,12,6,2,8,6,6,
11,7,1,5,10,4,7,13,1,3,2,2,7,3,9,11,2,4,2,3,6,2,17,2,4,4,2,4,24,2,4,3,3,4,24,2,2,1,7,4,
24,5,7,4,2,2,20,5,7,3,3,4,1,5,11,5,8,2,4,11,8,5,1,27,6,6,1,26,4,6,1,2,2,9,4,4,10,7,2,2,
4,1,3,3,4,3,10,7,3,2,7,3,4,4,11,5,4,2,7,3,4,4,12,2,6,2,7,10,21,2,9,7,21,3,11,7,19,3,10,10,
13,8,7,6,1,7,12,7,6,6,3,6,13,5,4,7,7,5,13,4,3,7,8,6,12,4,20,4,13,2,22,2,85,0,85,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "key") {
int temp1[185] = {170,4,36,4,36,4,36,5,35,8,31,9,30,4,2,4,30,4,3,3,30,3,15,10,11,4,11,15,9,4,4,2,4,9,3,4,10,4,2,6,
3,7,4,4,9,12,7,4,4,4,8,12,8,4,4,4,7,4,3,4,10,4,4,4,7,3,4,4,10,4,4,3,7,3,5,8,6,3,5,6,
3,3,6,8,6,3,3,9,1,3,1,12,2,24,2,9,5,19,13,3,2,3,2,3,1,2,5,3,10,2,4,3,2,3,5,3,5,3,10,4,
2,3,1,4,5,3,4,4,11,4,1,3,1,3,6,3,4,4,12,3,1,3,1,1,1,4,2,3,5,4,12,3,1,3,1,6,2,3,5,3,
16,8,5,3,1,14,6,9,5,20,1,11,4,24,1,9,6,9,17,4,38,2,194,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "Taiwan1") {
int temp1[145] = {189,3,36,2,1,2,34,2,3,2,32,2,5,4,25,5,9,2,22,3,14,2,20,2,17,2,19,1,17,2,19,2,16,2,20,1,16,2,20,2,
16,1,21,1,17,1,20,2,17,1,19,2,18,2,17,2,20,1,16,2,21,1,16,1,22,1,15,2,21,2,14,2,22,1,15,1,22,2,14,2,
22,1,15,1,22,2,14,2,21,2,15,1,22,1,15,2,21,2,15,1,22,1,15,2,22,1,14,2,23,1,14,1,24,1,13,2,24,1,13,1,
24,2,12,2,24,1,12,2,25,1,12,1,26,1,11,2,25,2,11,1,26,1,10,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
if (chinese_word == "Taiwan2") {
int temp1[145] = {2,1,26,1,12,1,26,1,12,1,26,1,12,1,25,2,12,1,25,1,13,1,24,2,12,2,24,1,13,1,25,1,13,1,25,1,12,2,24,2,
12,1,25,1,13,2,23,2,14,2,22,1,16,2,20,2,17,1,19,2,18,1,19,1,19,2,17,2,20,1,17,1,21,1,15,3,21,1,14,2,
23,2,13,1,25,2,11,2,26,3,9,1,29,3,7,1,31,2,5,2,32,1,5,1,33,2,4,1,34,1,4,1,34,2,3,1,35,1,3,1,
35,1,3,1,35,1,3,1,35,1,3,1,35,1,2,2,35,4,37,1,1,1,183,0} ;
do
{
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
goto DECODING; }
return;
ARRAY:
i = 0;
do {
encode1[i] = temp1[i];
i++;
} while ( temp1[i] != 0);
DECODING:
// 40*40
i = 0;
do
{
for (int j = 0; j < encode1[i]; j++) {
chinese[x][y] = num;
x++;
if (x == 40) { x = 0; y++; }
}
if (num == false) num = true;
else num = false;
i++;
} while ((encode1[i] != 0) && (y != 40));
// 0
i = 10 * times;
if (rotate == 0) {
for (y = 0; y < i; y++) {
for (x = 0; x < i; x++) {
switch (times) {
case 2: // 20*20
sum1 = 0;
for (int m = 0; m < 2; m++)
for (int n = 0; n < 2; n++)
sum1 += chinese[m + x * 2][n + y * 2];
if (sum1 > 1) tft.drawPixel(xx + x, yy + y, text_color);
else tft.drawPixel(xx + x, yy + y, back_color);
break;
case 3: // 30*30
sum1 = 0;
sum1 += chinese[x + int(x / 4)][y + int(y / 4)] + chinese[x + int(x / 4)][y + 1 + int(y / 4)];
if (sum1 >= 1) tft.drawPixel(xx + x, yy + y, text_color);
else tft.drawPixel(xx + x, yy + y, back_color);
break;
case 4: // 40*40
if (chinese[x][y] == 1) tft.drawPixel(xx + x, yy + y, text_color);
else tft.drawPixel(xx + x, yy + y, back_color);
break;
case 8: // 80*80
if (chinese[int(x / 2)][int(y / 2)] == 1) tft.drawPixel(xx + x, yy + y, text_color);
else tft.drawPixel(xx + x, yy + y, back_color);
if ((((y + 1) % 40) == 0) && (x == 0)) { }
break; }
}
}
}
// 90
if (rotate == 1) {
for (y = 0; y < i; y++) {
for (x = 0; x < i; x++) {
switch (times) {
case 2: // 20*20
sum1 = 0;
for (int m = 0; m < 2; m++)
for (int n = 0; n < 2; n++)
sum1 += chinese[ m + x * 2][n + y * 2];
if (sum1 > 1) tft.drawPixel(xx + (i - 1) - y, yy + x, text_color);
else tft.drawPixel(xx + (i - 1) - y, yy + x, back_color);
break;
case 3: // 30*30
sum1 = 0;
sum1 += chinese[x + int(x / 4)][y + int(y / 4)] + chinese[x + int(x / 4)][y + 1 + int(y / 4)];
if (sum1 >= 1) tft.drawPixel(xx + (i - 1) - y, yy + x, text_color);
else tft.drawPixel(xx + (i - 1) - y, yy + x, back_color);
break;
case 4: // 40*40
if (chinese[x][y] == 1) tft.drawPixel(xx + (i - 1) - y, yy + x, text_color);
else tft.drawPixel(xx + (i - 1) - y, yy + x, back_color);
break;
case 8: // 80*80
if (chinese[int(x / 2)][int(y / 2)] == 1) tft.drawPixel(xx + (i - 1) - y, yy + x, text_color);
else tft.drawPixel(xx + (i - 1) - y, yy + x, back_color);
break; }
}
}
}
// 180
if (rotate == 2) {
for (y = 0; y < i; y++) {
for (x = 0; x < i; x++) {
switch (times) {
case 2: // 20*20
sum1 = 0;
for (int m = 0; m < 2; m++)
for (int n = 0; n < 2; n++)
sum1 += chinese[m + x * 2][n + y * 2];
if (sum1 > 1) tft.drawPixel(xx + (i - 1) - x, yy + (i -1 ) - y, text_color);
else tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, back_color);
break;
case 3: // 30*30
sum1 = 0;
sum1 += chinese[x + int(x / 4)][y + int(y / 4)] + chinese[x + int(x / 4)][y + 1 + int(y / 4)];
if (sum1 >= 1) tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, text_color);
else tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, back_color);
break;
case 4: // 40*40
if (chinese[x][y] == 1) tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, text_color);
else tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, back_color);
break;
case 8: // 80*80
if (chinese[int(x / 2)][int(y / 2)] == 1) tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, text_color);
else tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, back_color);
break; }
}
}
}
// 270
if (rotate == 3) {
for (y = 0; y < i; y++) {
for (x = 0; x < i; x++) {
switch (times) {
case 2: // 20*20
sum1 = 0;
for (int m = 0; m < 2; m++)
for (int n = 0; n < 2; n++)
sum1 += chinese[m + x * 2][n + y * 2];
if (sum1 > 1) tft.drawPixel(xx + y, yy + (i - 1) - x, text_color);
else tft.drawPixel(xx + y, yy + (i - 1) - x, back_color);
break;
case 3: // 30*30
sum1 = 0;
sum1 += chinese[x + int(x / 4)][y + int(y / 4)] + chinese[x + int(x / 4)][y + 1 + int(y / 4)];
if (sum1 >= 1) tft.drawPixel(xx + y, yy + (i - 1) - x, text_color);
else tft.drawPixel(xx + y, yy + (i - 1) - x, back_color);
break;
case 4: // 40*40
if (chinese[x][y] == 1) tft.drawPixel(xx + y, yy + (i - 1) - x, text_color);
else tft.drawPixel(xx + y, yy + (i - 1) - x, back_color);
break;
case 8: // 80*80
if (chinese[int(x / 2)][int(y / 2)] == 1) tft.drawPixel(xx + y, yy + (i - 1) - x, text_color);
else tft.drawPixel(xx + y, yy + (i - 1) - x, back_color);
break; }
}
}
}
}
// Written by ChihNan Chuang
//
// make word by Unicode and MicroSD card
//
// AXXXX means:
// A: Font or Symbol
// XXXX: Unicode
//
// < Micro SD card module for Mega 2560 >
// DIO pin 50: MISO
// DIO pin 51: MOSI
// DIO pin 52: SCK
// DIO pin 53: CS
// Vcc: 3.3~5V
// GND: 0V
//
//
#include <SoftwareSerial.h> //
#include <Adafruit_GFX.h> // , points, lines, circles, etc
#include <Adafruit_TFTLCD.h> // , 8-bit 16-channel PWM & Servo driver, shield or FeatherWing
#include <TouchScreen.h> // , 4-wire resistive touch screen firmware
#include <SPI.h> // SPI
#include <SD.h> // MicroSD card
#define YP A2 // HX8347G , , "An" !
#define XM A1 // HX8347G , , "An" !
#define YM 6 // HX8347G ,
#define XP 7 // HX8347G ,
//#define YP A3 // ILI9328 , , "An" !
//#define XM A2 // ILI9328 , , "An" !
//#define YM 9 // ILI9328 ,
//#define XP 8 // ILI9328 ,
#define TS_MINX 250 // , ;USB 150
#define TS_MINY 210 // , ;USB 120
#define TS_MAXX 870 // , ;USB 920
#define TS_MAXY 940 // , ;USB 940
#define MINPRESSURE 10 // , z
#define MAXPRESSURE 1000 // , z
#define LCD_CS A3 // , Chip Select
#define LCD_CD A2 // , Command/Data
#define LCD_WR A1 // , LCD Write
#define LCD_RD A0 // , LCD Read
#define LCD_RESET A4 // , connect to Arduino RESET pin,
// 16-bit:
#define BLACK 0x0000 // ,
#define WHITE 0xFFFF // ,
#define RED 0xF800 // ,
#define ORANGE 0xFD20 // ,
#define YELLOW 0xFFE0 // ,
#define GREEN 0x07E0 // ,
#define CYAN 0x07FF // ,
#define BLUE 0x001F // ,
#define PURPLE 0x780F // ,
#define PINK 0xF81F // ,
File myFile; // MicroSD card filename
String filename; // Word filename with encoder
// For better pressure precision, we need to know the resistance between X+ and X- using any multimeter
// to read it. For the one we're using, it's 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); // X300
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); //
Adafruit_GFX_Button buttons[1]; // 1
int TFT_WIDTH; // 2.4" TFT LCD width pixels
int TFT_HEIGHT; // 2.4" TFT LCD height pixels
void setup() {
Serial.begin(9600); // most baud rate set 9600 for touch panel
Serial.println("TFT LCD TEST...");
#ifdef USE_ADAFRUIT_SHIELD_PINOUT
Serial.println("Using Adafruit 2.4\" TFT Arduino Shield Pinout");
#else
Serial.println("Using Adafruit 2.4\" TFT Breakout Board Pinout");
#endif
TFT_WIDTH = tft.width(); // 2.4" TFT LCD width pixels = 240
TFT_HEIGHT = tft.height(); // 2.4" TFT LCD height pixels = 320
Serial.print("TFT size is ");
Serial.print(TFT_WIDTH);
Serial.print("x");
Serial.println(TFT_HEIGHT);
tft.reset(); // reset touch screen
uint16_t identifier = tft.readID(); //
if (identifier == 0x0101) identifier = 0x9341;
if (identifier == 0x6767) identifier = 0x7575;
if (identifier == 0x9325) {
Serial.println("Found ILI9325 LCD driver");
} else if (identifier == 0x4535) {
Serial.println("Found LGDP4535 LCD driver");
} else if (identifier == 0x9328) {
ts = TouchScreen(8, A3, A2, 9, 300);
Serial.println("Found ILI9328 LCD driver");
} else if (identifier == 0x7575) {
ts = TouchScreen(7, A2, A1, 6, 300);
Serial.println("Found HX8347G LCD driver");
} else if (identifier == 0x9341) {
Serial.println("Found ILI9341 LCD driver");
} else if (identifier == 0x8357) {
Serial.println("Found HX8357D LCD driver");
} else {
Serial.print("Unknown LCD driver chip: ");
Serial.println(identifier, HEX);
return;
}
// Initialize MicroSD card
Serial.print("Initializing SD card... ");
if (!SD.begin(53)) Serial.println("failed!");
else Serial.println("done.");
delay(200);
tft.begin(identifier); // touch panel begin to start touch panel
key_menu(); // key menu
}
void loop() {
int i = 10;
TSPoint p;
do {
i--;
digitalWrite(13, HIGH);
p = ts.getPoint(); // Get the touch value on the panel
digitalWrite(13, LOW);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
} while ((p.z == 0) && (i > 0));
if (p.z > MINPRESSURE && p.z < MAXPRESSURE) { // get p.x and p.y
p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0); // scale from 0->1023
p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
Serial.print("(");
Serial.print(p.x);
Serial.print(", ");
Serial.print(p.y);
Serial.print(", ");
Serial.print(p.z);
Serial.println(") ");
}
// Which button is touched?
for (uint8_t bt = 0; bt < 1; bt++) {
delay(50);
if (buttons[bt].contains(p.x, p.y)) {
buttons[bt].press(true); // touch down
if (bt == 0) {
show_word();
key_menu(); // key menu
break;
}
} else {
buttons[bt].press(false); // no touch
}
}
}
//
void key_menu() {
tft.fillScreen(BLACK); // touch panel background set to black
//
buttons[0].initButton(&tft, 120, 160, 240, 130, RED, YELLOW, BLACK,"", 1);
buttons[0].drawButton();
tftChineseLibrary( 40,120,"",BLUE,YELLOW,4,0);
tftChineseLibrary(100,120,"",BLUE,YELLOW,4,0);
tftChineseLibrary(160,120,"",BLUE,YELLOW,4,0);
tft.setTextSize(4); //
tft.setTextColor(BLUE); //
tft.setCursor(30, 175); //
tft.print("Press Me"); //
}
void show_word() {
tft.fillScreen(WHITE);
tft.fillRect(10, 10, 220, 140, PURPLE); // rectangle
tftChineseLibrary(30 ,40 ,"",RED,YELLOW,8,0);
tftChineseLibrary(130,40 ,"",RED,YELLOW,8,0);
tft.drawLine(0 , 160, 239, 160, RED); // line
tft.fillRect(10 , 170, 220, 140, PURPLE);
tft.fillRect(12 , 220, 98 , 46 , YELLOW);
tft.fillRect(130, 220, 98 , 46 , YELLOW);
tft.setTextSize(4);
tft.setTextColor(RED);
tft.setCursor(14, 230);
tft.print("MAKE WORD");
delay(2000);
tft.fillScreen(GREEN);
tftChineseLibrary(10 ,30 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(55 ,30 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(100,30 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(145,30 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(190,30 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(25 ,80 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(75 ,80 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(125,80 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(175,80 ,"" ,BLACK,GREEN,4,0);
tftChineseLibrary(105,130,"Taiwan1",BLACK,GREEN,4,0);
tftChineseLibrary(105,170,"Taiwan2",BLACK,GREEN,4,0);
tft.setTextSize(2);
tft.setTextColor(BLACK);
tft.setCursor(30, 220);
tft.print("I'm from Taiwan");
tft.setTextSize(4);
tft.setCursor(40, 250);
tft.print("Welcome");
delay(2000);
// 0 degree
tft.fillScreen(BLUE);
tft.setTextSize(2);
tft.setTextColor(YELLOW);
tft.setCursor(0, 3);
tft.print("20*20");
tft.setCursor(0, 35);
tft.print("30*30");
tft.setCursor(0, 73);
tft.print("40*40");
tft.setCursor(0,128);
tft.print("80*80");
tftChineseLibrary(60 ,0 ,"" ,YELLOW,BLUE,2,0);
tftChineseLibrary(85 ,0 ,"" ,YELLOW,BLUE,2,0);
tftChineseLibrary(60 ,25 ,"" ,YELLOW,BLUE,3,0);
tftChineseLibrary(95 ,25 ,"" ,YELLOW,BLUE,3,0);
tftChineseLibrary(60 ,58 ,"" ,YELLOW,BLUE,4,0);
tftChineseLibrary(105,58 ,"" ,YELLOW,BLUE,4,0);
tftChineseLibrary(60 ,95 ,"" ,YELLOW,BLUE,8,0);
tftChineseLibrary(145,95 ,"" ,YELLOW,BLUE,8,0);
tftChineseLibrary(80 ,169,"Taiwan1",YELLOW,BLUE,8,0);
tftChineseLibrary(80 ,249,"Taiwan2",YELLOW,BLUE,8,0);
delay(2000);
// 90 degree
tft.fillScreen(ORANGE);
tft.setTextSize(2);
tft.setTextColor(PURPLE);
tft.setCursor(0, 3);
tft.print("20*20");
tft.setCursor(0, 35);
tft.print("30*30");
tft.setCursor(0, 73);
tft.print("40*40");
tft.setCursor(0, 128);
tft.print("80*80");
tftChineseLibrary(85 ,0 ,"" ,PURPLE,ORANGE,2,1);
tftChineseLibrary(60 ,0 ,"" ,PURPLE,ORANGE,2,1);
tftChineseLibrary(95 ,25 ,"" ,PURPLE,ORANGE,3,1);
tftChineseLibrary(60 ,25 ,"" ,PURPLE,ORANGE,3,1);
tftChineseLibrary(105,58 ,"" ,PURPLE,ORANGE,4,1);
tftChineseLibrary(60 ,58 ,"" ,PURPLE,ORANGE,4,1);
tftChineseLibrary(145,95 ,"" ,PURPLE,ORANGE,8,1);
tftChineseLibrary(60 ,95 ,"" ,PURPLE,ORANGE,8,1);
tftChineseLibrary(120,209,"Taiwan1",PURPLE,ORANGE,8,1);
tftChineseLibrary(40 ,209,"Taiwan2",PURPLE,ORANGE,8,1);
delay(2000);
// 180 degree
tft.fillScreen(CYAN);
tft.setTextSize(2);
tft.setTextColor(RED);
tft.setCursor(0, 3);
tft.print("20*20");
tft.setCursor(0, 35);
tft.print("30*30");
tft.setCursor(0, 73);
tft.print("40*40");
tft.setCursor(0, 128);
tft.print("80*80");
tftChineseLibrary(85 ,0 ,"" ,RED,CYAN,2,2);
tftChineseLibrary(60 ,0 ,"" ,RED,CYAN,2,2);
tftChineseLibrary(95 ,25 ,"" ,RED,CYAN,3,2);
tftChineseLibrary(60 ,25 ,"" ,RED,CYAN,3,2);
tftChineseLibrary(105,58 ,"" ,RED,CYAN,4,2);
tftChineseLibrary(60 ,58 ,"" ,RED,CYAN,4,2);
tftChineseLibrary(145,95 ,"" ,RED,CYAN,8,2);
tftChineseLibrary(60 ,95 ,"" ,RED,CYAN,8,2);
tftChineseLibrary(80 ,249,"Taiwan1",RED,CYAN,8,2);
tftChineseLibrary(80 ,169,"Taiwan2",RED,CYAN,8,2);
delay(2000);
// 270 degree
tft.fillScreen(PINK);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.setCursor(0, 3);
tft.print("20*20");
tft.setCursor(0, 35);
tft.print("30*30");
tft.setCursor(0, 73);
tft.print("40*40");
tft.setCursor(0, 128);
tft.print("80*80");
tftChineseLibrary(60 ,0 ,"" ,WHITE,PINK,2,3);
tftChineseLibrary(85 ,0 ,"" ,WHITE,PINK,2,3);
tftChineseLibrary(60 ,25 ,"" ,WHITE,PINK,3,3);
tftChineseLibrary(95 ,25 ,"" ,WHITE,PINK,3,3);
tftChineseLibrary(60 ,58 ,"" ,WHITE,PINK,4,3);
tftChineseLibrary(105,58 ,"" ,WHITE,PINK,4,3);
tftChineseLibrary(60 ,95 ,"" ,WHITE,PINK,8,3);
tftChineseLibrary(145,95 ,"" ,WHITE,PINK,8,3);
tftChineseLibrary(40 ,209,"Taiwan1",WHITE,PINK,8,3);
tftChineseLibrary(120,209,"Taiwan2",WHITE,PINK,8,3);
delay(2000);
}
// , (xx,yy), chinese_word, text_color,
// back_color, times10times*10times(2,3,4,8),
// rotate =0~3, 0,90,180,270rotation
void tftChineseLibrary(int xx, int yy, char chinese_word[], uint16_t text_color,
uint16_t back_color, int times, int rotate)
{
int encode1[400]; // , 400
int space = 0; //
int number = 0; //
int i = 0;
int x = 0;
int y = 0;
int sum1 = 0;
char c;
boolean num = false;
boolean chinese[40][40]; //
String acc = "";
String word1 = ""; //
//
if (chinese_word == "") word1 = "A9020";
if (chinese_word == "") word1 = "A5B57";
if (chinese_word == "") word1 = "A6211";
if (chinese_word == "") word1 = "A4F86";
if (chinese_word == "") word1 = "A81EA";
if (chinese_word == "") word1 = "A53F0";
if (chinese_word == "") word1 = "A7063";
if (chinese_word == "") word1 = "A6B61";
if (chinese_word == "") word1 = "A8FCE";
if (chinese_word == "") word1 = "A5149";
if (chinese_word == "") word1 = "A81E8";
if (chinese_word == "") word1 = "A8ACB";
if (chinese_word == "") word1 = "A6309";
if (chinese_word == "") word1 = "A9215";
if (chinese_word == "Taiwan1") word1 = "S0001";
if (chinese_word == "Taiwan2") word1 = "S0002";
filename = word1 + ".TXT";
if (SD.exists(filename)) {
myFile = SD.open(filename);
if (myFile) {
while (myFile.available()) {
c = myFile.read();
Serial.write(c);
if (c == ' ') space++;
if (space >= 2) {
if ((c >= '0') && (c <= '9')) acc += c;
else {
if (c == ',') {
number = acc.toInt();
encode1[i] = number;
acc = "";
i++;
}
}
}
}
}
Serial.println("");
myFile.close();
}
DECODING:
// 40*40
i = 0;
do
{
for (int j = 0; j < encode1[i]; j++) {
chinese[x][y] = num;
x++;
if (x == 40) { x = 0; y++; }
}
if (num == false) num = true;
else num = false;
i++;
} while ((encode1[i] != 0) && (y != 40));
// 0
i = 10 * times;
if (rotate == 0) {
for (y = 0; y < i; y++) {
for (x = 0; x < i; x++) {
switch (times) {
case 2: // 20*20
sum1 = 0;
for (int m = 0; m < 2; m++)
for (int n = 0; n < 2; n++)
sum1 += chinese[m + x * 2][n + y * 2];
if (sum1 > 1) tft.drawPixel(xx + x, yy + y, text_color);
else tft.drawPixel(xx + x, yy + y, back_color);
break;
case 3: // 30*30
sum1 = 0;
sum1 += chinese[x + int(x / 4)][y + int(y / 4)] + chinese[x + int(x / 4)][y + 1 + int(y / 4)];
if (sum1 >= 1) tft.drawPixel(xx + x, yy + y, text_color);
else tft.drawPixel(xx + x, yy + y, back_color);
break;
case 4: // 40*40
if (chinese[x][y] == 1) tft.drawPixel(xx + x, yy + y, text_color);
else tft.drawPixel(xx + x, yy + y, back_color);
break;
case 8: // 80*80
if (chinese[int(x / 2)][int(y / 2)] == 1) tft.drawPixel(xx + x, yy + y, text_color);
else tft.drawPixel(xx + x, yy + y, back_color);
if ((((y + 1) % 40) == 0) && (x == 0)) { }
break; }
}
}
}
// 90
if (rotate == 1) {
for (y = 0; y < i; y++) {
for (x = 0; x < i; x++) {
switch (times) {
case 2: // 20*20
sum1 = 0;
for (int m = 0; m < 2; m++)
for (int n = 0; n < 2; n++)
sum1 += chinese[ m + x * 2][n + y * 2];
if (sum1 > 1) tft.drawPixel(xx + (i - 1) - y, yy + x, text_color);
else tft.drawPixel(xx + (i - 1) - y, yy + x, back_color);
break;
case 3: // 30*30
sum1 = 0;
sum1 += chinese[x + int(x / 4)][y + int(y / 4)] + chinese[x + int(x / 4)][y + 1 + int(y / 4)];
if (sum1 >= 1) tft.drawPixel(xx + (i - 1) - y, yy + x, text_color);
else tft.drawPixel(xx + (i - 1) - y, yy + x, back_color);
break;
case 4: // 40*40
if (chinese[x][y] == 1) tft.drawPixel(xx + (i - 1) - y, yy + x, text_color);
else tft.drawPixel(xx + (i - 1) - y, yy + x, back_color);
break;
case 8: // 80*80
if (chinese[int(x / 2)][int(y / 2)] == 1) tft.drawPixel(xx + (i - 1) - y, yy + x, text_color);
else tft.drawPixel(xx + (i - 1) - y, yy + x, back_color);
break; }
}
}
}
// 180
if (rotate == 2) {
for (y = 0; y < i; y++) {
for (x = 0; x < i; x++) {
switch (times) {
case 2: // 20*20
sum1 = 0;
for (int m = 0; m < 2; m++)
for (int n = 0; n < 2; n++)
sum1 += chinese[m + x * 2][n + y * 2];
if (sum1 > 1) tft.drawPixel(xx + (i - 1) - x, yy + (i -1 ) - y, text_color);
else tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, back_color);
break;
case 3: // 30*30
sum1 = 0;
sum1 += chinese[x + int(x / 4)][y + int(y / 4)] + chinese[x + int(x / 4)][y + 1 + int(y / 4)];
if (sum1 >= 1) tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, text_color);
else tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, back_color);
break;
case 4: // 40*40
if (chinese[x][y] == 1) tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, text_color);
else tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, back_color);
break;
case 8: // 80*80
if (chinese[int(x / 2)][int(y / 2)] == 1) tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, text_color);
else tft.drawPixel(xx + (i - 1) - x, yy + (i - 1) - y, back_color);
break; }
}
}
}
// 270
if (rotate == 3) {
for (y = 0; y < i; y++) {
for (x = 0; x < i; x++) {
switch (times) {
case 2: // 20*20
sum1 = 0;
for (int m = 0; m < 2; m++)
for (int n = 0; n < 2; n++)
sum1 += chinese[m + x * 2][n + y * 2];
if (sum1 > 1) tft.drawPixel(xx + y, yy + (i - 1) - x, text_color);
else tft.drawPixel(xx + y, yy + (i - 1) - x, back_color);
break;
case 3: // 30*30
sum1 = 0;
sum1 += chinese[x + int(x / 4)][y + int(y / 4)] + chinese[x + int(x / 4)][y + 1 + int(y / 4)];
if (sum1 >= 1) tft.drawPixel(xx + y, yy + (i - 1) - x, text_color);
else tft.drawPixel(xx + y, yy + (i - 1) - x, back_color);
break;
case 4: // 40*40
if (chinese[x][y] == 1) tft.drawPixel(xx + y, yy + (i - 1) - x, text_color);
else tft.drawPixel(xx + y, yy + (i - 1) - x, back_color);
break;
case 8: // 80*80
if (chinese[int(x / 2)][int(y / 2)] == 1) tft.drawPixel(xx + y, yy + (i - 1) - x, text_color);
else tft.drawPixel(xx + y, yy + (i - 1) - x, back_color);
break; }
}
}
}
}
A81E8 102,3,37,4,36,4,36,4,27,3,6,4,23,8,5,4,16,16,3,3,4,7,7,13,5,4,1,11,7,4,3,4,6,11,13,3,3,3,7,7,
17,3,3,3,6,3,22,3,3,3,5,4,6,4,12,3,3,6,2,2,1,13,10,3,3,9,2,7,1,5,10,14,4,3,5,3,11,7,3,4,
4,3,4,4,11,3,6,3,6,3,4,3,12,3,6,3,6,3,3,4,12,2,6,4,7,10,11,2,4,6,7,7,14,12,28,9,21,2,8,2,
4,3,9,16,6,2,4,2,4,2,2,18,6,2,4,2,4,11,1,2,4,4,6,2,4,2,5,3,3,3,2,2,4,4,6,2,4,2,5,3,
3,3,2,2,4,3,7,2,4,2,6,2,3,3,2,2,4,3,6,17,2,4,2,3,1,4,7,17,1,5,2,9,7,5,7,1,1,8,2,7,
9,2,12,4,7,2,249,0
A81EA 97,2,37,4,36,6,34,6,34,4,36,4,35,3,36,4,36,3,5,6,25,3,3,10,20,21,19,12,4,5,20,4,12,3,21,3,13,3,21,3,
13,3,21,3,13,3,21,3,3,13,21,19,21,10,6,3,21,6,10,3,21,3,13,3,21,3,13,3,21,2,6,11,21,2,2,15,21,13,3,3,
21,8,8,3,21,2,14,3,21,2,14,3,20,3,13,4,20,3,13,5,19,21,19,21,19,9,6,5,20,3,12,5,21,2,13,3,37,3,92,0
A5149 96,4,36,5,36,5,35,5,35,4,36,4,5,3,28,4,5,5,26,4,4,6,18,4,4,3,4,7,18,5,3,3,4,6,20,5,2,3,2,5,
23,5,2,3,2,3,27,3,2,3,32,3,2,3,37,3,37,3,6,6,22,20,12,28,10,14,1,5,21,12,2,5,29,4,3,4,29,4,3,4,
28,4,4,3,29,4,4,3,28,4,5,3,13,1,14,4,5,3,13,1,13,4,6,3,13,2,11,5,6,3,12,3,10,4,8,3,12,3,10,4,
8,3,11,4,8,5,9,4,10,4,8,4,10,4,9,5,6,4,13,17,5,5,13,17,4,3,17,15,27,11,85,0
A6211 100,3,37,4,36,4,36,4,36,4,31,3,3,3,2,3,25,5,2,3,3,5,21,6,2,3,4,4,18,7,4,3,4,4,18,6,6,2,5,3,
14,10,6,2,22,5,1,4,6,2,28,3,7,2,2,7,19,3,7,11,19,18,21,14,19,14,4,4,4,3,11,11,8,3,4,4,12,4,2,3,
8,3,4,4,18,3,8,3,4,4,18,3,9,2,3,5,18,6,6,3,2,4,18,6,7,3,1,4,18,6,8,8,14,9,10,6,13,11,10,5,
12,8,2,3,9,5,13,6,4,4,8,6,6,2,6,2,6,4,6,8,6,2,14,4,6,4,1,4,5,2,14,4,4,4,4,4,4,2,10,3,
1,4,2,5,5,5,2,3,11,6,3,2,10,8,12,5,15,8,13,4,17,6,13,3,18,6,36,4,42,0
A6309 129,3,37,5,35,5,8,4,24,4,9,5,22,4,9,5,22,3,11,4,22,3,11,4,22,3,5,2,5,12,13,3,5,20,12,6,2,8,6,6,
11,7,1,5,10,4,7,13,1,3,2,2,7,3,9,11,2,4,2,3,6,2,17,2,4,4,2,4,24,2,4,3,3,4,24,2,2,1,7,4,
24,5,7,4,2,2,20,5,7,3,3,4,1,5,11,5,8,2,4,11,8,5,1,27,6,6,1,26,4,6,1,2,2,9,4,4,10,7,2,2,
4,1,3,3,4,3,10,7,3,2,7,3,4,4,11,5,4,2,7,3,4,4,12,2,6,2,7,10,21,2,9,7,21,3,11,7,19,3,10,10,
13,8,7,6,1,7,12,7,6,6,3,6,13,5,4,7,7,5,13,4,3,7,8,6,12,4,20,4,13,2,22,2,85,0,85,0
A7063 61,2,31,2,5,4,5,3,21,2,5,4,5,3,11,4,5,3,6,6,1,3,1,2,9,6,3,3,4,12,1,3,10,4,2,3,1,9,3,2,
2,4,10,4,2,3,1,3,8,8,12,3,1,3,1,3,2,6,1,7,14,10,2,6,1,7,16,7,5,4,3,3,1,3,15,7,2,6,2,8,
16,3,1,3,5,2,1,6,1,2,6,3,7,8,2,10,2,2,6,6,3,8,1,7,1,5,1,4,5,5,3,3,2,1,3,2,2,14,6,4,
5,1,2,3,1,6,2,2,1,3,1,3,6,4,5,6,1,6,2,2,2,2,2,2,8,2,2,6,1,2,2,1,5,3,20,3,1,2,8,6,
18,5,3,15,17,2,1,2,3,10,1,4,17,2,16,4,17,3,12,8,16,3,6,15,16,3,6,11,19,3,8,3,10,2,13,4,8,3,5,8,
12,4,8,18,8,5,8,9,4,6,8,4,9,3,11,4,9,4,9,3,11,3,10,4,23,3,10,4,22,4,11,2,17,3,2,5,12,1,17,10,
32,7,33,6,35,4,36,3,12,0,36,3,12,0
A9020 102,4,36,4,36,4,37,3,18,4,15,3,18,5,8,3,3,3,19,5,7,4,2,3,19,5,7,4,2,3,20,4,6,4,3,8,16,3,6,4,
3,8,25,14,26,11,28,3,5,3,29,3,5,3,20,4,4,2,7,3,3,6,10,7,2,2,7,13,6,10,1,23,6,9,2,15,18,4,4,3,
29,3,19,3,15,2,9,16,13,3,8,16,14,3,8,3,7,5,15,3,7,3,7,4,16,3,7,3,7,4,16,3,7,3,7,4,16,2,8,14,
16,2,9,13,8,16,3,2,20,19,22,2,10,25,17,23,21,17,25,14,30,6,128,0
A9215 170,4,36,4,36,4,36,5,35,8,31,9,30,4,2,4,30,4,3,3,30,3,15,10,11,4,11,15,9,4,4,2,4,9,3,4,10,4,2,6,
3,7,4,4,9,12,7,4,4,4,8,12,8,4,4,4,7,4,3,4,10,4,4,4,7,3,4,4,10,4,4,3,7,3,5,8,6,3,5,6,
3,3,6,8,6,3,3,9,1,3,1,12,2,24,2,9,5,19,13,3,2,3,2,3,1,2,5,3,10,2,4,3,2,3,5,3,5,3,10,4,
2,3,1,4,5,3,4,4,11,4,1,3,1,3,6,3,4,4,12,3,1,3,1,1,1,4,2,3,5,4,12,3,1,3,1,6,2,3,5,3,
16,8,5,3,1,14,6,9,5,20,1,11,4,24,1,9,6,9,17,4,38,2,194,0
Taiwan1() S0001 189,3,36,2,1,2,34,2,3,2,32,2,5,4,25,5,9,2,22,3,14,2,20,2,17,2,19,1,17,2,19,2,16,2,20,1,16,2,20,2,
16,1,21,1,17,1,20,2,17,1,19,2,18,2,17,2,20,1,16,2,21,1,16,1,22,1,15,2,21,2,14,2,22,1,15,1,22,2,14,2,
22,1,15,1,22,2,14,2,21,2,15,1,22,1,15,2,21,2,15,1,22,1,15,2,22,1,14,2,23,1,14,1,24,1,13,2,24,1,13,1,
24,2,12,2,24,1,12,2,25,1,12,1,26,1,11,2,25,2,11,1,26,1,10,0
Taiwan2() S0002 2,1,26,1,12,1,26,1,12,1,26,1,12,1,25,2,12,1,25,1,13,1,24,2,12,2,24,1,13,1,25,1,13,1,25,1,12,2,24,2,
12,1,25,1,13,2,23,2,14,2,22,1,16,2,20,2,17,1,19,2,18,1,19,1,19,2,17,2,20,1,17,1,21,1,15,3,21,1,14,2,
23,2,13,1,25,2,11,2,26,3,9,1,29,3,7,1,31,2,5,2,32,1,5,1,33,2,4,1,34,1,4,1,34,2,3,1,35,1,3,1,
35,1,3,1,35,1,3,1,35,1,3,1,35,1,2,2,35,4,37,1,1,1,183,0
A4F86 56,2,37,5,36,4,36,4,36,4,36,4,2,5,29,12,20,20,20,17,24,5,2,4,5,3,28,4,4,5,20,4,3,4,4,4,21,4,3,4,
4,4,20,5,3,4,4,3,21,4,4,4,3,3,22,4,4,4,2,6,19,7,2,4,2,8,16,9,1,3,1,4,2,5,15,3,2,4,1,3,
1,3,3,5,13,4,4,2,2,5,7,3,13,3,8,5,8,3,12,2,9,8,32,9,29,7,1,4,28,7,1,5,25,5,1,3,3,5,23,4,
2,3,3,6,20,5,3,3,5,6,18,4,4,3,5,8,14,5,5,4,5,10,10,5,6,4,6,11,6,5,8,4,7,11,4,4,10,4,8,8,
19,5,35,5,35,5,36,3,37,3,37,2,22,0
A5B57 96,4,36,5,36,5,35,5,8,2,15,2,9,16,13,2,6,19,12,15,8,6,11,10,12,8,9,4,19,6,11,4,18,4,14,3,11,7,19,3,
8,11,24,9,2,6,23,6,4,6,33,5,35,4,33,5,35,4,37,3,8,5,24,3,3,12,15,26,6,34,5,12,4,4,22,7,7,4,36,4,
36,4,36,4,36,4,36,4,36,4,36,4,32,2,2,4,32,8,33,6,35,5,36,3,100,0
A6B61 96,3,37,4,6,3,19,3,5,4,6,4,18,3,5,4,6,4,18,4,4,8,2,4,18,4,4,6,1,1,2,4,14,8,4,2,7,4,15,8,
4,2,7,4,21,2,3,2,7,4,22,2,3,2,2,2,3,4,22,12,2,12,12,14,2,13,8,12,2,3,1,5,4,5,9,2,2,3,1,3,
1,4,1,3,6,4,10,2,2,3,2,10,6,3,12,7,2,9,2,2,3,2,13,5,2,2,6,2,3,4,17,4,2,3,5,1,4,4,18,4,
2,6,6,4,18,3,3,8,4,3,17,15,5,3,17,12,8,3,16,5,4,6,6,4,14,6,3,8,5,4,13,3,2,12,5,6,11,4,2,8,
9,7,8,3,5,2,4,7,3,4,1,3,8,2,6,13,3,3,3,3,15,8,8,2,4,4,13,3,4,2,7,3,4,5,12,3,4,12,6,5,
10,18,7,6,8,10,4,4,9,7,6,4,9,3,11,7,7,3,37,3,110,0
A8ACB 103,5,35,5,20,3,13,4,20,4,12,3,21,5,11,10,14,5,7,14,15,4,5,10,22,6,2,9,19,12,6,9,9,16,6,10,7,9,10,10,
12,6,12,7,37,3,5,6,12,4,10,15,7,34,6,6,3,16,25,5,29,4,14,4,14,9,3,15,13,8,4,15,27,3,7,3,27,3,7,3,
16,7,4,13,11,12,4,13,11,5,3,4,4,5,5,3,12,3,4,3,5,2,8,3,13,2,4,2,6,13,13,2,4,2,6,13,13,8,6,2,
8,3,13,8,6,2,8,3,13,4,9,3,8,3,14,1,11,3,8,3,25,3,5,7,25,3,5,7,24,3,8,4,25,2,9,4,37,2,49,0
A8FCE 182,4,36,5,17,5,12,5,19,5,10,5,21,6,7,4,23,6,6,4,10,2,14,3,3,6,4,2,2,8,12,3,4,4,5,12,20,3,5,4,
4,4,20,2,6,4,4,4,11,3,6,2,6,4,4,4,10,5,5,2,6,4,4,4,6,10,4,2,6,4,4,4,6,10,4,2,6,4,4,4,
10,4,6,2,4,6,4,3,11,4,6,2,3,9,2,3,11,3,6,7,2,3,1,7,11,2,7,7,2,3,2,6,11,4,5,5,4,3,3,4,
13,3,5,5,4,3,3,4,14,3,4,3,6,3,21,3,4,3,6,3,21,3,13,3,21,3,13,3,14,11,12,3,14,13,10,3,15,16,6,2,
16,4,6,9,3,2,30,17,24,23,20,19,24,14,28,9,32,6,88,0








Comments