VTFT to turn on an LED

General discussion on Visual TFT Software.
Post Reply
Author
Message
ronjodu
Posts: 24
Joined: 02 Mar 2014 20:06

VTFT to turn on an LED

#1 Post by ronjodu » 30 Aug 2014 16:08

I'm sure this is a newbie problem but for some reason I'm having trouble comprehending how to do this. I think I have a pretty good understanding of VTFT for what I'm doing. I think my problem is with mikroBasic PRO for PIC32 and the EasyPic Fusion V7 board I'm using.
I've made the GUI to change the on screen LED to the color I wanted and also got it to change the caption as I wanted. The problem I'm having is I now want an LED on the EPF7 to go on with the RED button push. I've read MegaHurtz tutorial, (AWSOME JOB) and realize the code needs to be placed in the right area.
I placed one line of code in the event handler user space and another in the program just before the main:.

If anyone has a few minutes to have a look and give me some guidance it would be much appreciated.


https://www.dropbox.com/s/bqy272cbyxxtwjz/RGB.rar?dl=0

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

Re: VTFT to turn on an LED

#2 Post by ronjodu » 01 Sep 2014 15:14

OK, I got it to work but I don't think it's the right way to do it. Here is the working project if any other beginners are interested. It's working on a Mikromedia+ for PIC32MX7 with Mikrobasic Pro for PIC32 and VTFT.

https://www.dropbox.com/s/qclxfoua5fkw5ku/RGB2.rar?dl=0

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

Re: VTFT to turn on an LED

#3 Post by Megahurts » 09 Sep 2014 10:20

Hi ronjodu,

I'll try to get the time to look it over for you, been busy doing other work and another V-TFT tutorial, but the tutorial is done now (and on LibStock).

Thanks for the good mention of the other Tutorial, glad it helped you. :D

I wish I had that PIC32MX7 mmB in my HW collection too. It would help to be able to test run for troubleshooting, but will try to make do with what I got.

Will get back to you on this soon I hope, 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: VTFT to turn on an LED

#4 Post by ronjodu » 14 Sep 2014 23:19

I thought I needed to declare subroutines in the User Code Declaration area but I commented them out and the program still runs. It now makes a beep on each button press.

Code: Select all

module RGB2_events_code

include RGB2_objects
include RGB2_resources
include RGB2_driver

sub procedure GreenOnClick()
sub procedure REDOnClick()
sub procedure YellowOnClick()
'--------------------- Externals ---------------------'
'----------------- End of Externals ------------------'

'-------------- User code declarations ---------------'
'sub procedure Tone1()   '<------------------NOT NEEDED-?
'sub procedure Tone2()   '<------------------NOT NEEDED-?
'sub procedure Tone3()   '<------------------NOT NEEDED-?

'----------- End of User code declarations -----------'

implements

'--------------------- User code ---------------------'

sub procedure Tone1()
Sound_Init (PORTD, 3)
Sound_Play(200, 250)            ' Frequency = 200Hz, duration = 250ms
end sub


sub procedure Tone2()
Sound_Init (PORTD, 3)
Sound_Play(500, 250)            ' Frequency = 500Hz, duration = 250ms
end sub


sub procedure Tone3()
Sound_Init (PORTD, 3)
Sound_Play(800, 250)            ' Frequency = 800Hz, duration = 250ms
end sub


'----------------- End of User code ------------------'
Should I declare the subroutines or not?

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

Re: VTFT to turn on an LED

#5 Post by Megahurts » 15 Sep 2014 01:17

Hi ronjodu,

Sorry, I still have not had a chance to load and look over your project, V-TFT and Compilers are running 24/7 on a project design.

As to those routine declarations:
You only need to place a "module (file) interface" routine prototype description declaration in that area if
any other project "modules" will need to call the routine in the "User Code" area (implements).

Any code you have that calls routines that are in the same project module, can do so without those declarations needed.
The declarations are needed to let the compiler know it can find the "target" routine "here" when it examines any code in
a different file that calls a routine that is not in the same file the call is in.

By the same token rules (exclusion is the main program file), any "module" file that has code that calls a routine outside of itself,
must have a routine "external" declaration to tell the compiler to look in each project files "module interface" for the matching routine description declaration.
See the top of the "driver" file for examples of this, all object "OnEvent()" handler routines you assign to your
projects touch active objects have an entry there of the routines name, but marked as "external" so the
compiler can find the match in the "events_code" module interface.

It may seem like a confusing and complex system requirement :roll: , but once you get some time dealing with it,
it becomes clear and you will only get periodic compiler error messages telling you that you forgot to do all the declarations needed
as you fly through making your projects easier and faster. :D
(the faster aspect is usually the one that causes you to "forget" to do something needed by the compiler) :lol:

The power of this system is, you do not have to also state the file name for any and all routine calls to a routine that is in a different module file,
the compiler does the work of finding it in the included "Project Files" set by you.
This declaration system causes the compiler to search out the "link" to cross file routine calls and allows users
to swap out project files with a file with different versions or features of routines without the need to also change/update any file names in any routines call link path.

If you got that, I hope you are thinking "Oh, that's cool, :idea: ...and Awesome" :?:

I have said it before, using and studying V-TFT has taught me more about multiple file project designs than anything else I have tried combined.

I now look at any project proposal or idea as how it would be laid out like a V-TFT project.
And have not written any 'single file' applications for almost 2 years now (except a example of using the compilers software simulator earlier this year :D mBASIC for dsPIC forum).

Hope this inspires and helps you along, 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: VTFT to turn on an LED

#6 Post by ronjodu » 15 Sep 2014 02:00

Thanks for the reply Robert. I'm actually enjoying the trial and error part of learning Vtft. I do this as a hobby so there's no pressure on me to learn fast.
I'll absorb your words above and post more questions as they come up. :D

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

Re: VTFT to turn on an LED

#7 Post by Megahurts » 16 Sep 2014 22:49

ronjodu wrote:Thanks for the reply Robert. I'm actually enjoying the trial and error part of learning Vtft.
UR welcome. And that's the attitude I have long had too, since I started working on electronics. It will get you to learn stuff better than other methods I believe.
ronjodu wrote:I'll absorb your words above and post more questions as they come up. :D
Any time. Will help with anything I can when I can, 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”