Graphic LCD driver in new cog (code help)
Cobalt
Posts: 31
Hi all.
I'm new to the propeller, I've had the demo board for about a week and a half now, and I love it.· I ordered two of the 40-pin DIP chips so that I can breadboard and have access to all of the IO pins for more experiments.· I've run into a small problem that I'm hoping has a simple solution:
I have a small graphic LCD, 122x32 pixels (122 wide, 32 tall).· Its uses the SED1520 controller, and I've written an object spin file that has a few methods that can handle basic stuff for it to do.· The problem is that I want to be able to load the methods into a cog such that I can easily send data to it, and let the cog handle displaying the info.· It is also all written in spin, not assembly.
It's kind of like with the TV/VGA objects that come with the prop library, you can just use something like "lcd.out(@data)".· However, I've looked over code that loads into another cog to handle things like this, and it is all in assembly.· It also looks like the assembly is all that gets loaded into the cog, and the spin code is just extra stuff that will modify variables that the assembly portion uses.· Am I seeing this correctly?
Yeah, it may be hard to understand what I'm trying to explain (I'm not really great at that, haha), but basicly I would like help on how to·load my object with multiple methods into its own cog so I can just throw bytes at it here and there.
I haven't tried assembly yet, mainly because of the new words to use, I have about 3 years of experience with assembly with PIC microcontrollers, so most of this stuff isn't too new, just some of the coding is. Thanks!
I'm new to the propeller, I've had the demo board for about a week and a half now, and I love it.· I ordered two of the 40-pin DIP chips so that I can breadboard and have access to all of the IO pins for more experiments.· I've run into a small problem that I'm hoping has a simple solution:
I have a small graphic LCD, 122x32 pixels (122 wide, 32 tall).· Its uses the SED1520 controller, and I've written an object spin file that has a few methods that can handle basic stuff for it to do.· The problem is that I want to be able to load the methods into a cog such that I can easily send data to it, and let the cog handle displaying the info.· It is also all written in spin, not assembly.
It's kind of like with the TV/VGA objects that come with the prop library, you can just use something like "lcd.out(@data)".· However, I've looked over code that loads into another cog to handle things like this, and it is all in assembly.· It also looks like the assembly is all that gets loaded into the cog, and the spin code is just extra stuff that will modify variables that the assembly portion uses.· Am I seeing this correctly?
Yeah, it may be hard to understand what I'm trying to explain (I'm not really great at that, haha), but basicly I would like help on how to·load my object with multiple methods into its own cog so I can just throw bytes at it here and there.
I haven't tried assembly yet, mainly because of the new words to use, I have about 3 years of experience with assembly with PIC microcontrollers, so most of this stuff isn't too new, just some of the coding is. Thanks!
Comments
I also wanted to have one cog by itself that ran all of the LCD coding, and for it to always be on and ready to go, and not constantly launching a new cog to run a method, and then shut it back down.
I've attached my code if it helps at all, I know its really bad and not very clean, but I'm just trying to get down commands to make it do stuff before I go back and clean it up.
For the kind of thing you're doing, I don't see why you need a separate cog. Maybe you're confusing the idea of an "object" with a "cog".
The cogs really are effectively separate computers. You happen to have 8 computers in a Propeller that share I/O lines and memory. Your gfxlcd.spin is a collection of subroutines/functions that have some common variables and constant definitions and usually provide some packaged functionality. In your case, this is support for an LCD. Commonly, you need some kind of initialization for this package, usually called "start" or "init" or something similar. Any "program" using this package has to call this initialization routine once before it does anything else with the package. The package provides this functionality by defining some subroutines that can be called from "outside" (PUB). There may be some internal subroutines that cannot be referenced from "outside" (PRI).
One of these objects may provide its functionality just by providing these subroutine calls. Sometimes an object needs to do something in parallel with whatever's going on in the calling program. This is done by starting up another cog to do the work. Since it takes some time (100's of us) to start up a cog, this is usually not done to do one function at a time. In your case, there's not much point to using a separate cog for the I/O unless the pauses for the LCD to do its work are significant.
a. Cog-A - acts as a sensory processor
b. Cog-B - acts as a reactionary processor
Cog-A - runs an endless repeat loop and w/i this loop, I gather input values from various sensory devices (such as Temperature, GPS, Ping, etc) and store the values in an array of data
Cog-B - runs an endless repeat loop and w/i this loop, I simply take the values from the data array and display on my Parallax 2 line LCD display. Pretty straight forward.
One thing to keep in mind is, if you're looking for multiple Cogs to "share" the LCD device, you must get a Semaphore Lock. It is sort of like, "App or Key Lock" if you're familiar of such a thing in PC programming. So, for example, if Cog-C wants to display on LCD, it will get a Lock and Display on LCD, and once done, "unlocks" the SemaphoreId. The methods you will use are ::LockNew() and ::LockClr()
hope that helps - and I did not further confuse you
[noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"any small object, accidentally dropped, goes and hides behind a larger object."
ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot
http://ALIBE.crosscity.com/
·