FT800

SwordfishUser.FT800 History

Hide minor edits - Show changes to output

Added lines 2-3:

'+Changed on Feb 2017:+'
Changed line 7 from:
'''=code [=
to:
=code [=
Added lines 2-140:

Compared to the original version to be able to properly display many objects and be able to use the tracking properly, you must change the following routines :

rows added are indicated by // <----------------

'''=code [=
'********************************************************************************
'* Name    : CMD_PROGRESS                                                      *
'* Purpose : Draw a progress bar                                                *
'********************************************************************************
Public Sub CMD_PROGRESS(x As Integer,
                        y As Integer,
                        w As Integer,
                        h As Integer,
                        options As Word,
                        val As Word,
                        range As Word)
  cmd(FT_CMD_PROGRESS)
  wr16(RAM_CMD+cmd_offset, x)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, y)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, w)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, h)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, options)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, val)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, range)
  cmd_increment2()   
  wr16(RAM_CMD+cmd_offset, 0)      // <----------------
  cmd_increment2()                  // <----------------
End Sub

'********************************************************************************
'* Name    : CMD_SLIDER                                                        *
'* Purpose : draw a slider                                                      *
'********************************************************************************
Public Sub CMD_SLIDER(x As Integer,
                      y As Integer,
                      w As Word,
                      h As Word,
                      options As Word,
                      val As Word,
                      range As Word)
  cmd(FT_CMD_SLIDER)
  wr16(RAM_CMD+cmd_offset, x)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, y)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, w)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, h)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, options)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, val)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, range)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, 0)      // <----------------
  cmd_increment2()                  // <----------------
End Sub

'********************************************************************************
'* Name    : CMD_DIAL                                                          *
'* Purpose : Draw a rotary dial control                                        *
'********************************************************************************
Public Sub CMD_DIAL(x As Integer,
                    y As Integer,
                    r As Integer,
                    options As Word,
                    val As Word)
  cmd(FT_CMD_DIAL)
  wr16(RAM_CMD+cmd_offset, x)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, y)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, r)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, options)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, val)
  cmd_increment2()                // <----------------
  wr16(RAM_CMD+cmd_offset, 0)    // <----------------
  cmd_increment2()                // <----------------
End Sub

'********************************************************************************
'* Name    : CMD_TOGGLE                                                        *
'* Purpose : draw a toggle switch                                              *
'********************************************************************************
Public Sub CMD_TOGGLE(x As Integer,
                      y As Integer,
                      w As Integer,
                      font As Byte,
                      options As Word,
                      state As Word,
                      s As String)
  cmd(FT_CMD_TOGGLE)
  wr16(RAM_CMD+cmd_offset, x)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, y)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, w)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, font)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, options)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, state)
  cmd_increment2()                          // <----------------
  cmd_incrementn(wr8s(RAM_CMD+cmd_offset, s))
End Sub

'********************************************************************************
'* Name    : CMD_TRACK                                                          *
'* Purpose : enable co-processor engine to track the touch on the particular    *
'*          graphics object with one valid tag value assigned                  *
'********************************************************************************
Public Sub CMD_TRACK(x As Integer, y As Integer, w As Integer, h As Integer, TAG As Integer)
  cmd(FT_CMD_TRACK)
  wr16(RAM_CMD+cmd_offset, x)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, y)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, w)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset, h)
  cmd_increment2()
  wr16(RAM_CMD+cmd_offset,TAG )
  cmd_increment2()   
  wr16(RAM_CMD+cmd_offset,0 )    // <----------------
  cmd_increment2()              // <----------------
End Sub

=]
Changed line 133 from:
If Not FT.Load("chipmunk.jpg") Then ' chipmunk.jpg") then
to:
If Not FT.Load("chipmunk.jpg") Then
Changed lines 208-211 from:
       FT.Swap()
 
     
 
   
to:
       FT.Swap()   
Changed lines 177-180 from:
           FT.Tag(128)
to:
           FT.Tag(128)               ' Display is OFF then
                                      ' the rectangle on all display area
                                      ' become active when touch with a tag
                                      ' value of 128
Changed lines 183-186 from:
       FT.VERTEX2II(480, 272)
to:
       FT.VERTEX2II(480, 272)         ' Draw a rectangle on all display area
                                      ' active with a tag only when display is
                                      ' off

Added lines 198-199:
           ' Touch on all display area when display is off then
            ' pressed message is not display
Added line 204:
           ' Touch on an element and not when display is off
Changed line 159 from:
               TurnOn(5) 
to:
               TurnOn(5)           ' <-- Backlight set to 5 duty
Changed line 186 from:
           TurnOn()
to:
           TurnOn()                     ' <-- Backlight set to 128 duty
Changed lines 19-21 from:
with only necessary routines for use with the FT800 module maked via option. Default value is False, only a subset is included.
 - FT.Clear became FT.Cls since Clear is a keyword in Swordfish.

to:
with only necessary routines for use with the FT800 module maked via option.
Default value is False, only a subset is included.
Added lines 24-26:

 - FT.Clear became FT.Cls since Clear is a keyword in Swordfish.

Added line 20:
 - FT.Clear became FT.Cls since Clear is a keyword in Swordfish.
Changed line 1 from:
This library, obtained by porting from Firewing source written by David Barker, lets you use the display module FT800 / Gameduino2 from Swordifsh.
to:
This library, obtained by porting from [[http://www.firewing.info/pmwiki.php?n=FirewingUser.FT800| Firewing source written by David Barker ]], lets you use the display module FT800 / Gameduino2 from Swordifsh.
Changed lines 25-29 from:
In the second example "Numpad.BAS" found how to switch off the display after a period of time without use until they touch the screen.

Below schematic and PCB design.

to:
Added lines 57-58:

In the second example "Numpad.BAS" found how to switch off the display after a period of time without use until they touch the screen.
Changed lines 18-19 from:
 - The ability to use the SDCard module completely or a subset of it with only necessary routines for use with the FT800 maked via option. Default value is False, only a subset is included.
to:
 - The ability to use the SDCard module completely or a subset of it
with only necessary routines for use with the FT800 module maked via option. Default value is False, only a subset is included.
Added lines 18-22:
 - The ability to use the SDCard module completely or a subset of it with only necessary routines for use with the FT800 maked via option. Default value is False, only a subset is included.

=code [=
#option FT800_FULL_SD_LIB = false
=]
Changed lines 1-3 from:
This library, obtained by porting from Firewing source written by David Barker, lets you use the display module FT800 / Gameduino2 from Swordifsh.
We recommend using MPU with a speed higher or equal to 32MHz, I used a xtal of 10MHz with a 4xPLL device.

to:
This library, obtained by porting from Firewing source written by David Barker, lets you use the display module FT800 / Gameduino2 from Swordifsh.

You can download [[http://sfcompiler.co.uk/wiki/uploads/coccoliso/Gameduino2-PIC18-Swordfish.zip| Swordfish FT800 Library ]] here

You can download [[http://sfcompiler.co.uk/wiki/uploads/coccoliso/Gameduino2-PIC18-Project.zip| Diagram and PCB ]] here

Added lines 8-9:

I used a Gameduino 2 display module and recommend using a MPU with a speed higher or equal to 32MHz, I used a xtal of 10MHz with a 4xPLL device.
Added lines 3-6:

http://sfcompiler.co.uk/wiki/uploads/coccoliso/Gameduino2-PIC18-1.jpg

http://sfcompiler.co.uk/wiki/uploads/coccoliso/Gameduino2-PIC18-2.jpg
Changed line 10 from:
In the second example "Keypad.BAS" found how to switch off the display after a period of time without use until they touch the screen.
to:
In the second example "Numpad.BAS" found how to switch off the display after a period of time without use until they touch the screen.
Added lines 2-3:
We recommend using MPU with a speed higher or equal to 32MHz, I used a xtal of 10MHz with a 4xPLL device.
Changed lines 9-189 from:
 Below schematic and PCB design.
to:

In the second example "Keypad.BAS" found how to switch off the display after a period of time without use until they touch the screen.

Below schematic and PCB design.


=code [=
{
*****************************************************************************
*  Name    : Ballons.BAS                                                    *
*****************************************************************************
}

Device = 18F2682
Clock = 40

#option FT800_MODEL = GAMEDUINO
#option FT800_SDCS  = PORTC.1
#option FT800_CS    = PORTC.0
#option FT800_CLK  = PORTC.3
#option FT800_DI    = PORTC.4
#option FT800_DO    = PORTC.5
Include "FT800"

Dim i As Word
While true
    FT.Cls()
    FT.Begin(POINTS)
    For i = 0 To 100
        FT.PointSize(FT.Random(16 * 50))
        FT.ColorRGB(FT.Random(256), FT.Random(256), FT.Random(256))
        FT.ColorA(FT.Random(256))
        FT.VERTEX2II(FT.Random(480), FT.Random(272))
    Next
    FT.Swap()
End While
=]

=code [=
{
*****************************************************************************
*  Name    : Numpad.BAS                                                    *
*****************************************************************************
}

Device = 18F2682
Clock = 40

#option FT800_MODEL = GAMEDUINO
#option FT800_SDCS  = PORTC.1
#option FT800_CS    = PORTC.0
#option FT800_CLK  = PORTC.3
#option FT800_DI    = PORTC.4
#option FT800_DO    = PORTC.5
Include "FT800"
Include "convert"

Private Sub Paint_Alpha()
    FT.BlendFunc(ONE, ONE_MINUS_SRC_ALPHA)
End Sub

Private Sub Clear_Alpha()
    FT.BlendFunc(ZERO, ONE_MINUS_SRC_ALPHA)
End Sub

Private Sub button(x As Integer, y As Integer, size As Byte, label As Byte)
    Paint_Alpha()
    FT.TagMask(1)
    FT.Tag(label)
    FT.Begin(RECTS)
    FT.LineWidth(16 * 20)
    FT.VERTEX2II(x - size, y - size)
    FT.VERTEX2II(x + size, y + size)
    Clear_Alpha()
    FT.ColorA(200)
    FT.ColorA(200)
    FT.LineWidth(16 * 15)
    FT.VERTEX2II(x - size, y - size)
    FT.VERTEX2II(x + size, y + size)
    FT.ColorA($ff)
    Paint_Alpha()
    FT.Begin(POINTS)
    FT.cmd_number(x, y, 31, OPT_CENTER, label)
    FT.TagMask(0)
End Sub

Dim x0, x1, x2,
    y0, y1, y2  As Integer
Dim selectedTag,
    lastselected As Byte
Dim loops As Word,
    on As Boolean

x0 = 40  ' 160
x1 = 110 ' 240
x2 = 180 ' 320

y0 = 50  ' 56
y1 = 120 ' 136
y2 = 190 ' 216

lastselected = 0
loops = 0
on = true

FT.SelfCalibrate()
FT.cmd_loadimage(0,0)

If Not FT.Load("chipmunk.jpg") Then ' chipmunk.jpg") then
    FT.Cls()
    FT.cmd_text(240, 136, 29, OPT_CENTER, "Unable to load file") 
    FT.Swap()         
Else
         
    While true
        FT.Cls()
        FT.ColorMask(1, 1, 1, 0)
        FT.TagMask(0)
        FT.Begin(BITMAPS)
        FT.VERTEX2II(0, 0)
        FT.ColorMask(0, 0, 0, 1)
 
        button(x0, y0, 14 ,1)
        button(x1, y0, 14 ,2)
        button(x2, y0, 14 ,3)
        button(x0, y1, 14 ,4)
        button(x1, y1, 14 ,5)
        button(x2, y1, 14 ,6)
        button(x0, y2, 14 ,7)
        button(x1, y2, 14 ,8)
        button(x2, y2, 14 ,9)
       
        If on Then   
            If loops > 1000 Then
                TurnOn(5) 
                loops = 0
                on = false
            Else
                Inc(loops)
            End If
        End If
       
        If on Then
            FT.TagMask(0)
        Else
            FT.TagMask(1)       
        End If
        FT.ColorMask(1, 1, 1, 1)
        FT.ColorRGB($ffffff)
        FT.BlendFunc(DST_ALPHA, ONE_MINUS_DST_ALPHA)
        FT.Begin(RECTS)
        If Not on Then
            FT.Tag(128)
        End If
        FT.VERTEX2II(0, 0)
        FT.VERTEX2II(480, 272)
        FT.RestoreContext()
       
        selectedTag = FT.GetTag()
        If selectedTag<>0 Then
            lastselected = selectedTag
            TurnOn()
            loops = 0
            on = true             
        End If
       
        If selectedTag<>128 Then
            FT.cmd_text(15, 240, 27, 0, "Pressed : " + DecToStr(selectedTag))
        End If
       
        If lastselected <>0 And lastselected<>128 Then
            FT.cmd_text(200, 240, 27, 0, "Last Selected : " + DecToStr(lastselected))
        End If
       
        FT.Swap()
 
     
       
    End While
End If
=]
Changed lines 3-4 from:
 - Storing the calibration in EEPROM (address 0 by default but can be selected differently and if the device has an EEPROM) that is stored on the first run of SelfCalibrate ().
 - The ability to adjust the intensity of the backlight via software through procedures TurnOff (), which turns it off completely, and TurnOn () where you can pass as a parameter the duty cycle with a byte value between 0 and 128.
to:
 - Storing the calibration in EEPROM
(at address 0 by default but can be selected differently) if the device has an EEPROM that stored parameters on the first run of SelfCalibrate().
 - The ability to adjust the intensity of the backlight
via software through procedures TurnOff (), which turns it off completely, and TurnOn () where you can pass as a parameter the duty cycle with a byte value between 0 and 128.
Added lines 1-5:
This library, obtained by porting from Firewing source written by David Barker, lets you use the display module FT800 / Gameduino2 from Swordifsh.
Respect from original of David I added:
 - Storing the calibration in EEPROM (address 0 by default but can be selected differently and if the device has an EEPROM) that is stored on the first run of SelfCalibrate ().
 - The ability to adjust the intensity of the backlight via software through procedures TurnOff (), which turns it off completely, and TurnOn () where you can pass as a parameter the duty cycle with a byte value between 0 and 128.
 Below schematic and PCB design.