need object help just not understanding how to use/drivers/objects from downloa
mikediv
Posts: 825
Instead of wasting space I just edited my original post....Mike thanks, I am really trying not to ask any more question here·but I just cant figure this out . , I can get the prop to blink differant leds all day what I am having a problem with is using Objects, I do have the class papers even the one on objects but it is not answearing my question I will try and explain a bit better.
Again I am only using the blinking led program as an example for what I am trying do with OBJECTS..
first I wrote an led blinking program
Example ::::::
'' File: LedOnP4.spin
PUB LedOn··································· ' Method declaration
············································
··· dira[noparse][[/noparse]4] := 1···························· ' Set P4 to output
··· outa[noparse][[/noparse]4] := 1···························· ' Set P4 high
··· repeat·································· ' Endless loop prevents program from ending
Ok now I wrote another one and called it mike1 my name plus the number 1 and made this my OBJECT???..
Example ::::::
'' File: mike1.spin
PUB LedOn··································· ' Method declaration
············································
··· dira[noparse][[/noparse]6] := 1···························· ' Set P6 to output
··· outa[noparse][[/noparse]6] := 1···························· ' Set P6 high
··· repeat·································· ' Endless loop prevents program from ending
I did this to try and figure out how to load objects that are available from the·"OBJECT EXCHANGE"
This led code does not matter I am trying to figure out how to call in outside programs and have them WORK.
So here is my third code example Note trying to call the other program as an OBJECT/Driver:::::
'' File: LedOnP4.spin
OBJ· 'Objects Section
· Blink2: "mike1"· 'to see if I can load an object·
PUB LedOn························ ' Method declaration
· Blink2.start ' Just want to load an object to see if it will work
············································
··· dira[noparse][[/noparse]4] := 1···························· ' Set P4 to output
··· outa[noparse][[/noparse]4] := 1···························· ' Set P4 high
··· repeat·································· ' Endless loop prevents program from ending
Again I just want to learn how to use the porgrams in the Object Exchange this is just an example of what I am trying to do so everyone can see the errors I am getting.
For the sake of argument pretend I just wrote code that will say "Hello World. and I want to send it out to a serial terminal
So I would write little porgram but use "FullSerialDuplex" Driver/Object from the Object download section this is what I am trying to learn. I do not know how to USE Objects or get them to work in my main program ..all the driver programs everyone has written and placed there for everyone to use
So my question is how do you use these drivers???? as you can see by my examples of how I am trying to do it its not working so what am I doing wrong thanks guys. P.S I know that they/Object/Drivers can be loaded into a main program I just dont know how to get them to work properly???
Post Edited (mikediv) : 1/10/2009 1:47:16 AM GMT
Again I am only using the blinking led program as an example for what I am trying do with OBJECTS..
first I wrote an led blinking program
Example ::::::
'' File: LedOnP4.spin
PUB LedOn··································· ' Method declaration
············································
··· dira[noparse][[/noparse]4] := 1···························· ' Set P4 to output
··· outa[noparse][[/noparse]4] := 1···························· ' Set P4 high
··· repeat·································· ' Endless loop prevents program from ending
Ok now I wrote another one and called it mike1 my name plus the number 1 and made this my OBJECT???..
Example ::::::
'' File: mike1.spin
PUB LedOn··································· ' Method declaration
············································
··· dira[noparse][[/noparse]6] := 1···························· ' Set P6 to output
··· outa[noparse][[/noparse]6] := 1···························· ' Set P6 high
··· repeat·································· ' Endless loop prevents program from ending
I did this to try and figure out how to load objects that are available from the·"OBJECT EXCHANGE"
This led code does not matter I am trying to figure out how to call in outside programs and have them WORK.
So here is my third code example Note trying to call the other program as an OBJECT/Driver:::::
'' File: LedOnP4.spin
OBJ· 'Objects Section
· Blink2: "mike1"· 'to see if I can load an object·
PUB LedOn························ ' Method declaration
· Blink2.start ' Just want to load an object to see if it will work
············································
··· dira[noparse][[/noparse]4] := 1···························· ' Set P4 to output
··· outa[noparse][[/noparse]4] := 1···························· ' Set P4 high
··· repeat·································· ' Endless loop prevents program from ending
Again I just want to learn how to use the porgrams in the Object Exchange this is just an example of what I am trying to do so everyone can see the errors I am getting.
For the sake of argument pretend I just wrote code that will say "Hello World. and I want to send it out to a serial terminal
So I would write little porgram but use "FullSerialDuplex" Driver/Object from the Object download section this is what I am trying to learn. I do not know how to USE Objects or get them to work in my main program ..all the driver programs everyone has written and placed there for everyone to use
So my question is how do you use these drivers???? as you can see by my examples of how I am trying to do it its not working so what am I doing wrong thanks guys. P.S I know that they/Object/Drivers can be loaded into a main program I just dont know how to get them to work properly???
Post Edited (mikediv) : 1/10/2009 1:47:16 AM GMT
Comments
Including "anothblinkprg" in your program simply compiles it with your program. It doesn't execute it.
There are other errors in what you've posted. What you posted won't compile (at the very least because "d2" is not defined). Please post your actual program and use the [noparse][[/noparse] code ] and [noparse][[/noparse] /code ] tags around it (without the extra spaces) so we can see the formatting clearly.
Here's a simple multi-blink program. I haven't compiled it, but it should compile and run blinking LEDs on pins 0, 1, and 2 at different rates.
OBJ 'Objects Section
Blink2: "mike1" 'to see if I can load an object
...isn't actually running anything. It creates an object called Blink2 which contains functions declared in "mike1.spin". Using your above example, it'll have a function called LedOn that turns on an LED and never returns because of the repeat at the end. If you take that out, your program will probably work. Creating an object doesn't change how the functions work - if you want to run one on another cog you need to call cognew on that function, whether it's local (like Mike Green's example) or in a different object. Your 'mike1' file doesn't contain a function called 'start', so the compiler will complain.
The objects in the object exchange will all have different functions to initialize and interact with them. Some will start their own cogs, while others are just 'function sets' that you call.
The best way to learn about objects and cogs is to go through the dirt simple example files provided with the Propeller Tool. The Prop takes a little getting used to, but it's not difficult.
Jason