[TUTORIALS] V-TFT beginners example projects

General discussion on Visual TFT Software.
Author
Message
lejeff
Posts: 218
Joined: 04 Dec 2011 16:10
Location: France

Re: [TUTORIAL] V-TFT beginners example project

#46 Post by lejeff » 30 Jan 2014 07:47

No problem

here is an extract of my code (working code) used to display a 4 digit value (rallye odometer) on smartglcd

Code: Select all

sub procedure display_part()
 dim value as string[10]
     digit as string[1]
 if dist_part > 9999 then nbpulse_part = 0 end if
 dwordtostrwithzeros(dist_part,value)
 digit[1] = 0
 digit[0] = value[9]
 if (str2byte(part_centh_caption) <> str2byte(digit)) then
   part_centh_caption =  digit
   DrawButton(@part_centh)
 end if
 digit[0] = value[8]
 if (str2byte(part_tenth_caption) <>  str2byte(digit)) then
   part_tenth_caption =  digit
   DrawButton(@part_tenth)
 end if
 digit[0] = value[7]
 if (str2byte(part_ones_caption) <>  str2byte(digit)) then
   part_ones_caption =  digit
   DrawButton(@part_ones)
 end if
 digit[0] = value[6]
 if (str2byte(part_tens_caption) <>  str2byte(digit)) then
   part_tens_caption =  digit
   DrawButton(@part_tens)
 end if
end sub

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: [TUTORIAL] V-TFT beginners example project

#47 Post by aCkO » 30 Jan 2014 13:46

There is no need to invoke additional functions. It is enough to use:

Code: Select all

if (Button_Million_Caption[0] <> SHRT_STR[0]) then ...
Regards

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

Re: [TUTORIAL] V-TFT beginners example project

#48 Post by Megahurts » 01 Feb 2014 17:59

Hi Guys,

Thanks for the example Jeff, but I'll bet you switch to Aleksandar's method too.
I think that one of the hardest things to do in programming is make the programs as simple as possible.

It takes some skill, a lot of knowledge and a lot of experience and (for me anyway) a good dose of luck to spot the better / simpler solutions like that.
Thankfully, we get to receive help and guidance here in the community from some very bright members, wink wink.

I'm still busy with a couple of prototype projects right now and one requires me taking the head-first crash course in learning mPASCAL
to program the controller used. It's been fun and frustrating and sadly slow to get results, but it has to be done.
So I'll be a little absent here for this month and have to put on hold any updates to the tutorials until I get the PASCAL programming done.
I'll be checking still, and making notes (always), for tutorial additions and changes.

Happy programming to all, Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

Re: [TUTORIAL] V-TFT beginners example project

#49 Post by Megahurts » 16 Feb 2014 16:41

Hi All,

Just a quick mention of something I want to add to the tutorial PDF, but worth showing here for the thread readers now.

What a person sees of components in the V-TFT screen editor will be different sometimes than what you will see on the actual device screen
when you are changing some of the components visual properties.

Properties like "transparent" and "visible" are main ones that differ.

In V-TFT, changing the "Transparent" property results with the object being redrawn on the screen and showing whatever is behind the objects area(s) that went transparent.
But in actual running code, changing the objects (dynamic objects only) transparent property and just redrawing it results with no apparent change on the screen.
To see anything that is behind the objects transparent area(s), you need to redraw the object(s) that are behind it first, then redraw the object that had its transparent property changed to "True" over the top of those other(s).

Basically, any change to properties that will cause subtractive pixel changes to a top-most layered object and should result with objects that are behind the top-most one to be visible after change, requires the behind objects to be redrawn then top-most object redrawn last.

Tip of the month for ya. The tutorial PDF version will include pictures to illustrate what happens visually.

Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

ronjodu
Posts: 24
Joined: 02 Mar 2014 20:06

Re: [TUTORIAL] V-TFT beginners example project

#50 Post by ronjodu » 22 Mar 2014 20:47

Hello all, Robert,
This is my first post to this forum. I just purchased the TFT Plus Professional Kit 1. I'm still waiting for it to arrive so I'm working with the trial software and reading as much as I can on Mbasic and VTFT. I have to say up until I found this thread I wasn't very optimistic about a "Quick Start" with this product. The work you have put into this is awsome. Just reading through this thread has helped me to understand more about VTFT than anything I've found on the product website.
I'm moving from PicBasic Pro to Mbasic so I have that learning curve to go through. Your tutorial here will help greatly with the VTFT learning curve.

Thanks for sharing this great learning tool.
How's that Mpascal working for you?

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

Re: [TUTORIAL] V-TFT beginners example project

#51 Post by Megahurts » 28 Mar 2014 15:24

Hi ronjodu,

Welcome to the forums and thank you for posting about how the tutorial helped you. That makes my work and time spent worthwhile. :D

I hope it helps you get your projects up and running as you wanted them to be.

I am having a lot of fun with the mPASCAL compiler so far. There are a few things I find hard to get used to, like the need to have every line end with a semicolon ";", (most times, but not always :? ).

But I am liking the structure it imposes more each day I work with it. My first scratch built project with it is almost done, one more (I think) routine to write, but it is a very complex multitasking (multiple passes to complete over time schedule) one and still burning up brain cells thinking it out.

Thanks for asking on that too.

Anyway, hope you have good times using the tools and feel free to ask for help if you need it, Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

Re: [TUTORIAL] V-TFT beginners example project

#52 Post by Megahurts » 05 Apr 2014 20:53

Hi Everyone,

A tip-of-the-month post for you all.

If you have not discovered this yet, here is one for working in the components properties window.

In any components properties that require you to type in characters or numeric values, there are 3 ways to evoke the changes you made
so they take effect.

1. the "Enter" or "Return" keyboard key.
(this results with the highlight going to next property below it and a "Windows Chime" sound being made, if volume is up enough to hear it.)

2. the "UP" or "DOWN" arrow keyboard keys.
(this results with the changes entered taking effect, the highlight moves either up or down to other property, depending on arrow key pressed, and there is no "Windows Chime" sound being made.)

3. mouse pointer left or right clicked anywhere else in V-TFT.
(this results with the changes you entered taking effect and the object or other property you clicked on becoming highlighted now and no "Windows Chime" sound being made.)

Enjoy and happy project building everyone, Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

TIP of Month for May: Compiler comment trick.

#53 Post by Megahurts » 24 Apr 2014 21:03

Greetings V-TFT Users,

I have a early tip-of-the-month for May posting for you all. I think this one can really help you when you are working on your V-TFT project in your compiler. :D
(If you do not already do something similar) :wink:

This one helps you keep track of which V-TFT object (component) drawing routines you may need to call for the objects you used in your V-TFT project.
(the code examples are for mBASIC, but mC and mPASCAL versions should be close to same)

STEP 1. Find the drawing routines external declarations in your V-TFT projects "driver" file. You can refer to the tutorial PDF for more info on the driver file.

With your project loaded into your compiler and the projects driver file also loaded for viewing/editing, starting at the top of the file you will see the modules name, then any other file includes,
then external declarations (these should be a listing of all object/button event handler routines you set in V-TFT).

After the externals should be a grouping of routine forwards declarations of all routines V-TFT placed in the driver file that are or might be required for your project,
based on which components you used in your project.

Here is an example driver file code listing of one of my projects that did not use too many different components:

Code: Select all

module PWM_PIC32_H2O_Cell_driver

include PWM_PIC32_H2O_Cell_objects
include PWM_PIC32_H2O_Cell_resources

' External Declarations  *(shortened for this example - Robert)
sub procedure Scrn1_Btn_GATE10_OnClick() external
sub procedure Scrn1_Btn_PULSE10_OnClick() external
sub procedure Scrn1_Btn_PWM_OnClick() external
'/////////////////////////

sub procedure DrawScreen(dim aScreenID as word)   '* these first 4 routines are required for your project and always listed here.
sub procedure Process_TP_Press(dim X as word, dim Y as word)
sub procedure Check_TP()
sub procedure Start_TP()
sub procedure DrawButton(dim Abutton as ^TButton)   '* Here are the routines V-TFT thinks you will need for your projects objects. Copy the ones your project has.
sub procedure DrawCButton(dim Abutton as ^TCButton)
sub procedure DrawRoundButton(dim Around_button as ^TButton_Round)
sub procedure DrawCRoundButton(dim Around_button as ^TCButton_Round)
sub procedure DrawCLabel(dim ALabel as ^TCLabel)
sub procedure DrawCBox(dim ABox as ^TCBox)
sub procedure DrawRoundBox(dim Around_box as ^TBox_Round)
sub procedure DrawCheckBox(dim ACheckBox as ^TCheckBox)
sub procedure DrawProgressBar(dim AProgressBar as ^TProgressBar)
sub procedure UpdatePBPosition(dim AProgressBar as ^TProgressBar)
STEP 2. Copy all drawing routines your project has listed like shown above in my example code (drag pointer from start to end lines to highlight all of them and right-click - Copy.)
You should also copy the "sub procedure DrawScreen(dim aScreenID as word)" declaration too.
Or copy all lines from the drawscreen() entry to the last line entry, and remove the unneeded routines after pasting in the next step.

STEP 3. Paste the routine declarations you copied in step 2 into your projects "events_code" file in the '-------------- User code declarations ---------------'
section, (near the top of the file and below that comment line), so you will see something like this:

Code: Select all

'-------------- User code declarations ---------------'
sub procedure DrawScreen(dim aScreenID as word)
sub procedure Process_TP_Press(dim X as word, dim Y as word)
sub procedure Check_TP()
sub procedure Start_TP()
sub procedure DrawButton(dim Abutton as ^TButton)
sub procedure DrawCButton(dim Abutton as ^TCButton)
sub procedure DrawRoundButton(dim Around_button as ^TButton_Round)
sub procedure DrawCRoundButton(dim Around_button as ^TCButton_Round)
sub procedure DrawCLabel(dim ALabel as ^TCLabel)
sub procedure DrawCBox(dim ABox as ^TCBox)
sub procedure DrawRoundBox(dim Around_box as ^TBox_Round)
sub procedure DrawCheckBox(dim ACheckBox as ^TCheckBox)
sub procedure DrawProgressBar(dim AProgressBar as ^TProgressBar)
sub procedure UpdatePBPosition(dim AProgressBar as ^TProgressBar)
STEP 4. Edit the stuff you just pasted so it looks something like this:
(You can copy my comment line ' LIST OF V-TFT OBJECT DRAWING ROUTINES USED BY THIS PROGRAM: and use it if you want also.)

Code: Select all

'-------------- User code declarations ---------------'
' LIST OF V-TFT OBJECT DRAWING ROUTINES USED BY THIS PROGRAM:
'  DrawScreen()
'  DrawButton(@)
'  DrawCButton(@)
'  DrawRoundButton(@)
'  DrawCRoundButton(@)
'  DrawCLabel(@)
'  DrawCBox(@)
'  DrawRoundBox(@)
'  DrawCheckBox(@)
'  DrawProgressBar(@)
'  UpdatePBPosition(@)
Making them comments and removing the ones you won't be calling (start_TP(), Check_TP(), Process_TP_Press(dim X as word, dim Y as word) ).

Now you can easily copy the prototype routine call and paste them where you need them and fill (copy/paste) in the objects identifier name after the "@" inside the parentheses.
Example: DrawRoundButton(@RoundButton1)
Drawing Routine you want to use copied from the comments you made.
Object in your project you need to be drawn or redrawn (copy the name from elsewhere in the code, why type it or try to remember its name :wink: ),
and paste it after the @ symbol, and ding - your done setting up the proper object drawing routine. 8)

Also: If you did not know this, the drawing routines that have a Capitol "C" in the routine name are the drawing routines for "Static" components.
Make sure you use the right one for the object(s) you are wanting to draw/redraw.

Examples:
DrawButton(@) is the drawing routine for Dynamic Buttons.
DrawCButton(@) is the drawing routine for Static Buttons. ("C" = Constant, and this naming convention is used thru out the V-TFT generated code.)

Bonus Tip: Where to find the V-TFT assigned name(s) for any screens in your project- (the proper screen identifier to be used with the "DrawScreen(screennameScreenID)" routine.)
Load your V-TFT projects "objects" file into the compiler, then scroll to the bottom of the file and you will see the proper V-TFT assigned constant (if static), identifier(s) for your screen(s).
They should be just above the "Implements" statement like this:

Code: Select all

  const Screen1ScreenID = 32768
  const Screen2ScreenID = 32769
  const Screen3ScreenID = 32770

implements
You may want to copy these also and place them in the "events_code" file also as comments for later reference.

I hope this helps you with your projects and you find it useful, Robert. :D
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

aCkO
Posts: 1119
Joined: 14 Feb 2011 04:07
Location: Bar, Montenegro

Re: [TUTORIAL] V-TFT beginners example project

#54 Post by aCkO » 26 Apr 2014 00:39

Hi Robert,

An alternative to your approach would be to just start typing: draw and pressing CTRL + SPACE to activate Code Assistant/code completion feature of the IDE:
code_assistant.png
code_assistant.png (27.56 KiB) Viewed 7601 times
Regards

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

Re: [TUTORIAL] V-TFT beginners example project

#55 Post by Megahurts » 13 May 2014 14:12

Hi Aleksandar,

I tried the "code assistant" method and while it does a good job finishing the identifiers name, it does not place the reference prefix symbol (@) in the code or include the opening/closing parentheses.

So I have mixed feelings which is actually easier or best serves the programmer. (usage does not induce syntax errors if not paying attention)

Both have pros and cons, and neither is a perfect solution. Even using both has limits due to the need to move in the file to go copy my commented prototype listings.

But I thank you for adding to the topic and helping users discover (or remember) a useful tool in the compilers.

I guess making micros is also an option, but it also has cons to implement successfully.

Open for discussion from you other users, feel free to step in and post opinions or your "secret" method to assist programming V-TFT code.

B^) Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

How to use the compilers software simulator example:

#56 Post by Megahurts » 03 Jun 2014 01:25

Hi Users,

I made a program recently to test some nested "Select Case" code logic with the software version of the compilers simulator and
wanted to pass the work on to all of you so you can benefit from my experience.

It was written with the dsPIC BASIC Pro compiler for simulating user input and logging a Port Pins output state on a dsPIC33EP for MMB development board.

You can use this example to see how to use the compiler(s) software simulator to test your own routines logic operation(s) during different settings a MMB user may input with your applications GUI.

It also shows how to use an array variable to log input/output operations so you can track down logic/operation programming errors you made in your code.
(the software simulator can not do HW input/outputs)

The example is posted in a thread for the dsPIC BASIC Pro compiler forum topic here:
http://www.mikroe.com/forum/viewtopic.php?f=111&t=60194

This methodology can be used by all of the different compilers and languages.

I hope this can help anyone solve programming problems by making use of the software simulator.

On a different help topic for you readers,

I have noticed that new users are sometimes confused about what a V-TFT/V-GLCD project output really is and the interaction needed with the compiler selected.

V-TFT and V-GLCD projects are mainly governed by the rules and restrictions of the chosen language compiler.
As such, a project must first adhere to the rules of the compilers program organization layout it expects.
This is where a lot of users will make mistakes with their first projects, (I did too).

For many of you users, a V-TFT/V-GLCD project may be the first time you have a project that has more than One file and it does require you to understand how multiple file projects in your compiler need to be organized.
(see your compilers help document on program organization for details)

Here are some common tips to these projects and all compilers:

A project must have a "main" file that has 'program name line', 'program start' identifier line and a 'program end' identifier line.
(code that needs to be executed on start can be placed here, if it does not interfere with generated code execution flow)

A projects additional files are modules and have their own organizational layout they must adhere to also, so you have to follow the rules for putting your code in them.
(They are similar rules like the 'main' file/module has except there is no open program code execution allowed in them.)

The main file has the only area where code is or can be executed that is not inside of a routine.

All other 'Executable' program code that is not in the 'main' file, must be inside of a properly declared routine in any other module files (routines are all declared and established BELOW the modules "Implements" statement, variables & constants & structures are declared above the "Implements" statement in each module file.).

Your own executable code in routines must not have any conditions that halt program flow or result in a endless loop that does not allow the routine to be exited. This causes a condition where TP input is not acted on or device seems to be locked-up.

Hopefully this will be of some help to someone on their project(s), Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

MaGiK
Posts: 897
Joined: 19 Apr 2013 10:00

Re: [TUTORIAL] V-TFT beginners example project

#57 Post by MaGiK » 03 Jun 2014 17:08

As always, helping us all to get along with our problems.
Your work is very appreciated :D
By the way, I've recently read your (About the author) and I think it's a great story that's indeed worth sharing.

This is my favourite part:
I took anything I owned (and my siblings), that had a motor or electricity used in it, apart to see how it worked. I also got spanked a lot for destroying my little brothers toys when I did not get them put back together before anyone found out, or they discovered after the fact I had taken them apart. Sometimes they just would not work ever again and once discovered, there was only one person to blame ... me. I also got spanked and blamed for a lot of household gadgets or appliances that I had no part in of its untimely death. But no one believed me most times and I got my butt heated up pretty good a lot.
Best Regards
My hobby is collecting MikroElektronika products.
Gotta catch them all!

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

Re: [TUTORIAL] V-TFT beginners example project

#58 Post by Megahurts » 05 Jun 2014 02:57

Thanks MaGiK,

I was not sure anyone actually read it. :oops:

Thank you for posting that you did and found it entertaining.

I still have to fight the urge to take everything electronic apart to see what makes it tick. I now try to only take apart things completely that no longer work or only stuff that has been given to me for repair.
Too many things of mine have been disassembled that are of more value if they were left intact and functional.

The development boards and kits from mE have helped a lot in keeping me from dissecting the household appliances lol. :wink:

Best regards as always, Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

igeorge
Posts: 593
Joined: 28 Dec 2005 09:15

Re: [TUTORIAL] V-TFT beginners example project

#59 Post by igeorge » 09 Jun 2014 17:23

How to program a vtft file on Mikromedia for pic18fj ?
I have a file from wifi plus page, with a video and code
But i do not know why i need the mikrosd and where and how to program the WiFi_AdHoc_Client.vtft file
Video it looks great but for no experience persons is completely useless
Link
http://www.mikroe.com/click/wifi-plus/
Experience is something you don't get until just after you need it

Megahurts
Posts: 900
Joined: 01 Oct 2009 22:48
Location: Rocky Mountains, USA.

Re: [TUTORIAL] V-TFT beginners example project

#60 Post by Megahurts » 10 Jun 2014 05:14

Hi igeorge,

I have not used that Click board, so not sure what all you would need to do to make it run on a PIC18F MMB.
If there is an example supplied with it that was written for the PIC18F MMB, and you do not have a need to modify the original
code, then all you have to do is locate the examples HEX file (it will be the same name as the project, but with .hex file suffix
identifier), (you may have to change the setting in your windows folder options to make it so all file suffixes are shown),
and then use the PC software (from mikroe) for programming devices using the USB BootLoader option or a mikroprog HW and its
software, load the HEX file and program the device.

If the example documentation mentions that there are other files needed by the application when it runs and mentions they should be on a MicroSD, then those files need to be placed on a MicroSD Flash memory card and it then inserted in to the MMBs
SD card holder (slot) before powering up the MMB.

If the documents only state that there should be a memory card in the SD card slot, then it is probably needed and used for storing
data that is generated while the application is running.

If I get time, and I can not promise I will, I will check out the wifi example package and see what is required if this does not help you use it.

If this does not help, you should post the question in the V-TFT general forum area as new topic or in the Development Boards forum section,
Mikroe Staff might not see/read it in this thread.

Best regards, Robert.
HW: easyPIC5|PICFlash2|easyBT|smartGSM|easyGSM|PICPLC16|mmWorkStation|FT800 Eve|PIC Clicker/2|
MMBs:PIC18F,PIC33EP,PIC32|CLICKs:DAC,ADC,GPS L10,Thermo,8x8B LED,Stepper,W/B OLED,9DOF,GPS3,tRF,Hall I|

SW: mP for PIC|mB for PIC-dsPIC-PIC32|Visual-TFT|

Post Reply

Return to “Visual TFT General”