AN_258 FT800 Chinese Font Demo Application Design Note

AN_258
FT800 Chinese Font Demo
Application
Design Note
Document Reference No.:FT_000896
Version 1.0
Issue Date: 2014-06-09
This document is to introduce the design flow and note of FT800 Chinese Font Demo
Application. It will give the audience the overall picture of the software.
Future Technology Devices International Limited (FTDI)
Unit 1,2 Seaward Place, Glasgow G41 1HH, United Kingdom
Tel.: +44 (0) 141 429 2777 Fax: + 44 (0) 141 429 2758
E-Mail (Support): [email protected] Web: http://www.ftdichip.com
Copyright © 2014Future Technology Devices International Limited
1 Table of Contents
2
Introduction .................................................................... 3
2.1
Audience ................................................................................... 3
2.2
Scope ........................................................................................ 3
2.3
Overview ................................................................................... 3
2.3.1
Hardware ................................................................................................. 3
2.3.2
Application flow......................................................................................... 4
2.3.3
Architecture .............................................................................................. 4
2.4
Hardware requirement .............................................................. 5
2.5
Software requirement ............................................................... 5
2.5.1
3
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
Software package introduction .................................................................... 5
Application design note .................................................. 7
3.1
Bitmap data information ........................................................... 8
3.2
Character code and bitmap handle ............................................ 9
4
Tag layout ....................................................................... 9
5
Generate the bitmap data and metrics block ................. 10
6
Contact Information ...................................................... 12
7
Appendix A– References ................................................ 13
7.1
Document References ............................................................. 13
7.2
Acronyms and Abbreviations ................................................... 13
8
Appendix B – List of Tables & Figures ............................ 14
9
Appendix C– Revision History ........................................ 15
Copyright © 2014 Future Technology Devices International Limited
2
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
2 Introduction
FT800 combines display, audio and touch functionality into one single chip, powered by
advanced FTDI Chip’s EVE technology (Embedded Video Engine). The FT800 device
interfaces with a system MCU via either SPI or I2C interface. To help customers easily
make Chinese UI with the feature of FT800, a sample application is provided here for
tutorial purposes.
In this application, FT800 custom font is created for Chinese UI and applied on widgets,
such as toggle, keys, buttons as well as texts.
Note that the code relating to the creation of the screen shots could be reused in different
MCU design environments.
To learn more about Arduino platform and its IDE, please check http://www.arduino.cc
2.1 Audience
This document assumes the audience has read the datasheet and programmer guide of the
FT800. In addition, familiarity of the C/C++programming language is necessary to
understand the sample application source code. Since the SPI interface is the main
interface of FT800, the knowledge of SPI interface is also preferred.
2.2 Scope
The Chinese Font Demo Application mentioned in this document is created with Arduino
Pro IDE and Microsoft Windows Visual Studio. It is able to run on VM800P or Windows PC.
2.3 Overview
2.3.1
Hardware
The diagram below gives the basic hardware setup.
TFT Display
VM800P /
Windows PC
FT800
Touch
Panel
Speaker
Figure 1 Block Diagram of Setup
Copyright © 2014 Future Technology Devices International Limited
3
2.3.2
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
Application flow
The diagram below gives the basic flow and structure to configuring the FT800 in an
application.
CONFIGURE
THE SPI
MASTER
(MODE 0 – MSB)
INITIALISE THE FT800
RESET THE
FT800 CORE –
WRITE 0x68,
0x00
READ
DUMMY
DATA AT
ADDRESS 0
SET THE
CLOCK –
WRITE 0x44,
0x00
INITIALISE THE TFT DISPLAY
LOAD
DUMMY
DISPLAY
LIST (e.g.
blank screen)
CONFIGURE
VSYNC
CONFIGURE
HSYNC
ENABLE
PCLK
CONFIGURE
THE TFT TOUCH
SENSE
CONFIGURE
THE AUDIO
VOLUME
CREATE
DISPLAY LIST
UPDATE (SWAP)
DISPLAY LIST
Figure 2 Application Flow
2.3.3
Architecture
The application is designed to easily port to various platforms with SPI host functionality.
Therefore, the application introduces one generic HAL (hardware abstraction layer) which
can be used as a guideline for other platforms.
Copyright © 2014 Future Technology Devices International Limited
4
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
FT800 Demo Application
Application
HAL
FT800
Figure 3 Architecture Diagram
2.4 Hardware requirement
Option A:

VM800B or VM800C development kit.
Note that this kit comes with an option for 3 different size displays, 3.5”, 4.3”, or
5.0”(VM800B35A-D, VM800C35A-D, VM800B35A-D, VM800C43A-D, VM800B50A-D,
VM800C50A-D, respectively).

One FTDI MPSSE cable for USB to SPI bridge or VA800A-SPI board.

Windows PC
Option B:

VM800P development kit.

One USB cable with MicroB connector to provide power to the VM800P board and
download binary into VM800P.

Windows PC
2.5 Software requirement

D2XX driver for FTDI MPSSE cable. Please download and install on the PC.

Arduino IDE 1.0.5

FT800 Chinese Font Demo Application release package.
2.5.1
Software package introduction
 “Bin” folder contains the library and run time executables for Windows platform.
 “Docs” folder contains the application note of this application.
Copyright © 2014 Future Technology Devices International Limited
5
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
 “Hdr” folder contains the header file of windows MSVC project.
 “Src” folder contains the source code of windows MSVC project.
 “Test” folder contains the font file used by application when running up.
 “Project” folder contains both the project files for Windows and Arduino platform.
Copyright © 2014 Future Technology Devices International Limited
6
3 Application design note
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
This application implements one notepad with simple Chinese Input method enabled. It
enables users to input the simplified or traditional Chinese font with SimFang (仿宋) style.
All the bitmap information used in this application for Chinese UI are extracted from
simfang.ttf, which is part of windows 7 installation. You can find it from
“$(WindowsInstallPaths)\windows\fonts\”.
When users touches any letter from ‘A’ to ‘Z’, the application gives 10 characters
candidates for users to select. Users can choose any characters and constructs one note
with up to 10 rows , 16 characters per row including space. After users complete the
editing, users can view all the characters in a scrolling window.
Figure 4 Main UI of Application
Copyright © 2014 Future Technology Devices International Limited
7
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
Figure 5 Preview interface
3.1 Bitmap data information
Out of “A” to “Z”, every key maps to 10 Chinese characters. All the fonts is in L4 format.
The font style is SimFang (仿宋). The following table describes the bitmap data
information in details.
Table 1 Bitmap data information used in font application
Input File
CELL
Handl
e
Address
in
RAM_G
Bitmap
Source
Raw
file
size
in
byte
2870
8
Format &
Style
Description
AF_ChineseS.tx
t/
AF_ChineseT.tx
t
GL_ChineseS.tx
t/
GL_ChineseT.tx
t
MR_ChineseS.t
xt/MR_ChineseT.t
xt
SX_ChineseS.t
xt/SX_ChineseT.t
xt
YZ_ChineseS.t
1~60
1
0
(RAM_G)
-328
L4 format
Stride 14
width 28
Height 34
60 characters
whose pinyin
begins with
from ‘A’ to ‘F’
1~60
2
28708
28380
2870
8
L4 format
Stride 14
width 28
Height 34
60 characters
whose pinyin
begins with
from ‘G’ to ‘L’
1~60
3
57416
57088
2870
8
L4 format
Stride 14
width 28
Height 34
60 characters
whose pinyin
begins with
from ‘M’ to ‘R’
1~60
4
86124
85796
2870
8
L4 format
Stride 14
width 28
Height 34
60 characters
whose pinyin
begins with
from ‘S’ to ‘X’
1~28
5
114832
114504
1347
6
L4 format
Stride 14
20 characters
whose pinyin
Copyright © 2014 Future Technology Devices International Limited
8
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
width 28
begins with
xt/YZ_ChineseT.t
xt
SC_Note.txt
Height 34
1~12
6
128308
127946
6268
L4 format
Stride 15
width 30
Height 34
from ‘Y’ to ‘Z’
8 characters
for buttons
12 characters
consists of
space, cursor
etc.
3.2 Character code and bitmap handle
The character code is invented to store the code of each character and there is one
notepad buffer storing character code: (Max Row: 10, Max Col: 16) in the application.
Every character code is 2 byte valid and range from 1 to 270. Application translates the
tag value of touching character into character code by following formula and storing it into
notepad buffer:
Given Handle and Cell , calculate the character code by:
Character code = (Handle-1) * 60 + CELL when Handle falls in 1 to 5.
Character code between 1 to 268
Character code = 60*4 + 28 + CELL when Handle is 6.
Character code between 269 to 280
When displaying all the characters stored in notepad buffer, i.e., all the characters selected
by users, the character code has to be converted back into handle and cell number by
following formula:
Given Character code, calculate the handle and cell by:
If Character code between 269 to 280 ,
Handle = 6
Cell = character code – 268
If Character code between 1 to 268 ,
Handle = character code / 60 + 1
Cell = character code % 60
if (character code % 60) is not zero
Handle = character code / 60
Cell = 60
if (character code % 60) is zero
4 Tag layout
In main interface, tag feature of FT800 is utilized to detect user’s touch. The table below
shows the tag value layout in main interface.
Table 2 Tag layout table at the main interface
UI element
Tag value
Cmd_keys
Cmd_keys
Description
“QWERTYUIOP”
65-90
“ASDFGHJKL”
Copyright © 2014 Future Technology Devices International Limited
9
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
“ZXCVBNM”
Cmd_keys
Cmd_keys
1 – 60
Candidate characters
Cmd_button
251
Backspace
Cmd_button
252
Space
Cmd_button
253
Enter
Cmd_button
254
Input Done(Finish editing)
Cmd_toggle
250
Traditional/Simpified chinese toggle
5 Generate the bitmap data and metrics block
There is one font conversion utility from FTDI to export the bitmap information from
windows true type font file and form metrics blocks as FT800 specified. Users can easily
run the following commands and find the output data at the output folder. For example, for
command line 1, the output data is in file “simfang_AF_ChineseS.txt30\L4\simfang.ttf_30_L4.raw”. Its format is in file “simfang_AF_ChineseS.txt30\L4\simfang.ttf_30_L4.rawh”.
About the fnt_cvt details , please refer to its release package.
To generate for Simplified Chinese:
1.
2.
3.
4.
5.
6.
fnt_cvt.exe
fnt_cvt.exe
fnt_cvt.exe
fnt_cvt.exe
fnt_cvt.exe
fnt_cvt.exe
-i
-i
-i
-i
-i
-i
simfang.ttf
simfang.ttf
simfang.ttf
simfang.ttf
simfang.ttf
simfang.ttf
-s
-s
-s
-s
-s
-s
30
30
30
30
30
30
-u
-u
-u
-u
-u
-u
A-F_ChineseS.txt -d 0
G-L_ChineseS.txt -d 28708
M-R_ChineseS.txt -d 57416
S-X_ChineseS.txt -d 86124
Y-Z_ChineseS.txt -d 114832
SC_Note.txt -d 128308
To generate for traditional Chinese:
1.
2.
3.
4.
5.
6.
fnt_cvt.exe
fnt_cvt.exe
fnt_cvt.exe
fnt_cvt.exe
fnt_cvt.exe
fnt_cvt.exe
-i
-i
-i
-i
-i
-i
simfang.ttf
simfang.ttf
simfang.ttf
simfang.ttf
simfang.ttf
simfang.ttf
-s
-s
-s
-s
-s
-s
30
30
30
30
30
30
-u
-u
-u
-u
-u
-u
A-F_ChineseT.txt -d 0
G-L_ChineseT.txt -d 28708
M-R_ChineseT.txt -d 57416
S-X_ChineseT.txt -d 86124
Y-Z_ChineseT.txt -d 114832
SC_Note.txt -d 128308
The resource used in both scenario*:
SC_Note.txt
Simplified Chinese input file*:
Y-Z_ChineseS.txt
S-X_ChineseS.txt
M-R_ChineseS.txt
A-F_ChineseS.txt
G-L_ChineseS.txt
Traditional Chinese input file*:
Copyright © 2014 Future Technology Devices International Limited
10
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
Y-Z_ChineseT.txt
S-X_ChineseT.txt
M-R_ChineseT.txt
G-L_ChineseT.txt
A-F_ChineseT.txt
*All files are available for download in the EVE Software example – FT_Chinese Font,
available here: http://www.ftdichip.com/Support/SoftwareExamples/FT800_Projects.htm
Copyright © 2014 Future Technology Devices International Limited
11
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
6 Contact Information
Head Office – Glasgow, UK
Future Technology Devices International Limited
Unit 1, 2 Seaward Place, Centurion Business Park
Glasgow G41 1HH
United Kingdom
Tel: +44 (0) 141 429 2777
Fax: +44 (0) 141 429 2758
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
[email protected]
[email protected]
[email protected]
Branch Office – Tigard, Oregon, USA
Future Technology Devices International Limited (USA)
7130 SW Fir Loop
Tigard, OR 97223-8160
USA
Tel: +1 (503) 547 0988
Fax: +1 (503) 547 0987
E-Mail (Sales)
E-Mail (Support)
[email protected]
[email protected]
[email protected]
E-Mail (General Enquiries)
Branch Office – Taipei, Taiwan
Future Technology Devices International Limited (Taiwan)
2F, No. 516, Sec. 1, NeiHu Road
Taipei 114
Taiwan , R.O.C.
Tel: +886 (0) 2 8791 3570
Fax: +886 (0) 2 8791 3576
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
[email protected]
[email protected]
[email protected]
Branch Office – Shanghai, China
Future Technology Devices International Limited (China)
Room 1103, No. 666 West Huaihai Road,
Shanghai, 200052
China
Tel: +86 21 62351596
Fax: +86 21 62351595
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
[email protected]
[email protected]
[email protected]
Web Site
http://www.ftdichip.com
Distributor and Sales Representatives
Please visit the Sales Network page of the FTDI Web site for the contact
details of our distributor(s) and sales representative(s) in your country.
System and equipment manufacturers and designers are responsible to ensure that their systems, and any Future
Technology Devices International Ltd (FTDI) devices incorporated in their systems, meet all applicable safety,
regulatory and system-level performance requirements. All application-related information in this document
(including application descriptions, suggested FTDI devices and other materials) is provided for reference only. While
FTDI has taken care to assure it is accurate, this information is subject to customer confirmation, and FTDI disclaims
all liability for system designs and for any applications assistance provided by FTDI. Use of FTDI devices in life
support and/or safety applications is entirely at the user’s risk, and the user agrees to defend, indemnify and hold
harmless FTDI from any and all damages, claims, suits or expense resulting from such use. This document is subject
to change without notice. No freedom to use patents or other intellectual property rights is implied by the publication
of this document. Neither the whole nor any part of the information contained in, or the product described in this
document, may be adapted or reproduced in any material or electronic form without the prior written consent of the
copyright holder. Future Technology Devices International Ltd, Unit 1, 2 Seaward Place, Centurion Business Park,
Glasgow G41 1HH, United Kingdom. Scotland Registered Company Number: SC136640
Copyright © 2014 Future Technology Devices International Limited
12
7 Appendix A– References
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
7.1 Document References
1.
2.
3.
4.
5.
datasheet for VM800C
datasheet for VM800B
datasheet for VM800P
FT800 programmer guide FT_000793
FT800 Embedded Video Engine Datasheet FT_000792
7.2 Acronyms and Abbreviations
Terms
Arduino Pro
Description
The open source platform variety based on ATMEL’s ATMEGA
chipset
EVE
Embedded Video Engine
SPI
Serial Peripheral Interface
UI
User Interface
USB
Universal Serial Bus
Copyright © 2014 Future Technology Devices International Limited
13
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
8 Appendix B – List of Tables & Figures
Figure 1 Block Diagram of Setup ................................................................................ 3
Figure 2 Application Flow ........................................................................................... 4
Figure 3 Architecture Diagram .................................................................................. 5
Figure 4 Main UI of Application ................................................................................. 7
Figure 5 Preview interface ......................................................................................... 8
Table 1 Bitmap data information used in font application ......................................... 8
Table 2 Tag layout table at the main interface ........................................................... 9
Copyright © 2014 Future Technology Devices International Limited
14
9 Appendix C– Revision History
Document Reference No.: FT_000896
AN258_FT800_App_Font_Design_Note.docx
Version 1.0
Clearance No.: FTDI# 388
FTDI_388
Document Title:
AN_258_FT800_APP_Font_Design_Note
Document Reference No:
FT_000896
Clearance No:
FTDI# 388
Product Page:
http://www.ftdichip.com/Products/ICs/FT800.html
Document Feedback:
Send Feedback
Revision
Changes
Date
0.1
Initial draft release
2013-03-06
1.0
Initial release
2014-09-06
Copyright © 2014 Future Technology Devices International Limited
15