AN_311_FT800_App_Dials

Application Note
AN_311
FT800 Demo Application - Absolute
& Relative Dials
Version 1.0
Issue Date: 2014-03-25
This document is to introduce the setup of a Sample Application running on
MSVC. The objective of the Sample Application is to enable users to become
familiar with the usage of the FT800, the design flow, and display list used to
design the desired user interface or visual effect.
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 FTDI harmless from any and all damages, claims, suits
or expense resulting from such use.
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
Web Site: http://ftdichip.com
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
Table of Contents
1
2
3
Introduction .................................................................................................................................... 2
1.1
Overview ................................................................................................................................. 2
1.2
Scope ....................................................................................................................................... 2
Application Flow.............................................................................................................................. 3
2.1
Absolute Dial Flowchart .......................................................................................................... 3
2.2
Relative Dial Flowchart ........................................................................................................... 4
Description ...................................................................................................................................... 5
3.1
3.1.1
Download Bitmaps .......................................................................................................... 5
3.1.2
Set the Tracker Properties to Point Using CMD_TRACK ................................................. 5
3.2
4
Initialization............................................................................................................................. 5
Functionality ........................................................................................................................... 5
3.2.1
Absolute Dial ................................................................................................................... 5
3.2.2
Relative Dial .................................................................................................................... 7
Contact Information........................................................................................................................ 9
Appendix A – References ...................................................................................................................... 10
Document References....................................................................................................................... 10
Acronyms and Abbreviations ............................................................................................................ 10
Appendix B – List of Figures .................................................................................................................. 11
List of Figures .................................................................................................................................... 11
Appendix C – Revision History .............................................................................................................. 12
1
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
1 Introduction
This application demonstrates interactive Absolute and Relative dials using points, track and
button commands on an FT800 platform.
The Absolute dial user interactive function involves moving the knob around from its minimum to
maximum position, while playing sound. This dial can be activated by enabling the following define
statement in “FT_Platform.h”. Absolute Dial is enabled by default.
#define Absolute Dial
The Relative dial user interactive function involves moving the knob, while playing sound which
increases or decreases in volume. This dial can be activated by enabling the following define
statement in “FT_Platform.h”
#define Relative Dial
It is not possible to enable both modes at the same time.
1.1 Overview
The document will present a basic understanding of the FT800 CPU features Track, Points and
Buttons commands.
1.2 Scope
This document will be used by software programmers to develop GUI applications by using FT800
with any MCU via SPI .
2
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
2 Application Flow
2.1 Absolute Dial Flowchart
Figure 2-1 Absolute Dial Flowchart
3
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
2.2 Relative Dial Flowchart
Figure 2-2 Relative Dial Flowchart
4
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
3 Description
Parameters needed to be initialized are described below before constructing the display list.
3.1 Initialization
3.1.1 Download Bitmaps
The bitmaps are downloaded into the desired FT800 memory locations. The bitmap handles are
also assigned here.
Note: After these configurations are set, swap the display list and flush into the Graphics CoProcessor memory.
3.1.2 Set the Tracker Properties to Point Using CMD_TRACK
In the Function
Ft_Gpu_CoCmd_Track(phost,240, 136, 1, 1, tagval);
where ‘tagval’– Tag value of the white circle.
A w and h of (1,1) means that the tracker is rotary, and reports an angle value in REG_TRACKER.
3.2 Functionality
3.2.1 Absolute Dial
The Absolute Dial demo has been designed to work like a volume dial.
In this demo, the knob has to be moved according to the minimum or maximum limit on its
position.
Before the demo is started, the info screen is displayed with information. When the play button is
pressed, the absolute dial demo is started.
3.2.1.1 Output of the Dial
Ten FTpoints are drawn with the outermost circle in dark colour, gradually lightening the inner
circles to have a glowing effect.
The Dial is rotated with minimum and maximum positions. When the dial is moved away from its
initial position, the circles are unhidden to show the output.
In the dial, the bottom part of the FTPOINTS should not be seen. So an edge strip is used to get
the triangle shape with only its alpha value. Stencil functions are used to mask the bottom part of
the Points as shown in the code below.
5
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
Ft_App_WrCoCmd_Buffer(phost,
enabled,so that no color is used for strip
Ft_App_WrCoCmd_Buffer(phost,
Ft_App_WrCoCmd_Buffer(phost,
Ft_App_WrCoCmd_Buffer(phost,
Ft_App_WrCoCmd_Buffer(phost,
Ft_App_WrCoCmd_Buffer(phost,
1.0
Clearance No.: FTDI# 383
COLOR_MASK(0,0,0,1) );//only alpha is
LINE_WIDTH(1*16));
STENCIL_OP(INCR,DECR) );
STENCIL_FUNC(EQUAL,0,255) );
BEGIN(EDGE_STRIP_B));
COLOR_RGB(136 ,136 ,136));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2II(Tx1,FT_DispHeight,0,0));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2II(Tx2,Ty2,0,0));
Ft_App_WrCoCmd_Buffer(phost, VERTEX2II(Tx3,FT_DispHeight,0,0));
Ft_App_WrCoCmd_Buffer(phost, STENCIL_OP(KEEP,INCR) );
Ft_App_WrCoCmd_Buffer(phost, STENCIL_FUNC(NOTEQUAL,255,255) );
Ft_App_WrCoCmd_Buffer(phost, COLOR_MASK(1,1,1,1) );//enable all colors
3.2.1.2 Edge Strips
Four edge strips are drawn. The first is from the left, second from above, third from the right,
fourth is from below. The edge strips are drawn according to the vertices that need to be hidden.
The edge strips are moved around according to the rotary tag value to unhide the FTpoints that
are drawn.
3.2.1.3 Blend the bitmap
Place the dial bitmap. On top of it place another bitmap like the one shown below. Rotate this
bitmap whenever the dial is moved to give an effect that the dial is rotating.
Figure 3-1 Strips Dial Bitmap
Reduce the alpha value of the strips bitmap to 20 and rotate it according to the rotary value.
6
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
Figure 3-2 Absolute Dial Screen
3.2.2 Relative Dial
The Relative Dial demo has been designed to work like a volume dial.
In this demo, the knob can be moved without any minimum or maximum limit on its position. The
rate at which the knob is rotated determines the velocity at which the knob will stop its movement.
Before the demo is started, the info screen is displayed with info. When the play button is pressed,
the relative dial demo is started.
3.2.2.1 Movement of the Dial
The Dial is rotated according to the rate at which it has been moved. So after the dial is rotated
and pen-up has been done the knob reaches it minimum value by slowly reducing its speed.
Velocity calculations are done in the MCU, not the FT800.
3.2.2.2 Button Highlight
There are twelve buttons above the dial. The buttons are highlighted according to the track
movement of the dial as shown in the code below.
if(BaseTrackVal < 11*65535)/* BaseTrackVal is the track value of the dial*/
{
/* Rotary tag when within range of particular index, highlight only the indexed
button in yellow*/
if(((BaseTrackVal >= k*65535)&&(BaseTrackVal < (k+1)*65535
{
Ft_Gpu_CoCmd_FgColor(phost,0xE3F914);//yellow
Ft_Gpu_CoCmd_Button(phost,Vx1,Vy1,20,30,16,0,"");
}
else/* Color the non indexed buttons in grey color*/
{
Ft_Gpu_CoCmd_FgColor(phost,0x787878);//grey
Ft_Gpu_CoCmd_Button(phost,Vx1,Vy1,20,30,16,0,"");
}
}
7
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
3.2.2.3 Bitmaps Rotation
The dial bitmap is placed at a specific location. The strips bitmap alpha value is reduced to 20 and
it is rotated according to the value at which it has been rotated.
Ft_Gpu_CoCmd_LoadIdentity(phost);
Ft_Gpu_CoCmd_Translate(phost,F16(73),F16(73));
Ft_Gpu_CoCmd_Rotate(phost,PrevValDeg*65536/360);
Ft_Gpu_CoCmd_Translate(phost,F16(-(73)),F16(-(73)));
Ft_Gpu_CoCmd_SetMatrix(phost);
Ft_App_WrCoCmd_Buffer(phost,TAG(1));
Ft_App_WrCoCmd_Buffer(phost,VERTEX2II((CircleX - 146/2)+40,CircleY 146/2,0,0));
3.2.2.4 Audio
Audio is played according to the volume that is selected. The Carousel effect (08H) is played
continuously.
Figure 3-3 Relative Dial Screen
8
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
4 Contact Information
Head Office – Glasgow, UK
Branch Office – Tigard, Oregon, USA
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
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)
E-mail (General Enquiries)
sales1@ftdichip.com
support1@ftdichip.com
admin1@ftdichip.com
E-Mail (Sales)
E-Mail (Support)
E-Mail (General Enquiries)
us.sales@ftdichip.com
us.support@ftdichip.com
us.admin@ftdichip.com
Branch Office – Taipei, Taiwan
Branch Office – Shanghai, China
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
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)
E-mail (Sales)
E-mail (Support)
E-mail (General Enquiries)
tw.sales1@ftdichip.com
tw.support1@ftdichip.com
tw.admin1@ftdichip.com
cn.sales@ftdichip.com
cn.support@ftdichip.com
cn.admin@ftdichip.com
Web Site
http://ftdichip.com
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
9
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
Appendix A – References
Document References
FT800 Embedded Video Engine Datasheet
FT800 programmer guide
Datasheet for VM800B
Datasheet for VM800C
Acronyms and Abbreviations
Terms
Arduino Pro
Description
The Open Source platform variety based on the Ateml ATMega chipset
EVE
Embedded Video Engine
SPI
Serial Peripheral Interface
UI
User Interface
10
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
Appendix B – List of Figures
List of Figures
Figure 2-1 Absolute Dial Flowchart ........................................................................................ 3
Figure 2-2 Relative Dial Flowchart ......................................................................................... 4
Figure 3-1 Strips Dial Bitmap ................................................................................................ 6
Figure 3-2 Absolute Dial Screen ............................................................................................ 7
Figure 3-3 Relative Dial Screen ............................................................................................. 8
11
Copyright © 2014 Future Technology Devices International Limited
Application Note
AN_311 FT800 Demo Application - Absolute & Relative Dials
Version
Document Reference No.: FT_001014
1.0
Clearance No.: FTDI# 383
Appendix C – Revision History
Document Title:
AN_286 FT800 Demo Application - Absolute & Relative Dials
Document Reference No.:
FT_001014
Clearance No.:
FTDI# 383
Product Page:
http://www.ftdichip.com/FTProducts.htm
Document Feedback:
Send Feedback
Revision
Changes
Date
1.0
Initial Release
YYYY-MM-DD
1.0
Revised according to comments
2014-03-20
12
Copyright © 2014 Future Technology Devices International Limited